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 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. 30include ../../../lib/Makefile.lib 31include ../../Makefile.cmd 32 33COMMON = .. 34UTSBASE = $(COMMON)/../../uts 35 36DEVFSADM_MOD = devfsadm 37 38DEVALLOCSRC = devalloc.c 39 40PLCYSRC = devpolicy.c plcysubr.c 41 42MODLOADDIR = $(COMMON)/../modload 43 44DEVFSADM_SRC = $(COMMON)/$(DEVFSADM_MOD:%=%.c) \ 45 $(DEVALLOCSRC:%=$(COMMON)/%) $(PLCYSRC:%=$(COMMON)/%) 46DEVFSADM_OBJ = $(DEVFSADM_MOD:%=%.o) $(DEVALLOCSRC:%.c=%.o) $(PLCYSRC:%.c=%.o) 47 48DEVFSADM_DAEMON = devfsadmd 49 50LINKMOD_DIR = linkmod 51DEVFSADM_DIR = devfsadm 52 53CLOBBERFILES = $(MODS) $(DEVLINKTAB) $(DEVFSCOMPATLINKS) $(DEVFSADM_DAEMON) 54CLOBBERFILES += $(POFILE) $(POFILES) ../plcysubr.c 55 56LINK_OBJS_CMN = \ 57 disk_link.o \ 58 ieee1394_link.o \ 59 dcam1394_link.o \ 60 tape_link.o \ 61 usb_link.o \ 62 port_link.o \ 63 audio_link.o \ 64 cfg_link.o \ 65 misc_link.o \ 66 lofi_link.o \ 67 ramdisk_link.o \ 68 fssnap_link.o \ 69 sgen_link.o \ 70 smp_link.o \ 71 dtrace_link.o \ 72 vscan_link.o \ 73 zfs_link.o \ 74 zut_link.o \ 75 sensor_link.o \ 76 dpio_link.o 77 78LINK_OBJS = $(LINK_OBJS_CMN) \ 79 $(LINK_OBJS_$(MACH)) 80 81LINK_SRCS = $(LINK_OBJS_CMN:%.o=$(COMMON)/%.c) \ 82 $(LINK_OBJS_$(MACH):%.o=%.c) 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 95CERRWARN += $(CNOWARN_UNINIT) 96CERRWARN += -_gcc=-Wno-char-subscripts 97CERRWARN += -_gcc=-Wno-parentheses 98 99# not linted 100SMATCH=off 101 102# Define the dependencies required by devfsadm and all shared objects. 103LDLIBS += -ldevinfo 104devfsadm := LDLIBS += -lgen -lsysevent -lnvpair -lzonecfg -lbsm 105SUNW_disk_link.so := LDLIBS += -ldevid 106SUNW_sgen_link.so := LDLIBS += -ldevid 107 108# All libraries are built from the same SUNW_%.so rule (see below), and define 109# their own SONAME using -h explicitly. Null the generic -h macro that gets 110# inherited from Makefile.lib, otherwise we'll get two -h definitions. 111HSONAME = 112 113SRCS = $(DEVFSADM_SRC) $(LINK_SRCS) 114OBJS = $(DEVFSADM_OBJ) $(LINK_OBJS) 115MODS = $(DEVFSADM_MOD) $(LINK_MODS) 116 117POFILES = $(LINK_SRCS:.c=.po) $(DEVFSADM_SRC:.c=.po) 118POFILE = pdevfsadm.po 119 120# install specifics 121 122ROOTLIB_DEVFSADM = $(ROOTLIB)/$(DEVFSADM_DIR) 123ROOTLIB_DEVFSADM_LINKMOD = $(ROOTLIB_DEVFSADM)/$(LINKMOD_DIR) 124 125ROOTLIB_DEVFSADM_LINK_MODS = $(LINK_MODS:%=$(ROOTLIB_DEVFSADM_LINKMOD)/%) 126 127ROOTUSRSBIN_COMPAT_LINKS = $(COMPAT_LINKS:%=$(ROOTUSRSBIN)/%) 128 129ROOTUSRSBIN_DEVFSADM = $(DEVFSADM_MOD:%=$(ROOTUSRSBIN)/%) 130 131ROOTLIB_DEVFSADM_DAEMON = $(ROOTLIB_DEVFSADM)/$(DEVFSADM_DAEMON) 132 133ROOTETC_DEVLINKTAB = $(DEVLINKTAB:%=$(ROOTETC)/%) 134 135FILEMODE= 755 136 137$(ROOTETC_DEVLINKTAB) := FILEMODE = 644 138 139all := TARGET= all 140install := TARGET= install 141clean := TARGET= clean 142clobber := TARGET= clobber 143 144.KEEP_STATE: 145 146all: $(MODS) $(DEVLINKTAB) 147 148install: all \ 149 $(ROOTLIB_DEVFSADM) \ 150 $(ROOTLIB_DEVFSADM_LINKMOD) \ 151 $(ROOTUSRSBIN_DEVFSADM) \ 152 $(ROOTETC_DEVLINKTAB) \ 153 $(ROOTLIB_DEVFSADM_LINK_MODS) \ 154 $(ROOTUSRINCLUDE) \ 155 $(ROOTLIB_DEVFSADM_DAEMON) \ 156 $(ROOTUSRSBIN_COMPAT_LINKS) 157 158 159clean: 160 $(RM) $(OBJS) 161 162include ../../Makefile.targ 163 164$(POFILE): $(POFILES) 165 $(RM) $@; cat $(POFILES) > $@ 166 167$(DEVFSADM_MOD): $(DEVFSADM_OBJ) 168 $(LINK.c) -o $@ $< $(DEVFSADM_OBJ) $(LDLIBS) 169 $(POST_PROCESS) 170 171SUNW_%.so: %.o $(MAPFILES) 172 $(LINK.c) -o $@ $(GSHARED) $(DYNFLAGS) -Wl,-h$@ $< $(LDLIBS) -lc 173 $(POST_PROCESS_SO) 174 175%.o: $(COMMON)/%.c 176 $(COMPILE.c) -o $@ $< $(CTFCONVERT_HOOK) 177 $(POST_PROCESS_O) 178 179 180$(DEVLINKTAB): $(DEVLINKTAB_SRC) 181 $(RM) $(DEVLINKTAB) 182 /bin/sh $(DEVLINKTAB_SRC) > $(DEVLINKTAB) 183 184$(ROOTUSRSBIN): 185 $(INS.dir) 186 187$(ROOTLIB_DEVFSADM): 188 $(INS.dir) 189 190$(ROOTUSRINCLUDE): 191 $(INS.dir) 192 193$(ROOTLIB_DEVFSADM_LINKMOD): 194 $(INS.dir) 195 196$(ROOTLIB_DEVFSADM_LINKMOD)/%: % 197 $(INS.file) 198 199$(ROOTLIB_DEVFSADM_DAEMON): 200 $(RM) $@; $(SYMLINK) ../../sbin/$(DEVFSADM_DIR) $@ 201 202$(ROOTUSRSBIN_COMPAT_LINKS): $(ROOTUSRSBIN_DEVFSADM) 203 $(RM) $@ ; $(LN) $(ROOTUSRSBIN_DEVFSADM) $@ 204 205# 206# Source shared with add_drv/update_drv 207# 208../plcysubr.c: 209 rm -f $@ 210 ln -s ../modload/plcysubr.c .. 211