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