Annotation of src/share/mk/bsd.lkm.mk, Revision 1.17
1.17 ! espie 1: # $OpenBSD: bsd.lkm.mk,v 1.16 2001/04/03 23:00:09 espie Exp $
1.1 mickey 2:
3: .if exists(${.CURDIR}/../Makefile.inc)
4: .include "${.CURDIR}/../Makefile.inc"
5: .endif
6:
7: .include <bsd.own.mk>
8:
9: .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
10:
1.9 niklas 11: # XXX In order to at least diminish the brokenness of trusting /sys to point
12: # to the tree we're actually belonging to we check BSDSRCDIR. On multi-tree
13: # machines /sys isn't always a link to the correct tree.
1.8 niklas 14: .if defined(BSDSRCDIR)
1.15 assar 15: CFLAGS+= ${COPTS} -D_KERNEL -D_LKM -I${BSDSRCDIR}/sys -I${BSDSRCDIR}/sys/arch
1.8 niklas 16: .else
1.15 assar 17: CFLAGS+= ${COPTS} -D_KERNEL -D_LKM -I/sys -I/sys/arch
1.17 ! espie 18: .endif
! 19: .if ${WARNINGS:L} == "yes"
! 20: CFLAGS+= ${CDIAGFLAGS}
1.8 niklas 21: .endif
1.1 mickey 22:
23: LDFLAGS+= -r
24: .if defined(LKM)
25: SRCS?= ${LKM}.c
26: .if !empty(SRCS:N*.h:N*.sh)
27: OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
28: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
29: .endif
30: COMBINED?=combined.o
1.3 mickey 31: .if !defined(POSTINSTALL)
32: POSTINSTALL= ${LKM}install
33: .endif
1.1 mickey 34:
35: .if defined(OBJS) && !empty(OBJS)
36:
37: ${COMBINED}: ${OBJS} ${DPADD}
38: ${LD} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
39:
40: .endif # defined(OBJS) && !empty(OBJS)
41:
42: .if !defined(MAN)
43: MAN= ${LKM}.1
44: .endif # !defined(MAN)
45: .endif # defined(LKM)
46:
47: .MAIN: all
48: all: ${COMBINED} _SUBDIRUSE
49:
50: .if !target(clean)
51: clean: _SUBDIRUSE
52: rm -f a.out [Ee]rrs mklog core *.core \
53: ${LKM} ${COMBINED} ${OBJS} ${LOBJS} ${CLEANFILES}
54: .endif
55:
56: cleandir: _SUBDIRUSE clean
57:
58: .if !target(install)
59: .if !target(beforeinstall)
60: beforeinstall:
61: .endif
62: .if !target(afterinstall)
63: afterinstall:
64: .endif
65:
66: .if !target(realinstall)
67: realinstall:
68: .if defined(LKM)
1.12 millert 69: ${INSTALL} ${INSTALL_COPY} -o ${LKMOWN} -g ${LKMGRP} -m ${LKMMODE} \
1.2 tholo 70: ${COMBINED} ${DESTDIR}${LKMDIR}/${LKM}.o
1.7 mickey 71: .if exists(${.CURDIR}/${POSTINSTALL})
1.12 millert 72: ${INSTALL} ${INSTALL_COPY} -o ${LKMOWN} -g ${LKMGRP} -m 555 \
1.11 downsj 73: ${.CURDIR}/${POSTINSTALL} ${DESTDIR}${LKMDIR}
1.7 mickey 74: .endif
1.1 mickey 75: .endif
76: .endif
77:
78:
79: load: ${COMBINED}
1.3 mickey 80: if [ -x ${.CURDIR}/${POSTINSTALL} ]; then \
81: modload -d -o $(LKM) -e$(LKM) -p${.CURDIR}/${POSTINSTALL} $(COMBINED); \
82: else \
83: modload -d -o $(LKM) -e$(LKM) $(COMBINED); \
84: fi
1.1 mickey 85:
86: unload:
87: modunload -n $(LKM)
88:
89: install: maninstall _SUBDIRUSE
90: .if defined(LINKS) && !empty(LINKS)
91: @set ${LINKS}; \
92: while test $$# -ge 2; do \
1.10 mickey 93: l=${DESTDIR}${LKMDIR}/$$1; \
1.1 mickey 94: shift; \
1.10 mickey 95: t=${DESTDIR}${LKMDIR}/$$1; \
1.1 mickey 96: shift; \
97: echo $$t -\> $$l; \
98: rm -f $$t; \
99: ln $$l $$t; \
100: done; true
101: .endif
102:
103: maninstall: afterinstall
104: afterinstall: realinstall
105: realinstall: beforeinstall
106: .endif
107:
108: .if !target(lint)
109: lint: ${LOBJS}
110: .if defined(LOBJS) && !empty(LOBJS)
111: @${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
112: .endif
113: .endif
114:
115: .if !defined(NOMAN)
116: .include <bsd.man.mk>
117: .endif
118:
119: .if !defined(NONLS)
120: .include <bsd.nls.mk>
121: .endif
122:
123: .include <bsd.obj.mk>
124: .include <bsd.dep.mk>
125: .include <bsd.subdir.mk>
126: .include <bsd.sys.mk>
1.16 espie 127:
128: .PHONY: load unload