xref: /illumos-gate/usr/src/cmd/modload/Makefile.com (revision 97088f6e9a2eb4c0085fb27842bd398fcba75846)
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#
25# Copyright (c) 2018, Joyent, Inc.
26# Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
27#
28# makefile for loadable module utilities
29
30DRVPROG = add_drv rem_drv update_drv
31MODPROG = modinfo modunload modload
32PROG = $(MODPROG) $(DRVPROG)
33
34include ../../Makefile.cmd
35
36MODCOMMONOBJ = modsubr.o
37MODCOMMONSRC = $(MODCOMMONOBJ:%.o=../%.c)
38
39PLCYOBJ = plcysubr.o
40PLCYSRC = $(PLCYOBJ:%.o=../%.c)
41
42$(PLCYOBJ) := CPPFLAGS += -D_REENTRANT
43
44ROOTDRVPROG = $(DRVPROG:%=$(ROOTUSRSBIN)/%)
45
46DRVCOMMONOBJ = drvsubr.o $(PLCYOBJ)
47DRVCOMMONSRC = $(DRVCOMMONOBJ:%.o=../%.c)
48
49modunload		:= CSTD = $(CSTD_GNU17)
50
51OBJECTS = $(MODCOMMONOBJ) $(DRVCOMMONOBJ) $(PROG:%=%.o)
52SRCS = $(OBJECTS:%.o=../%.c)
53
54COMMONSRC = $(DRVCOMMONSRC) $(MODCOMMONSRC)
55
56CLOBBERFILES = $(PROG)
57
58# install specifics
59
60$(ROOTDRVPROG) := FILEMODE = 0555
61
62add_drv			:= LDLIBS += -ldevinfo -lelf
63rem_drv			:= LDLIBS += -ldevinfo
64update_drv		:= LDLIBS += -ldevinfo
65
66.KEEP_STATE:
67
68%.o:	../%.c
69	$(COMPILE.c) $<
70
71all: $(PROG)
72
73add_drv:	add_drv.o $(DRVCOMMONOBJ)
74	$(LINK.c) -o $@ add_drv.o $(DRVCOMMONOBJ) $(LDLIBS)
75	$(POST_PROCESS)
76
77rem_drv:	rem_drv.o $(DRVCOMMONOBJ)
78	$(LINK.c) -o $@ rem_drv.o $(DRVCOMMONOBJ) $(LDLIBS)
79	$(POST_PROCESS)
80
81update_drv:	update_drv.o $(DRVCOMMONOBJ)
82	$(LINK.c) -o $@ update_drv.o $(DRVCOMMONOBJ) $(LDLIBS)
83	$(POST_PROCESS)
84
85modload:	modload.o $(MODCOMMONOBJ)
86	$(LINK.c) -o $@ modload.o $(MODCOMMONOBJ) $(LDLIBS)
87	$(POST_PROCESS)
88
89modunload:	modunload.o
90	$(LINK.c) $^ -o $@ $(LDLIBS)
91	$(POST_PROCESS)
92
93modinfo:	modinfo.o $(MODCOMMONOBJ)
94	$(LINK.c) -o $@ modinfo.o $(MODCOMMONOBJ) $(LDLIBS)
95	$(POST_PROCESS)
96
97clean:
98	$(RM) $(OBJECTS)
99
100include ../../Makefile.targ
101