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