diff options
Diffstat (limited to 'arch/powerpc/boot/Makefile')
-rw-r--r-- | arch/powerpc/boot/Makefile | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile new file mode 100644 index 000000000000..9770f587af73 --- /dev/null +++ b/arch/powerpc/boot/Makefile | |||
@@ -0,0 +1,149 @@ | |||
1 | # Makefile for making ELF bootable images for booting on CHRP | ||
2 | # using Open Firmware. | ||
3 | # | ||
4 | # Geert Uytterhoeven September 1997 | ||
5 | # | ||
6 | # Based on coffboot by Paul Mackerras | ||
7 | # Simplified for ppc64 by Todd Inglett | ||
8 | # | ||
9 | # NOTE: this code is built for 32 bit in ELF32 format even though | ||
10 | # it packages a 64 bit kernel. We do this to simplify the | ||
11 | # bootloader and increase compatibility with OpenFirmware. | ||
12 | # | ||
13 | # To this end we need to define BOOTCC, etc, as the tools | ||
14 | # needed to build the 32 bit image. These are normally HOSTCC, | ||
15 | # but may be a third compiler if, for example, you are cross | ||
16 | # compiling from an intel box. Once the 64bit ppc gcc is | ||
17 | # stable it will probably simply be a compiler switch to | ||
18 | # compile for 32bit mode. | ||
19 | # To make it easier to setup a cross compiler, | ||
20 | # CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE | ||
21 | # in the toplevel makefile. | ||
22 | |||
23 | |||
24 | HOSTCC := gcc | ||
25 | BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \ | ||
26 | $(shell $(CROSS32CC) -print-file-name=include) -fPIC | ||
27 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc | ||
28 | BOOTLFLAGS := -T $(srctree)/$(src)/zImage.lds | ||
29 | OBJCOPYFLAGS := contents,alloc,load,readonly,data | ||
30 | |||
31 | zlib := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c | ||
32 | zlibheader := infblock.h infcodes.h inffast.h inftrees.h infutil.h | ||
33 | zliblinuxheader := zlib.h zconf.h zutil.h | ||
34 | |||
35 | $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) | ||
36 | #$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h) | ||
37 | |||
38 | src-boot := string.S prom.c main.c div64.S crt0.S | ||
39 | src-boot += $(zlib) | ||
40 | src-boot := $(addprefix $(obj)/, $(src-boot)) | ||
41 | obj-boot := $(addsuffix .o, $(basename $(src-boot))) | ||
42 | |||
43 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) | ||
44 | |||
45 | quiet_cmd_copy_zlib = COPY $@ | ||
46 | cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@ | ||
47 | |||
48 | quiet_cmd_copy_zlibheader = COPY $@ | ||
49 | cmd_copy_zlibheader = sed "s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@ | ||
50 | # stddef.h for NULL | ||
51 | quiet_cmd_copy_zliblinuxheader = COPY $@ | ||
52 | cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@ | ||
53 | |||
54 | $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | ||
55 | $(call cmd,copy_zlib) | ||
56 | |||
57 | $(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | ||
58 | $(call cmd,copy_zlibheader) | ||
59 | |||
60 | $(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/% | ||
61 | $(call cmd,copy_zliblinuxheader) | ||
62 | |||
63 | clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) | ||
64 | |||
65 | |||
66 | quiet_cmd_bootcc = BOOTCC $@ | ||
67 | cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< | ||
68 | |||
69 | quiet_cmd_bootas = BOOTAS $@ | ||
70 | cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< | ||
71 | |||
72 | quiet_cmd_bootld = BOOTLD $@ | ||
73 | cmd_bootld = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(2) | ||
74 | |||
75 | $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c | ||
76 | $(call if_changed_dep,bootcc) | ||
77 | $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S | ||
78 | $(call if_changed_dep,bootas) | ||
79 | |||
80 | #----------------------------------------------------------- | ||
81 | # ELF sections within the zImage bootloader/wrapper | ||
82 | #----------------------------------------------------------- | ||
83 | required := vmlinux.strip | ||
84 | initrd := initrd | ||
85 | |||
86 | obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section))) | ||
87 | src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section))) | ||
88 | gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section))) | ||
89 | |||
90 | hostprogs-y := addnote addRamDisk | ||
91 | targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \ | ||
92 | $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \ | ||
93 | $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \ | ||
94 | $(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \ | ||
95 | vmlinux.initrd | ||
96 | extra-y := initrd.o | ||
97 | |||
98 | quiet_cmd_ramdisk = RAMDISK $@ | ||
99 | cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz $< $@ | ||
100 | |||
101 | quiet_cmd_stripvm = STRIP $@ | ||
102 | cmd_stripvm = $(STRIP) -s -R .comment $< -o $@ | ||
103 | |||
104 | vmlinux.strip: vmlinux | ||
105 | $(call if_changed,stripvm) | ||
106 | $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk $(obj)/ramdisk.image.gz | ||
107 | $(call if_changed,ramdisk) | ||
108 | |||
109 | quiet_cmd_addsection = ADDSEC $@ | ||
110 | cmd_addsection = $(CROSS32OBJCOPY) $@ \ | ||
111 | --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(patsubst %.o,%.gz, $@) \ | ||
112 | --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPYFLAGS) | ||
113 | |||
114 | quiet_cmd_addnote = ADDNOTE $@ | ||
115 | cmd_addnote = $(obj)/addnote $@ | ||
116 | |||
117 | $(call gz-sec, $(required)): $(obj)/kernel-%.gz: % | ||
118 | $(call if_changed,gzip) | ||
119 | |||
120 | $(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz | ||
121 | cp -f $(obj)/ramdisk.image.gz $@ | ||
122 | |||
123 | $(call src-sec, $(required) $(initrd)): $(obj)/kernel-%.c: $(obj)/kernel-%.gz | ||
124 | @touch $@ | ||
125 | |||
126 | $(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c | ||
127 | $(call if_changed_dep,bootcc) | ||
128 | $(call cmd,addsection) | ||
129 | |||
130 | $(obj)/zImage.vmode: obj-boot += $(call obj-sec, $(required)) | ||
131 | $(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(srctree)/$(src)/zImage.lds | ||
132 | $(call cmd,bootld,$(obj-boot)) | ||
133 | |||
134 | $(obj)/zImage.initrd.vmode: obj-boot += $(call obj-sec, $(required) $(initrd)) | ||
135 | $(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(srctree)/$(src)/zImage.lds | ||
136 | $(call cmd,bootld,$(obj-boot)) | ||
137 | |||
138 | $(obj)/zImage: $(obj)/zImage.vmode $(obj)/addnote | ||
139 | @cp -f $< $@ | ||
140 | $(call if_changed,addnote) | ||
141 | |||
142 | $(obj)/zImage.initrd: $(obj)/zImage.initrd.vmode $(obj)/addnote | ||
143 | @cp -f $< $@ | ||
144 | $(call if_changed,addnote) | ||
145 | |||
146 | install: $(CONFIGURE) $(BOOTIMAGE) | ||
147 | sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)" | ||
148 | |||
149 | clean-files := $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip) | ||