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