Commit 84b3c277 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: Makefile cleanup from Sam Ravnborg

parent 23c554b8
......@@ -23,92 +23,88 @@
CROSS32_COMPILE =
#CROSS32_COMPILE = /usr/local/ppc/bin/powerpc-linux-
BOOTCC = $(CROSS32_COMPILE)gcc
BOOTCFLAGS = $(HOSTCFLAGS) -I$(objtree)/include
BOOTLD = $(CROSS32_COMPILE)ld
BOOTAS = $(CROSS32_COMPILE)as
BOOTAFLAGS = -D__ASSEMBLY__ $(HOSTCFLAGS)
$(obj)/start.o: $(obj)/start.c
$(BOOTCC) $(BOOTCFLAGS) -c -o $*.o $<
$(obj)/main.o: $(obj)/main.c
$(BOOTCC) $(BOOTCFLAGS) -c -o $*.o $<
$(obj)/zlib.o: $(obj)/zlib.c
$(BOOTCC) $(BOOTCFLAGS) -c -o $*.o $<
$(obj)/imagesize.o: $(obj)/imagesize.c
$(BOOTCC) $(BOOTCFLAGS) -c -o $*.o $<
$(obj)/no_initrd.o: $(obj)/no_initrd.c
$(BOOTCC) $(BOOTCFLAGS) -c -o $*.o $<
$(obj)/crt0.o: $(obj)/crt0.S
$(BOOTCC) $(BOOTAFLAGS) -traditional -c -o $*.o $<
CFLAGS = $(CPPFLAGS) -O -fno-builtin -DSTDC_HEADERS
LD_ARGS = -Ttext 0x00400000 -e _start
BOOTCC := $(CROSS32_COMPILE)gcc
BOOTCFLAGS := $(HOSTCFLAGS) -Iinclude
BOOTLD := $(CROSS32_COMPILE)ld
BOOTAS := $(CROSS32_COMPILE)as
BOOTAFLAGS := -D__ASSEMBLY__ $(HOSTCFLAGS)
CFLAGS := $(CPPFLAGS) -O -fno-builtin -DSTDC_HEADERS
LD_ARGS := -Ttext 0x00400000 -e _start
OBJCOPYFLAGS := -S -O binary
OBJS = $(addprefix $(obj)/,crt0.o start.o main.o zlib.o image.o imagesize.o)
obj-boot := start.o main.o zlib.o imagesize.o no_initrd.o
OBJS := crt0.o start.o main.o zlib.o imagesize.o image.o
obj-boot := $(addprefix $(obj)/,$(obj-boot))
OBJS := $(addprefix $(obj)/,$(OBJS))
targets += $(obj-boot) $(addprefix $(obj)/,image.c image.o)
ifeq ($(CONFIG_PPC_ISERIES),y)
quiet_cmd_bootcc = BOOTCC $@
cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
$(obj-boot): %.o: %.c FORCE
$(call if_changed_dep,bootcc)
boot: vmlinux.sm
quiet_cmd_bootas = BOOTAS $@
cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -traditional \
-c -o $@ $<
$(obj)/crt0.o: %.o: %.S FORCE
$(call if_changed_dep,bootas)
$(obj)/addSystemMap: $(obj)/addSystemMap.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
host-progs := piggyback addnote addSystemMap addRamDisk
HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE)
EXTRA_TARGETS += zImage zImage.initrd vmlinux.bin vmlinux.gz \
vmlinux.sm vmlinux.initrd vmlinux.sminitrd \
sysmap.o initrd.o
$(obj)/vmlinux.sm: vmlinux $(obj)/addSystemMap
$(obj)/addSystemMap System.map vmlinux $(obj)/vmlinux.sm
quiet_cmd_sysmap = SYSMAP $@
cmd_sysmap = $(obj)/addSystemMap System.map $< $@
$(obj)/vmlinux.sm: vmlinux $(obj)/addSystemMap System.map FORCE
$(call if_changed,sysmap)
$(obj)/addRamDisk: $(obj)/addRamDisk.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
quiet_cmd_ramdisk = RAMDISK $@
cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz System.map $< $@
$(obj)/vmlinux.initrd: vmlinux $(obj)/addRamDisk $(obj)/ramdisk.image.gz System.map FORCE
$(call if_changed,ramdisk)
$(obj)/vmlinux.initrd: vmlinux $(obj)/addRamDisk $(obj)/ramdisk.image.gz System.map
$(obj)/addRamDisk $(obj)/ramdisk.image.gz System.map vmlinux $(obj)/vmlinux.initrd
$(obj)/vmlinux.sminitrd: $(obj)/vmlinux.sm $(obj)/addRamDisk $(obj)/ramdisk.image.gz FORCE
$(call if_changed,ramdisk)
$(obj)/vmlinux.sminitrd: $(obj)/vmlinux.sm $(obj)/addRamDisk $(obj)/ramdisk.image.gz System.map
$(obj)/addRamDisk $(obj)/ramdisk.image.gz System.map $(obj)/vmlinux.sm $(obj)/vmlinux.sminitrd
else
boot: zImage
endif
quiet_cmd_piggy = PIGGY $@
cmd_piggy = $(obj)/piggyback $(@:.o=) < $< | $(BOOTAS) -o $@
$(obj)/piggyback: $(obj)/piggyback.c
$(HOSTCC) $(HOSTCFLAGS) -DKERNELBASE=$(KERNELBASE) -o $@ $<
$(obj)/image.o: $(obj)/vmlinux.gz $(obj)/piggyback FORCE
$(call if_changed,piggy)
$(obj)/addnote: $(obj)/addnote.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
$(obj)/sysmap.o: System.map $(obj)/piggyback FORCE
$(call if_changed,piggy)
$(obj)/image.o: $(obj)/piggyback $(obj)/vmlinux.gz
$(obj)/piggyback $(obj)/image < $(obj)/vmlinux.gz | $(BOOTAS) -o $@
$(obj)/initrd.o: $(obj)/ramdisk.image.gz $(obj)/piggyback FORCE
$(call if_changed,piggy)
$(obj)/sysmap.o: $(obj)/piggyback System.map
$(obj)/piggyback $(obj)/sysmap < System.map | $(BOOTAS) -o $(obj)/sysmap.o
quiet_cmd_addnote = ADDNOTE $@
cmd_addnote = $(BOOTLD) $(LD_ARGS) -T $(obj)/zImage.lds -o $@ $(OBJS) $<\
&& $(obj)/addnote $@
$(obj)/initrd.o: $(obj)/ramdisk.image.gz $(obj)/piggyback
$(obj)/piggyback $(obj)/initrd < $(obj)/ramdisk.image.gz | $(BOOTAS) -o $(obj)/initrd.o
$(obj)/zImage: $(obj)/no_initrd.o $(OBJS) $(obj)/addnote FORCE
$(call if_changed,addnote)
$(obj)/zImage: $(OBJS) $(obj)/no_initrd.o $(obj)/addnote
$(BOOTLD) $(LD_ARGS) -T $(obj)/zImage.lds -o $@ $(OBJS) $(obj)/no_initrd.o
$(obj)/addnote $@
$(obj)/zImage.initrd: $(obj)/initrd.o $(OBJS) $(obj)/addnote FORCE
$(call if_changed,addnote)
$(obj)/zImage.initrd: $(OBJS) $(obj)/initrd.o $(obj)/addnote
$(BOOTLD) $(LD_ARGS) -T $(obj)/zImage.lds -o $@ $(OBJS) $(obj)/initrd.o
./addnote $@
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
$(obj)/vmlinux.gz: vmlinux
$(OBJCOPY) $(OBJCOPYFLAGS) vmlinux $(obj)/vmlinux
ls -l $(obj)/vmlinux | awk '{printf "/* generated -- do not edit! */\nint uncompressed_size = %d;\n", $$5}' > $(obj)/imagesize.c
$(CROSS_COMPILE)nm -n vmlinux | tail -1 | awk '{printf "long vmlinux_end = 0x%s;\n", substr($$1,8)}' >> $(obj)/imagesize.c
gzip -vf9 $(obj)/vmlinux
$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
$(call if_changed,gzip)
$(obj)/imagesize.c: $(obj)/vmlinux.gz
$(obj)/imagesize.c: vmlinux
@echo Generating $@
ls -l vmlinux | \
awk '{printf "/* generated -- do not edit! */\n" \
"int uncompressed_size = %d;\n", $$5}' > $(obj)/imagesize.c
$(CROSS_COMPILE)nm -n vmlinux | tail -1 | \
awk '{printf "long vmlinux_end = 0x%s;\n", substr($$1,8)}' \
>> $(obj)/imagesize.c
clean:
@rm -f $(OBJS)
@rm -f $(addprefix $(obj)/,piggyback note addnote zImage \
zImage.initrd vmlinux.gz no_initrd.o imagesize.c addSystemMap \
vmlinux.sm addRamDisk vmlinux.initrd vmlinux.sminitrd)
clean-files := $(targets)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment