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