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