xref: /titanic_51/usr/src/cmd/fm/modules/Makefile.plugin (revision d50bcaae2118610560f2b107d0d282315e47e4e4)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
534709573Sraf# Common Development and Distribution License (the "License").
634709573Sraf# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate#
22f6e214c7SGavin Maltby# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23*d50bcaaeSAndrew Stormont# Copyright 2015 RackTop Systems.
247c478bd9Sstevel@tonic-gate#
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate.KEEP_STATE:
277c478bd9Sstevel@tonic-gate.SUFFIXES:
287c478bd9Sstevel@tonic-gate
29f6e214c7SGavin Maltbyinclude $(SRC)/cmd/Makefile.cmd
307c478bd9Sstevel@tonic-gateMODCLASS = plugins
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate#
337c478bd9Sstevel@tonic-gate# Set PROG and OBJS based on the values of MODULE and SRCS.  We expect that
347c478bd9Sstevel@tonic-gate# these macros to be defined by the Makefile that is including this file.
357c478bd9Sstevel@tonic-gate#
367c478bd9Sstevel@tonic-gatePROG = $(MODULE:%=%.so)
377c478bd9Sstevel@tonic-gateYOBJS = $(YSRCS:%.y=%.o)
387c478bd9Sstevel@tonic-gateOBJS = $(YOBJS) $(SRCS:%.c=%.o)
397c478bd9Sstevel@tonic-gateCONF = $(MODULE:%=%.conf)
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gate#
42f6e214c7SGavin Maltby# We may have sources from directories other than the current, but
43f6e214c7SGavin Maltby# we build all objects in the current directory (not necessarily in the
44f6e214c7SGavin Maltby# directory of its source).
45f6e214c7SGavin MaltbySEDCMDLINE = echo $(OBJS) | sed 's!\.\./[a-z_/]*/!!g'
46f6e214c7SGavin MaltbyLINKOBJS = $(SEDCMDLINE:sh)
47f6e214c7SGavin Maltby
48f6e214c7SGavin Maltby#
498a40a695Sgavinm# A module may set DMOD and DMOD_SRCS if it has a mdb proc module.
508a40a695Sgavinm# DMOD, if set, must match PROG above (for mdb autoloading) so it will
518a40a695Sgavinm# be built in a subdirectory.
528a40a695Sgavinm#
538a40a695SgavinmROOTDMOD = $(DMOD:%.so=$(ROOT)/usr/lib/mdb/proc/%.so)
548a40a695SgavinmDMODPROG = $(DMOD:%=dmod/%)
558a40a695SgavinmDMOD_OBJS = $(DMOD_SRCS:%.c=%.o)
568a40a695Sgavinm
578a40a695Sgavinm#
587c478bd9Sstevel@tonic-gate# Set ROOTPROG and ROOTCONF based on the values of MODULE, CLASS, and PLATFORMS
597c478bd9Sstevel@tonic-gate# We expect these macros to be defined by the Makefile that is including us.
607c478bd9Sstevel@tonic-gate#
617c478bd9Sstevel@tonic-gatecommon_ROOTPROG = $(ROOT)/usr/lib/fm/fmd/plugins/$(PROG)
627c478bd9Sstevel@tonic-gatearch_ROOTPROG = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(PROG)
637c478bd9Sstevel@tonic-gateplat_ROOTPROG = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(PROG))
647c478bd9Sstevel@tonic-gateROOTPROG = $($(CLASS)_ROOTPROG)
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gatecommon_ROOTCONF = $(ROOT)/usr/lib/fm/fmd/plugins/$(CONF)
677c478bd9Sstevel@tonic-gatearch_ROOTCONF = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(CONF)
687c478bd9Sstevel@tonic-gateplat_ROOTCONF = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(CONF))
697c478bd9Sstevel@tonic-gateROOTCONF = $($(CLASS)_ROOTCONF)
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gateLINTFLAGS += -mu
727c478bd9Sstevel@tonic-gateLINTFILES = $(SRCS:%.c=%.ln)
737c478bd9Sstevel@tonic-gate
748a40a695SgavinmDMODLINTTGT = $(DMOD:%=lint_dmod)
758a40a695SgavinmDMODLINTFILES = $(DMOD_SRCS:%.c=%.ln)
768a40a695Sgavinm
77f6e214c7SGavin MaltbyAPIMAP = $(SRC)/cmd/fm/fmd/common/fmd_api.map
78f6e214c7SGavin MaltbyFMRIMAP = $(SRC)/cmd/fm/fmd/common/fmd_fmri.map
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gateCFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(XSTRCONST) $(CC_PICFLAGS)
817c478bd9Sstevel@tonic-gateCFLAGS += -G $(XREGSFLAG)
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gateCPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
8467e3a03eSrieLDFLAGS += $(ZDEFS) $(ZTEXT) $(ZIGNORE)
85b835471eSgavinm
8667e3a03eSrieMAPFILE-DMOD = $(SRC)/cmd/mdb/common/modules/conf/mapfile-extern
8767e3a03eSrie
8867e3a03eSrie
8967e3a03eSrie$(PROG) := LDFLAGS += -M$(APIMAP) -M$(FMRIMAP)
908a40a695Sgavinm$(PROG) := LDLIBS += -lnvpair -lc
917c478bd9Sstevel@tonic-gate
928a40a695Sgavinmall: $(PROG) $(DMODPROG)
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate.NO_PARALLEL:
958a40a695Sgavinm.PARALLEL: $(OBJS) $(LINTFILES) $(DMOD_OBJS) $(DMODLINTFILES)
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate$(PROG): $(OBJS) $(APIMAP)
98f6e214c7SGavin Maltby	$(LINK.c) $(LINKOBJS) -o $@ $(LDLIBS)
99f6e214c7SGavin Maltby	$(CTFMERGE) -L VERSION -o $@ $(LINKOBJS)
1007c478bd9Sstevel@tonic-gate	$(POST_PROCESS_SO)
1017c478bd9Sstevel@tonic-gate
10267e3a03eSrie$(DMODPROG): $(DMOD_OBJS) $(MAPFILE-DMOD)
1038a40a695Sgavinm	-@mkdir -p $(@D)
104*d50bcaaeSAndrew Stormont	$(LINK.c) $(DMOD_OBJS) $(MAPFILE-DMOD:%=-M%) -o $@ $(LDLIBS) -lc
1058a40a695Sgavinm	$(POST_PROCESS)
1068a40a695Sgavinm
1077c478bd9Sstevel@tonic-gate%.o: %.c
108f6e214c7SGavin Maltby	$(COMPILE.c) $< -o $(@F)
109f6e214c7SGavin Maltby	$(CTFCONVERT) $(CTFCVTFLAGS) $(@F)
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gateclean:
112f6e214c7SGavin Maltby	$(RM) $(OBJS) $(DMOD_OBJS) $(LINTFILES) $(DMODLINTFILES) $(CLEANFILES) \
113f6e214c7SGavin Maltby	    $(LINKOBJS)
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gateclobber: clean
1168a40a695Sgavinm	$(RM) $(PROG) $(DMODPROG)
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate%.ln: %.c
119f6e214c7SGavin Maltby	$(LINT.c) -dirout=$(@D) -c $<
1207c478bd9Sstevel@tonic-gate
1218a40a695Sgavinmlint_prog: $(LINTFILES)
1227c478bd9Sstevel@tonic-gate	$(LINT) $(LINTFLAGS) $(LINTFILES) $(LDLIBS)
1237c478bd9Sstevel@tonic-gate
1248a40a695Sgavinmlint_dmod: $(DMODLINTFILES)
1258a40a695Sgavinm	$(LINT) $(LINTFLAGS) $(DMODLINTFILES) $(LDLIBS)
1268a40a695Sgavinm
1278a40a695Sgavinmlint: lint_prog $(DMODLINTTGT)
1288a40a695Sgavinm
1297c478bd9Sstevel@tonic-gateinstall_h:
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate$(ROOTPROG): $$(@D) $(PROG)
1327c478bd9Sstevel@tonic-gate	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG)
1337c478bd9Sstevel@tonic-gate
1347c478bd9Sstevel@tonic-gate$(ROOTCONF): $$(@D) $(CONF)
1357c478bd9Sstevel@tonic-gate	$(RM) $@; $(INS) -s -m 0644 -f $(@D) $(CONF)
1367c478bd9Sstevel@tonic-gate
1378a40a695Sgavinm$(ROOTDMOD): $$(@D) $(DMODPROG)
1388a40a695Sgavinm	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(DMODPROG)
1398a40a695Sgavinm
1408a40a695Sgavinminstall: $(ROOTPROG) $(ROOTCONF) $(ROOTDMOD)
1417c478bd9Sstevel@tonic-gate
142f6e214c7SGavin Maltbyinclude $(SRC)/cmd/fm/modules/Makefile.rootdirs
143