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