Merge illumos-gate
[unleashed.git] / usr / src / cmd / devfsadm / Makefile.com
blobf4089f287925c4dbae36aff1073915070398b7b8
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
21 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
22 # Use is subject to license terms.
24 # Copyright (c) 2018, Joyent, Inc.
26 # This target builds both a command (daemon) and various shared objects.  This
27 # isn't a typical target, and the inclusion of both library and command
28 # Makefiles were probably not in their original design.  However, there doesn't
29 # presently seem to be a clash of any required definitions.
30 include ../../../lib/Makefile.lib
31 include ../../Makefile.cmd
33 COMMON = ..
34 UTSBASE = $(COMMON)/../../uts
36 DEVFSADM_MOD = devfsadm
38 PLCYSRC = devpolicy.c plcysubr.c
40 MODLOADDIR = $(COMMON)/../modload
42 DEVFSADM_SRC = $(COMMON)/$(DEVFSADM_MOD:%=%.c) \
43                 $(PLCYSRC:%=$(COMMON)/%)
44 DEVFSADM_OBJ = $(DEVFSADM_MOD:%=%.o) $(PLCYSRC:%.c=%.o)
46 DEVFSADM_DAEMON = devfsadmd
48 LINKMOD_DIR = linkmod
49 DEVFSADM_DIR = devfsadm
51 CLOBBERFILES = $(MODS) $(DEVLINKTAB) $(DEVFSCOMPATLINKS) $(DEVFSADM_DAEMON)
52 CLOBBERFILES += $(POFILE) $(POFILES) ../plcysubr.c
54 LINK_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         dtrace_link.o           \
70         vscan_link.o            \
71         zfs_link.o              \
72         zut_link.o
74 LINK_OBJS =     $(LINK_OBJS_CMN) \
75                 $(LINK_OBJS_$(MACH))
77 LINK_SRCS =     $(LINK_OBJS_CMN:%.o=$(COMMON)/%.c) \
78                 $(LINK_OBJS_$(MACH):%.o=%.c)
80 LINK_MODS =     $(LINK_OBJS:%.o=SUNW_%.so)
82 DEVLINKTAB = devlink.tab
83 DEVLINKTAB_SRC = $(COMMON)/$(DEVLINKTAB).sh
85 COMPAT_LINKS = disks tapes ports audlinks devlinks drvconfig
87 CPPFLAGS +=     -D_POSIX_PTHREAD_SEMANTICS \
88                 -I$(COMMON) -I$(SRCTOP)/include -I$(MODLOADDIR)
89 CFLAGS += $(C_PICFLAGS)
92 CERRWARN += -Wno-uninitialized
93 CERRWARN += -Wno-char-subscripts
94 CERRWARN += -Wno-parentheses
96 # not linted
97 SMATCH=off
99 # Define the dependencies required by devfsadm and all shared objects.
100 LDLIBS +=               -ldevinfo
101 devfsadm :=             LDLIBS += -lgen -lsysevent -lnvpair -lzonecfg
102 SUNW_md_link.so :=      LDLIBS += -lmeta
103 SUNW_disk_link.so :=    LDLIBS += -ldevid
104 SUNW_sgen_link.so :=    LDLIBS += -ldevid
106 # All libraries are built from the same SUNW_%.so rule (see below), and define
107 # their own SONAME using -h explicitly.  Null the generic -h macro that gets
108 # inherited from Makefile.lib, otherwise we'll get two -h definitions.
109 HSONAME =
111 SRCS = $(DEVFSADM_SRC) $(LINK_SRCS)
112 OBJS = $(DEVFSADM_OBJ) $(LINK_OBJS)
113 MODS = $(DEVFSADM_MOD) $(LINK_MODS)
115 POFILES = $(LINK_SRCS:.c=.po) $(DEVFSADM_SRC:.c=.po)
116 POFILE = pdevfsadm.po
118 # install specifics
120 ROOTLIB_DEVFSADM = $(ROOTLIB)/$(DEVFSADM_DIR)
121 ROOTLIB_DEVFSADM_LINKMOD = $(ROOTLIB_DEVFSADM)/$(LINKMOD_DIR)
123 ROOTLIB_DEVFSADM_LINK_MODS = $(LINK_MODS:%=$(ROOTLIB_DEVFSADM_LINKMOD)/%)
125 ROOTUSRSBIN_COMPAT_LINKS = $(COMPAT_LINKS:%=$(ROOTUSRSBIN)/%)
127 ROOTUSRSBIN_DEVFSADM = $(DEVFSADM_MOD:%=$(ROOTUSRSBIN)/%)
129 ROOTLIB_DEVFSADM_DAEMON = $(ROOTLIB_DEVFSADM)/$(DEVFSADM_DAEMON)
131 ROOTETC_DEVLINKTAB = $(DEVLINKTAB:%=$(ROOTETC)/%)
133 FILEMODE= 755
135 $(ROOTETC_DEVLINKTAB) := FILEMODE = 644
137 all :=          TARGET= all
138 install :=      TARGET= install
139 clean :=        TARGET= clean
140 clobber :=      TARGET= clobber
143 .KEEP_STATE:
145 all: $(MODS) $(DEVLINKTAB)
147 install: 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)
158 clean:
159         $(RM) $(OBJS) 
161 include ../../Makefile.targ
163 $(POFILE):      $(POFILES)
164         $(RM) $@; cat $(POFILES) > $@
166 $(DEVFSADM_MOD): $(DEVFSADM_OBJ)
167         $(LINK.c) -o $@ $< $(DEVFSADM_OBJ) $(LDLIBS)
168         $(POST_PROCESS)
170 SUNW_%.so: %.o $(MAPFILES)
171         $(CC) -m32 -o $@ $(GSHARED) $(DYNFLAGS) -Wl,-h$@ $< $(LDLIBS) -lc
172         $(POST_PROCESS_SO)
174 %.o: $(COMMON)/%.c
175         $(COMPILE.c) -o $@ $< $(CTFCONVERT_HOOK)
176         $(POST_PROCESS_O)
179 $(DEVLINKTAB): $(DEVLINKTAB_SRC)
180         $(RM) $(DEVLINKTAB)
181         /bin/sh $(DEVLINKTAB_SRC) > $(DEVLINKTAB)
183 $(ROOTUSRSBIN):
184         $(INS.dir)
186 $(ROOTLIB_DEVFSADM):
187         $(INS.dir)
189 $(ROOTUSRINCLUDE):
190         $(INS.dir)
192 $(ROOTLIB_DEVFSADM_LINKMOD):
193         $(INS.dir)
195 $(ROOTLIB_DEVFSADM_LINKMOD)/%: %
196         $(INS.file)
198 $(ROOTLIB_DEVFSADM_DAEMON):
199         $(RM) $@; $(SYMLINK) ../../sbin/$(DEVFSADM_DIR) $@
201 $(ROOTUSRSBIN_COMPAT_LINKS):    $(ROOTUSRSBIN_DEVFSADM)
202         $(RM) $@ ; $(LN) $(ROOTUSRSBIN_DEVFSADM) $@
205 # Source shared with add_drv/update_drv
207 ../plcysubr.c:
208         rm -f $@
209         ln -s ../modload/plcysubr.c ..