xref: /illumos-gate/usr/src/Makefile (revision edb348833aaacfa1176e502ad38875fd0b2717ab)
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# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23#
24#
25# Makefile for system source
26#
27# include global definitions
28include Makefile.master
29#
30# the Targetdirs file is the AT&T target.dirs file in a makefile format.
31# it defines TARGETDIRS and ROOTDIRS.
32include Targetdirs
33
34COMMON_SUBDIRS=	uts lib cmd ucblib ucbcmd psm man
35sparc_SUBDIRS= stand
36i386_SUBDIRS= grub
37
38#
39# sparc needs to build stand before psm
40#
41$(SPARC_BLD)psm: stand
42
43SUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)
44
45HDRSUBDIRS=	uts head lib cmd
46
47# UCB headers are bug-for-bug compatible and not checkable against the header
48# standards.
49#
50CHKHDRSUBDIRS=	head uts lib
51
52#
53# Headers that can be built in parallel
54#
55PARALLEL_HEADERS = sysheaders userheaders libheaders cmdheaders
56
57#
58# Directories that can be built in parallel
59#
60PARALLEL_DIRS = uts lib man
61
62# The check target also causes smf(5) service manifests to be validated.
63CHKMFSTSUBDIRS=	cmd
64
65MSGSUBDIRS=	cmd ucbcmd lib
66DOMAINS= \
67	SUNW_OST_ADMIN \
68	SUNW_OST_NETRPC \
69	SUNW_OST_OSCMD \
70	SUNW_OST_OSLIB \
71	SUNW_OST_UCBCMD \
72	SUNW_OST_ZONEINFO
73
74MSGDDIRS=       $(DOMAINS:%=$(MSGROOT)/%)
75MSGDIRS=        $(MSGROOT) $(MSGDDIRS) $(MSGROOT)/LC_TIME
76
77all all_xmod :=		TARGET= all
78install install_xmod :=	TARGET= install
79install1 :=		TARGET= install
80install2 :=		TARGET= install
81install_h :=		TARGET= install_h
82clean :=		TARGET= clean
83clobber :=		TARGET= clobber
84check :=		TARGET= check
85
86.KEEP_STATE:
87
88#
89# Note: install does not cause a build in pkg.  To build packages,
90#	cd pkg and do a 'make install'
91#
92
93all: mapfiles closedbins sgs .WAIT $(SUBDIRS) pkg
94
95#
96# The _msg build is a two-step process.  First, the _msg dependency
97# causes recursive makes in $(MSGSUBDIRS), which stages raw message
98# files in $(ROOT)/catalog.  Second, the action from the install
99# target rule causes those messages to be post-processed from where
100# they were staged in $(ROOT)/catalog, and the results placed into the
101# proto area.
102#
103# The stage-licenses target causes the license files needed for
104# packaging to be pulled from $(SRC) and $(CLOSED) and staged in
105# $(ROOT)/licenses.
106#
107install: install1 install2 _msg stage-licenses
108	@cd msg; pwd; $(MAKE) _msg
109	@rm -rf "$(ROOT)/catalog"
110
111stage-licenses: install2
112	@cd pkg; pwd; $(MAKE) stage-licenses
113
114install1: mapfiles closedbins sgs
115
116install2: install1 $(SUBDIRS)
117
118_msg: _msgdirs rootdirs install2 FRC
119	@for m in $(MSGSUBDIRS); do \
120		cd $$m; pwd; $(MAKE) _msg; cd ..; \
121	done
122
123mapfiles: bldtools
124	@cd common/mapfiles; pwd; $(MAKE) install
125
126clean clobber: $(SUBDIRS) head pkg
127
128closedbins: FRC $(ROOTDIRS)
129	@CLOSED_ROOT="$$ON_CLOSED_BINS/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
130	if [ "$$CLOSED_IS_PRESENT" = no ]; then \
131		if [ ! -d "$$CLOSED_ROOT" ]; then \
132			$(ECHO) "Error: if closed sources are not present," \
133			    "ON_CLOSED_BINS must point to closed binaries."; \
134			$(ECHO) "root_$(MACH)$${RELEASE_BUILD+-nd} is not" \
135			    "present in $$ON_CLOSED_BINS."; \
136			exit 1; \
137		fi; \
138		$(ECHO) "Copying closed binaries from $$CLOSED_ROOT"; \
139		(cd $$CLOSED_ROOT; \
140		    $(TAR) cfX - $(CODEMGR_WS)/exception_lists/closed-bins .) | \
141		    (cd $(ROOT); $(TAR) xBpf -); \
142	fi
143
144#
145# Declare what parts can be built in parallel
146# DUMMY at the end is used in case macro expansion produces an empty string to
147# prevent everything going in parallel
148#
149.PARALLEL: $(PARALLEL_HEADERS) DUMMY
150.PARALLEL: $(PARALLEL_DIRS) DUMMY
151
152$(SUBDIRS) head pkg: FRC
153	@cd $@; pwd; $(MAKE) $(TARGET)
154
155# librpcsvc has a dependency on headers installed by
156# userheaders, hence the .WAIT before libheaders.
157sgs: rootdirs .WAIT sysheaders userheaders .WAIT \
158	libheaders cmdheaders
159
160#
161# Top-level setup target to setup the development environment that includes
162# headers, tools and generated mapfiles.  For open-only builds (i.e.: source
163# trees w/o usr/closed), this also depends on the closedbins target (above)
164# in order to properly seed the proto area.  Note, although the tools are
165# dependent on a number of constant mapfiles, the tools themselves are
166# required to build the generated mapfiles.
167#
168setup: closedbins bldtools sgs mapfiles
169
170bldtools:
171	@cd tools; pwd; $(MAKE) install
172
173# /var/mail/:saved is a special case because of the colon in the name.
174#
175rootdirs: $(ROOTDIRS)
176	$(INS) -d -m 775 $(ROOT)/var/mail/:saved
177
178lint: FRC
179	$(MAKE) -f Makefile.lint
180
181_msgdirs:       $(MSGDIRS)
182
183$(ROOTDIRS) $(MSGDIRS):
184	$(INS.dir)
185
186userheaders: FRC
187	@cd head; pwd; $(MAKE) install_h
188
189libheaders: bldtools
190	@cd lib; pwd; $(MAKE) install_h
191
192sysheaders: FRC
193	@cd uts; pwd; $(MAKE) install_h
194
195cmdheaders: FRC
196	@cd cmd/fm; pwd; $(MAKE) install_h
197	@cd cmd/mdb; pwd; $(MAKE) install_h
198
199# each xmod target depends on a corresponding MACH-specific pseudotarget
200# before doing common xmod work
201#
202all_xmod install_xmod: $$@_$(MACH)
203	@cd uts/common/sys; pwd; $(MAKE) svvs_h
204
205all_xmod_sparc install_xmod_sparc: FRC
206	@cd uts/sparc; pwd; \
207	  $(MAKE) TARGET=$(TARGET) svvs pm wsdrv
208
209all_xmod_i386 install_xmod_i386: FRC
210	@cd uts/i86; pwd; $(MAKE) TARGET=$(TARGET) svvs
211
212check:	$(CHKHDRSUBDIRS) $(CHKMFSTSUBDIRS)
213
214#
215# Cross-reference customization: skip all of the subdirectories that
216# don't contain actual source code.
217#
218$(CLOSED_BUILD)XRDIRS += ../closed
219XRPRUNE = pkg prototypes xmod
220XRINCDIRS = uts/common head ucbhead
221$(CLOSED_BUILD)XRINCDIRS = uts/common ../closed/uts/common head ucbhead
222
223cscope.out tags: FRC
224	$(XREF) -f -x $@
225
226FRC:
227
228# EXPORT DELETE START
229
230XMOD_DELETE_FILES:sh = cat xmod/xmod_files
231
232EXPORT_SRC:
233	@cd $(CLOSED)/cmd/cmd-inet/usr.lib/in.iked;  pwd; $(MAKE) EXPORT_SRC
234	@cd $(CLOSED)/cmd/cmd-inet/usr.lib/ike-certutils;  pwd; \
235	    $(MAKE) EXPORT_SRC
236	@cd cmd/cmd-inet/usr.sbin; pwd; $(MAKE) EXPORT_SRC
237	@cd $(CLOSED)/cmd/cmd-crypto/etc; pwd; $(MAKE) EXPORT_SRC
238	@cd cmd/crypt;	  pwd; $(MAKE) EXPORT_SRC
239	@cd cmd/gss/gssd;         pwd; $(MAKE) EXPORT_SRC
240	@cd cmd/krb5/kadmin;  pwd; $(MAKE) EXPORT_SRC
241	@cd cmd/sendmail/src; pwd; $(MAKE) EXPORT_SRC
242	@cd common/crypto/aes;	  pwd; $(MAKE) EXPORT_SRC
243	@cd common/crypto/arcfour; pwd; $(MAKE) EXPORT_SRC
244	@cd common/crypto/blowfish;	  pwd; $(MAKE) EXPORT_SRC
245	@cd common/crypto/des;	  pwd; $(MAKE) EXPORT_SRC
246	@cd common/crypto/rsa;	  pwd; $(MAKE) EXPORT_SRC
247	@cd lib/crypt_modules/bsdbf; pwd ; $(MAKE) EXPORT_SRC
248	@cd lib/gss_mechs/mech_dummy;   pwd; $(MAKE) EXPORT_SRC
249	@cd lib/gss_mechs/mech_dh/backend;	pwd; $(MAKE) EXPORT_SRC
250	@cd lib/gss_mechs/mech_krb5;		pwd; $(MAKE) EXPORT_SRC
251	@cd lib/gss_mechs/mech_spnego;		pwd; $(MAKE) EXPORT_SRC
252	@cd lib/libcrypt; pwd; $(MAKE) EXPORT_SRC
253	@cd lib/libgss;   pwd; $(MAKE) EXPORT_SRC
254	@cd $(CLOSED)/lib/libike;   pwd; $(MAKE) EXPORT_SRC
255	@cd lib/libnsl;	  pwd; $(MAKE) EXPORT_SRC
256	@cd lib/pkcs11/pkcs11_softtoken/common;  pwd; $(MAKE) EXPORT_SRC
257	@cd lib/libsldap; pwd; $(MAKE) EXPORT_SRC
258	@cd lib/libsasl; pwd; $(MAKE) EXPORT_SRC
259	@cd lib/sasl_plugins; pwd; $(MAKE) EXPORT_SRC
260	@cd lib/pam_modules/krb5;   pwd; $(MAKE) EXPORT_SRC
261	@cd psm/stand/boot; pwd; $(MAKE) EXPORT_SRC
262	@cd uts/common/crypto/io; pwd; $(MAKE) EXPORT_SRC
263	@cd uts/common/des; pwd; $(MAKE) EXPORT_SRC
264	@cd uts/common/rpc; pwd; $(MAKE) EXPORT_SRC
265	@cd uts/common/sys; pwd; $(MAKE) EXPORT_SRC
266	@cd uts/common/gssapi/include;		pwd; $(MAKE) EXPORT_SRC
267	@cd uts/common/gssapi;			pwd; $(MAKE) EXPORT_SRC
268	@cd uts/common/gssapi/mechs/dummy;	pwd; $(MAKE) EXPORT_SRC
269	@cd uts/common/gssapi/mechs/krb5;	pwd; $(MAKE) EXPORT_SRC
270	@cd uts/common; pwd; $(MAKE) EXPORT_SRC
271	@cd uts/sparc; pwd; $(MAKE) EXPORT_SRC
272	@cd $(CLOSED)/uts/sun4u/forthdebug; pwd; $(MAKE) EXPORT_SRC
273	@cd $(CLOSED)/uts/sun4v/forthdebug; pwd; $(MAKE) EXPORT_SRC
274	@cd uts/intel; pwd; $(MAKE) EXPORT_SRC
275	@cd uts/sun4u; pwd; $(MAKE) EXPORT_SRC
276	@cd $(CLOSED)/uts/sun4v/io/ncp;	pwd;	$(MAKE) EXPORT_SRC
277	@cd $(CLOSED)/uts/sun4v/io/n2cp; pwd;	$(MAKE) EXPORT_SRC
278	@cd pkg; pwd;	$(MAKE) EXPORT_SRC
279	$(RM) -r $(XMOD_DELETE_FILES)
280	$(RM) Targetdirs+
281	sed -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
282			< Targetdirs > Targetdirs+
283	$(MV) Targetdirs+ Targetdirs
284	$(CHMOD) 444 Targetdirs
285	$(RM) Makefile+
286	sed -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
287			< Makefile > Makefile+
288	$(MV) Makefile+ Makefile
289	$(CHMOD) 444 Makefile
290	$(RM) Makefile.master+
291	sed -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
292			< Makefile.master > Makefile.master+
293	$(MV) Makefile.master+ Makefile.master
294	$(CHMOD) 444 Makefile.master
295
296CRYPT_SRC:
297	@cd $(CLOSED)/cmd/cmd-crypto/etc;  pwd; $(MAKE) CRYPT_SRC
298	@cd $(CLOSED)/cmd/cmd-inet/usr.lib/in.iked;  pwd; $(MAKE) CRYPT_SRC
299	@cd $(CLOSED)/cmd/cmd-inet/usr.lib/ike-certutils;  pwd; \
300	    $(MAKE) CRYPT_SRC
301	@cd lib/crypt_modules/bsdbf; pwd ; $(MAKE) CRYPT_SRC
302	@cd lib/gss_mechs/mech_dummy;   pwd; $(MAKE) CRYPT_SRC
303	@cd lib/gss_mechs/mech_dh/backend; pwd; $(MAKE) CRYPT_SRC
304	@cd lib/gss_mechs/mech_krb5; pwd; $(MAKE) CRYPT_SRC
305	@cd lib/gss_mechs/mech_spnego; pwd; $(MAKE) CRYPT_SRC
306	@cd $(CLOSED)/lib/libike;   pwd; $(MAKE) CRYPT_SRC
307	@cd lib/libnsl;	 pwd; $(MAKE) CRYPT_SRC
308	@cd lib/libsasl;	 pwd; $(MAKE) CRYPT_SRC
309	@cd lib/sasl_plugins; pwd; $(MAKE) CRYPT_SRC
310	@cd lib/pam_modules/krb5;   pwd; $(MAKE) CRYPT_SRC
311	@cd uts/common/gssapi;    pwd; $(MAKE) CRYPT_SRC
312	@cd uts/common/gssapi/include;    pwd; $(MAKE) CRYPT_SRC
313	@cd uts/common/gssapi/mechs/dummy;        pwd; $(MAKE) CRYPT_SRC
314	@cd uts/common/gssapi/mechs/krb5; pwd; $(MAKE) CRYPT_SRC
315	$(RM) Makefile+
316	sed -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
317			< Makefile > Makefile+
318	$(MV) Makefile+ Makefile
319	$(CHMOD) 444 Makefile
320	$(RM) Makefile.master+
321	sed -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
322			< Makefile.master > Makefile.master+
323	$(MV) Makefile.master+ Makefile.master
324	$(CHMOD) 444 Makefile.master
325
326# EXPORT DELETE END
327
328ONC_PLUS:
329	@cd cmd/login; pwd; $(MAKE) ONC_PLUS
330	@cd uts; pwd; $(MAKE) ONC_PLUS
331
332#
333# Targets for reporting compiler versions; nightly uses these.
334#
335
336cc-version:
337	@if $($(MACH)_CC) -_versions >/dev/null 2>/dev/null; then \
338		$(ECHO) 32-bit compiler;			\
339		$(ECHO) $($(MACH)_CC);				\
340		$($(MACH)_CC) -_versions 2>&1 |			\
341		    $(EGREP) '^(cw|cc|gcc|primary|shadow)';	\
342	else							\
343		__COMPILER=`$($(MACH)_CC) -_compiler 2>/dev/null || $(TRUE)`;\
344		if [ -z "$$__COMPILER" ]; then			\
345			$(ECHO) No 32-bit compiler found;	\
346			exit 1;					\
347		else						\
348			$(ECHO) 32-bit compiler;		\
349			$(ECHO) $($(MACH)_CC);			\
350			$(ECHO) $$__COMPILER;			\
351			$($(MACH)_CC) -V 2>&1 | head -1;	\
352		fi;						\
353	fi
354
355cc64-version:
356	@if $($(MACH64)_CC) -_versions >/dev/null 2>/dev/null; then \
357		$(ECHO) 64-bit compiler;			\
358		$(ECHO) $($(MACH64)_CC);			\
359		$($(MACH64)_CC) -_versions 2>&1 |		\
360		    $(EGREP) '^(cw|cc|gcc|primary|shadow)';	\
361	else							\
362		__COMPILER=`$($(MACH64)_CC) -_compiler 2>/dev/null || $(TRUE)`;\
363		if [ -z "$$__COMPILER" ]; then			\
364			$(ECHO) No 64-bit compiler found;	\
365			exit 1;					\
366		else						\
367			$(ECHO) 64-bit compiler;		\
368			$(ECHO) $($(MACH64)_CC);		\
369			$(ECHO) $$__COMPILER;			\
370			$($(MACH64)_CC) -V 2>&1 | head -1;	\
371		fi;						\
372	fi
373
374java-version:
375	@if [ -x "$(JAVAC)" ]; then			\
376		$(ECHO) $(JAVAC);			\
377		$(JAVA_ROOT)/bin/java -fullversion 2>&1 | head -1;	\
378	else						\
379		$(ECHO) No Java compiler found;		\
380		exit 1;					\
381	fi
382