xref: /illumos-gate/usr/src/cmd/modload/Makefile.com (revision 54f916c8df8cc80d841868fd67146743b1d266dc)
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#
27# makefile for loadable module utilities
28
29DRVPROG = add_drv rem_drv update_drv
30MODPROG = modinfo modunload modload
31PROG = $(MODPROG) $(DRVPROG)
32
33include ../../Makefile.cmd
34
35MODCOMMONOBJ = modsubr.o
36MODCOMMONSRC = $(MODCOMMONOBJ:%.o=../%.c)
37
38PLCYOBJ = plcysubr.o
39PLCYSRC = $(PLCYOBJ:%.o=../%.c)
40
41$(PLCYOBJ) := CPPFLAGS += -D_REENTRANT
42
43ROOTDRVPROG = $(DRVPROG:%=$(ROOTUSRSBIN)/%)
44
45DRVCOMMONOBJ = drvsubr.o $(PLCYOBJ)
46DRVCOMMONSRC = $(DRVCOMMONOBJ:%.o=../%.c)
47
48OBJECTS = $(MODCOMMONOBJ) $(DRVCOMMONOBJ) $(PROG:%=%.o)
49SRCS = $(OBJECTS:%.o=../%.c)
50
51COMMONSRC = $(DRVCOMMONSRC) $(MODCOMMONSRC)
52
53CLOBBERFILES = $(PROG)
54
55# lint is complicated here by the fact that we
56# build multiple commands and with differing
57# common source, drvsubr vs modsubr/plcysubr
58#
59LINT_PROG= $(PROG:%=lint_%.c)
60LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2
61
62CERRWARN += -_gcc=-Wno-parentheses
63
64# not linted
65SMATCH=off
66
67# install specifics
68
69$(ROOTDRVPROG) := FILEMODE = 0555
70
71add_drv			:= LDLIBS += -ldevinfo -lelf
72rem_drv			:= LDLIBS += -ldevinfo
73update_drv		:= LDLIBS += -ldevinfo
74
75lint_add_drv.c		:= LDLIBS += -ldevinfo -lelf
76lint_rem_drv.c		:= LDLIBS += -ldevinfo
77lint_update_drv.c	:= LDLIBS += -ldevinfo
78
79.KEEP_STATE:
80
81%.o:	../%.c
82	$(COMPILE.c) $<
83
84all: $(PROG)
85
86add_drv:	add_drv.o $(DRVCOMMONOBJ)
87	$(LINK.c)  -o $@ add_drv.o $(DRVCOMMONOBJ) $(LDLIBS)
88	$(POST_PROCESS)
89
90rem_drv:	rem_drv.o $(DRVCOMMONOBJ)
91	$(LINK.c)  -o $@ rem_drv.o $(DRVCOMMONOBJ) $(LDLIBS)
92	$(POST_PROCESS)
93
94update_drv:	update_drv.o $(DRVCOMMONOBJ)
95	$(LINK.c)  -o $@ update_drv.o $(DRVCOMMONOBJ) $(LDLIBS)
96	$(POST_PROCESS)
97
98modload:	modload.o $(MODCOMMONOBJ)
99	 $(LINK.c)  -o $@ modload.o $(MODCOMMONOBJ) $(LDLIBS)
100	$(POST_PROCESS)
101
102modunload:	modunload.o $(MODCOMMONOBJ)
103	 $(LINK.c)  -o $@ modunload.o $(MODCOMMONOBJ) $(LDLIBS)
104	$(POST_PROCESS)
105
106modinfo:	modinfo.o $(MODCOMMONOBJ)
107	 $(LINK.c)  -o $@ modinfo.o $(MODCOMMONOBJ) $(LDLIBS)
108	$(POST_PROCESS)
109
110clean:
111	$(RM) $(OBJECTS)
112
113lint_%.c:
114	$(LINT.c) $(@:lint_%.c=../%.c) $(COMMONSRC) $(LDLIBS)
115
116lint:	$(LINT_PROG)
117
118include ../../Makefile.targ
119