xref: /illumos-gate/usr/src/cmd/Makefile.cmd (revision 02b17e23cf5bf66a5ea787e066ae3d1aa49bd856)
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# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23#
24# Definitions common to command source.
25#
26# include global definitions; SRC should be defined in the shell.
27# SRC is needed until RFE 1026993 is implemented.
28
29include $(SRC)/Makefile.master
30
31FILEMODE=	0555
32LIBFILEMODE=	0444
33XPG4=		$(XPG4PROG:%=%.xpg4)
34XPG6=		$(XPG6PROG:%=%.xpg6)
35
36KRB5DIR=	$(ROOT)/usr
37KRB5BIN=	$(KRB5DIR)/bin
38KRB5SBIN=	$(KRB5DIR)/sbin
39KRB5LIB=	$(KRB5DIR)/lib/krb5
40KRB5RUNPATH=	/usr/lib/krb5
41GSSRUNPATH=	/usr/lib/gss
42
43
44ROOTBIN=		$(ROOT)/usr/bin
45ROOTLIB=		$(ROOT)/usr/lib
46ROOTLIBSVCBIN=		$(ROOT)/lib/svc/bin
47ROOTLIBSVCMETHOD=	$(ROOT)/lib/svc/method
48ROOTLIBXEN=		$(ROOT)/usr/lib/xen/bin
49ROOTLIBZONES=		$(ROOT)/lib/zones
50
51ROOTSHLIB=	$(ROOT)/usr/share/lib
52ROOTPKGBIN=	$(ROOT)/usr/sadm/install/bin
53ROOTCLASS_SCR_DIR= $(ROOT)/usr/sadm/install/scripts
54ROOTADMIN_SRC_DIR= $(ROOT)/var/sadm/install/admin
55
56ROOTSHLIBCCS=	$(ROOTSHLIB)/ccs
57ROOTSBIN=	$(ROOT)/sbin
58ROOTUSRSBIN=	$(ROOT)/usr/sbin
59ROOTETC=	$(ROOT)/etc
60
61ROOTETCSECURITY=	$(ROOTETC)/security
62ROOTETCTSOL=	$(ROOTETCSECURITY)/tsol
63ROOTETCSECLIB=	$(ROOTETCSECURITY)/lib
64ROOTETCZONES=	$(ROOTETC)/zones
65
66ROOTETCFTPD=	$(ROOT)/etc/ftpd
67ROOTETCINET=	$(ROOT)/etc/inet
68ROOTCCSBIN=	$(ROOT)/usr/ccs/bin
69ROOTCCSBIN64=	$(ROOTCCSBIN)/$(MACH64)
70ROOTCCSBINLINKDIR=	$(ROOT)/../../bin
71ROOTCCSBINLINKDIR64=	$(ROOT)../../../bin/$(MACH)
72ROOTCCSLIB=	$(ROOT)/usr/ccs/lib
73ROOTUSRKVM=	$(ROOT)/usr/kvm
74ROOTHAS=	$(ROOT)/usr/has
75ROOTHASBIN=	$(ROOT)/usr/has/bin
76ROOTHASLIB=	$(ROOT)/usr/has/lib
77ROOTXPG4=	$(ROOT)/usr/xpg4
78ROOTXPG4BIN=	$(ROOT)/usr/xpg4/bin
79ROOTXPG4BIN32=	$(ROOTXPG4BIN)/$(MACH32)
80ROOTXPG4BIN64=	$(ROOTXPG4BIN)/$(MACH64)
81ROOTXPG6=	$(ROOT)/usr/xpg6
82ROOTXPG6BIN=	$(ROOT)/usr/xpg6/bin
83ROOTLOCALEDEF=	$(ROOT)/usr/lib/localedef
84ROOTCHARMAP=	$(ROOTLOCALEDEF)/charmap
85ROOTI18NEXT=	$(ROOTLOCALEDEF)/extensions
86ROOTI18NEXT64=	$(ROOTLOCALEDEF)/extensions/$(MACH64)
87ROOTBIN32=	$(ROOTBIN)/$(MACH32)
88ROOTBIN64=	$(ROOTBIN)/$(MACH64)
89ROOTCMDDIR64=	$(ROOTCMDDIR)/$(MACH64)
90ROOTLIB64=	$(ROOTLIB)/$(MACH64)
91ROOTUSRSBIN32=	$(ROOTUSRSBIN)/$(MACH32)
92ROOTUSRSBIN64=	$(ROOTUSRSBIN)/$(MACH64)
93ROOTVARSMB=	$(ROOT)/var/smb
94
95
96#
97# Like ROOTLIBDIR in $(SRC)/Makefile.lib, any lower-level Makefiles that
98# put their binaries in a non-standard location should reset this and use
99# $(ROOTCMD) in their `install' target. By default we set this to a bogus
100# value so that it will not conflict with any of the other values already
101# defined in this Makefile.
102#
103ROOTCMDDIR=	$(ROOT)/__nonexistent_directory__
104
105ROOTSHAUDIO=	$(ROOT)/usr/share/audio
106ROOTAUDIOSAMP=	$(ROOTSHAUDIO)/samples
107ROOTAUDIOSAMPAU=$(ROOTAUDIOSAMP)/au
108
109ISAEXEC=	$(ROOT)/usr/lib/isaexec
110PLATEXEC=	$(ROOT)/usr/lib/platexec
111
112#
113# Enable the stack protector by default.
114#
115CFLAGS +=	$(CCSTACKPROTECT)
116CFLAGS64 +=	$(CCSTACKPROTECT)
117
118LDLIBS =	$(LDLIBS.cmd) $(LDSTACKPROTECT)
119
120LDFLAGS.cmd = \
121	$(BDIRECT) $(ENVLDFLAGS1) $(ENVLDFLAGS2) $(ENVLDFLAGS3) \
122	$(MAPFILE.NES:%=-Wl,-M%) $(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%)
123
124LDFLAGS =	$(LDFLAGS.cmd)
125
126KRB5PROG=	$(PROG:%=$(KRB5BIN)/%)
127KRB5SBINPROG=	$(PROG:%=$(KRB5SBIN)/%)
128KRB5LIBPROG=	$(PROG:%=$(KRB5LIB)/%)
129
130ROOTPROG=	$(PROG:%=$(ROOTBIN)/%)
131ROOTCMD=	$(PROG:%=$(ROOTCMDDIR)/%)
132ROOTSHFILES=	$(SHFILES:%=$(ROOTBIN)/%)
133ROOTLIBPROG=	$(PROG:%=$(ROOTLIB)/%)
134ROOTLIBSHFILES= $(SHFILES:%=$(ROOTLIB)/%)
135ROOTSHLIBPROG=	$(PROG:%=$(ROOTSHLIB)/%)
136ROOTSBINPROG=	$(PROG:%=$(ROOTSBIN)/%)
137ROOTPKGBINPROG= $(PROG:%=$(ROOTPKGBIN)/%)
138ROOTCLASS_SCR_FILES= $(SCRIPTS:%=$(ROOTCLASS_SCR_DIR)/%)
139ROOTUSRSBINPROG=$(PROG:%=$(ROOTUSRSBIN)/%)
140ROOTUSRSBINSCRIPT=$(SCRIPT:%=$(ROOTUSRSBIN)/%)
141ROOTETCPROG=	$(PROG:%=$(ROOTETC)/%)
142ROOTHASBINPROG= $(PROG:%=$(ROOTHASBIN)/%)
143ROOTHASLIBPROG= $(PROG:%=$(ROOTHASLIB)/%)
144ROOTCCSBINPROG=	$(PROG:%=$(ROOTCCSBIN)/%)
145ROOTCCSBINPROG64=	  $(PROG:%=$(ROOTCCSBIN64)/%)
146ROOTCCSBINLINK=$(PROG:%=  $(ROOTCCSBINLINKDIR)/%)
147ROOTCCSBINLINK64=$(PROG:%=$(ROOTCCSBINLINKDIR64)/%)
148ROOTUSRKVMPROG=	$(PROG:%=$(ROOTUSRKVM)/%)
149ROOTXPG4PROG=	$(XPG4PROG:%=$(ROOTXPG4BIN)/%)
150ROOTXPG4PROG32=	$(XPG4PROG:%=$(ROOTXPG4BIN32)/%)
151ROOTXPG4PROG64=	$(XPG4PROG:%=$(ROOTXPG4BIN64)/%)
152ROOTXPG6PROG=	$(XPG6PROG:%=$(ROOTXPG6BIN)/%)
153ROOTLOCALEPROG=	$(PROG:%=$(ROOTLOCALEDEF)/%)
154ROOTPROG64=	$(PROG:%=$(ROOTBIN64)/%)
155ROOTPROG32=	$(PROG:%=$(ROOTBIN32)/%)
156ROOTCMD64=	$(PROG:%=$(ROOTCMDDIR64)/%)
157ROOTUSRSBINPROG32=	$(PROG:%=$(ROOTUSRSBIN32)/%)
158ROOTUSRSBINPROG64=	$(PROG:%=$(ROOTUSRSBIN64)/%)
159ROOTLIBSVCBINPROG=	$(PROG:%=$(ROOTLIBSVCBIN)/%)
160
161# Symlink rules for /usr/ccs/bin commands. Note, those commands under
162# the rule of the linker area, are controlled by a different set of
163# rules defined in $(SRC)/cmd/sgs/Makefile.var.
164
165INS.ccsbinlink= \
166	$(RM) $(ROOTCCSBINPROG); \
167	$(SYMLINK) ../../bin/$(PROG) $(ROOTCCSBINPROG)
168
169INS.ccsbinlink64= \
170	$(RM) $(ROOTCCSBINPROG64); \
171	$(SYMLINK) ../../../bin/$(MACH64)/$(PROG) $(ROOTCCSBINPROG64)
172
173ROOTETCDEFAULT=	$(ROOTETC)/default
174ROOTETCDEFAULTFILES=	$(DEFAULTFILES:%.dfl=$(ROOTETCDEFAULT)/%)
175$(ROOTETCDEFAULTFILES) :=	FILEMODE = 0644
176
177ROOTETCSECFILES=	$(ETCSECFILES:%=$(ROOTETCSECURITY)/%)
178$(ROOTETCSECFILES) :=	FILEMODE = 0644
179
180ROOTETCTSOLFILES=	$(ETCTSOLFILES:%=$(ROOTETCTSOL)/%)
181$(ROOTETCTSOLFILES) :=	FILEMODE = 0644
182
183ROOTETCSECLIBFILES=	$(ETCSECLIBFILES:%=$(ROOTETCSECLIB)/%)
184
185ROOTETCZONESFILES=	$(ETCZONESFILES:%=$(ROOTETCZONES)/%)
186$(ROOTETCZONESFILES) :=	FILEMODE = 0444
187
188ROOTLIBZONESFILES=	$(LIBZONESFILES:%=$(ROOTLIBZONES)/%)
189$(ROOTLIBZONESFILES) :=	FILEMODE = 0555
190
191ROOTADMIN_SRC_FILE= $(ADMINFILE:%=$(ROOTADMIN_SRC_DIR)/%)
192$(ROOTADMIN_SRC_FILE) := FILEMODE = 0444
193
194#
195# Directories for smf(7) service manifests and profiles.
196#
197ROOTSVC=			$(ROOT)/lib/svc
198ROOTETCSVC=			$(ROOT)/etc/svc
199
200ROOTSVCMANIFEST=		$(ROOTSVC)/manifest
201ROOTSVCPROFILE=			$(ROOTETCSVC)/profile
202
203ROOTSVCMILESTONE=		$(ROOTSVCMANIFEST)/milestone
204ROOTSVCDEVICE=			$(ROOTSVCMANIFEST)/device
205ROOTSVCSYSTEM=			$(ROOTSVCMANIFEST)/system
206ROOTSVCSYSTEMDEVICE=		$(ROOTSVCSYSTEM)/device
207ROOTSVCSYSTEMFILESYSTEM=	$(ROOTSVCSYSTEM)/filesystem
208ROOTSVCSYSTEMSECURITY=		$(ROOTSVCSYSTEM)/security
209ROOTSVCNETWORK=			$(ROOTSVCMANIFEST)/network
210ROOTSVCNETWORKDNS=		$(ROOTSVCNETWORK)/dns
211ROOTSVCNETWORKISCSI=		$(ROOTSVCNETWORK)/iscsi
212ROOTSVCNETWORKLDAP=		$(ROOTSVCNETWORK)/ldap
213ROOTSVCNETWORKNFS=		$(ROOTSVCNETWORK)/nfs
214ROOTSVCNETWORKNIS=		$(ROOTSVCNETWORK)/nis
215ROOTSVCNETWORKROUTING=		$(ROOTSVCNETWORK)/routing
216ROOTSVCNETWORKRPC=		$(ROOTSVCNETWORK)/rpc
217ROOTSVCNETWORKSMB=		$(ROOTSVCNETWORK)/smb
218ROOTSVCNETWORKSECURITY=		$(ROOTSVCNETWORK)/security
219ROOTSVCNETWORKSSL=		$(ROOTSVCNETWORK)/ssl
220ROOTSVCNETWORKIPSEC=		$(ROOTSVCNETWORK)/ipsec
221ROOTSVCNETWORKSHARES=		$(ROOTSVCNETWORK)/shares
222ROOTSVCSMB=			$(ROOTSVCNETWORK)/smb
223ROOTSVCPLATFORM=		$(ROOTSVCMANIFEST)/platform
224ROOTSVCPLATFORMSUN4U=		$(ROOTSVCPLATFORM)/sun4u
225ROOTSVCPLATFORMSUN4V=		$(ROOTSVCPLATFORM)/sun4v
226ROOTSVCAPPLICATION=		$(ROOTSVCMANIFEST)/application
227ROOTSVCAPPLICATIONMANAGEMENT=	$(ROOTSVCAPPLICATION)/management
228ROOTSVCAPPLICATIONSECURITY=	$(ROOTSVCAPPLICATION)/security
229ROOTSVCAPPLICATIONPRINT=	$(ROOTSVCAPPLICATION)/print
230
231#
232# Commands Makefiles delivering a manifest are expected to define MANIFEST.
233#
234# Like ROOTCMDDIR, any lower-level Makefiles that put their manifests in a
235# subdirectory of the manifest directories listed above should reset
236# ROOTMANIFESTDIR and use it in their `install' target. By default we set this
237# to a bogus value so that it will not conflict with any of the other values
238# already  defined in this Makefile.
239#
240# The manifest validation of the $SRC/cmd check target is also derived from a
241# valid MANIFEST setting.
242#
243ROOTMANIFESTDIR=	$(ROOTSVCMANIFEST)/__nonexistent_directory__
244ROOTMANIFEST=		$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
245CHKMANIFEST=		$(MANIFEST:%.xml=%.xmlchk)
246
247# Manifests cannot be checked in parallel, because we are using the global
248# repository that is in $(SRC)/cmd/svc/seed/global.db.  This is a
249# repository that is built from the manifests in this workspace, whereas
250# the build machine's repository may be out of sync with these manifests.
251# Because we are using a private repository, svccfg-native must start up a
252# private copy of configd-native.  We cannot have multiple copies of
253# configd-native trying to access global.db simultaneously.
254
255.NO_PARALLEL:	$(CHKMANIFEST)
256
257#
258# For installing "starter scripts" of services
259#
260
261ROOTSVCMETHOD=		$(SVCMETHOD:%=$(ROOTLIBSVCMETHOD)/%)
262
263ROOTSVCBINDIR=		$(ROOTLIBSVCBIN)/__nonexistent_directory__
264ROOTSVCBIN=		$(SVCBIN:%=$(ROOTSVCBINDIR)/%)
265
266#
267
268$(KRB5BIN)/%: %
269	$(INS.file)
270
271$(KRB5SBIN)/%: %
272	$(INS.file)
273
274$(KRB5LIB)/%: %
275	$(INS.file)
276
277$(ROOTBIN)/%: %
278	$(INS.file)
279
280$(ROOTLIB)/%: %
281	$(INS.file)
282
283$(ROOTBIN64)/%: %
284	$(INS.file)
285
286$(ROOTLIB64)/%: %
287	$(INS.file)
288
289$(ROOTBIN32)/%: %
290	$(INS.file)
291
292$(ROOTSHLIB)/%: %
293	$(INS.file)
294
295$(ROOTPKGBIN)/%: %
296	$(INS.file)
297
298$(ROOTCLASS_SCR_DIR)/%: %
299	$(INS.file)
300
301$(ROOTADMIN_SRC_DIR)/%: %
302	$(INS.file)
303
304$(ROOTSBIN)/%: %
305	$(INS.file)
306
307$(ROOTUSRSBIN)/%: %
308	$(INS.file)
309
310$(ROOTUSRSBIN32)/%: %
311	$(INS.file)
312
313$(ROOTUSRSBIN64)/%: %
314	$(INS.file)
315
316$(ROOTETC)/%: %
317	$(INS.file)
318
319$(ROOTETCFTPD)/%: %
320	$(INS.file)
321
322$(ROOTETCINET)/%: %
323	$(INS.file)
324
325$(ROOTETCDEFAULT)/%:	%.dfl
326	$(INS.rename)
327
328$(ROOTETCTSOL)/%: %
329	$(INS.file)
330
331$(ROOTETCSECLIB)/%: %
332	$(INS.file)
333
334$(ROOTETCZONES)/%: %
335	$(INS.file)
336
337$(ROOTLIBZONES)/%: %
338	$(INS.file)
339
340$(ROOTLIBXEN)/%: %
341	$(INS.file)
342
343$(ROOTHASBIN)/%: %
344	$(INS.file)
345
346$(ROOTHASLIB)/%: %
347	$(INS.file)
348
349$(ROOTUSRKVM)/%: %
350	$(INS.file)
351
352$(ROOTXPG4BIN)/%: %.xpg4
353	$(INS.rename)
354
355$(ROOTXPG4BIN32)/%: %.xpg4
356	$(INS.rename)
357
358$(ROOTXPG4BIN64)/%: %.xpg4
359	$(INS.rename)
360
361$(ROOTXPG6BIN)/%: %.xpg6
362	$(INS.rename)
363
364$(ROOTLOCALEDEF)/%: %
365	$(INS.file)
366
367$(ROOTCHARMAP)/%: %
368	$(INS.file)
369
370$(ROOTI18NEXT)/%: %
371	$(INS.file)
372
373$(ROOTI18NEXT64)/%: %
374	$(INS.file)
375
376$(ROOTLIBSVCMETHOD)/%: %
377	$(INS.file)
378
379$(ROOTLIBSVCBIN)/%: %
380	$(INS.file)
381
382$(ROOTSVCMILESTONE)/%: %
383	$(INS.file)
384
385$(ROOTSVCDEVICE)/%: %
386	$(INS.file)
387
388$(ROOTSVCSYSTEM)/%: %
389	$(INS.file)
390
391$(ROOTSVCSYSTEMDEVICE)/%: %
392	$(INS.file)
393
394$(ROOTSVCSYSTEMFILESYSTEM)/%: %
395	$(INS.file)
396
397$(ROOTSVCSYSTEMSECURITY)/%: %
398	$(INS.file)
399
400$(ROOTSVCNETWORK)/%: %
401	$(INS.file)
402
403$(ROOTSVCNETWORKLDAP)/%: %
404	$(INS.file)
405
406$(ROOTSVCNETWORKNFS)/%: %
407	$(INS.file)
408
409$(ROOTSVCNETWORKNIS)/%: %
410	$(INS.file)
411
412$(ROOTSVCNETWORKRPC)/%: %
413	$(INS.file)
414
415$(ROOTSVCNETWORKSECURITY)/%: %
416	$(INS.file)
417
418$(ROOTSVCNETWORKSSL)/%: %
419	$(INS.file)
420
421$(ROOTSVCNETWORKIPSEC)/%: %
422	$(INS.file)
423
424$(ROOTSVCNETWORKSHARES)/%: %
425	$(INS.file)
426
427$(ROOTSVCNETWORKSMB)/%: %
428	$(INS.file)
429
430$(ROOTSVCAPPLICATION)/%: %
431	$(INS.file)
432
433$(ROOTSVCAPPLICATIONMANAGEMENT)/%: %
434	$(INS.file)
435
436$(ROOTSVCAPPLICATIONSECURITY)/%: %
437	$(INS.file)
438
439$(ROOTSVCAPPLICATIONPRINT)/%: %
440	$(INS.file)
441
442$(ROOTSVCPLATFORM)/%: %
443	$(INS.file)
444
445$(ROOTSVCPLATFORMSUN4U)/%: %
446	$(INS.file)
447
448$(ROOTSVCPLATFORMSUN4V)/%: %
449	$(INS.file)
450
451# Install rule for gprof, yacc, and lex dependency files
452$(ROOTSHLIBCCS)/%: ../common/%
453	$(INS.file)
454
455$(ROOTCCSBINLINKDIR)/%: %
456	$(INS.ccsbinlink)
457
458$(ROOTCCSBINLINKDIR64)/%: %
459	$(INS.ccsbinlink64)
460
461$(ROOTVARSMB)/%: %
462	$(INS.file)
463
464# build rule for statically linked programs with single source file.
465%.static: %.c
466	$(LINK.c) -o $@ $< $(LDLIBS)
467	$(POST_PROCESS)
468
469%.xpg4: %.c
470	$(LINK.c) -o $@ $< $(LDLIBS)
471	$(POST_PROCESS)
472
473%.xpg6: %.c
474	$(LINK.c) -o $@ $< $(LDLIBS)
475	$(POST_PROCESS)
476
477# Define the majority text domain in this directory.
478TEXT_DOMAIN= SUNW_OST_OSCMD
479
480CLOBBERFILES += $(XPG4) $(XPG6) $(DCFILE)
481
482# This flag is for programs which should not build a 32-bit binary
483sparc_64ONLY= $(POUND_SIGN)
48464ONLY=	 $($(MACH)_64ONLY)
485
486# For programs that are installed in the root filesystem,
487# build $(ROOTFS_PROG) rather than $(PROG)
488$(64ONLY)$(ROOTFS_PROG) := LDFLAGS += -Wl,-I/lib/ld.so.1
489