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