Annotation of src/share/mk/bsd.lkm.mk, Revision 1.23
1.23 ! jsg 1: # $OpenBSD: bsd.lkm.mk,v 1.22 2011/07/16 23:34:21 guenther 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:
1.21 mikeb 23: .if ${MACHINE} == "amd64"
24: CFLAGS+= -mcmodel=kernel
25: .endif
26:
1.1 mickey 27: LDFLAGS+= -r
28: .if defined(LKM)
29: SRCS?= ${LKM}.c
30: .if !empty(SRCS:N*.h:N*.sh)
1.22 guenther 31: OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/}
1.1 mickey 32: .endif
33: COMBINED?=combined.o
1.3 mickey 34: .if !defined(POSTINSTALL)
35: POSTINSTALL= ${LKM}install
36: .endif
1.1 mickey 37:
38: .if defined(OBJS) && !empty(OBJS)
39:
40: ${COMBINED}: ${OBJS} ${DPADD}
41: ${LD} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
42:
43: .endif # defined(OBJS) && !empty(OBJS)
44:
45: .if !defined(MAN)
46: MAN= ${LKM}.1
47: .endif # !defined(MAN)
48: .endif # defined(LKM)
49:
50: .MAIN: all
51: all: ${COMBINED} _SUBDIRUSE
52:
53: .if !target(clean)
54: clean: _SUBDIRUSE
55: rm -f a.out [Ee]rrs mklog core *.core \
1.23 ! jsg 56: ${LKM} ${COMBINED} ${OBJS} ${CLEANFILES}
1.1 mickey 57: .endif
58:
59: cleandir: _SUBDIRUSE clean
60:
61: .if !target(install)
62: .if !target(beforeinstall)
63: beforeinstall:
64: .endif
65: .if !target(afterinstall)
66: afterinstall:
67: .endif
68:
69: .if !target(realinstall)
70: realinstall:
71: .if defined(LKM)
1.12 millert 72: ${INSTALL} ${INSTALL_COPY} -o ${LKMOWN} -g ${LKMGRP} -m ${LKMMODE} \
1.2 tholo 73: ${COMBINED} ${DESTDIR}${LKMDIR}/${LKM}.o
1.7 mickey 74: .if exists(${.CURDIR}/${POSTINSTALL})
1.12 millert 75: ${INSTALL} ${INSTALL_COPY} -o ${LKMOWN} -g ${LKMGRP} -m 555 \
1.11 downsj 76: ${.CURDIR}/${POSTINSTALL} ${DESTDIR}${LKMDIR}
1.7 mickey 77: .endif
1.1 mickey 78: .endif
1.20 espie 79: .if defined(LINKS) && !empty(LINKS)
80: . for lnk file in ${LINKS}
81: @l=${DESTDIR}${LKMDIR}${lnk}; \
82: t=${DESTDIR}${LKMDIR}${file}; \
83: echo $$t -\> $$l; \
84: rm -f $$t; ln $$l $$t
85: . endfor
86: .endif
1.1 mickey 87: .endif
88:
89:
90: load: ${COMBINED}
1.3 mickey 91: if [ -x ${.CURDIR}/${POSTINSTALL} ]; then \
1.21 mikeb 92: modload -d -o ${LKM} -e${LKM}_lkmentry \
93: -p${.CURDIR}/${POSTINSTALL} ${COMBINED}; \
1.3 mickey 94: else \
1.21 mikeb 95: modload -d -o ${LKM} -e${LKM}_lkmentry ${COMBINED}; \
1.3 mickey 96: fi
1.1 mickey 97:
98: unload:
1.21 mikeb 99: modunload -n ${LKM}
1.1 mickey 100:
101: install: maninstall _SUBDIRUSE
102:
103: maninstall: afterinstall
104: afterinstall: realinstall
105: realinstall: beforeinstall
106: .endif
107:
108: .if !defined(NOMAN)
109: .include <bsd.man.mk>
110: .endif
111:
112: .if !defined(NONLS)
113: .include <bsd.nls.mk>
114: .endif
115:
116: .include <bsd.obj.mk>
117: .include <bsd.dep.mk>
118: .include <bsd.subdir.mk>
119: .include <bsd.sys.mk>
1.16 espie 120:
121: .PHONY: load unload