xref: /linux/arch/sparc/boot/Makefile (revision e33936451484b06b61b259172fa3761a7d1cd4dc)
11da177e4SLinus Torvalds# Makefile for the Sparc boot stuff.
21da177e4SLinus Torvalds#
31da177e4SLinus Torvalds# Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
41da177e4SLinus Torvalds# Copyright (C) 1997,1998 Jakub Jelinek (jj@ultra.linux.cz)
51da177e4SLinus Torvalds
61da177e4SLinus TorvaldsROOT_IMG	:= /usr/src/root.img
71da177e4SLinus TorvaldsELFTOAOUT	:= elftoaout
81da177e4SLinus Torvalds
956818a6fSSam Ravnborghostprogs-y	:= piggyback btfixupprep
10a8c601caSSam Ravnborgtargets		:= tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
11c4893269SSam Ravnborgclean-files	:= System.map
121da177e4SLinus Torvalds
131da177e4SLinus Torvaldsquiet_cmd_elftoaout	= ELFTOAOUT $@
141da177e4SLinus Torvalds      cmd_elftoaout	= $(ELFTOAOUT) $(obj)/image -o $@
1556818a6fSSam Ravnborgquiet_cmd_piggy		= PIGGY   $@
1656818a6fSSam Ravnborg      cmd_piggy		= $(obj)/piggyback $(BITS) $@ System.map $(ROOT_IMG)
179202db22SSam Ravnborgquiet_cmd_strip		= STRIP   $@
189202db22SSam Ravnborg      cmd_strip		= $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $< -o $@
19a8c601caSSam Ravnborg
20a8c601caSSam Ravnborgifeq ($(CONFIG_SPARC32),y)
211da177e4SLinus Torvaldsquiet_cmd_btfix		= BTFIX   $@
221da177e4SLinus Torvalds      cmd_btfix		= $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@
231da177e4SLinus Torvaldsquiet_cmd_sysmap        = SYSMAP  $(obj)/System.map
241da177e4SLinus Torvalds      cmd_sysmap        = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
251da177e4SLinus Torvaldsquiet_cmd_image = LD      $@
261da177e4SLinus Torvalds      cmd_image = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) -o $@
271da177e4SLinus Torvalds
281da177e4SLinus Torvaldsdefine rule_image
291da177e4SLinus Torvalds	$(if $($(quiet)cmd_image),               \
301da177e4SLinus Torvalds	  echo '  $($(quiet)cmd_image)' &&)      \
311da177e4SLinus Torvalds	  $(cmd_image);                          \
321da177e4SLinus Torvalds	$(if $($(quiet)cmd_sysmap),              \
331da177e4SLinus Torvalds	  echo '  $($(quiet)cmd_sysmap)' &&)  \
341da177e4SLinus Torvalds	$(cmd_sysmap) $@ $(obj)/System.map;      \
351da177e4SLinus Torvalds	if [ $$? -ne 0 ]; then                   \
361da177e4SLinus Torvalds		rm -f $@;                        \
371da177e4SLinus Torvalds		/bin/false;                      \
381da177e4SLinus Torvalds	fi;                                      \
391da177e4SLinus Torvalds	echo 'cmd_$@ := $(cmd_image)' > $(@D)/.$(@F).cmd
401da177e4SLinus Torvaldsendef
411da177e4SLinus Torvalds
42db5ea21aSSam RavnborgBTOBJS := $(patsubst %/, %/built-in.o, $(VMLINUX_INIT))
43db5ea21aSSam RavnborgBTLIBS := $(patsubst %/, %/built-in.o, $(VMLINUX_MAIN))
441da177e4SLinus TorvaldsLDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds $(BTOBJS) \
451da177e4SLinus Torvalds                  --start-group $(BTLIBS) --end-group \
461da177e4SLinus Torvalds                  $(kallsyms.o) $(obj)/btfix.o
471da177e4SLinus Torvalds
481da177e4SLinus Torvalds# Link the final image including btfixup'ed symbols.
491da177e4SLinus Torvalds# This is a replacement for the link done in the top-level Makefile.
501da177e4SLinus Torvalds# Note: No dependency on the prerequisite files since that would require
511da177e4SLinus Torvalds# make to try check if they are updated - and due to changes
521da177e4SLinus Torvalds# in gcc options (path for example) this would result in
531da177e4SLinus Torvalds# these files being recompiled for each build.
541da177e4SLinus Torvalds$(obj)/image: $(obj)/btfix.o FORCE
551da177e4SLinus Torvalds	$(call if_changed_rule,image)
561da177e4SLinus Torvalds
57349101daSMartin Habets$(obj)/zImage: $(obj)/image
58349101daSMartin Habets	$(call if_changed,strip)
599202db22SSam Ravnborg	@echo '  kernel: $@ is ready'
60349101daSMartin Habets
611da177e4SLinus Torvalds$(obj)/btfix.S: $(obj)/btfixupprep vmlinux FORCE
621da177e4SLinus Torvalds	$(call if_changed,btfix)
63a8c601caSSam Ravnborg
64a8c601caSSam Ravnborgendif
65a8c601caSSam Ravnborg
66a8c601caSSam Ravnborgifeq ($(CONFIG_SPARC64),y)
67a8c601caSSam Ravnborg
68a8c601caSSam Ravnborg# Actual linking
69a8c601caSSam Ravnborg$(obj)/image: vmlinux FORCE
70a8c601caSSam Ravnborg	$(call if_changed,strip)
71a8c601caSSam Ravnborg	@echo '  kernel: $@ is ready'
72a8c601caSSam Ravnborg
7348e46b7bSJurij Smakov$(obj)/zImage: $(obj)/image
7448e46b7bSJurij Smakov	$(call if_changed,gzip)
759202db22SSam Ravnborg	@echo '  kernel: $@ is ready'
7648e46b7bSJurij Smakov
77a8c601caSSam Ravnborg$(obj)/vmlinux.aout: vmlinux FORCE
78a8c601caSSam Ravnborg	$(call if_changed,elftoaout)
79a8c601caSSam Ravnborg	@echo '  kernel: $@ is ready'
80684151a7SDaniel Hellstromelse
81684151a7SDaniel Hellstrom
82684151a7SDaniel Hellstrom# The following lines make a readable image for U-Boot.
83684151a7SDaniel Hellstrom#  uImage   - Binary file read by U-boot
84684151a7SDaniel Hellstrom#  uImage.o - object file of uImage for loading with a
85684151a7SDaniel Hellstrom#             flash programmer understanding ELF.
86684151a7SDaniel Hellstrom
87684151a7SDaniel HellstromOBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment
88684151a7SDaniel Hellstrom$(obj)/image.bin: $(obj)/image FORCE
89684151a7SDaniel Hellstrom	$(call if_changed,objcopy)
90684151a7SDaniel Hellstrom
91684151a7SDaniel Hellstrom$(obj)/image.gz: $(obj)/image.bin
92684151a7SDaniel Hellstrom	$(call if_changed,gzip)
93684151a7SDaniel Hellstrom
94*e3393645SStephen WarrenUIMAGE_LOADADDR = $(CONFIG_UBOOT_LOAD_ADDR)
95*e3393645SStephen WarrenUIMAGE_ENTRYADDR = $(CONFIG_UBOOT_ENTRY_ADDR)
96*e3393645SStephen WarrenUIMAGE_COMPRESSION = gzip
97684151a7SDaniel Hellstrom
98684151a7SDaniel Hellstromquiet_cmd_uimage.o = UIMAGE.O $@
99684151a7SDaniel Hellstrom      cmd_uimage.o = $(LD) -Tdata $(CONFIG_UBOOT_FLASH_ADDR) \
100684151a7SDaniel Hellstrom                     -r -b binary $@ -o $@.o
101684151a7SDaniel Hellstrom
102684151a7SDaniel Hellstromtargets += uImage
103684151a7SDaniel Hellstrom$(obj)/uImage: $(obj)/image.gz
104684151a7SDaniel Hellstrom	$(call if_changed,uimage)
105684151a7SDaniel Hellstrom	$(call if_changed,uimage.o)
106684151a7SDaniel Hellstrom	@echo '  Image $@ is ready'
107684151a7SDaniel Hellstrom
108a8c601caSSam Ravnborgendif
109a8c601caSSam Ravnborg
11056818a6fSSam Ravnborg$(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback System.map $(ROOT_IMG) FORCE
11156818a6fSSam Ravnborg	$(call if_changed,elftoaout)
11256818a6fSSam Ravnborg	$(call if_changed,piggy)
113