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