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