Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | # Makefile for the Sparc boot stuff. |
| 2 | # |
| 3 | # Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) |
| 4 | # Copyright (C) 1997,1998 Jakub Jelinek (jj@ultra.linux.cz) |
| 5 | |
| 6 | ROOT_IMG := /usr/src/root.img |
| 7 | ELFTOAOUT := elftoaout |
Daniel Hellstrom | 684151a | 2011-01-26 06:36:35 +0000 | [diff] [blame] | 8 | MKIMAGE := $(srctree)/scripts/mkuboot.sh |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Sam Ravnborg | 56818a6 | 2011-01-04 11:39:17 +0000 | [diff] [blame] | 10 | hostprogs-y := piggyback btfixupprep |
Sam Ravnborg | a8c601c | 2008-12-03 03:14:26 -0800 | [diff] [blame] | 11 | targets := tftpboot.img btfix.o btfix.S image zImage vmlinux.aout |
Sam Ravnborg | c4893269 | 2008-11-29 21:53:26 -0800 | [diff] [blame] | 12 | clean-files := System.map |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | quiet_cmd_elftoaout = ELFTOAOUT $@ |
| 15 | cmd_elftoaout = $(ELFTOAOUT) $(obj)/image -o $@ |
Sam Ravnborg | 56818a6 | 2011-01-04 11:39:17 +0000 | [diff] [blame] | 16 | quiet_cmd_piggy = PIGGY $@ |
| 17 | cmd_piggy = $(obj)/piggyback $(BITS) $@ System.map $(ROOT_IMG) |
Sam Ravnborg | 9202db2 | 2011-01-04 11:39:18 +0000 | [diff] [blame] | 18 | quiet_cmd_strip = STRIP $@ |
| 19 | cmd_strip = $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $< -o $@ |
Sam Ravnborg | a8c601c | 2008-12-03 03:14:26 -0800 | [diff] [blame] | 20 | |
| 21 | ifeq ($(CONFIG_SPARC32),y) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | quiet_cmd_btfix = BTFIX $@ |
| 23 | cmd_btfix = $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@ |
| 24 | quiet_cmd_sysmap = SYSMAP $(obj)/System.map |
| 25 | cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap |
| 26 | quiet_cmd_image = LD $@ |
| 27 | cmd_image = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) -o $@ |
| 28 | |
| 29 | define rule_image |
| 30 | $(if $($(quiet)cmd_image), \ |
| 31 | echo ' $($(quiet)cmd_image)' &&) \ |
| 32 | $(cmd_image); \ |
| 33 | $(if $($(quiet)cmd_sysmap), \ |
| 34 | echo ' $($(quiet)cmd_sysmap)' &&) \ |
| 35 | $(cmd_sysmap) $@ $(obj)/System.map; \ |
| 36 | if [ $$? -ne 0 ]; then \ |
| 37 | rm -f $@; \ |
| 38 | /bin/false; \ |
| 39 | fi; \ |
| 40 | echo 'cmd_$@ := $(cmd_image)' > $(@D)/.$(@F).cmd |
| 41 | endef |
| 42 | |
Sam Ravnborg | db5ea21 | 2008-12-02 23:15:42 -0800 | [diff] [blame] | 43 | BTOBJS := $(patsubst %/, %/built-in.o, $(VMLINUX_INIT)) |
| 44 | BTLIBS := $(patsubst %/, %/built-in.o, $(VMLINUX_MAIN)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds $(BTOBJS) \ |
| 46 | --start-group $(BTLIBS) --end-group \ |
| 47 | $(kallsyms.o) $(obj)/btfix.o |
| 48 | |
| 49 | # Link the final image including btfixup'ed symbols. |
| 50 | # This is a replacement for the link done in the top-level Makefile. |
| 51 | # Note: No dependency on the prerequisite files since that would require |
| 52 | # make to try check if they are updated - and due to changes |
| 53 | # in gcc options (path for example) this would result in |
| 54 | # these files being recompiled for each build. |
| 55 | $(obj)/image: $(obj)/btfix.o FORCE |
| 56 | $(call if_changed_rule,image) |
| 57 | |
Martin Habets | 349101d | 2008-08-18 22:37:18 -0700 | [diff] [blame] | 58 | $(obj)/zImage: $(obj)/image |
| 59 | $(call if_changed,strip) |
Sam Ravnborg | 9202db2 | 2011-01-04 11:39:18 +0000 | [diff] [blame] | 60 | @echo ' kernel: $@ is ready' |
Martin Habets | 349101d | 2008-08-18 22:37:18 -0700 | [diff] [blame] | 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | $(obj)/btfix.S: $(obj)/btfixupprep vmlinux FORCE |
| 63 | $(call if_changed,btfix) |
Sam Ravnborg | a8c601c | 2008-12-03 03:14:26 -0800 | [diff] [blame] | 64 | |
| 65 | endif |
| 66 | |
| 67 | ifeq ($(CONFIG_SPARC64),y) |
Sam Ravnborg | a8c601c | 2008-12-03 03:14:26 -0800 | [diff] [blame] | 68 | |
| 69 | # Actual linking |
| 70 | $(obj)/image: vmlinux FORCE |
| 71 | $(call if_changed,strip) |
| 72 | @echo ' kernel: $@ is ready' |
| 73 | |
Jurij Smakov | 48e46b7 | 2009-08-16 18:21:47 -0700 | [diff] [blame] | 74 | $(obj)/zImage: $(obj)/image |
| 75 | $(call if_changed,gzip) |
Sam Ravnborg | 9202db2 | 2011-01-04 11:39:18 +0000 | [diff] [blame] | 76 | @echo ' kernel: $@ is ready' |
Jurij Smakov | 48e46b7 | 2009-08-16 18:21:47 -0700 | [diff] [blame] | 77 | |
Sam Ravnborg | a8c601c | 2008-12-03 03:14:26 -0800 | [diff] [blame] | 78 | $(obj)/vmlinux.aout: vmlinux FORCE |
| 79 | $(call if_changed,elftoaout) |
| 80 | @echo ' kernel: $@ is ready' |
Daniel Hellstrom | 684151a | 2011-01-26 06:36:35 +0000 | [diff] [blame] | 81 | else |
| 82 | |
| 83 | # The following lines make a readable image for U-Boot. |
| 84 | # uImage - Binary file read by U-boot |
| 85 | # uImage.o - object file of uImage for loading with a |
| 86 | # flash programmer understanding ELF. |
| 87 | |
| 88 | OBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment |
| 89 | $(obj)/image.bin: $(obj)/image FORCE |
| 90 | $(call if_changed,objcopy) |
| 91 | |
| 92 | $(obj)/image.gz: $(obj)/image.bin |
| 93 | $(call if_changed,gzip) |
| 94 | |
| 95 | quiet_cmd_uimage = UIMAGE $@ |
| 96 | cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux -T kernel \ |
| 97 | -C gzip -a $(CONFIG_UBOOT_LOAD_ADDR) \ |
| 98 | -e $(CONFIG_UBOOT_ENTRY_ADDR) -n 'Linux-$(KERNELRELEASE)' \ |
| 99 | -d $< $@ |
| 100 | |
| 101 | quiet_cmd_uimage.o = UIMAGE.O $@ |
| 102 | cmd_uimage.o = $(LD) -Tdata $(CONFIG_UBOOT_FLASH_ADDR) \ |
| 103 | -r -b binary $@ -o $@.o |
| 104 | |
| 105 | targets += uImage |
| 106 | $(obj)/uImage: $(obj)/image.gz |
| 107 | $(call if_changed,uimage) |
| 108 | $(call if_changed,uimage.o) |
| 109 | @echo ' Image $@ is ready' |
| 110 | |
Sam Ravnborg | a8c601c | 2008-12-03 03:14:26 -0800 | [diff] [blame] | 111 | endif |
| 112 | |
Sam Ravnborg | 56818a6 | 2011-01-04 11:39:17 +0000 | [diff] [blame] | 113 | $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback System.map $(ROOT_IMG) FORCE |
| 114 | $(call if_changed,elftoaout) |
| 115 | $(call if_changed,piggy) |