xref: /illumos-gate/usr/src/cmd/Makefile.cmd (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
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# Note that commands in usr/src/cmd/sgs have separate targets for this
162INS.ccsbinlink= \
163	$(RM) $(ROOTCCSBINPROG); \
164	$(SYMLINK) ../../bin/$(PROG) $(ROOTCCSBINPROG)
165
166INS.ccsbinlink64= \
167	$(RM) $(ROOTCCSBINPROG64); \
168	$(SYMLINK) ../../../bin/$(MACH64)/$(PROG) $(ROOTCCSBINPROG64)
169
170ROOTETCDEFAULT=	$(ROOTETC)/default
171ROOTETCDEFAULTFILES=	$(DEFAULTFILES:%.dfl=$(ROOTETCDEFAULT)/%)
172$(ROOTETCDEFAULTFILES) :=	FILEMODE = 0644
173
174ROOTETCSECFILES=	$(ETCSECFILES:%=$(ROOTETCSECURITY)/%)
175$(ROOTETCSECFILES) :=	FILEMODE = 0644
176
177ROOTETCTSOLFILES=	$(ETCTSOLFILES:%=$(ROOTETCTSOL)/%)
178$(ROOTETCTSOLFILES) :=	FILEMODE = 0644
179
180ROOTETCSECLIBFILES=	$(ETCSECLIBFILES:%=$(ROOTETCSECLIB)/%)
181
182ROOTETCZONESFILES=	$(ETCZONESFILES:%=$(ROOTETCZONES)/%)
183$(ROOTETCZONESFILES) :=	FILEMODE = 0444
184
185ROOTLIBZONESFILES=	$(LIBZONESFILES:%=$(ROOTLIBZONES)/%)
186$(ROOTLIBZONESFILES) :=	FILEMODE = 0555
187
188ROOTADMIN_SRC_FILE= $(ADMINFILE:%=$(ROOTADMIN_SRC_DIR)/%)
189$(ROOTADMIN_SRC_FILE) := FILEMODE = 0444
190
191#
192# Directories for smf(7) service manifests and profiles.
193#
194ROOTSVC=			$(ROOT)/lib/svc
195ROOTETCSVC=			$(ROOT)/etc/svc
196
197ROOTSVCMANIFEST=		$(ROOTSVC)/manifest
198ROOTSVCPROFILE=			$(ROOTETCSVC)/profile
199
200ROOTSVCMILESTONE=		$(ROOTSVCMANIFEST)/milestone
201ROOTSVCDEVICE=			$(ROOTSVCMANIFEST)/device
202ROOTSVCSYSTEM=			$(ROOTSVCMANIFEST)/system
203ROOTSVCSYSTEMDEVICE=		$(ROOTSVCSYSTEM)/device
204ROOTSVCSYSTEMFILESYSTEM=	$(ROOTSVCSYSTEM)/filesystem
205ROOTSVCSYSTEMSECURITY=		$(ROOTSVCSYSTEM)/security
206ROOTSVCNETWORK=			$(ROOTSVCMANIFEST)/network
207ROOTSVCNETWORKDNS=		$(ROOTSVCNETWORK)/dns
208ROOTSVCNETWORKISCSI=		$(ROOTSVCNETWORK)/iscsi
209ROOTSVCNETWORKLDAP=		$(ROOTSVCNETWORK)/ldap
210ROOTSVCNETWORKNFS=		$(ROOTSVCNETWORK)/nfs
211ROOTSVCNETWORKNIS=		$(ROOTSVCNETWORK)/nis
212ROOTSVCNETWORKROUTING=		$(ROOTSVCNETWORK)/routing
213ROOTSVCNETWORKRPC=		$(ROOTSVCNETWORK)/rpc
214ROOTSVCNETWORKSMB=		$(ROOTSVCNETWORK)/smb
215ROOTSVCNETWORKSECURITY=		$(ROOTSVCNETWORK)/security
216ROOTSVCNETWORKSSL=		$(ROOTSVCNETWORK)/ssl
217ROOTSVCNETWORKIPSEC=		$(ROOTSVCNETWORK)/ipsec
218ROOTSVCNETWORKSHARES=		$(ROOTSVCNETWORK)/shares
219ROOTSVCSMB=			$(ROOTSVCNETWORK)/smb
220ROOTSVCPLATFORM=		$(ROOTSVCMANIFEST)/platform
221ROOTSVCPLATFORMSUN4U=		$(ROOTSVCPLATFORM)/sun4u
222ROOTSVCPLATFORMSUN4V=		$(ROOTSVCPLATFORM)/sun4v
223ROOTSVCAPPLICATION=		$(ROOTSVCMANIFEST)/application
224ROOTSVCAPPLICATIONMANAGEMENT=	$(ROOTSVCAPPLICATION)/management
225ROOTSVCAPPLICATIONSECURITY=	$(ROOTSVCAPPLICATION)/security
226ROOTSVCAPPLICATIONPRINT=	$(ROOTSVCAPPLICATION)/print
227
228#
229# Commands Makefiles delivering a manifest are expected to define MANIFEST.
230#
231# Like ROOTCMDDIR, any lower-level Makefiles that put their manifests in a
232# subdirectory of the manifest directories listed above should reset
233# ROOTMANIFESTDIR and use it in their `install' target. By default we set this
234# to a bogus value so that it will not conflict with any of the other values
235# already  defined in this Makefile.
236#
237# The manifest validation of the $SRC/cmd check target is also derived from a
238# valid MANIFEST setting.
239#
240ROOTMANIFESTDIR=	$(ROOTSVCMANIFEST)/__nonexistent_directory__
241ROOTMANIFEST=		$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
242CHKMANIFEST=		$(MANIFEST:%.xml=%.xmlchk)
243
244# Manifests cannot be checked in parallel, because we are using the global
245# repository that is in $(SRC)/cmd/svc/seed/global.db.  This is a
246# repository that is built from the manifests in this workspace, whereas
247# the build machine's repository may be out of sync with these manifests.
248# Because we are using a private repository, svccfg-native must start up a
249# private copy of configd-native.  We cannot have multiple copies of
250# configd-native trying to access global.db simultaneously.
251
252.NO_PARALLEL:	$(CHKMANIFEST)
253
254#
255# For installing "starter scripts" of services
256#
257
258ROOTSVCMETHOD=		$(SVCMETHOD:%=$(ROOTLIBSVCMETHOD)/%)
259
260ROOTSVCBINDIR=		$(ROOTLIBSVCBIN)/__nonexistent_directory__
261ROOTSVCBIN=		$(SVCBIN:%=$(ROOTSVCBINDIR)/%)
262
263#
264
265$(KRB5BIN)/%: %
266	$(INS.file)
267
268$(KRB5SBIN)/%: %
269	$(INS.file)
270
271$(KRB5LIB)/%: %
272	$(INS.file)
273
274$(ROOTBIN)/%: %
275	$(INS.file)
276
277$(ROOTLIB)/%: %
278	$(INS.file)
279
280$(ROOTBIN64)/%: %
281	$(INS.file)
282
283$(ROOTLIB64)/%: %
284	$(INS.file)
285
286$(ROOTBIN32)/%: %
287	$(INS.file)
288
289$(ROOTSHLIB)/%: %
290	$(INS.file)
291
292$(ROOTPKGBIN)/%: %
293	$(INS.file)
294
295$(ROOTCLASS_SCR_DIR)/%: %
296	$(INS.file)
297
298$(ROOTADMIN_SRC_DIR)/%: %
299	$(INS.file)
300
301$(ROOTSBIN)/%: %
302	$(INS.file)
303
304$(ROOTUSRSBIN)/%: %
305	$(INS.file)
306
307$(ROOTUSRSBIN32)/%: %
308	$(INS.file)
309
310$(ROOTUSRSBIN64)/%: %
311	$(INS.file)
312
313$(ROOTETC)/%: %
314	$(INS.file)
315
316$(ROOTETCFTPD)/%: %
317	$(INS.file)
318
319$(ROOTETCINET)/%: %
320	$(INS.file)
321
322$(ROOTETCDEFAULT)/%:	%.dfl
323	$(INS.rename)
324
325$(ROOTETCTSOL)/%: %
326	$(INS.file)
327
328$(ROOTETCSECLIB)/%: %
329	$(INS.file)
330
331$(ROOTETCZONES)/%: %
332	$(INS.file)
333
334$(ROOTLIBZONES)/%: %
335	$(INS.file)
336
337$(ROOTLIBXEN)/%: %
338	$(INS.file)
339
340$(ROOTHASBIN)/%: %
341	$(INS.file)
342
343$(ROOTHASLIB)/%: %
344	$(INS.file)
345
346$(ROOTUSRKVM)/%: %
347	$(INS.file)
348
349$(ROOTXPG4BIN)/%: %.xpg4
350	$(INS.rename)
351
352$(ROOTXPG4BIN32)/%: %.xpg4
353	$(INS.rename)
354
355$(ROOTXPG4BIN64)/%: %.xpg4
356	$(INS.rename)
357
358$(ROOTXPG6BIN)/%: %.xpg6
359	$(INS.rename)
360
361$(ROOTLOCALEDEF)/%: %
362	$(INS.file)
363
364$(ROOTCHARMAP)/%: %
365	$(INS.file)
366
367$(ROOTI18NEXT)/%: %
368	$(INS.file)
369
370$(ROOTI18NEXT64)/%: %
371	$(INS.file)
372
373$(ROOTLIBSVCMETHOD)/%: %
374	$(INS.file)
375
376$(ROOTLIBSVCBIN)/%: %
377	$(INS.file)
378
379$(ROOTSVCMILESTONE)/%: %
380	$(INS.file)
381
382$(ROOTSVCDEVICE)/%: %
383	$(INS.file)
384
385$(ROOTSVCSYSTEM)/%: %
386	$(INS.file)
387
388$(ROOTSVCSYSTEMDEVICE)/%: %
389	$(INS.file)
390
391$(ROOTSVCSYSTEMFILESYSTEM)/%: %
392	$(INS.file)
393
394$(ROOTSVCSYSTEMSECURITY)/%: %
395	$(INS.file)
396
397$(ROOTSVCNETWORK)/%: %
398	$(INS.file)
399
400$(ROOTSVCNETWORKLDAP)/%: %
401	$(INS.file)
402
403$(ROOTSVCNETWORKNFS)/%: %
404	$(INS.file)
405
406$(ROOTSVCNETWORKNIS)/%: %
407	$(INS.file)
408
409$(ROOTSVCNETWORKRPC)/%: %
410	$(INS.file)
411
412$(ROOTSVCNETWORKSECURITY)/%: %
413	$(INS.file)
414
415$(ROOTSVCNETWORKSSL)/%: %
416	$(INS.file)
417
418$(ROOTSVCNETWORKIPSEC)/%: %
419	$(INS.file)
420
421$(ROOTSVCNETWORKSHARES)/%: %
422	$(INS.file)
423
424$(ROOTSVCNETWORKSMB)/%: %
425	$(INS.file)
426
427$(ROOTSVCAPPLICATION)/%: %
428	$(INS.file)
429
430$(ROOTSVCAPPLICATIONMANAGEMENT)/%: %
431	$(INS.file)
432
433$(ROOTSVCAPPLICATIONSECURITY)/%: %
434	$(INS.file)
435
436$(ROOTSVCAPPLICATIONPRINT)/%: %
437	$(INS.file)
438
439$(ROOTSVCPLATFORM)/%: %
440	$(INS.file)
441
442$(ROOTSVCPLATFORMSUN4U)/%: %
443	$(INS.file)
444
445$(ROOTSVCPLATFORMSUN4V)/%: %
446	$(INS.file)
447
448# Install rule for gprof, yacc, and lex dependency files
449$(ROOTSHLIBCCS)/%: ../common/%
450	$(INS.file)
451
452$(ROOTCCSBINLINKDIR)/%: %
453	$(INS.ccsbinlink)
454
455$(ROOTCCSBINLINKDIR64)/%: %
456	$(INS.ccsbinlink64)
457
458$(ROOTVARSMB)/%: %
459	$(INS.file)
460
461# build rule for statically linked programs with single source file.
462%.static: %.c
463	$(LINK.c) -o $@ $< $(LDLIBS)
464	$(POST_PROCESS)
465
466%.xpg4: %.c
467	$(LINK.c) -o $@ $< $(LDLIBS)
468	$(POST_PROCESS)
469
470%.xpg6: %.c
471	$(LINK.c) -o $@ $< $(LDLIBS)
472	$(POST_PROCESS)
473
474# Define the majority text domain in this directory.
475TEXT_DOMAIN= SUNW_OST_OSCMD
476
477CLOBBERFILES += $(XPG4) $(XPG6) $(DCFILE)
478
479# This flag is for programs which should not build a 32-bit binary
480sparc_64ONLY= $(POUND_SIGN)
48164ONLY=	 $($(MACH)_64ONLY)
482
483# For programs that are installed in the root filesystem,
484# build $(ROOTFS_PROG) rather than $(PROG)
485$(64ONLY)$(ROOTFS_PROG) := LDFLAGS += -Wl,-I/lib/ld.so.1
486