xref: /illumos-gate/usr/src/Makefile (revision 199767f8)
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#
29
30#
31# Makefile for system source
32#
33# include global definitions
34include Makefile.master
35#
36# the Targetdirs file is the AT&T target.dirs file in a makefile format.
37# it defines TARGETDIRS and ROOTDIRS.
38include Targetdirs
39
40COMMON_SUBDIRS=	uts lib cmd ucblib ucbcmd psm man test
41sparc_SUBDIRS= stand
42i386_SUBDIRS= grub boot
43
44#
45# sparc needs to build stand before psm
46#
47$(SPARC_BLD)psm: stand
48
49SUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)
50
51HDRSUBDIRS=	uts head lib cmd
52
53# UCB headers are bug-for-bug compatible and not checkable against the header
54# standards.
55#
56CHKHDRSUBDIRS=	head uts lib
57
58#
59# Headers that can be built in parallel
60#
61PARALLEL_HEADERS = sysheaders userheaders libheaders cmdheaders
62
63#
64# Directories that can be built in parallel
65#
66PARALLEL_DIRS = uts lib man
67
68# The check target also causes smf(5) service manifests to be validated.
69CHKMFSTSUBDIRS=	cmd
70
71# And man page formats
72CHKMANSUBDIRS = man
73
74MSGSUBDIRS=	cmd ucbcmd lib
75DOMAINS= \
76	SUNW_OST_ADMIN \
77	SUNW_OST_NETRPC \
78	SUNW_OST_OSCMD \
79	SUNW_OST_OSLIB \
80	SUNW_OST_UCBCMD \
81	SUNW_OST_ZONEINFO
82
83MSGDDIRS=       $(DOMAINS:%=$(MSGROOT)/%)
84MSGDIRS=        $(MSGROOT) $(MSGDDIRS) $(MSGROOT)/LC_TIME
85
86all :=			TARGET= all
87install :=		TARGET= install
88install1 :=		TARGET= install
89install2 :=		TARGET= install
90install_h :=		TARGET= install_h
91clean :=		TARGET= clean
92clobber :=		TARGET= clobber
93check :=		TARGET= check
94
95.KEEP_STATE:
96
97#
98# Note: install does not cause a build in pkg.  To build packages,
99#	cd pkg and do a 'make install'
100#
101
102all: mapfiles closedbins sgs .WAIT $(SUBDIRS) pkg
103
104#
105# The _msg build is a two-step process.  First, the _msg dependency
106# causes recursive makes in $(MSGSUBDIRS), which stages raw message
107# files in $(ROOT)/catalog.  Second, the action from the install
108# target rule causes those messages to be post-processed from where
109# they were staged in $(ROOT)/catalog, and the results placed into the
110# proto area.
111#
112# The stage-licenses target causes the license files needed for
113# packaging to be pulled from $(SRC) and $(CLOSED) and staged in
114# $(ROOT)/licenses.
115#
116install: install1 install2 _msg stage-licenses
117	@cd msg; pwd; $(MAKE) _msg
118	@rm -rf "$(ROOT)/catalog"
119
120stage-licenses: install2
121	@cd pkg; pwd; $(MAKE) stage-licenses
122
123install1: mapfiles closedbins sgs
124
125install2: install1 $(SUBDIRS)
126
127_msg: _msgdirs rootdirs FRC
128	@for m in $(MSGSUBDIRS); do \
129		cd $$m; pwd; $(MAKE) _msg; cd ..; \
130	done
131
132mapfiles: bldtools
133	@cd common/mapfiles; pwd; $(MAKE) install
134
135clean: $(SUBDIRS) head pkg
136clobber: $(SUBDIRS) head pkg clobber_local
137clobber_local:
138	@cd tools; pwd; $(MAKE) clobber
139	@cd common/mapfiles; pwd; $(MAKE) clobber
140	@cd msg; pwd; $(MAKE) clobber
141
142# If the tarballs are included inside ON_CLOSED_BINS, use those to extract and
143# preserve the permissions (in case a distro ships them).
144
145closedbins: bldtools $(ROOTDIRS) FRC
146	@CLOSED_ROOT="$$ON_CLOSED_BINS/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
147	if [ -f "$$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2" ]; then \
148		$(ECHO) "Extracting tarball $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2"; \
149		(cd $(CODEMGR_WS); \
150		   $(TAR) xjpf $$ON_CLOSED_BINS/on-closed-bins$${RELEASE_BUILD+-nd}.$(MACH).tar.bz2); \
151		CLOSED_ROOT="$(CODEMGR_WS)/closed/root_$(MACH)$${RELEASE_BUILD+-nd}"; \
152	fi; \
153	if [ ! -d "$$CLOSED_ROOT" ]; then \
154		$(ECHO) "Error: ON_CLOSED_BINS must point to closed" \
155		    "binaries."; \
156		$(ECHO) "root_$(MACH)$${RELEASE_BUILD+-nd} is not" \
157		    "present in $$ON_CLOSED_BINS."; \
158		exit 1; \
159	fi; \
160	$(ECHO) "Copying closed binaries from $$CLOSED_ROOT"; \
161	(cd $$CLOSED_ROOT; \
162	    $(TAR) cfX - $(CODEMGR_WS)/exception_lists/closed-bins .) | \
163	    (cd $(ROOT); $(TAR) xBpf -); \
164	( cd $(ROOT); $(CTFSTRIP) $$(cd $$CLOSED_ROOT; $(FIND) \
165	    ./kernel ./usr/kernel ./platform/*/kernel -type f -a -perm -u+x | \
166	    $(EGREP) -vf $(CODEMGR_WS)/exception_lists/closed-bins) )
167
168#
169# Declare what parts can be built in parallel
170# DUMMY at the end is used in case macro expansion produces an empty string to
171# prevent everything going in parallel
172#
173.PARALLEL: $(PARALLEL_HEADERS) DUMMY
174.PARALLEL: $(PARALLEL_DIRS) DUMMY
175
176$(SUBDIRS) head pkg: FRC
177	@cd $@; pwd; $(MAKE) $(TARGET)
178
179# librpcsvc has a dependency on headers installed by
180# userheaders, hence the .WAIT before libheaders.
181sgs: rootdirs .WAIT sysheaders userheaders .WAIT \
182	libheaders cmdheaders
183
184#
185# Top-level setup target to setup the development environment that includes
186# headers, tools and generated mapfiles.  For open-only builds (i.e.: source
187# trees w/o usr/closed), this also depends on the closedbins target (above)
188# in order to properly seed the proto area.  Note, although the tools are
189# dependent on a number of constant mapfiles, the tools themselves are
190# required to build the generated mapfiles.
191#
192setup: closedbins bldtools sgs mapfiles
193
194bldtools:
195	@cd tools; pwd; $(MAKE) install
196
197# /var/mail/:saved is a special case because of the colon in the name.
198#
199rootdirs: $(ROOTDIRS)
200	$(INS) -d -m 775 $(ROOT)/var/mail/:saved
201
202lint: FRC
203	$(MAKE) -f Makefile.lint
204
205_msgdirs:       $(MSGDIRS)
206
207$(ROOTDIRS) $(MSGDIRS):
208	$(INS.dir)
209
210userheaders: FRC
211	@cd head; pwd; $(MAKE) install_h
212
213libheaders: bldtools
214	@cd lib; pwd; $(MAKE) install_h
215
216sysheaders: FRC
217	@cd uts; pwd; $(MAKE) install_h
218
219cmdheaders: FRC
220	@cd cmd/fm; pwd; $(MAKE) install_h
221	@cd cmd/mdb; pwd; $(MAKE) install_h
222
223check:	$(CHKHDRSUBDIRS) $(CHKMFSTSUBDIRS) $(CHKMANSUBDIRS)
224
225#
226# Cross-reference customization: skip all of the subdirectories that
227# don't contain actual source code.
228#
229XRPRUNE = pkg prototypes
230XRINCDIRS = uts/common head ucbhead
231
232cscope.out tags: FRC
233	$(XREF) -f -x $@
234
235FRC:
236
237#
238# Targets for reporting compiler versions; nightly uses these.
239#
240
241cc-version:
242	@if $($(MACH)_CC) -_versions >/dev/null 2>/dev/null; then \
243		$(ECHO) 32-bit compiler;			\
244		$(ECHO) $($(MACH)_CC);				\
245		$($(MACH)_CC) -_versions 2>&1 |			\
246		    $(EGREP) '^(cw|cc|gcc|primary|shadow)';	\
247	else							\
248		__COMPILER=`$($(MACH)_CC) -_compiler 2>/dev/null || $(TRUE)`;\
249		if [ -z "$$__COMPILER" ]; then			\
250			$(ECHO) No 32-bit compiler found;	\
251			exit 1;					\
252		else						\
253			$(ECHO) 32-bit compiler;		\
254			$(ECHO) $($(MACH)_CC);			\
255			$(ECHO) $$__COMPILER;			\
256			$($(MACH)_CC) -V 2>&1 | head -1;	\
257		fi;						\
258	fi
259
260cc64-version:
261	@if $($(MACH64)_CC) -_versions >/dev/null 2>/dev/null; then \
262		$(ECHO) 64-bit compiler;			\
263		$(ECHO) $($(MACH64)_CC);			\
264		$($(MACH64)_CC) -_versions 2>&1 |		\
265		    $(EGREP) '^(cw|cc|gcc|primary|shadow)';	\
266	else							\
267		__COMPILER=`$($(MACH64)_CC) -_compiler 2>/dev/null || $(TRUE)`;\
268		if [ -z "$$__COMPILER" ]; then			\
269			$(ECHO) No 64-bit compiler found;	\
270			exit 1;					\
271		else						\
272			$(ECHO) 64-bit compiler;		\
273			$(ECHO) $($(MACH64)_CC);		\
274			$(ECHO) $$__COMPILER;			\
275			$($(MACH64)_CC) -V 2>&1 | head -1;	\
276		fi;						\
277	fi
278
279java-version:
280	@if [ -x "$(JAVAC)" ]; then			\
281		$(ECHO) $(JAVAC);			\
282		$(JAVA_ROOT)/bin/java -fullversion 2>&1 | head -1;	\
283	else						\
284		$(ECHO) No Java compiler found;		\
285		exit 1;					\
286	fi
287