Annotation of src/share/mk/bsd.lkm.mk, Revision 1.4
1.4 ! mickey 1: # $OpenBSD: bsd.lkm.mk,v 1.3 1996/03/05 11:12:45 mickey Exp $
1.3 mickey 2: # from @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
1.1 mickey 3:
4: .if exists(${.CURDIR}/../Makefile.inc)
5: .include "${.CURDIR}/../Makefile.inc"
6: .endif
7:
8: .include <bsd.own.mk>
9:
10: .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
11:
12: CFLAGS+= ${COPTS} -D_KERNEL -I/sys -I/sys/arch
13:
14: LDFLAGS+= -r
15: .if defined(LKM)
16: SRCS?= ${LKM}.c
17: .if !empty(SRCS:N*.h:N*.sh)
18: OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
19: LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
20: .endif
21: COMBINED?=combined.o
1.3 mickey 22: .if !defined(POSTINSTALL)
23: POSTINSTALL= ${LKM}install
24: .endif
1.1 mickey 25:
26: .if defined(OBJS) && !empty(OBJS)
27:
28: ${COMBINED}: ${OBJS} ${DPADD}
29: ${LD} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
30:
31: .endif # defined(OBJS) && !empty(OBJS)
32:
33: .if !defined(MAN)
34: MAN= ${LKM}.1
35: .endif # !defined(MAN)
36: .endif # defined(LKM)
37:
38: .MAIN: all
39: all: ${COMBINED} _SUBDIRUSE
40:
41: .if !target(clean)
42: clean: _SUBDIRUSE
43: rm -f a.out [Ee]rrs mklog core *.core \
44: ${LKM} ${COMBINED} ${OBJS} ${LOBJS} ${CLEANFILES}
45: .endif
46:
47: cleandir: _SUBDIRUSE clean
48:
49: .if !target(install)
50: .if !target(beforeinstall)
51: beforeinstall:
1.4 ! mickey 52: @-[ -d ${DESTDIR}${LKMDIR} ] || mkdir ${DESTDIR}${LKMDIR}
1.1 mickey 53: .endif
54: .if !target(afterinstall)
55: afterinstall:
56: .endif
57:
58: .if !target(realinstall)
59: realinstall:
60: .if defined(LKM)
61: install ${COPY} ${STRIP} -o ${LKMOWN} -g ${LKMGRP} -m ${LKMMODE} \
1.2 tholo 62: ${COMBINED} ${DESTDIR}${LKMDIR}/${LKM}.o
1.1 mickey 63: .endif
64: .endif
65:
66:
67: load: ${COMBINED}
1.3 mickey 68: if [ -x ${.CURDIR}/${POSTINSTALL} ]; then \
69: modload -d -o $(LKM) -e$(LKM) -p${.CURDIR}/${POSTINSTALL} $(COMBINED); \
70: else \
71: modload -d -o $(LKM) -e$(LKM) $(COMBINED); \
72: fi
1.1 mickey 73:
74: unload:
75: modunload -n $(LKM)
76:
77: install: maninstall _SUBDIRUSE
78: .if defined(LINKS) && !empty(LINKS)
79: @set ${LINKS}; \
80: while test $$# -ge 2; do \
81: l=${DESTDIR}$$1; \
82: shift; \
83: t=${DESTDIR}$$1; \
84: shift; \
85: echo $$t -\> $$l; \
86: rm -f $$t; \
87: ln $$l $$t; \
88: done; true
89: .endif
90:
91: maninstall: afterinstall
92: afterinstall: realinstall
93: realinstall: beforeinstall
94: .endif
95:
96: .if !target(lint)
97: lint: ${LOBJS}
98: .if defined(LOBJS) && !empty(LOBJS)
99: @${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
100: .endif
101: .endif
102:
103: .if !defined(NOMAN)
104: .include <bsd.man.mk>
105: .endif
106:
107: .if !defined(NONLS)
108: .include <bsd.nls.mk>
109: .endif
110:
111: .include <bsd.obj.mk>
112: .include <bsd.dep.mk>
113: .include <bsd.subdir.mk>
114: .include <bsd.sys.mk>