xref: /illumos-gate/usr/src/cmd/fm/modules/Makefile.plugin (revision 1a2d662a91cee3bf82f41cd47c7ae6f3825d9db2)
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#
22# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23# Copyright 2015 RackTop Systems.
24#
25
26.KEEP_STATE:
27.SUFFIXES:
28
29include $(SRC)/cmd/Makefile.cmd
30MODCLASS = plugins
31
32#
33# Set PROG and OBJS based on the values of MODULE and SRCS.  We expect that
34# these macros to be defined by the Makefile that is including this file.
35#
36PROG = $(MODULE:%=%.so)
37YOBJS = $(YSRCS:%.y=%.o)
38OBJS = $(YOBJS) $(SRCS:%.c=%.o)
39CONF = $(MODULE:%=%.conf)
40
41#
42# We may have sources from directories other than the current, but
43# we build all objects in the current directory (not necessarily in the
44# directory of its source).
45SEDCMDLINE = echo $(OBJS) | sed 's!\.\./[a-z_/]*/!!g'
46LINKOBJS = $(SEDCMDLINE:sh)
47
48#
49# A module may set DMOD and DMOD_SRCS if it has a mdb proc module.
50# DMOD, if set, must match PROG above (for mdb autoloading) so it will
51# be built in a subdirectory.
52#
53ROOTDMOD = $(DMOD:%.so=$(ROOT)/usr/lib/mdb/proc/%.so)
54DMODPROG = $(DMOD:%=dmod/%)
55DMOD_OBJS = $(DMOD_SRCS:%.c=%.o)
56
57#
58# Set ROOTPROG and ROOTCONF based on the values of MODULE, CLASS, and PLATFORMS
59# We expect these macros to be defined by the Makefile that is including us.
60#
61common_ROOTPROG = $(ROOT)/usr/lib/fm/fmd/plugins/$(PROG)
62arch_ROOTPROG = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(PROG)
63plat_ROOTPROG = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(PROG))
64ROOTPROG = $($(CLASS)_ROOTPROG)
65
66common_ROOTCONF = $(ROOT)/usr/lib/fm/fmd/plugins/$(CONF)
67arch_ROOTCONF = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(CONF)
68plat_ROOTCONF = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(CONF))
69ROOTCONF = $($(CLASS)_ROOTCONF)
70
71APIMAP = $(SRC)/cmd/fm/fmd/common/fmd_api.map
72FMRIMAP = $(SRC)/cmd/fm/fmd/common/fmd_fmri.map
73
74CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(CC_PICFLAGS)
75CFLAGS += $(GSHARED)
76
77CPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
78LDFLAGS += $(ZDEFS) $(ZTEXT) $(ZIGNORE)
79
80MAPFILE-DMOD = $(SRC)/cmd/mdb/common/modules/conf/mapfile-extern
81
82
83$(PROG) := LDFLAGS += -Wl,-M$(APIMAP) -Wl,-M$(FMRIMAP)
84$(PROG) := LDLIBS += -lnvpair -lc
85
86all: $(PROG) $(DMODPROG)
87
88.NO_PARALLEL:
89.PARALLEL: $(OBJS) $(DMOD_OBJS)
90
91$(PROG): $(OBJS) $(APIMAP)
92	$(LINK.c) $(LINKOBJS) -o $@ $(LDLIBS)
93	$(CTFMERGE) -L VERSION -o $@ $(LINKOBJS)
94	$(POST_PROCESS_SO)
95
96$(DMODPROG): $(DMOD_OBJS) $(MAPFILE-DMOD)
97	-@mkdir -p $(@D)
98	$(LINK.c) $(DMOD_OBJS) $(MAPFILE-DMOD:%=-Wl,-M%) -o $@ $(LDLIBS) -lc
99	$(POST_PROCESS)
100
101%.o: %.c
102	$(COMPILE.c) $< -o $(@F)
103	$(CTFCONVERT) $(CTFCVTFLAGS) $(@F)
104
105clean:
106	$(RM) $(OBJS) $(DMOD_OBJS) $(CLEANFILES) $(LINKOBJS)
107
108clobber: clean
109	$(RM) $(PROG) $(DMODPROG)
110
111install_h:
112
113$(ROOTPROG): $$(@D) $(PROG)
114	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG)
115
116$(ROOTCONF): $$(@D) $(CONF)
117	$(RM) $@; $(INS) -s -m 0644 -f $(@D) $(CONF)
118
119$(ROOTDMOD): $$(@D) $(DMODPROG)
120	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(DMODPROG)
121
122install: $(ROOTPROG) $(ROOTCONF) $(ROOTDMOD)
123
124include $(SRC)/cmd/fm/modules/Makefile.rootdirs
125