xref: /titanic_50/usr/src/psm/stand/boot/sparcv9/Makefile.com (revision de3d2ce46fc25c7b67ccbae4afe5f15e5357568f)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21#
22#ident	"%Z%%M%	%I%	%E% SMI"
23#
24# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# psm/stand/boot/sparcv9/Makefile.com
28
29
30include $(TOPDIR)/psm/stand/boot/Makefile.boot
31
32TARG_MACH	= sparcv9
33
34BOOTSRCDIR	= ../..
35
36TOP_CMN_DIR	= $(SRC)/common
37CMN_DIR		= $(BOOTSRCDIR)/common
38MACH_DIR	= ../../sparc/common
39PLAT_DIR	= .
40BOOT_DIR        = $(SRC)/psm/stand/boot
41
42BOOT_SRC	= inetboot.c wanboot.c
43
44CONF_SRC	= nfsconf.c wbfsconf.c wbcli.c
45
46TOP_CMN_C_SRC	= getoptstr.c
47
48MISC_SRC	= ramdisk.c
49
50CMN_C_SRC	= heap_kmem.c readfile.c
51
52MACH_C_SRC	= boot_plat.c bootops.c bootprop.c bootflags.c
53MACH_C_SRC	+= get.c
54
55BOOT_OBJS	= $(BOOT_SRC:%.c=%.o)
56BOOT_L_OBJS	= $(BOOT_OBJS:%.o=%.ln)
57
58CONF_OBJS	= $(CONF_SRC:%.c=%.o)
59CONF_L_OBJS	= $(CONF_OBJS:%.o=%.ln)
60
61MISC_OBJS	= $(MISC_SRC:%.c=%.o)
62MISC_L_OBJS	= $(MISC_OBJS:%.o=%.ln)
63
64SRT0_OBJ	= $(SRT0_S:%.s=%.o)
65SRT0_L_OBJ	= $(SRT0_OBJ:%.o=%.ln)
66
67C_SRC		= $(TOP_CMN_C_SRC) $(CMN_C_SRC) $(MACH_C_SRC) $(ARCH_C_SRC)
68C_SRC		+= $(PLAT_C_SRC)
69S_SRC		= $(MACH_S_SRC) $(ARCH_S_SRC) $(PLAT_S_SRC)
70
71OBJS		= $(C_SRC:%.c=%.o) $(S_SRC:%.s=%.o)
72L_OBJS		= $(OBJS:%.o=%.ln)
73
74CPPDEFS		= $(ARCHOPTS) -D$(PLATFORM) -D_BOOT -D_KERNEL -D_MACHDEP
75CPPDEFS		+= -D_ELF64_SUPPORT
76CPPINCS		+= -I$(TOP_CMN_DIR)
77CPPINCS		+= -I$(SRC)/uts/common
78CPPINCS		+= -I$(SRC)/uts/sun
79CPPINCS		+= -I$(SRC)/uts/sun4
80CPPINCS		+= -I$(SRC)/uts/$(PLATFORM)
81CPPINCS		+= -I$(SRC)/uts/sparc/$(ARCHVERS)
82CPPINCS		+= -I$(SRC)/uts/sparc
83CPPINCS		+= -I$(SRC)/uts/$(ARCHMMU)
84CPPINCS		+= -I$(SRC)/common/net/wanboot
85CPPINCS		+= -I$(SRC)/common/net/wanboot/crypt
86CPPINCS		+= -I$(ROOT)/usr/platform/$(PLATFORM)/include
87CPPINCS		+= -I$(ROOT)/usr/include/$(ARCHVERS)
88CPPINCS		+= -I$(PSMSYSHDRDIR)
89CPPINCS		+= -I$(STANDDIR)
90CPPINCS		+= -I$(STANDDIR)/lib
91CPPINCS		+= -I$(STANDDIR)/lib/sa
92CPPINCS		+= -I$(SRC)/common/net/dhcp
93CPPINCS		+= -I$(BOOT_DIR)/sparc/common
94CPPFLAGS	= $(CPPDEFS) $(CPPINCS)
95CPPFLAGS	+= $(CCYFLAG)$(STANDDIR)
96ASFLAGS		+= $(CPPDEFS) -P -D_ASM $(CPPINCS)
97CFLAGS64	+= ../../sparc/common/sparc.il
98
99#
100# Until we are building on a MACH=sparcv9 machine, we have to override
101# where to look for libraries.
102#
103PSMNAMELIBDIR	= $(PSMSTANDDIR)/lib/names/$(TARG_MACH)
104PSMPROMLIBDIR	= $(PSMSTANDDIR)/lib/promif/$(TARG_MACH)
105
106#
107# The following libraries are built in LIBNAME_DIR
108#
109LIBNAME_DIR     += $(PSMNAMELIBDIR)/$(PLATFORM)
110LIBNAME_LIBS    += libnames.a
111
112#
113# The following libraries are built in LIBPROM_DIR
114#
115LIBPROM_DIR     += $(PSMPROMLIBDIR)/$(PROMVERS)/common
116LIBPROM_LIBS    += libprom.a
117
118#
119# The following libraries are built in LIBSYS_DIR
120#
121LIBSYS_DIR      += $(SYSLIBDIR)
122
123#
124# Used to convert ELF to an a.out and ensure alignment
125#
126STRIPALIGN = stripalign
127
128#
129# Program used to post-process the ELF executables
130#
131ELFCONV	= ./$(STRIPALIGN)			# Default value
132
133.KEEP_STATE:
134
135.PARALLEL:	$(OBJS) $(CONF_OBJS) $(MISC_OBJS) $(SRT0_OBJ) $(BOOT_OBJS)
136.PARALLEL:	$(L_OBJS) $(CONF_L_OBJS) $(MISC_L_OBJS) $(SRT0_L_OBJ) \
137		$(BOOT_L_OBJS)
138.PARALLEL:	$(NFSBOOT) $(WANBOOT)
139
140all: $(ELFCONV) $(NFSBOOT) $(WANBOOT)
141
142$(STRIPALIGN): $(CMN_DIR)/$$(@).c
143	$(NATIVECC) -o $@ $(CMN_DIR)/$@.c
144
145#
146# Note that the presumption is that someone has already done a `make
147# install' from usr/src/stand/lib, such that all of the standalone
148# libraries have been built and placed in $ROOT/stand/lib.
149#
150LIBDEPS=	$(LIBPROM_DIR)/libprom.a $(LIBPLAT_DEP) \
151		$(LIBNAME_DIR)/libnames.a
152
153L_LIBDEPS=	$(LIBPROM_DIR)/llib-lprom.ln $(LIBPLAT_DEP_L) \
154		$(LIBNAME_DIR)/llib-lnames.ln
155
156#
157#  WANboot booter
158#
159# Libraries used to build wanboot
160#
161# EXPORT DELETE START
162LIBWANBOOT =	libwanboot.a
163LIBSCRYPT =	libscrypt.a
164LIBSSL =	libssl.a
165LIBCRYPTO =	libcrypto.a
166# EXPORT DELETE END
167
168LIBWAN_LIBS     = \
169		$(LIBWANBOOT) \
170		libnvpair.a libufs.a libhsfs.a libnfs.a \
171		libxdr.a libnames.a libsock.a libinet.a libtcp.a \
172		$(LIBSCRYPT) $(LIBSSL) $(LIBCRYPTO) \
173		libmd5.a libsa.a libprom.a \
174		$(LIBSSL) \
175		$(LIBPLAT_LIBS)
176WAN_LIBS        = $(LIBWAN_LIBS:lib%.a=-l%)
177WAN_DIRS        = $(LIBNAME_DIR:%=-L%) $(LIBSYS_DIR:%=-L%)
178WAN_DIRS        += $(LIBPLAT_DIR:%=-L%) $(LIBPROM_DIR:%=-L%)
179
180#
181# Loader flags used to build wanboot
182#
183WAN_MAPFILE	= $(MACH_DIR)/mapfile
184WAN_LDFLAGS	= -dn -M $(WAN_MAPFILE) -e _start $(WAN_DIRS)
185WAN_L_LDFLAGS	= $(WAN_DIRS)
186
187#
188# Object files used to build wanboot
189#
190WAN_SRT0        = $(SRT0_OBJ)
191WAN_OBJS        = $(OBJS) wbfsconf.o wbcli.o wanboot.o ramdisk.o
192WAN_L_OBJS      = $(WAN_SRT0:%.o=%.ln) $(WAN_OBJS:%.o=%.ln)
193
194#
195# Build rules to build wanboot
196#
197
198$(WANBOOT).elf: $(WAN_MAPFILE) $(WAN_SRT0) $(WAN_OBJS) $(LIBDEPS)
199	$(LD) $(WAN_LDFLAGS) -o $@ $(WAN_SRT0) $(WAN_OBJS) $(WAN_LIBS)
200	$(MCS) -d $@
201	$(POST_PROCESS)
202	$(POST_PROCESS)
203	$(MCS) -c $@
204
205$(WANBOOT): $(WANBOOT).elf
206	$(RM) $@; cp $@.elf $@
207	$(STRIP) $@
208
209$(WANBOOT)_lint: $(L_LIBDEPS) $(WAN_L_OBJS)
210	@echo ""
211	@echo wanboot lint: global crosschecks:
212	$(LINT.c) $(WAN_L_LDFLAGS) $(WAN_L_OBJS) $(WAN_LIBS)
213
214# High-sierra filesystem booter.  Probably doesn't work.
215
216# NFS booter
217
218#
219# Libraries used to build nfsboot
220#
221LIBNFS_LIBS     = libnfs.a libxdr.a libnames.a \
222		libsock.a libinet.a libtcp.a libsa.a libprom.a \
223		$(LIBPLAT_LIBS)
224NFS_LIBS        = $(LIBNFS_LIBS:lib%.a=-l%)
225NFS_DIRS        = $(LIBNAME_DIR:%=-L%) $(LIBSYS_DIR:%=-L%)
226NFS_DIRS        += $(LIBPLAT_DIR:%=-L%) $(LIBPROM_DIR:%=-L%)
227
228#
229# Loader flags used to build inetboot
230#
231NFS_MAPFILE	= $(MACH_DIR)/mapfile
232NFS_LDFLAGS	= -dn -M $(NFS_MAPFILE) -e _start $(NFS_DIRS)
233NFS_L_LDFLAGS	= $(NFS_DIRS)
234
235#
236# Object files used to build inetboot
237#
238NFS_SRT0        = $(SRT0_OBJ)
239NFS_OBJS        = $(OBJS) nfsconf.o inetboot.o ramdisk.o
240NFS_L_OBJS      = $(NFS_SRT0:%.o=%.ln) $(NFS_OBJS:%.o=%.ln)
241
242$(NFSBOOT).elf: $(ELFCONV) $(NFS_MAPFILE) $(NFS_SRT0) $(NFS_OBJS) $(LIBDEPS)
243	$(LD) $(NFS_LDFLAGS) -o $@ $(NFS_SRT0) $(NFS_OBJS) $(NFS_LIBS)
244	$(MCS) -d $@
245	$(POST_PROCESS)
246	$(POST_PROCESS)
247	$(MCS) -c $@
248
249#
250# This is a bit strange because some platforms boot elf and some don't.
251# So this rule strips the file no matter which ELFCONV is used.
252#
253$(NFSBOOT): $(NFSBOOT).elf
254	$(RM) $@.tmp; cp $@.elf $@.tmp; $(STRIP) $@.tmp
255	$(RM) $@; $(ELFCONV) $@.tmp $@; $(RM) $@.tmp
256
257$(NFSBOOT)_lint: $(NFS_L_OBJS) $(L_LIBDEPS)
258	@echo ""
259	@echo inetboot lint: global crosschecks:
260	$(LINT.c) $(NFS_L_LDFLAGS) $(NFS_L_OBJS) $(NFS_LIBS)
261
262include $(BOOTSRCDIR)/Makefile.rules
263
264install: $(ROOT_PSM_WANBOOT)
265
266clean:
267	$(RM) make.out lint.out
268	$(RM) $(OBJS) $(CONF_OBJS) $(MISC_OBJS) $(BOOT_OBJS) $(SRT0_OBJ)
269	$(RM) $(NFSBOOT).elf $(WANBOOT).elf
270	$(RM) $(L_OBJS) $(CONF_L_OBJS) $(MISC_L_OBJS) $(BOOT_L_OBJS) \
271	      $(SRT0_L_OBJ)
272
273clobber: clean
274	$(RM) $(NFSBOOT) $(WANBOOT) $(STRIPALIGN)
275
276lint: $(NFSBOOT)_lint $(WANBOOT)_lint
277
278include $(BOOTSRCDIR)/Makefile.targ
279