xref: /illumos-gate/usr/src/lib/fm/topo/modules/Makefile.plugin (revision 2aa8db5932a99c01d32f2aea7dbbf15b4898169b)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24# Copyright 2026 Oxide Computer Company
25#
26
27.KEEP_STATE:
28.SUFFIXES:
29
30MODCLASS = plugins
31
32include ../../../../../Makefile.lib
33include ../../../../../../Makefile.lib
34
35#
36# Set PROG and OBJS based on the values of MODULE and SRCS.  We expect that
37# these macros to be defined by the Makefile that is including this file.
38#
39# SHAREDSRCS is used to share sources between multiple libtopo modules.
40#
41SRCS = $(MODULESRCS:%.c=%.c) $(SHAREDSRCS:%.c=../../common/$(SHAREDMODULE)/%.c)
42PROG = $(MODULE:%=%.so)
43OBJS = $(MODULESRCS:%.c=%.o) $(SHAREDSRCS:%.c=%.o)
44
45#
46# Set ROOTPROG and ROOTCONF based on the values of MODULE, CLASS, and PLATFORMS
47# We expect these macros to be defined by the Makefile that is including us.
48#
49common_ROOTPROG = $(ROOT)/usr/lib/fm/topo/plugins/$(PROG)
50common_ROOTPROG64 = $(ROOT)/usr/lib/fm/topo/plugins/64/$(PROG)
51arch_ROOTPROG = $(ROOT)/usr/platform/$(ARCH)/lib/fm/topo/plugins/$(PROG)
52arch_ROOTPROG64 = $(ROOT)/usr/platform/$(ARCH)/lib/fm/topo/plugins/64/$(PROG)
53plat_ROOTPROG = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/topo/plugins/$(PROG))
54plat_ROOTPROG64 = $(PLATFORMS:%=$(ROOT)/usr/platform/%/lib/fm/topo/plugins/64/$(PROG))
55ROOTPROG = $($(CLASS)_ROOTPROG)
56ROOTPROG64 = $($(CLASS)_ROOTPROG64)
57
58APIMAP = ../../../../libtopo/common/topo_mod.map
59MAPFILES =		# use APIMAP instead
60
61CSTD  = $(CSTD_GNU99)
62#
63# Makefile.plugin.64 uses Makefile.master.64 which assigns CFLAGS64 to
64# CFLAGS, so we need this set for both unlike the rest of the fields.
65#
66CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(CC_PICFLAGS)
67CFLAGS += $(GSHARED)
68CFLAGS64 += $(CTF_FLAGS) $(CCVERBOSE) $(CC_PICFLAGS)
69CFLAGS64 += $(GSHARED)
70
71#
72# The ELFCLASS macro is overriden by Makefile.plugin.64 to 64, allowing plugins
73# to set LDFLAGS and LBLIBS paths to 32/64-bit dependent values.
74#
75CPPFLAGS += -I.
76CPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
77ELFCLASS = 32
78LDFLAGS_ELF32 = -R/usr/lib/fm
79LDFLAGS_ELF64 = -R/usr/lib/fm/64
80LDFLAGS += $(ZIGNORE) -Wl,-M$(APIMAP) $(LDFLAGS_ELF$(ELFCLASS))
81LDLIBS_ELF32 = -L$(ROOTLIBDIR)/fm
82LDLIBS_ELF64 = -L$(ROOTLIBDIR)/fm/64
83LDLIBS += $(LDLIBS_ELF$(ELFCLASS)) -ltopo -lnvpair -lc
84
85all: $(PROG)
86
87.NO_PARALLEL:
88.PARALLEL: $(OBJS)
89
90$(PROG): $(OBJS) $(APIMAP)
91	$(LINK.c) $(DYNFLAGS) $(OBJS) -o $@ $(LDLIBS)
92	$(CTFMERGE) -L VERSION -o $@ $(OBJS)
93	$(POST_PROCESS_SO)
94
95%.o: ../../../common/$(MODULE)/%.c
96	$(COMPILE.c) $<
97	$(CTFCONVERT_O)
98
99%.o: ../../../common/$(SHAREDMODULE)/%.c
100	$(COMPILE.c) $<
101	$(CTFCONVERT_O)
102
103%.o: ../%.c
104	$(COMPILE.c) $<
105	$(CTFCONVERT_O)
106
107clean:
108	$(RM) $(OBJS) $(CLEANFILES)
109
110clobber: clean
111	$(RM) $(PROG) $(CLOBBERFILES)
112
113check:	$(CHECKHDRS)
114
115install_h:
116
117$(ROOTPROG): $$(@D) $(PROG)
118	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG)
119
120$(ROOTPROG64): $$(@D) $(PROG)
121	$(RM) $@; $(INS) -s -m 0555 -f $(@D) $(PROG)
122
123include ../../../../Makefile.rootdirs
124