]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/ppc64/boot/Makefile
[PATCH] ppc64 boot: remove need for imagesize.c
[linux-2.6-omap-h63xx.git] / arch / ppc64 / boot / Makefile
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 $(shell $(CROSS32CC) -print-file-name=include)
26 BOOTAFLAGS      := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
27 BOOTLFLAGS      := -Ttext 0x00400000 -e _start -T $(srctree)/$(src)/zImage.lds
28 OBJCOPYFLAGS    := contents,alloc,load,readonly,data
29
30 zlib       := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c
31 zlibheader := infblock.h infcodes.h inffast.h inftrees.h infutil.h
32 zliblinuxheader := zlib.h zconf.h zutil.h
33
34 $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
35 #$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h)
36
37 src-boot := crt0.S string.S prom.c main.c div64.S
38 src-boot += $(zlib)
39 src-boot := $(addprefix $(obj)/, $(src-boot))
40 obj-boot := $(addsuffix .o, $(basename $(src-boot)))
41
42 BOOTCFLAGS      += -I$(obj) -I$(srctree)/$(obj)
43
44 quiet_cmd_copy_zlib = COPY    $@
45       cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
46
47 quiet_cmd_copy_zlibheader = COPY    $@
48       cmd_copy_zlibheader = sed "s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
49 # stddef.h for NULL
50 quiet_cmd_copy_zliblinuxheader = COPY    $@
51       cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
52
53 $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
54         $(call cmd,copy_zlib)
55
56 $(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
57         $(call cmd,copy_zlibheader)
58
59 $(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
60         $(call cmd,copy_zliblinuxheader)
61
62 clean-files := $(zlib) $(zlibheader) $(zliblinuxheader)
63
64
65 quiet_cmd_bootcc = BOOTCC  $@
66       cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
67
68 quiet_cmd_bootas = BOOTAS  $@
69       cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
70
71 quiet_cmd_bootld = BOOTLD  $@
72       cmd_bootld = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(2)
73
74 $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
75         $(call if_changed_dep,bootcc)
76 $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
77         $(call if_changed_dep,bootas)
78
79 #-----------------------------------------------------------
80 # ELF sections within the zImage bootloader/wrapper
81 #-----------------------------------------------------------
82 required := vmlinux.strip
83 initrd   := initrd
84
85 obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section)))
86 src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section)))
87 gz-sec  = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section)))
88
89 hostprogs-y             := addnote addRamDisk
90 targets                 += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \
91                            $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
92                            $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
93                            $(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
94                            vmlinux.initrd
95 extra-y                 := initrd.o
96
97 quiet_cmd_ramdisk = RAMDISK $@
98       cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz $< $@
99
100 quiet_cmd_stripvm = STRIP   $@
101       cmd_stripvm = $(STRIP) -s $< -o $@
102
103 vmlinux.strip: vmlinux
104         $(call if_changed,stripvm)
105 $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk $(obj)/ramdisk.image.gz
106         $(call if_changed,ramdisk)
107
108 quiet_cmd_addsection = ADDSEC  $@
109       cmd_addsection = $(CROSS32OBJCOPY) $@ \
110                 --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(patsubst %.o,%.gz, $@) \
111                 --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPYFLAGS)
112
113 quiet_cmd_addnote = ADDNOTE $@
114       cmd_addnote = $(obj)/addnote $@
115
116 $(call gz-sec, $(required)): $(obj)/kernel-%.gz: %
117         $(call if_changed,gzip)
118
119 $(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz
120         cp -f $(obj)/ramdisk.image.gz $@
121
122 $(call src-sec, $(required) $(initrd)): $(obj)/kernel-%.c: $(obj)/kernel-%.gz
123         @touch $@
124
125 $(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c
126         $(call if_changed_dep,bootcc)
127         $(call cmd,addsection)
128
129 $(obj)/zImage.vmode: obj-boot += $(call obj-sec, $(required))
130 $(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot)
131         $(call cmd,bootld,$(obj-boot))
132
133 $(obj)/zImage.initrd.vmode: obj-boot += $(call obj-sec, $(required) $(initrd))
134 $(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot)
135         $(call cmd,bootld,$(obj-boot))
136
137 $(obj)/zImage: $(obj)/zImage.vmode $(obj)/addnote
138         @cp -f $< $@
139         $(call if_changed,addnote)
140
141 $(obj)/zImage.initrd: $(obj)/zImage.initrd.vmode $(obj)/addnote
142         @cp -f $< $@
143         $(call if_changed,addnote)
144
145 install: $(CONFIGURE) $(BOOTIMAGE)
146         sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)"
147
148 clean-files := $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)