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