xref: /titanic_41/usr/src/cmd/fm/modules/Makefile.plugin (revision 177fd15c9f814babb60e824f89984cdd8acf7c85)
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 2006 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 += $(ZTEXT) $(ZCOMBRELOC) $(ZIGNORE)
79
80$(PROG) := LDFLAGS += $(ZDEFS) -M$(APIMAP) -M$(FMRIMAP)
81$(PROG) := LDLIBS += -lnvpair -lc
82
83$(DMODPROG) := LDFLAGS += $(ZNODEFS)
84
85all: $(PROG) $(DMODPROG)
86
87.NO_PARALLEL:
88.PARALLEL: $(OBJS) $(LINTFILES) $(DMOD_OBJS) $(DMODLINTFILES)
89
90$(PROG): $(OBJS) $(APIMAP)
91	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
92	$(CTFMERGE) -L VERSION -o $@ $(OBJS)
93	$(POST_PROCESS_SO)
94
95$(DMODPROG): $(DMOD_OBJS)
96	-@mkdir -p $(@D)
97	$(LINK.c) $(DMOD_OBJS) -o $@
98	$(POST_PROCESS)
99
100%.o: %.c
101	$(COMPILE.c) $<
102	$(CTFCONVERT_O)
103
104clean:
105	$(RM) $(OBJS) $(DMOD_OBJS) $(LINTFILES) $(DMODLINTFILES) $(CLEANFILES)
106
107clobber: clean
108	$(RM) $(PROG) $(DMODPROG)
109
110%.ln: %.c
111	$(LINT.c) -c $<
112
113lint_prog: $(LINTFILES)
114	$(LINT) $(LINTFLAGS) $(LINTFILES) $(LDLIBS)
115
116lint_dmod: $(DMODLINTFILES)
117	$(LINT) $(LINTFLAGS) $(DMODLINTFILES) $(LDLIBS)
118
119lint: lint_prog $(DMODLINTTGT)
120
121install_h:
122
123$(ROOTPROG): $$(@D) $(PROG)
124	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG)
125
126$(ROOTCONF): $$(@D) $(CONF)
127	$(RM) $@; $(INS) -s -m 0644 -f $(@D) $(CONF)
128
129$(ROOTDMOD): $$(@D) $(DMODPROG)
130	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(DMODPROG)
131
132install: $(ROOTPROG) $(ROOTCONF) $(ROOTDMOD)
133
134include ../../Makefile.rootdirs
135