xref: /illumos-gate/usr/src/Makefile (revision 7c34a79b137bcbd26ee8292e08e8bf031e93089f)
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#
23# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24# Copyright (c) 2012 by Delphix. All rights reserved.
25# Copyright 2014 Garrett D'Amore <garrett@damore.org>
26# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
27# Copyright 2016 Toomas Soome <tsoome@me.com>
28# Copyright 2018 Joyent, Inc.
29# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
30#
31
32#
33# Makefile for system source
34#
35# include global definitions
36include Makefile.master
37#
38# the Targetdirs file is the AT&T target.dirs file in a makefile format.
39# it defines TARGETDIRS and ROOTDIRS.
40include Targetdirs
41
42COMMON_SUBDIRS=	data uts lib cmd ucblib ucbcmd man test
43sparc_SUBDIRS= psm stand
44i386_SUBDIRS= grub boot
45
46#
47# sparc needs to build stand before psm
48#
49$(SPARC_BLD)psm: stand
50
51SUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)
52
53HDRSUBDIRS=	uts head lib cmd
54
55# UCB headers are bug-for-bug compatible and not checkable against the header
56# standards.
57#
58CHKHDRSUBDIRS=	head uts lib
59
60#
61# Headers that can be built in parallel
62#
63PARALLEL_HEADERS = sysheaders userheaders libheaders cmdheaders
64
65#
66# Directories that can be built in parallel
67#
68PARALLEL_DIRS = data uts lib man
69
70# The check target also causes smf(7) service manifests to be validated.
71CHKMFSTSUBDIRS=	cmd
72
73# And man page formats
74CHKMANSUBDIRS = man
75
76# And test runfiles
77CHKTESTSUBDIRS = test
78
79MSGSUBDIRS=	cmd ucbcmd lib data
80
81all :=			TARGET= all
82install :=		TARGET= install
83install1 :=		TARGET= install
84install2 :=		TARGET= install
85install_h :=		TARGET= install_h
86clean :=		TARGET= clean
87clobber :=		TARGET= clobber
88check :=		TARGET= check
89
90.KEEP_STATE:
91
92#
93# Note: install does not cause a build in pkg.  To build packages,
94#	cd pkg and do a 'make install'
95#
96
97all: mapfiles closedbins sgs .WAIT $(SUBDIRS) pkg
98
99#
100# The _msg build is a two-step process.  First, the _msg dependency
101# causes recursive makes in $(MSGSUBDIRS), which stages raw message
102# files in $(ROOT)/catalog.  Second, the action from the install
103# target rule causes those messages to be post-processed from where
104# they were staged in $(ROOT)/catalog, and the results placed into the
105# proto area.
106#
107# The stage-licenses target causes the license files needed for
108# packaging to be pulled from $(SRC) and $(CLOSED) and staged in
109# $(ROOT)/licenses.
110#
111install: install1 install2 _msg stage-licenses
112	@cd msg; pwd; $(MAKE) _msg
113	@rm -rf "$(ROOT)/catalog"
114
115stage-licenses: install2
116	@cd pkg; pwd; $(MAKE) stage-licenses
117
118install1: mapfiles closedbins sgs
119
120install2: install1 .WAIT $(SUBDIRS)
121
122_msg: rootdirs FRC
123	@for m in $(MSGSUBDIRS); do \
124		cd $$m; pwd; $(MAKE) _msg; cd ..; \
125	done
126
127mapfiles: bldtools
128	@cd common/mapfiles; pwd; $(MAKE) install
129
130clean: $(SUBDIRS) head pkg
131clobber: $(SUBDIRS) head pkg clobber_local
132clobber_local:
133	@cd tools; pwd; $(MAKE) clobber
134	@cd common/mapfiles; pwd; $(MAKE) clobber
135	@cd msg; pwd; $(MAKE) clobber
136
137# If the tarballs are included inside ON_CLOSED_BINS, use those to extract and
138# preserve the permissions (in case a distro ships them).
139
140closedbins: bldtools $(ROOTDIRS) FRC
141	@CLOSED_ROOT="$$ON_CLOSED_BINS/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
142	if [ -f "$$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2" ]; then \
143		$(ECHO) "Extracting tarball $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2"; \
144		(cd $(CODEMGR_WS); \
145		   $(TAR) xjpf $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2); \
146		CLOSED_ROOT="$(CODEMGR_WS)/closed/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
147	fi; \
148	if [ ! -d "$$CLOSED_ROOT" ]; then \
149		$(ECHO) "Error: ON_CLOSED_BINS must point to closed" \
150		    "binaries."; \
151		$(ECHO) "root_$(MACH)$${RELEASE_BUILD+-nd} is not" \
152		    "present in $$ON_CLOSED_BINS."; \
153		exit 1; \
154	fi; \
155	$(ECHO) "Copying closed binaries from $$CLOSED_ROOT"; \
156	(cd $$CLOSED_ROOT; \
157	    $(TAR) cfX - $(CODEMGR_WS)/exception_lists/closed-bins .) | \
158	    (cd $(ROOT); $(TAR) xBpf -); \
159	$(CHMOD) 0400 $(ROOT)/etc/security/tsol/label_encodings; \
160	( cd $(ROOT); $(CTFSTRIP) $$(cd $$CLOSED_ROOT; $(FIND) \
161	    ./kernel ./usr/kernel ./platform/*/kernel -type f -a -perm -u+x | \
162	    $(EGREP) -vf $(CODEMGR_WS)/exception_lists/closed-bins) )
163
164#
165# Declare what parts can be built in parallel
166# DUMMY at the end is used in case macro expansion produces an empty string to
167# prevent everything going in parallel
168#
169.PARALLEL: $(PARALLEL_HEADERS) DUMMY
170.PARALLEL: $(PARALLEL_DIRS) DUMMY
171
172$(SUBDIRS) head pkg: FRC
173	@cd $@; pwd; $(MAKE) $(TARGET)
174
175# librpcsvc has a dependency on headers installed by
176# userheaders, hence the .WAIT before libheaders.
177sgs: rootdirs .WAIT sysheaders userheaders .WAIT \
178	libheaders cmdheaders
179
180#
181# Top-level setup target to setup the development environment that includes
182# headers, tools and generated mapfiles.  For open-only builds (i.e.: source
183# trees w/o usr/closed), this also depends on the closedbins target (above)
184# in order to properly seed the proto area.  Note, although the tools are
185# dependent on a number of constant mapfiles, the tools themselves are
186# required to build the generated mapfiles.
187#
188setup: closedbins bldtools sgs mapfiles
189
190#
191# Always build tools as non-DEBUG.
192# When nightly launches a build it first builds non-DEBUG tools and then
193# configures the environment so that these tools are used for building
194# subsequently. If a recursive build from usr/src then builds DEBUG tools,
195# the tools will be rebuilt using themselves resulting in a race condition
196# that can cause the build to fail - see https://www.illumos.org/issues/10462
197# for more details.
198# A manual build in usr/src/tools in a DEBUG bldenv will still do a DEBUG
199# tools build.
200#
201bldtools:
202	@cd tools; pwd; $(MAKE) RELEASE_BUILD= install
203
204# /var/mail/:saved is a special case because of the colon in the name.
205#
206rootdirs: $(ROOTDIRS)
207	$(INS) -d -m 775 $(ROOT)/var/mail/:saved
208
209$(ROOTDIRS):
210	$(INS.dir)
211
212userheaders: FRC
213	@cd head; pwd; $(MAKE) install_h
214
215libheaders: bldtools
216	@cd lib; pwd; $(MAKE) install_h
217
218sysheaders: FRC
219	@cd uts; pwd; $(MAKE) install_h
220
221cmdheaders: FRC
222	@cd cmd/devfsadm; pwd; $(MAKE) install_h
223	@cd cmd/fm; pwd; $(MAKE) install_h
224	@cd cmd/mdb; pwd; $(MAKE) install_h
225
226FRC:
227
228check:	$(CHKHDRSUBDIRS) $(CHKMFSTSUBDIRS) $(CHKMANSUBDIRS) $(CHKTESTSUBDIRS)
229
230#
231# Cross-reference customization: skip all of the subdirectories that
232# don't contain actual source code.
233#
234XRPRUNE = pkg prototypes
235XRINCDIRS = uts/common head ucbhead
236
237include Makefile.xref
238
239XREFFLAGS = -f -x
240
241# used by nightly
242cc-version:
243	@$(CW) --versions $(CW_CC_COMPILERS) 2>&1
244
245# for older nightlies
246cc64-version:
247
248java-version:
249	@if [ -x "$(JAVAC)" ]; then			\
250		$(ECHO) $(JAVAC);			\
251		$(JAVA_ROOT)/bin/java -fullversion 2>&1 | head -1;	\
252	else						\
253		$(ECHO) No Java compiler found;		\
254		exit 1;					\
255	fi
256
257openssl-version:
258	@if [ -x "$(OPENSSL)" ]; then				\
259		$(ECHO) $(OPENSSL);				\
260		$(OPENSSL) version;				\
261		$(OPENSSL) version -f |				\
262		    $(SED) -n '/_API/{s/.*_API/    API/;s/ -.*//;p;}'; \
263	else							\
264		$(ECHO) No OpenSSL utility found;		\
265	fi
266