xref: /titanic_52/usr/src/cmd/fm/modules/Makefile.plugin (revision c1ecd8b9404ee0d96d93f02e82c441b9bb149a3d)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25#ident	"%Z%%M%	%I%	%E% SMI"
26
27.KEEP_STATE:
28.SUFFIXES:
29
30include ../../../../Makefile.cmd
31MODCLASS = plugins
32
33#
34# Set PROG and OBJS based on the values of MODULE and SRCS.  We expect that
35# these macros to be defined by the Makefile that is including this file.
36#
37PROG = $(MODULE:%=%.so)
38YOBJS = $(YSRCS:%.y=%.o)
39OBJS = $(YOBJS) $(SRCS:%.c=%.o)
40CONF = $(MODULE:%=%.conf)
41
42#
43# A module may set DMOD and DMOD_SRCS if it has a mdb proc module.
44# DMOD, if set, must match PROG above (for mdb autoloading) so it will
45# be built in a subdirectory.
46#
47ROOTDMOD = $(DMOD:%.so=$(ROOT)/usr/lib/mdb/proc/%.so)
48DMODPROG = $(DMOD:%=dmod/%)
49DMOD_OBJS = $(DMOD_SRCS:%.c=%.o)
50
51#
52# Set ROOTPROG and ROOTCONF based on the values of MODULE, CLASS, and PLATFORMS
53# We expect these macros to be defined by the Makefile that is including us.
54#
55common_ROOTPROG = $(ROOT)/usr/lib/fm/fmd/plugins/$(PROG)
56arch_ROOTPROG = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(PROG)
57plat_ROOTPROG = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(PROG))
58ROOTPROG = $($(CLASS)_ROOTPROG)
59
60common_ROOTCONF = $(ROOT)/usr/lib/fm/fmd/plugins/$(CONF)
61arch_ROOTCONF = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(CONF)
62plat_ROOTCONF = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(CONF))
63ROOTCONF = $($(CLASS)_ROOTCONF)
64
65LINTFLAGS += -mu
66LINTFILES = $(SRCS:%.c=%.ln)
67
68DMODLINTTGT = $(DMOD:%=lint_dmod)
69DMODLINTFILES = $(DMOD_SRCS:%.c=%.ln)
70
71APIMAP = ../../../fmd/common/fmd_api.map
72FMRIMAP = ../../../fmd/common/fmd_fmri.map
73
74CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(XSTRCONST) $(CC_PICFLAGS)
75CFLAGS += -G $(XREGSFLAG)
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 += -M$(APIMAP) -M$(FMRIMAP)
84$(PROG) := LDLIBS += -lnvpair -lc
85
86all: $(PROG) $(DMODPROG)
87
88.NO_PARALLEL:
89.PARALLEL: $(OBJS) $(LINTFILES) $(DMOD_OBJS) $(DMODLINTFILES)
90
91$(PROG): $(OBJS) $(APIMAP)
92	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
93	$(CTFMERGE) -L VERSION -o $@ $(OBJS)
94	$(POST_PROCESS_SO)
95
96$(DMODPROG): $(DMOD_OBJS) $(MAPFILE-DMOD)
97	-@mkdir -p $(@D)
98	$(LINK.c) $(DMOD_OBJS) $(MAPFILE-DMOD:%=-M%) -o $@ -lc
99	$(POST_PROCESS)
100
101%.o: %.c
102	$(COMPILE.c) $<
103	$(CTFCONVERT_O)
104
105clean:
106	$(RM) $(OBJS) $(DMOD_OBJS) $(LINTFILES) $(DMODLINTFILES) $(CLEANFILES)
107
108clobber: clean
109	$(RM) $(PROG) $(DMODPROG)
110
111%.ln: %.c
112	$(LINT.c) -c $<
113
114lint_prog: $(LINTFILES)
115	$(LINT) $(LINTFLAGS) $(LINTFILES) $(LDLIBS)
116
117lint_dmod: $(DMODLINTFILES)
118	$(LINT) $(LINTFLAGS) $(DMODLINTFILES) $(LDLIBS)
119
120lint: lint_prog $(DMODLINTTGT)
121
122install_h:
123
124$(ROOTPROG): $$(@D) $(PROG)
125	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG)
126
127$(ROOTCONF): $$(@D) $(CONF)
128	$(RM) $@; $(INS) -s -m 0644 -f $(@D) $(CONF)
129
130$(ROOTDMOD): $$(@D) $(DMODPROG)
131	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(DMODPROG)
132
133install: $(ROOTPROG) $(ROOTCONF) $(ROOTDMOD)
134
135include ../../Makefile.rootdirs
136