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