xref: /illumos-gate/usr/src/cmd/devfsadm/Makefile.com (revision 6d02032db7b674f185405d42cc8bf10a46a9ab3a)
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# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
22# Use is subject to license terms.
23#
24
25# This target builds both a command (daemon) and various shared objects.  This
26# isn't a typical target, and the inclusion of both library and command
27# Makefiles were probably not in their original design.  However, there doesn't
28# presently seem to be a clash of any required definitions.
29include ../../../lib/Makefile.lib
30include ../../Makefile.cmd
31
32COMMON = ..
33UTSBASE = $(COMMON)/../../uts
34
35DEVFSADM_MOD = devfsadm
36
37DEVALLOCSRC =	devalloc.c
38
39PLCYSRC = devpolicy.c plcysubr.c
40
41MODLOADDIR = $(COMMON)/../modload
42
43DEVFSADM_SRC = $(COMMON)/$(DEVFSADM_MOD:%=%.c) \
44		$(DEVALLOCSRC:%=$(COMMON)/%) $(PLCYSRC:%=$(COMMON)/%)
45DEVFSADM_OBJ = $(DEVFSADM_MOD:%=%.o) $(DEVALLOCSRC:%.c=%.o) $(PLCYSRC:%.c=%.o)
46
47DEVFSADM_DAEMON = devfsadmd
48
49LINKMOD_DIR = linkmod
50DEVFSADM_DIR = devfsadm
51
52CLOBBERFILES = $(MODS) $(DEVLINKTAB) $(DEVFSCOMPATLINKS) $(DEVFSADM_DAEMON)
53
54LINK_OBJS_CMN =			\
55	disk_link.o		\
56	ieee1394_link.o		\
57	dcam1394_link.o		\
58	tape_link.o		\
59	usb_link.o		\
60	port_link.o		\
61	audio_link.o		\
62	cfg_link.o		\
63	misc_link.o		\
64	lofi_link.o		\
65	ramdisk_link.o		\
66	fssnap_link.o           \
67	sgen_link.o		\
68	smp_link.o		\
69	md_link.o		\
70	dtrace_link.o		\
71	vscan_link.o		\
72	zfs_link.o		\
73	zut_link.o
74
75LINK_OBJS =	$(LINK_OBJS_CMN) \
76		$(LINK_OBJS_$(MACH))
77
78LINK_SRCS =	$(LINK_OBJS_CMN:%.o=$(COMMON)/%.c) \
79		$(LINK_OBJS_$(MACH):%.o=%.c)
80
81LINT_MODULES = $(LINK_SRCS:%.c=%.ln)
82
83LINK_MODS =	$(LINK_OBJS:%.o=SUNW_%.so)
84
85DEVLINKTAB = devlink.tab
86DEVLINKTAB_SRC = $(COMMON)/$(DEVLINKTAB).sh
87
88COMPAT_LINKS = disks tapes ports audlinks devlinks drvconfig
89
90CPPFLAGS +=	-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
91		-I$(COMMON) -I$(UTSBASE)/common -I$(MODLOADDIR)
92CFLAGS += $(CCVERBOSE) $(C_PICFLAGS)
93
94LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
95LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2
96LINTFLAGS += -erroff=E_NAME_MULTIPLY_DEF2
97
98# Define the dependencies required by devfsadm and all shared objects.
99LDLIBS +=		-ldevinfo
100devfsadm :=		LDLIBS += -lgen -lsysevent -lnvpair -lzonecfg -lbsm
101SUNW_md_link.so :=	LDLIBS += -lmeta
102SUNW_disk_link.so :=	LDLIBS += -ldevid
103SUNW_sgen_link.so :=	LDLIBS += -ldevid
104
105# All libraries are built from the same SUNW_%.so rule (see below), and define
106# their own SONAME using -h explicitly.  Null the generic -h macro that gets
107# inherited from Makefile.lib, otherwise we'll get two -h definitions.
108HSONAME =
109
110SRCS = $(DEVFSADM_SRC) $(LINK_SRCS)
111OBJS = $(DEVFSADM_OBJ) $(LINK_OBJS)
112MODS = $(DEVFSADM_MOD) $(LINK_MODS)
113
114POFILES = $(LINK_SRCS:.c=.po) $(DEVFSADM_SRC:.c=.po)
115POFILE = pdevfsadm.po
116
117# install specifics
118
119ROOTLIB_DEVFSADM = $(ROOTLIB)/$(DEVFSADM_DIR)
120ROOTLIB_DEVFSADM_LINKMOD = $(ROOTLIB_DEVFSADM)/$(LINKMOD_DIR)
121
122ROOTLIB_DEVFSADM_LINK_MODS = $(LINK_MODS:%=$(ROOTLIB_DEVFSADM_LINKMOD)/%)
123
124ROOTUSRSBIN_COMPAT_LINKS = $(COMPAT_LINKS:%=$(ROOTUSRSBIN)/%)
125
126ROOTUSRSBIN_DEVFSADM = $(DEVFSADM_MOD:%=$(ROOTUSRSBIN)/%)
127
128ROOTLIB_DEVFSADM_DAEMON = $(ROOTLIB_DEVFSADM)/$(DEVFSADM_DAEMON)
129
130ROOTETC_DEVLINKTAB = $(DEVLINKTAB:%=$(ROOTETC)/%)
131
132FILEMODE= 755
133
134$(ROOTETC_DEVLINKTAB) := FILEMODE = 644
135
136all :=		TARGET= all
137install :=	TARGET= install
138clean :=	TARGET= clean
139clobber :=	TARGET= clobber
140lint :=		TARGET= lint
141
142
143.KEEP_STATE:
144
145all: $(MODS) $(DEVLINKTAB)
146
147install: all				\
148	$(ROOTLIB_DEVFSADM)		\
149	$(ROOTLIB_DEVFSADM_LINKMOD)	\
150	$(ROOTUSRSBIN_DEVFSADM)		\
151	$(ROOTETC_DEVLINKTAB)		\
152	$(ROOTLIB_DEVFSADM_LINK_MODS)	\
153	$(ROOTUSRINCLUDE)		\
154	$(ROOTLIB_DEVFSADM_DAEMON)	\
155	$(ROOTUSRSBIN_COMPAT_LINKS)
156
157
158clean:
159	$(RM) $(OBJS)
160
161
162lint: $(DEVFSADM_MOD).ln $(LINT_MODULES)
163
164devfsadm.ln: $(DEVFSADM_SRC)
165	$(LINT.c) $(DEVFSADM_SRC) $(LDLIBS)
166
167%.ln: $(DEVFSADM_SRC) %.c
168	$(LINT.c) $(DEVFSADM_SRC) $(@:.ln=.c) $(LDLIBS)
169
170include ../../Makefile.targ
171
172$(POFILE):      $(POFILES)
173	$(RM) $@; cat $(POFILES) > $@
174
175$(DEVFSADM_MOD): $(DEVFSADM_OBJ)
176	$(LINK.c) -o $@ $< $(DEVFSADM_OBJ) $(LDLIBS)
177	$(POST_PROCESS)
178
179SUNW_%.so: %.o $(MAPFILES)
180	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) -h $@ $< $(LDLIBS) -lc
181	$(POST_PROCESS_SO)
182
183%.o: $(COMMON)/%.c
184	$(COMPILE.c) -o $@ $< $(CTFCONVERT_HOOK)
185	$(POST_PROCESS_O)
186
187
188$(DEVLINKTAB): $(DEVLINKTAB_SRC)
189	$(RM) $(DEVLINKTAB)
190	/bin/sh $(DEVLINKTAB_SRC) > $(DEVLINKTAB)
191
192$(ROOTUSRSBIN):
193	$(INS.dir)
194
195$(ROOTLIB_DEVFSADM):
196	$(INS.dir)
197
198$(ROOTUSRINCLUDE):
199	$(INS.dir)
200
201$(ROOTLIB_DEVFSADM_LINKMOD):
202	$(INS.dir)
203
204$(ROOTLIB_DEVFSADM_LINKMOD)/%: %
205	$(INS.file)
206
207$(ROOTLIB_DEVFSADM_DAEMON):
208	$(RM) $@; $(SYMLINK) ../../sbin/$(DEVFSADM_DIR) $@
209
210$(ROOTUSRSBIN_COMPAT_LINKS):	$(ROOTUSRSBIN_DEVFSADM)
211	$(RM) $@ ; $(LN) $(ROOTUSRSBIN_DEVFSADM) $@
212
213#
214# Source shared with add_drv/update_drv
215#
216../plcysubr.c:
217	rm -f $@
218	ln -s ../modload/plcysubr.c ..
219