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# 22*f6e214c7SGavin Maltby# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate# 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate.KEEP_STATE: 267c478bd9Sstevel@tonic-gate.SUFFIXES: 277c478bd9Sstevel@tonic-gate 28*f6e214c7SGavin Maltbyinclude $(SRC)/cmd/Makefile.cmd 297c478bd9Sstevel@tonic-gateMODCLASS = plugins 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate# 327c478bd9Sstevel@tonic-gate# Set PROG and OBJS based on the values of MODULE and SRCS. We expect that 337c478bd9Sstevel@tonic-gate# these macros to be defined by the Makefile that is including this file. 347c478bd9Sstevel@tonic-gate# 357c478bd9Sstevel@tonic-gatePROG = $(MODULE:%=%.so) 367c478bd9Sstevel@tonic-gateYOBJS = $(YSRCS:%.y=%.o) 377c478bd9Sstevel@tonic-gateOBJS = $(YOBJS) $(SRCS:%.c=%.o) 387c478bd9Sstevel@tonic-gateCONF = $(MODULE:%=%.conf) 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate# 41*f6e214c7SGavin Maltby# We may have sources from directories other than the current, but 42*f6e214c7SGavin Maltby# we build all objects in the current directory (not necessarily in the 43*f6e214c7SGavin Maltby# directory of its source). 44*f6e214c7SGavin MaltbySEDCMDLINE = echo $(OBJS) | sed 's!\.\./[a-z_/]*/!!g' 45*f6e214c7SGavin MaltbyLINKOBJS = $(SEDCMDLINE:sh) 46*f6e214c7SGavin Maltby 47*f6e214c7SGavin Maltby# 488a40a695Sgavinm# A module may set DMOD and DMOD_SRCS if it has a mdb proc module. 498a40a695Sgavinm# DMOD, if set, must match PROG above (for mdb autoloading) so it will 508a40a695Sgavinm# be built in a subdirectory. 518a40a695Sgavinm# 528a40a695SgavinmROOTDMOD = $(DMOD:%.so=$(ROOT)/usr/lib/mdb/proc/%.so) 538a40a695SgavinmDMODPROG = $(DMOD:%=dmod/%) 548a40a695SgavinmDMOD_OBJS = $(DMOD_SRCS:%.c=%.o) 558a40a695Sgavinm 568a40a695Sgavinm# 577c478bd9Sstevel@tonic-gate# Set ROOTPROG and ROOTCONF based on the values of MODULE, CLASS, and PLATFORMS 587c478bd9Sstevel@tonic-gate# We expect these macros to be defined by the Makefile that is including us. 597c478bd9Sstevel@tonic-gate# 607c478bd9Sstevel@tonic-gatecommon_ROOTPROG = $(ROOT)/usr/lib/fm/fmd/plugins/$(PROG) 617c478bd9Sstevel@tonic-gatearch_ROOTPROG = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(PROG) 627c478bd9Sstevel@tonic-gateplat_ROOTPROG = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(PROG)) 637c478bd9Sstevel@tonic-gateROOTPROG = $($(CLASS)_ROOTPROG) 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gatecommon_ROOTCONF = $(ROOT)/usr/lib/fm/fmd/plugins/$(CONF) 667c478bd9Sstevel@tonic-gatearch_ROOTCONF = $(ROOT)/usr/platform/$(ARCH)/lib/fm/fmd/plugins/$(CONF) 677c478bd9Sstevel@tonic-gateplat_ROOTCONF = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/fmd/plugins/$(CONF)) 687c478bd9Sstevel@tonic-gateROOTCONF = $($(CLASS)_ROOTCONF) 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gateLINTFLAGS += -mu 717c478bd9Sstevel@tonic-gateLINTFILES = $(SRCS:%.c=%.ln) 727c478bd9Sstevel@tonic-gate 738a40a695SgavinmDMODLINTTGT = $(DMOD:%=lint_dmod) 748a40a695SgavinmDMODLINTFILES = $(DMOD_SRCS:%.c=%.ln) 758a40a695Sgavinm 76*f6e214c7SGavin MaltbyAPIMAP = $(SRC)/cmd/fm/fmd/common/fmd_api.map 77*f6e214c7SGavin MaltbyFMRIMAP = $(SRC)/cmd/fm/fmd/common/fmd_fmri.map 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gateCFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(XSTRCONST) $(CC_PICFLAGS) 807c478bd9Sstevel@tonic-gateCFLAGS += -G $(XREGSFLAG) 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gateCPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT 8367e3a03eSrieLDFLAGS += $(ZDEFS) $(ZTEXT) $(ZIGNORE) 84b835471eSgavinm 8567e3a03eSrieMAPFILE-DMOD = $(SRC)/cmd/mdb/common/modules/conf/mapfile-extern 8667e3a03eSrie 8767e3a03eSrie 8867e3a03eSrie$(PROG) := LDFLAGS += -M$(APIMAP) -M$(FMRIMAP) 898a40a695Sgavinm$(PROG) := LDLIBS += -lnvpair -lc 907c478bd9Sstevel@tonic-gate 918a40a695Sgavinmall: $(PROG) $(DMODPROG) 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate.NO_PARALLEL: 948a40a695Sgavinm.PARALLEL: $(OBJS) $(LINTFILES) $(DMOD_OBJS) $(DMODLINTFILES) 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate$(PROG): $(OBJS) $(APIMAP) 97*f6e214c7SGavin Maltby $(LINK.c) $(LINKOBJS) -o $@ $(LDLIBS) 98*f6e214c7SGavin Maltby $(CTFMERGE) -L VERSION -o $@ $(LINKOBJS) 997c478bd9Sstevel@tonic-gate $(POST_PROCESS_SO) 1007c478bd9Sstevel@tonic-gate 10167e3a03eSrie$(DMODPROG): $(DMOD_OBJS) $(MAPFILE-DMOD) 1028a40a695Sgavinm -@mkdir -p $(@D) 10367e3a03eSrie $(LINK.c) $(DMOD_OBJS) $(MAPFILE-DMOD:%=-M%) -o $@ -lc 1048a40a695Sgavinm $(POST_PROCESS) 1058a40a695Sgavinm 1067c478bd9Sstevel@tonic-gate%.o: %.c 107*f6e214c7SGavin Maltby $(COMPILE.c) $< -o $(@F) 108*f6e214c7SGavin Maltby $(CTFCONVERT) $(CTFCVTFLAGS) $(@F) 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gateclean: 111*f6e214c7SGavin Maltby $(RM) $(OBJS) $(DMOD_OBJS) $(LINTFILES) $(DMODLINTFILES) $(CLEANFILES) \ 112*f6e214c7SGavin Maltby $(LINKOBJS) 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gateclobber: clean 1158a40a695Sgavinm $(RM) $(PROG) $(DMODPROG) 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate%.ln: %.c 118*f6e214c7SGavin Maltby $(LINT.c) -dirout=$(@D) -c $< 1197c478bd9Sstevel@tonic-gate 1208a40a695Sgavinmlint_prog: $(LINTFILES) 1217c478bd9Sstevel@tonic-gate $(LINT) $(LINTFLAGS) $(LINTFILES) $(LDLIBS) 1227c478bd9Sstevel@tonic-gate 1238a40a695Sgavinmlint_dmod: $(DMODLINTFILES) 1248a40a695Sgavinm $(LINT) $(LINTFLAGS) $(DMODLINTFILES) $(LDLIBS) 1258a40a695Sgavinm 1268a40a695Sgavinmlint: lint_prog $(DMODLINTTGT) 1278a40a695Sgavinm 1287c478bd9Sstevel@tonic-gateinstall_h: 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate$(ROOTPROG): $$(@D) $(PROG) 1317c478bd9Sstevel@tonic-gate $(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG) 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate$(ROOTCONF): $$(@D) $(CONF) 1347c478bd9Sstevel@tonic-gate $(RM) $@; $(INS) -s -m 0644 -f $(@D) $(CONF) 1357c478bd9Sstevel@tonic-gate 1368a40a695Sgavinm$(ROOTDMOD): $$(@D) $(DMODPROG) 1378a40a695Sgavinm $(RM) $@; $(INS) -s -m 0555 -f $(@D) $(DMODPROG) 1388a40a695Sgavinm 1398a40a695Sgavinminstall: $(ROOTPROG) $(ROOTCONF) $(ROOTDMOD) 1407c478bd9Sstevel@tonic-gate 141*f6e214c7SGavin Maltbyinclude $(SRC)/cmd/fm/modules/Makefile.rootdirs 142