xref: /titanic_41/usr/src/cmd/devfsadm/Makefile.com (revision bce835f2166e1510cc776830775859ba3e49c1ce)
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)
53CLOBBERFILES += $(POFILE) $(POFILES) ../plcysubr.c
54
55LINK_OBJS_CMN =			\
56	disk_link.o		\
57	ieee1394_link.o		\
58	dcam1394_link.o		\
59	tape_link.o		\
60	usb_link.o		\
61	port_link.o		\
62	audio_link.o		\
63	cfg_link.o		\
64	misc_link.o		\
65	lofi_link.o		\
66	ramdisk_link.o		\
67	fssnap_link.o           \
68	sgen_link.o		\
69	smp_link.o		\
70	md_link.o		\
71	dtrace_link.o		\
72	vscan_link.o		\
73	zfs_link.o		\
74	zut_link.o
75
76LINK_OBJS =	$(LINK_OBJS_CMN) \
77		$(LINK_OBJS_$(MACH))
78
79LINK_SRCS =	$(LINK_OBJS_CMN:%.o=$(COMMON)/%.c) \
80		$(LINK_OBJS_$(MACH):%.o=%.c)
81
82LINT_MODULES = $(LINK_SRCS:%.c=%.ln)
83
84LINK_MODS =	$(LINK_OBJS:%.o=SUNW_%.so)
85
86DEVLINKTAB = devlink.tab
87DEVLINKTAB_SRC = $(COMMON)/$(DEVLINKTAB).sh
88
89COMPAT_LINKS = disks tapes ports audlinks devlinks drvconfig
90
91CPPFLAGS +=	-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
92		-I$(COMMON) -I$(UTSBASE)/common -I$(MODLOADDIR)
93CFLAGS += $(CCVERBOSE) $(C_PICFLAGS)
94
95LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
96LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2
97LINTFLAGS += -erroff=E_NAME_MULTIPLY_DEF2
98
99CERRWARN += -_gcc=-Wno-uninitialized
100CERRWARN += -_gcc=-Wno-char-subscripts
101CERRWARN += -_gcc=-Wno-parentheses
102
103# Define the dependencies required by devfsadm and all shared objects.
104LDLIBS +=		-ldevinfo
105devfsadm :=		LDLIBS += -lgen -lsysevent -lnvpair -lzonecfg -lbsm
106SUNW_md_link.so :=	LDLIBS += -lmeta
107SUNW_disk_link.so :=	LDLIBS += -ldevid
108SUNW_sgen_link.so :=	LDLIBS += -ldevid
109
110# All libraries are built from the same SUNW_%.so rule (see below), and define
111# their own SONAME using -h explicitly.  Null the generic -h macro that gets
112# inherited from Makefile.lib, otherwise we'll get two -h definitions.
113HSONAME =
114
115SRCS = $(DEVFSADM_SRC) $(LINK_SRCS)
116OBJS = $(DEVFSADM_OBJ) $(LINK_OBJS)
117MODS = $(DEVFSADM_MOD) $(LINK_MODS)
118
119POFILES = $(LINK_SRCS:.c=.po) $(DEVFSADM_SRC:.c=.po)
120POFILE = pdevfsadm.po
121
122# install specifics
123
124ROOTLIB_DEVFSADM = $(ROOTLIB)/$(DEVFSADM_DIR)
125ROOTLIB_DEVFSADM_LINKMOD = $(ROOTLIB_DEVFSADM)/$(LINKMOD_DIR)
126
127ROOTLIB_DEVFSADM_LINK_MODS = $(LINK_MODS:%=$(ROOTLIB_DEVFSADM_LINKMOD)/%)
128
129ROOTUSRSBIN_COMPAT_LINKS = $(COMPAT_LINKS:%=$(ROOTUSRSBIN)/%)
130
131ROOTUSRSBIN_DEVFSADM = $(DEVFSADM_MOD:%=$(ROOTUSRSBIN)/%)
132
133ROOTLIB_DEVFSADM_DAEMON = $(ROOTLIB_DEVFSADM)/$(DEVFSADM_DAEMON)
134
135ROOTETC_DEVLINKTAB = $(DEVLINKTAB:%=$(ROOTETC)/%)
136
137FILEMODE= 755
138
139$(ROOTETC_DEVLINKTAB) := FILEMODE = 644
140
141all :=		TARGET= all
142install :=	TARGET= install
143clean :=	TARGET= clean
144clobber :=	TARGET= clobber
145lint :=		TARGET= lint
146
147
148.KEEP_STATE:
149
150all: $(MODS) $(DEVLINKTAB)
151
152install: all				\
153	$(ROOTLIB_DEVFSADM)		\
154	$(ROOTLIB_DEVFSADM_LINKMOD)	\
155	$(ROOTUSRSBIN_DEVFSADM)		\
156	$(ROOTETC_DEVLINKTAB)		\
157	$(ROOTLIB_DEVFSADM_LINK_MODS)	\
158	$(ROOTUSRINCLUDE)		\
159	$(ROOTLIB_DEVFSADM_DAEMON)	\
160	$(ROOTUSRSBIN_COMPAT_LINKS)
161
162
163clean:
164	$(RM) $(OBJS)
165
166
167lint: $(DEVFSADM_MOD).ln $(LINT_MODULES)
168
169devfsadm.ln: $(DEVFSADM_SRC)
170	$(LINT.c) $(DEVFSADM_SRC) $(LDLIBS)
171
172%.ln: $(DEVFSADM_SRC) %.c
173	$(LINT.c) $(DEVFSADM_SRC) $(@:.ln=.c) $(LDLIBS)
174
175include ../../Makefile.targ
176
177$(POFILE):      $(POFILES)
178	$(RM) $@; cat $(POFILES) > $@
179
180$(DEVFSADM_MOD): $(DEVFSADM_OBJ)
181	$(LINK.c) -o $@ $< $(DEVFSADM_OBJ) $(LDLIBS)
182	$(POST_PROCESS)
183
184SUNW_%.so: %.o $(MAPFILES)
185	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) -h $@ $< $(LDLIBS) -lc
186	$(POST_PROCESS_SO)
187
188%.o: $(COMMON)/%.c
189	$(COMPILE.c) -o $@ $< $(CTFCONVERT_HOOK)
190	$(POST_PROCESS_O)
191
192
193$(DEVLINKTAB): $(DEVLINKTAB_SRC)
194	$(RM) $(DEVLINKTAB)
195	/bin/sh $(DEVLINKTAB_SRC) > $(DEVLINKTAB)
196
197$(ROOTUSRSBIN):
198	$(INS.dir)
199
200$(ROOTLIB_DEVFSADM):
201	$(INS.dir)
202
203$(ROOTUSRINCLUDE):
204	$(INS.dir)
205
206$(ROOTLIB_DEVFSADM_LINKMOD):
207	$(INS.dir)
208
209$(ROOTLIB_DEVFSADM_LINKMOD)/%: %
210	$(INS.file)
211
212$(ROOTLIB_DEVFSADM_DAEMON):
213	$(RM) $@; $(SYMLINK) ../../sbin/$(DEVFSADM_DIR) $@
214
215$(ROOTUSRSBIN_COMPAT_LINKS):	$(ROOTUSRSBIN_DEVFSADM)
216	$(RM) $@ ; $(LN) $(ROOTUSRSBIN_DEVFSADM) $@
217
218#
219# Source shared with add_drv/update_drv
220#
221../plcysubr.c:
222	rm -f $@
223	ln -s ../modload/plcysubr.c ..
224