xref: /linux/arch/sparc/boot/Makefile (revision c489326939b28ca93a8cfcbda8adbeb328101682)
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
6ROOT_IMG	:= /usr/src/root.img
7ELFTOAOUT	:= elftoaout
8
9hostprogs-y	:= piggyback btfixupprep
10targets		:= tftpboot.img btfix.o btfix.S image zImage
11clean-files	:= System.map
12
13quiet_cmd_elftoaout	= ELFTOAOUT $@
14      cmd_elftoaout	= $(ELFTOAOUT) $(obj)/image -o $@
15quiet_cmd_piggy		= PIGGY   $@
16      cmd_piggy		= $(obj)/piggyback $@ $(obj)/System.map $(ROOT_IMG)
17quiet_cmd_btfix		= BTFIX   $@
18      cmd_btfix		= $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@
19quiet_cmd_sysmap        = SYSMAP  $(obj)/System.map
20      cmd_sysmap        = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
21quiet_cmd_image = LD      $@
22      cmd_image = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) -o $@
23quiet_cmd_strip = STRIP   $@
24      cmd_strip = $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $(obj)/image -o $@
25
26
27define rule_image
28	$(if $($(quiet)cmd_image),               \
29	  echo '  $($(quiet)cmd_image)' &&)      \
30	  $(cmd_image);                          \
31	$(if $($(quiet)cmd_sysmap),              \
32	  echo '  $($(quiet)cmd_sysmap)' &&)  \
33	$(cmd_sysmap) $@ $(obj)/System.map;      \
34	if [ $$? -ne 0 ]; then                   \
35		rm -f $@;                        \
36		/bin/false;                      \
37	fi;                                      \
38	echo 'cmd_$@ := $(cmd_image)' > $(@D)/.$(@F).cmd
39endef
40
41BTOBJS := $(patsubst %/, %/built-in.o, $(VMLINUX_INIT))
42BTLIBS := $(patsubst %/, %/built-in.o, $(VMLINUX_MAIN))
43LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds $(BTOBJS) \
44                  --start-group $(BTLIBS) --end-group \
45                  $(kallsyms.o) $(obj)/btfix.o
46
47# Link the final image including btfixup'ed symbols.
48# This is a replacement for the link done in the top-level Makefile.
49# Note: No dependency on the prerequisite files since that would require
50# make to try check if they are updated - and due to changes
51# in gcc options (path for example) this would result in
52# these files being recompiled for each build.
53$(obj)/image: $(obj)/btfix.o FORCE
54	$(call if_changed_rule,image)
55
56$(obj)/zImage: $(obj)/image
57	$(call if_changed,strip)
58
59$(obj)/tftpboot.img: $(obj)/piggyback $(obj)/System.map $(obj)/image FORCE
60	$(call if_changed,elftoaout)
61	$(call if_changed,piggy)
62
63$(obj)/btfix.S: $(obj)/btfixupprep vmlinux FORCE
64	$(call if_changed,btfix)
65