xref: /illumos-gate/usr/src/Makefile (revision 199767f8)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5fb9f9b97Skupfer# Common Development and Distribution License (the "License").
6fb9f9b97Skupfer# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
21d583b39bSJohn Wren Kennedy
227c478bd9Sstevel@tonic-gate#
2378add226Sjmcp# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24d583b39bSJohn Wren Kennedy# Copyright (c) 2012 by Delphix. All rights reserved.
2595c635efSGarrett D'Amore# Copyright 2014 Garrett D'Amore <garrett@damore.org>
262e27c225SDan McDonald# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
27*199767f8SToomas Soome# Copyright 2016 Toomas Soome <tsoome@me.com>
2878add226Sjmcp#
29d583b39bSJohn Wren Kennedy
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gate# Makefile for system source
327c478bd9Sstevel@tonic-gate#
337c478bd9Sstevel@tonic-gate# include global definitions
347c478bd9Sstevel@tonic-gateinclude Makefile.master
357c478bd9Sstevel@tonic-gate#
367c478bd9Sstevel@tonic-gate# the Targetdirs file is the AT&T target.dirs file in a makefile format.
377c478bd9Sstevel@tonic-gate# it defines TARGETDIRS and ROOTDIRS.
387c478bd9Sstevel@tonic-gateinclude Targetdirs
397c478bd9Sstevel@tonic-gate
40d583b39bSJohn Wren KennedyCOMMON_SUBDIRS=	uts lib cmd ucblib ucbcmd psm man test
41e3c7c8f8SMark J. Nelsonsparc_SUBDIRS= stand
42*199767f8SToomas Soomei386_SUBDIRS= grub boot
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate#
45e3c7c8f8SMark J. Nelson# sparc needs to build stand before psm
467c478bd9Sstevel@tonic-gate#
47e3c7c8f8SMark J. Nelson$(SPARC_BLD)psm: stand
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gateSUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)
507c478bd9Sstevel@tonic-gate
515bbb4db2SGarrett D'AmoreHDRSUBDIRS=	uts head lib cmd
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate# UCB headers are bug-for-bug compatible and not checkable against the header
547c478bd9Sstevel@tonic-gate# standards.
557c478bd9Sstevel@tonic-gate#
567c478bd9Sstevel@tonic-gateCHKHDRSUBDIRS=	head uts lib
577c478bd9Sstevel@tonic-gate
5898157a70Sakolb#
5998157a70Sakolb# Headers that can be built in parallel
6098157a70Sakolb#
615bbb4db2SGarrett D'AmorePARALLEL_HEADERS = sysheaders userheaders libheaders cmdheaders
6298157a70Sakolb
6398157a70Sakolb#
6498157a70Sakolb# Directories that can be built in parallel
6598157a70Sakolb#
66c10c16deSRichard LowePARALLEL_DIRS = uts lib man
6798157a70Sakolb
687c478bd9Sstevel@tonic-gate# The check target also causes smf(5) service manifests to be validated.
697c478bd9Sstevel@tonic-gateCHKMFSTSUBDIRS=	cmd
707c478bd9Sstevel@tonic-gate
7195c635efSGarrett D'Amore# And man page formats
7295c635efSGarrett D'AmoreCHKMANSUBDIRS = man
7395c635efSGarrett D'Amore
747c478bd9Sstevel@tonic-gateMSGSUBDIRS=	cmd ucbcmd lib
757c478bd9Sstevel@tonic-gateDOMAINS= \
767c478bd9Sstevel@tonic-gate	SUNW_OST_ADMIN \
777c478bd9Sstevel@tonic-gate	SUNW_OST_NETRPC \
787c478bd9Sstevel@tonic-gate	SUNW_OST_OSCMD \
797c478bd9Sstevel@tonic-gate	SUNW_OST_OSLIB \
807c478bd9Sstevel@tonic-gate	SUNW_OST_UCBCMD \
817c478bd9Sstevel@tonic-gate	SUNW_OST_ZONEINFO
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gateMSGDDIRS=       $(DOMAINS:%=$(MSGROOT)/%)
847c478bd9Sstevel@tonic-gateMSGDIRS=        $(MSGROOT) $(MSGDDIRS) $(MSGROOT)/LC_TIME
857c478bd9Sstevel@tonic-gate
86694c35faSJosef 'Jeff' Sipekall :=			TARGET= all
87694c35faSJosef 'Jeff' Sipekinstall :=		TARGET= install
88e3c7c8f8SMark J. Nelsoninstall1 :=		TARGET= install
89e3c7c8f8SMark J. Nelsoninstall2 :=		TARGET= install
907c478bd9Sstevel@tonic-gateinstall_h :=		TARGET= install_h
917c478bd9Sstevel@tonic-gateclean :=		TARGET= clean
927c478bd9Sstevel@tonic-gateclobber :=		TARGET= clobber
937c478bd9Sstevel@tonic-gatecheck :=		TARGET= check
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate.KEEP_STATE:
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate#
98e3c7c8f8SMark J. Nelson# Note: install does not cause a build in pkg.  To build packages,
99ead1f93eSLiane Praza#	cd pkg and do a 'make install'
1007c478bd9Sstevel@tonic-gate#
101e3c7c8f8SMark J. Nelson
102e3c7c8f8SMark J. Nelsonall: mapfiles closedbins sgs .WAIT $(SUBDIRS) pkg
103e3c7c8f8SMark J. Nelson
1045084e753SMark J. Nelson#
1055084e753SMark J. Nelson# The _msg build is a two-step process.  First, the _msg dependency
1065084e753SMark J. Nelson# causes recursive makes in $(MSGSUBDIRS), which stages raw message
1075084e753SMark J. Nelson# files in $(ROOT)/catalog.  Second, the action from the install
1085084e753SMark J. Nelson# target rule causes those messages to be post-processed from where
1095084e753SMark J. Nelson# they were staged in $(ROOT)/catalog, and the results placed into the
1105084e753SMark J. Nelson# proto area.
1115084e753SMark J. Nelson#
1125084e753SMark J. Nelson# The stage-licenses target causes the license files needed for
1135084e753SMark J. Nelson# packaging to be pulled from $(SRC) and $(CLOSED) and staged in
1145084e753SMark J. Nelson# $(ROOT)/licenses.
1155084e753SMark J. Nelson#
1165084e753SMark J. Nelsoninstall: install1 install2 _msg stage-licenses
117581cede6SMark J. Nelson	@cd msg; pwd; $(MAKE) _msg
1187c478bd9Sstevel@tonic-gate	@rm -rf "$(ROOT)/catalog"
1197c478bd9Sstevel@tonic-gate
1205084e753SMark J. Nelsonstage-licenses: install2
1215084e753SMark J. Nelson	@cd pkg; pwd; $(MAKE) stage-licenses
1225084e753SMark J. Nelson
123e3c7c8f8SMark J. Nelsoninstall1: mapfiles closedbins sgs
1247c478bd9Sstevel@tonic-gate
125e3c7c8f8SMark J. Nelsoninstall2: install1 $(SUBDIRS)
1267c478bd9Sstevel@tonic-gate
127b6805bf7SGordon Ross_msg: _msgdirs rootdirs FRC
128e3c7c8f8SMark J. Nelson	@for m in $(MSGSUBDIRS); do \
129e3c7c8f8SMark J. Nelson		cd $$m; pwd; $(MAKE) _msg; cd ..; \
130e3c7c8f8SMark J. Nelson	done
1317c478bd9Sstevel@tonic-gate
132e3c7c8f8SMark J. Nelsonmapfiles: bldtools
133e3c7c8f8SMark J. Nelson	@cd common/mapfiles; pwd; $(MAKE) install
1347c478bd9Sstevel@tonic-gate
135b6805bf7SGordon Rossclean: $(SUBDIRS) head pkg
136b6805bf7SGordon Rossclobber: $(SUBDIRS) head pkg clobber_local
137b6805bf7SGordon Rossclobber_local:
138b6805bf7SGordon Ross	@cd tools; pwd; $(MAKE) clobber
139b6805bf7SGordon Ross	@cd common/mapfiles; pwd; $(MAKE) clobber
140b6805bf7SGordon Ross	@cd msg; pwd; $(MAKE) clobber
1417c478bd9Sstevel@tonic-gate
1422e27c225SDan McDonald# If the tarballs are included inside ON_CLOSED_BINS, use those to extract and
1432e27c225SDan McDonald# preserve the permissions (in case a distro ships them).
1442e27c225SDan McDonald
145a0ed5030SJason Kingclosedbins: bldtools $(ROOTDIRS) FRC
1465b43ca41Sah	@CLOSED_ROOT="$$ON_CLOSED_BINS/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
1472e27c225SDan McDonald	if [ -f "$$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2" ]; then \
1482e27c225SDan McDonald		$(ECHO) "Extracting tarball $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2"; \
1492e27c225SDan McDonald		(cd $(CODEMGR_WS); \
1502e27c225SDan McDonald		   $(TAR) xjpf $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2); \
1512e27c225SDan McDonald		CLOSED_ROOT="$(CODEMGR_WS)/closed/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
1522e27c225SDan McDonald	fi; \
153c0e7977aSJosef 'Jeff' Sipek	if [ ! -d "$$CLOSED_ROOT" ]; then \
154c0e7977aSJosef 'Jeff' Sipek		$(ECHO) "Error: ON_CLOSED_BINS must point to closed" \
155c0e7977aSJosef 'Jeff' Sipek		    "binaries."; \
156c0e7977aSJosef 'Jeff' Sipek		$(ECHO) "root_$(MACH)$${RELEASE_BUILD+-nd} is not" \
157c0e7977aSJosef 'Jeff' Sipek		    "present in $$ON_CLOSED_BINS."; \
158c0e7977aSJosef 'Jeff' Sipek		exit 1; \
159c0e7977aSJosef 'Jeff' Sipek	fi; \
160c0e7977aSJosef 'Jeff' Sipek	$(ECHO) "Copying closed binaries from $$CLOSED_ROOT"; \
161c0e7977aSJosef 'Jeff' Sipek	(cd $$CLOSED_ROOT; \
162c0e7977aSJosef 'Jeff' Sipek	    $(TAR) cfX - $(CODEMGR_WS)/exception_lists/closed-bins .) | \
163c0e7977aSJosef 'Jeff' Sipek	    (cd $(ROOT); $(TAR) xBpf -); \
164c0e7977aSJosef 'Jeff' Sipek	( cd $(ROOT); $(CTFSTRIP) $$(cd $$CLOSED_ROOT; $(FIND) \
165c0e7977aSJosef 'Jeff' Sipek	    ./kernel ./usr/kernel ./platform/*/kernel -type f -a -perm -u+x | \
166c0e7977aSJosef 'Jeff' Sipek	    $(EGREP) -vf $(CODEMGR_WS)/exception_lists/closed-bins) )
167fb9f9b97Skupfer
16898157a70Sakolb#
169e3c7c8f8SMark J. Nelson# Declare what parts can be built in parallel
17098157a70Sakolb# DUMMY at the end is used in case macro expansion produces an empty string to
17198157a70Sakolb# prevent everything going in parallel
17298157a70Sakolb#
17398157a70Sakolb.PARALLEL: $(PARALLEL_HEADERS) DUMMY
17498157a70Sakolb.PARALLEL: $(PARALLEL_DIRS) DUMMY
17598157a70Sakolb
176ead1f93eSLiane Praza$(SUBDIRS) head pkg: FRC
1777c478bd9Sstevel@tonic-gate	@cd $@; pwd; $(MAKE) $(TARGET)
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gate# librpcsvc has a dependency on headers installed by
1807c478bd9Sstevel@tonic-gate# userheaders, hence the .WAIT before libheaders.
1817c478bd9Sstevel@tonic-gatesgs: rootdirs .WAIT sysheaders userheaders .WAIT \
1825bbb4db2SGarrett D'Amore	libheaders cmdheaders
1837c478bd9Sstevel@tonic-gate
1847c478bd9Sstevel@tonic-gate#
185232c6638Srie# Top-level setup target to setup the development environment that includes
186232c6638Srie# headers, tools and generated mapfiles.  For open-only builds (i.e.: source
187232c6638Srie# trees w/o usr/closed), this also depends on the closedbins target (above)
188232c6638Srie# in order to properly seed the proto area.  Note, although the tools are
189232c6638Srie# dependent on a number of constant mapfiles, the tools themselves are
190232c6638Srie# required to build the generated mapfiles.
1917345d6c1Sstevel#
19278add226Sjmcpsetup: closedbins bldtools sgs mapfiles
193232c6638Srie
19478add226Sjmcpbldtools:
1957c478bd9Sstevel@tonic-gate	@cd tools; pwd; $(MAKE) install
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate# /var/mail/:saved is a special case because of the colon in the name.
1987c478bd9Sstevel@tonic-gate#
1997c478bd9Sstevel@tonic-gaterootdirs: $(ROOTDIRS)
2007c478bd9Sstevel@tonic-gate	$(INS) -d -m 775 $(ROOT)/var/mail/:saved
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gatelint: FRC
2037c478bd9Sstevel@tonic-gate	$(MAKE) -f Makefile.lint
2047c478bd9Sstevel@tonic-gate
2057c478bd9Sstevel@tonic-gate_msgdirs:       $(MSGDIRS)
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate$(ROOTDIRS) $(MSGDIRS):
2087c478bd9Sstevel@tonic-gate	$(INS.dir)
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gateuserheaders: FRC
2117c478bd9Sstevel@tonic-gate	@cd head; pwd; $(MAKE) install_h
2127c478bd9Sstevel@tonic-gate
21378add226Sjmcplibheaders: bldtools
2147c478bd9Sstevel@tonic-gate	@cd lib; pwd; $(MAKE) install_h
2157c478bd9Sstevel@tonic-gate
2167c478bd9Sstevel@tonic-gatesysheaders: FRC
2177c478bd9Sstevel@tonic-gate	@cd uts; pwd; $(MAKE) install_h
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gatecmdheaders: FRC
2207c478bd9Sstevel@tonic-gate	@cd cmd/fm; pwd; $(MAKE) install_h
2217c478bd9Sstevel@tonic-gate	@cd cmd/mdb; pwd; $(MAKE) install_h
2227c478bd9Sstevel@tonic-gate
22395c635efSGarrett D'Amorecheck:	$(CHKHDRSUBDIRS) $(CHKMFSTSUBDIRS) $(CHKMANSUBDIRS)
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate#
2267c478bd9Sstevel@tonic-gate# Cross-reference customization: skip all of the subdirectories that
2277c478bd9Sstevel@tonic-gate# don't contain actual source code.
2287c478bd9Sstevel@tonic-gate#
229694c35faSJosef 'Jeff' SipekXRPRUNE = pkg prototypes
2307c478bd9Sstevel@tonic-gateXRINCDIRS = uts/common head ucbhead
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gatecscope.out tags: FRC
2337c478bd9Sstevel@tonic-gate	$(XREF) -f -x $@
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gateFRC:
2367c478bd9Sstevel@tonic-gate
2377c478bd9Sstevel@tonic-gate#
2387c478bd9Sstevel@tonic-gate# Targets for reporting compiler versions; nightly uses these.
2397c478bd9Sstevel@tonic-gate#
2407c478bd9Sstevel@tonic-gate
2417c478bd9Sstevel@tonic-gatecc-version:
2421912d2c4Swesolows	@if $($(MACH)_CC) -_versions >/dev/null 2>/dev/null; then \
243010b217aSwesolows		$(ECHO) 32-bit compiler;			\
244bf40377cSwesolows		$(ECHO) $($(MACH)_CC);				\
2451912d2c4Swesolows		$($(MACH)_CC) -_versions 2>&1 |			\
2461912d2c4Swesolows		    $(EGREP) '^(cw|cc|gcc|primary|shadow)';	\
247bf40377cSwesolows	else							\
248bf40377cSwesolows		__COMPILER=`$($(MACH)_CC) -_compiler 2>/dev/null || $(TRUE)`;\
249bf40377cSwesolows		if [ -z "$$__COMPILER" ]; then			\
250010b217aSwesolows			$(ECHO) No 32-bit compiler found;	\
251bf40377cSwesolows			exit 1;					\
252bf40377cSwesolows		else						\
253010b217aSwesolows			$(ECHO) 32-bit compiler;		\
254bf40377cSwesolows			$(ECHO) $($(MACH)_CC);			\
255bf40377cSwesolows			$(ECHO) $$__COMPILER;			\
256bf40377cSwesolows			$($(MACH)_CC) -V 2>&1 | head -1;	\
257bf40377cSwesolows		fi;						\
2587c478bd9Sstevel@tonic-gate	fi
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gatecc64-version:
2611912d2c4Swesolows	@if $($(MACH64)_CC) -_versions >/dev/null 2>/dev/null; then \
262010b217aSwesolows		$(ECHO) 64-bit compiler;			\
263bf40377cSwesolows		$(ECHO) $($(MACH64)_CC);			\
2641912d2c4Swesolows		$($(MACH64)_CC) -_versions 2>&1 |		\
2651912d2c4Swesolows		    $(EGREP) '^(cw|cc|gcc|primary|shadow)';	\
266bf40377cSwesolows	else							\
267bf40377cSwesolows		__COMPILER=`$($(MACH64)_CC) -_compiler 2>/dev/null || $(TRUE)`;\
268bf40377cSwesolows		if [ -z "$$__COMPILER" ]; then			\
269bf40377cSwesolows			$(ECHO) No 64-bit compiler found;	\
270bf40377cSwesolows			exit 1;					\
271bf40377cSwesolows		else						\
272010b217aSwesolows			$(ECHO) 64-bit compiler;		\
273bf40377cSwesolows			$(ECHO) $($(MACH64)_CC);		\
274bf40377cSwesolows			$(ECHO) $$__COMPILER;			\
275bf40377cSwesolows			$($(MACH64)_CC) -V 2>&1 | head -1;	\
276bf40377cSwesolows		fi;						\
2777c478bd9Sstevel@tonic-gate	fi
2787c478bd9Sstevel@tonic-gate
2797c478bd9Sstevel@tonic-gatejava-version:
2807c478bd9Sstevel@tonic-gate	@if [ -x "$(JAVAC)" ]; then			\
2817c478bd9Sstevel@tonic-gate		$(ECHO) $(JAVAC);			\
2827c478bd9Sstevel@tonic-gate		$(JAVA_ROOT)/bin/java -fullversion 2>&1 | head -1;	\
2837c478bd9Sstevel@tonic-gate	else						\
2847c478bd9Sstevel@tonic-gate		$(ECHO) No Java compiler found;		\
2857c478bd9Sstevel@tonic-gate		exit 1;					\
2867c478bd9Sstevel@tonic-gate	fi
287