xref: /illumos-gate/usr/src/Makefile (revision 0fb96ba1)
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.
27199767f8SToomas Soome# Copyright 2016 Toomas Soome <tsoome@me.com>
28aa9ef484SJohn Levon# Copyright 2018 Joyent, Inc.
29856f710cSAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
3078add226Sjmcp#
31d583b39bSJohn Wren Kennedy
327c478bd9Sstevel@tonic-gate#
337c478bd9Sstevel@tonic-gate# Makefile for system source
347c478bd9Sstevel@tonic-gate#
357c478bd9Sstevel@tonic-gate# include global definitions
367c478bd9Sstevel@tonic-gateinclude Makefile.master
377c478bd9Sstevel@tonic-gate#
387c478bd9Sstevel@tonic-gate# the Targetdirs file is the AT&T target.dirs file in a makefile format.
397c478bd9Sstevel@tonic-gate# it defines TARGETDIRS and ROOTDIRS.
407c478bd9Sstevel@tonic-gateinclude Targetdirs
417c478bd9Sstevel@tonic-gate
42622d9a34SRichard LoweCOMMON_SUBDIRS=	data uts lib cmd ucblib ucbcmd man test
43622d9a34SRichard Lowesparc_SUBDIRS= psm stand
44199767f8SToomas Soomei386_SUBDIRS= grub boot
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate#
47e3c7c8f8SMark J. Nelson# sparc needs to build stand before psm
487c478bd9Sstevel@tonic-gate#
49e3c7c8f8SMark J. Nelson$(SPARC_BLD)psm: stand
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gateSUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)
527c478bd9Sstevel@tonic-gate
535bbb4db2SGarrett D'AmoreHDRSUBDIRS=	uts head lib cmd
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate# UCB headers are bug-for-bug compatible and not checkable against the header
567c478bd9Sstevel@tonic-gate# standards.
577c478bd9Sstevel@tonic-gate#
587c478bd9Sstevel@tonic-gateCHKHDRSUBDIRS=	head uts lib
597c478bd9Sstevel@tonic-gate
6098157a70Sakolb#
6198157a70Sakolb# Headers that can be built in parallel
6298157a70Sakolb#
635bbb4db2SGarrett D'AmorePARALLEL_HEADERS = sysheaders userheaders libheaders cmdheaders
6498157a70Sakolb
6598157a70Sakolb#
6698157a70Sakolb# Directories that can be built in parallel
6798157a70Sakolb#
68503609a9SYuri PankovPARALLEL_DIRS = data uts lib man
6998157a70Sakolb
70bbf21555SRichard Lowe# The check target also causes smf(7) service manifests to be validated.
717c478bd9Sstevel@tonic-gateCHKMFSTSUBDIRS=	cmd
727c478bd9Sstevel@tonic-gate
7395c635efSGarrett D'Amore# And man page formats
7495c635efSGarrett D'AmoreCHKMANSUBDIRS = man
7595c635efSGarrett D'Amore
76503609a9SYuri PankovMSGSUBDIRS=	cmd ucbcmd lib data
777c478bd9Sstevel@tonic-gate
78694c35faSJosef 'Jeff' Sipekall :=			TARGET= all
79694c35faSJosef 'Jeff' Sipekinstall :=		TARGET= install
80e3c7c8f8SMark J. Nelsoninstall1 :=		TARGET= install
81e3c7c8f8SMark J. Nelsoninstall2 :=		TARGET= install
827c478bd9Sstevel@tonic-gateinstall_h :=		TARGET= install_h
837c478bd9Sstevel@tonic-gateclean :=		TARGET= clean
847c478bd9Sstevel@tonic-gateclobber :=		TARGET= clobber
857c478bd9Sstevel@tonic-gatecheck :=		TARGET= check
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate.KEEP_STATE:
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate#
90e3c7c8f8SMark J. Nelson# Note: install does not cause a build in pkg.  To build packages,
91ead1f93eSLiane Praza#	cd pkg and do a 'make install'
927c478bd9Sstevel@tonic-gate#
93e3c7c8f8SMark J. Nelson
94e3c7c8f8SMark J. Nelsonall: mapfiles closedbins sgs .WAIT $(SUBDIRS) pkg
95e3c7c8f8SMark J. Nelson
965084e753SMark J. Nelson#
975084e753SMark J. Nelson# The _msg build is a two-step process.  First, the _msg dependency
985084e753SMark J. Nelson# causes recursive makes in $(MSGSUBDIRS), which stages raw message
995084e753SMark J. Nelson# files in $(ROOT)/catalog.  Second, the action from the install
1005084e753SMark J. Nelson# target rule causes those messages to be post-processed from where
1015084e753SMark J. Nelson# they were staged in $(ROOT)/catalog, and the results placed into the
1025084e753SMark J. Nelson# proto area.
1035084e753SMark J. Nelson#
1045084e753SMark J. Nelson# The stage-licenses target causes the license files needed for
1055084e753SMark J. Nelson# packaging to be pulled from $(SRC) and $(CLOSED) and staged in
1065084e753SMark J. Nelson# $(ROOT)/licenses.
1075084e753SMark J. Nelson#
1085084e753SMark J. Nelsoninstall: install1 install2 _msg stage-licenses
109581cede6SMark J. Nelson	@cd msg; pwd; $(MAKE) _msg
1107c478bd9Sstevel@tonic-gate	@rm -rf "$(ROOT)/catalog"
1117c478bd9Sstevel@tonic-gate
1125084e753SMark J. Nelsonstage-licenses: install2
1135084e753SMark J. Nelson	@cd pkg; pwd; $(MAKE) stage-licenses
1145084e753SMark J. Nelson
115e3c7c8f8SMark J. Nelsoninstall1: mapfiles closedbins sgs
1167c478bd9Sstevel@tonic-gate
117f15a6fdeSJason Kinginstall2: install1 .WAIT $(SUBDIRS)
1187c478bd9Sstevel@tonic-gate
1193a51e5c0SRichard Lowe_msg: rootdirs FRC
120e3c7c8f8SMark J. Nelson	@for m in $(MSGSUBDIRS); do \
121e3c7c8f8SMark J. Nelson		cd $$m; pwd; $(MAKE) _msg; cd ..; \
122e3c7c8f8SMark J. Nelson	done
1237c478bd9Sstevel@tonic-gate
124e3c7c8f8SMark J. Nelsonmapfiles: bldtools
125e3c7c8f8SMark J. Nelson	@cd common/mapfiles; pwd; $(MAKE) install
1267c478bd9Sstevel@tonic-gate
127b6805bf7SGordon Rossclean: $(SUBDIRS) head pkg
128b6805bf7SGordon Rossclobber: $(SUBDIRS) head pkg clobber_local
129b6805bf7SGordon Rossclobber_local:
130b6805bf7SGordon Ross	@cd tools; pwd; $(MAKE) clobber
131b6805bf7SGordon Ross	@cd common/mapfiles; pwd; $(MAKE) clobber
132b6805bf7SGordon Ross	@cd msg; pwd; $(MAKE) clobber
1337c478bd9Sstevel@tonic-gate
1342e27c225SDan McDonald# If the tarballs are included inside ON_CLOSED_BINS, use those to extract and
1352e27c225SDan McDonald# preserve the permissions (in case a distro ships them).
1362e27c225SDan McDonald
137a0ed5030SJason Kingclosedbins: bldtools $(ROOTDIRS) FRC
1385b43ca41Sah	@CLOSED_ROOT="$$ON_CLOSED_BINS/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
1392e27c225SDan McDonald	if [ -f "$$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2" ]; then \
1402e27c225SDan McDonald		$(ECHO) "Extracting tarball $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2"; \
1412e27c225SDan McDonald		(cd $(CODEMGR_WS); \
1422e27c225SDan McDonald		   $(TAR) xjpf $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2); \
1432e27c225SDan McDonald		CLOSED_ROOT="$(CODEMGR_WS)/closed/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
1442e27c225SDan McDonald	fi; \
145c0e7977aSJosef 'Jeff' Sipek	if [ ! -d "$$CLOSED_ROOT" ]; then \
146c0e7977aSJosef 'Jeff' Sipek		$(ECHO) "Error: ON_CLOSED_BINS must point to closed" \
147c0e7977aSJosef 'Jeff' Sipek		    "binaries."; \
148c0e7977aSJosef 'Jeff' Sipek		$(ECHO) "root_$(MACH)$${RELEASE_BUILD+-nd} is not" \
149c0e7977aSJosef 'Jeff' Sipek		    "present in $$ON_CLOSED_BINS."; \
150c0e7977aSJosef 'Jeff' Sipek		exit 1; \
151c0e7977aSJosef 'Jeff' Sipek	fi; \
152c0e7977aSJosef 'Jeff' Sipek	$(ECHO) "Copying closed binaries from $$CLOSED_ROOT"; \
153c0e7977aSJosef 'Jeff' Sipek	(cd $$CLOSED_ROOT; \
154c0e7977aSJosef 'Jeff' Sipek	    $(TAR) cfX - $(CODEMGR_WS)/exception_lists/closed-bins .) | \
155c0e7977aSJosef 'Jeff' Sipek	    (cd $(ROOT); $(TAR) xBpf -); \
15605c0ef07SKlaus Ziegler	$(CHMOD) 0400 $(ROOT)/etc/security/tsol/label_encodings; \
157c0e7977aSJosef 'Jeff' Sipek	( cd $(ROOT); $(CTFSTRIP) $$(cd $$CLOSED_ROOT; $(FIND) \
158c0e7977aSJosef 'Jeff' Sipek	    ./kernel ./usr/kernel ./platform/*/kernel -type f -a -perm -u+x | \
159c0e7977aSJosef 'Jeff' Sipek	    $(EGREP) -vf $(CODEMGR_WS)/exception_lists/closed-bins) )
160fb9f9b97Skupfer
16198157a70Sakolb#
162e3c7c8f8SMark J. Nelson# Declare what parts can be built in parallel
16398157a70Sakolb# DUMMY at the end is used in case macro expansion produces an empty string to
16498157a70Sakolb# prevent everything going in parallel
16598157a70Sakolb#
16698157a70Sakolb.PARALLEL: $(PARALLEL_HEADERS) DUMMY
16798157a70Sakolb.PARALLEL: $(PARALLEL_DIRS) DUMMY
16898157a70Sakolb
169ead1f93eSLiane Praza$(SUBDIRS) head pkg: FRC
1707c478bd9Sstevel@tonic-gate	@cd $@; pwd; $(MAKE) $(TARGET)
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate# librpcsvc has a dependency on headers installed by
1737c478bd9Sstevel@tonic-gate# userheaders, hence the .WAIT before libheaders.
1747c478bd9Sstevel@tonic-gatesgs: rootdirs .WAIT sysheaders userheaders .WAIT \
1755bbb4db2SGarrett D'Amore	libheaders cmdheaders
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate#
178232c6638Srie# Top-level setup target to setup the development environment that includes
179232c6638Srie# headers, tools and generated mapfiles.  For open-only builds (i.e.: source
180232c6638Srie# trees w/o usr/closed), this also depends on the closedbins target (above)
181232c6638Srie# in order to properly seed the proto area.  Note, although the tools are
182232c6638Srie# dependent on a number of constant mapfiles, the tools themselves are
183232c6638Srie# required to build the generated mapfiles.
1847345d6c1Sstevel#
18578add226Sjmcpsetup: closedbins bldtools sgs mapfiles
186232c6638Srie
1876d3b6de8SAndy Fiddaman#
1886d3b6de8SAndy Fiddaman# Always build tools as non-DEBUG.
1896d3b6de8SAndy Fiddaman# When nightly launches a build it first builds non-DEBUG tools and then
1906d3b6de8SAndy Fiddaman# configures the environment so that these tools are used for building
1916d3b6de8SAndy Fiddaman# subsequently. If a recursive build from usr/src then builds DEBUG tools,
1926d3b6de8SAndy Fiddaman# the tools will be rebuilt using themselves resulting in a race condition
1936d3b6de8SAndy Fiddaman# that can cause the build to fail - see https://www.illumos.org/issues/10462
1946d3b6de8SAndy Fiddaman# for more details.
1956d3b6de8SAndy Fiddaman# A manual build in usr/src/tools in a DEBUG bldenv will still do a DEBUG
1966d3b6de8SAndy Fiddaman# tools build.
1976d3b6de8SAndy Fiddaman#
19878add226Sjmcpbldtools:
1996d3b6de8SAndy Fiddaman	@cd tools; pwd; $(MAKE) RELEASE_BUILD= install
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gate# /var/mail/:saved is a special case because of the colon in the name.
2027c478bd9Sstevel@tonic-gate#
2037c478bd9Sstevel@tonic-gaterootdirs: $(ROOTDIRS)
2047c478bd9Sstevel@tonic-gate	$(INS) -d -m 775 $(ROOT)/var/mail/:saved
2057c478bd9Sstevel@tonic-gate
2063a51e5c0SRichard Lowe$(ROOTDIRS):
2077c478bd9Sstevel@tonic-gate	$(INS.dir)
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gateuserheaders: FRC
2107c478bd9Sstevel@tonic-gate	@cd head; pwd; $(MAKE) install_h
2117c478bd9Sstevel@tonic-gate
21278add226Sjmcplibheaders: bldtools
2137c478bd9Sstevel@tonic-gate	@cd lib; pwd; $(MAKE) install_h
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gatesysheaders: FRC
2167c478bd9Sstevel@tonic-gate	@cd uts; pwd; $(MAKE) install_h
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gatecmdheaders: FRC
2192dc323c7SPatrick Mooney	@cd cmd/devfsadm; pwd; $(MAKE) install_h
2207c478bd9Sstevel@tonic-gate	@cd cmd/fm; pwd; $(MAKE) install_h
2217c478bd9Sstevel@tonic-gate	@cd cmd/mdb; pwd; $(MAKE) install_h
2227c478bd9Sstevel@tonic-gate
223*0fb96ba1SBill SommerfeldFRC:
224*0fb96ba1SBill Sommerfeld
22595c635efSGarrett D'Amorecheck:	$(CHKHDRSUBDIRS) $(CHKMFSTSUBDIRS) $(CHKMANSUBDIRS)
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate#
2287c478bd9Sstevel@tonic-gate# Cross-reference customization: skip all of the subdirectories that
2297c478bd9Sstevel@tonic-gate# don't contain actual source code.
2307c478bd9Sstevel@tonic-gate#
231694c35faSJosef 'Jeff' SipekXRPRUNE = pkg prototypes
2327c478bd9Sstevel@tonic-gateXRINCDIRS = uts/common head ucbhead
2337c478bd9Sstevel@tonic-gate
234*0fb96ba1SBill Sommerfeldinclude Makefile.xref
2357c478bd9Sstevel@tonic-gate
236*0fb96ba1SBill SommerfeldXREFFLAGS = -f -x
2377c478bd9Sstevel@tonic-gate
238aa9ef484SJohn Levon# used by nightly
2397c478bd9Sstevel@tonic-gatecc-version:
240aa9ef484SJohn Levon	@$(CW) --versions $(CW_CC_COMPILERS) 2>&1
2417c478bd9Sstevel@tonic-gate
242aa9ef484SJohn Levon# for older nightlies
2437c478bd9Sstevel@tonic-gatecc64-version:
2447c478bd9Sstevel@tonic-gate
2457c478bd9Sstevel@tonic-gatejava-version:
2467c478bd9Sstevel@tonic-gate	@if [ -x "$(JAVAC)" ]; then			\
2477c478bd9Sstevel@tonic-gate		$(ECHO) $(JAVAC);			\
2487c478bd9Sstevel@tonic-gate		$(JAVA_ROOT)/bin/java -fullversion 2>&1 | head -1;	\
2497c478bd9Sstevel@tonic-gate	else						\
2507c478bd9Sstevel@tonic-gate		$(ECHO) No Java compiler found;		\
2517c478bd9Sstevel@tonic-gate		exit 1;					\
2527c478bd9Sstevel@tonic-gate	fi
253300fdee2SAndy Fiddaman
254300fdee2SAndy Fiddamanopenssl-version:
255300fdee2SAndy Fiddaman	@if [ -x "$(OPENSSL)" ]; then				\
256300fdee2SAndy Fiddaman		$(ECHO) $(OPENSSL);				\
257300fdee2SAndy Fiddaman		$(OPENSSL) version;				\
258300fdee2SAndy Fiddaman		$(OPENSSL) version -f |				\
259300fdee2SAndy Fiddaman		    $(SED) -n '/_API/{s/.*_API/    API/;s/ -.*//;p;}'; \
260300fdee2SAndy Fiddaman	else							\
261300fdee2SAndy Fiddaman		$(ECHO) No OpenSSL utility found;		\
262300fdee2SAndy Fiddaman	fi
263