remove support for 'trademark files'
[unleashed/tickless.git] / kernel / mk / kmod-build.mk
blobd81faa0afbf862f291b21fa074d6ee53316924fb
2 # Build and install a kernel module
4 # Inputs from user's Makefile:
6 # MODULE - name of the kernel module
7 # MODULE_TYPE - "fs", "drv", etc.
8 # MODULE_TYPE_LINKS - "fs", "drv", etc. which will be hardlinked to
9 # MODULE_TYPE
10 # MODULE_DEPS - dependencies
11 # MODULE_CONF - name of .conf file to install
12 # MODULE_FW - firmware files to install
13 # SRCS - source files
14 # SRCS32 - additional source files (32-bit build only)
15 # SRCS64 - additional source files (64-bit build only)
16 # SRCS_DIRS - additional source directories to search in
17 # INCS - compiler include directives
18 # DEFS - compiler defines (e.g., -DFOO -UBAR)
19 # CERRWARN - compiler error warning args (e.g., -Wno-parentheses)
21 # Additionally, we get the following values from kmod.mk:
23 # BITS - should we build a 32-bit or a 64-bit binary
24 # SRCTOP - root of the repository
27 .include <unleashed.mk>
28 .include <init.mk>
30 .include <${SRCTOP}/Makefile.cfgparam>
32 # prevent kmod.mk inclusion in user's Makefile from setting up confusing targets
33 _KMOD_BUILD=yes
34 .include <${.CURDIR}/Makefile>
36 .include <${SRCTOP}/kernel/mk/defines.mk>
38 CFLAGS = \
39 ${KERNEL_CFLAGS} \
40 ${CERRWARN} \
41 ${INCS:%=-I%} \
42 ${DEFS}
44 LDFLAGS = ${KERNEL_LDFLAGS}
45 .if !empty(MODULE_DEPS)
46 LDFLAGS += -dy ${MODULE_DEPS:%=-N %}
47 .endif
49 # generate all the hard link names even though we may not use it all
50 LINKS=
51 .if !empty(MODULE_TYPE_LINKS)
52 .for type in ${MODULE_TYPE_LINKS}
53 LINKS += "/kernel/${MODULE_TYPE}/${MODULE}" \
54 "/kernel/${type}/${MODULE}"
55 .endfor
56 .endif
58 .OBJDIR: ${.CURDIR}/obj${BITS}
60 OBJS = ${SRCS:%.c=%.o} \
61 ${SRCS${BITS}:%.c=%.o}
63 all: ${MODULE}
65 clean cleandir:
67 .include <links.mk>
69 install:
70 ${INSTALL} -d -m 755 "${DESTDIR}/kernel/${MODULE_TYPE}"
71 ${INSTALL} -m 755 ${MODULE} "${DESTDIR}/kernel/${MODULE_TYPE}/${MODULE}"
72 .if !empty(LINKS)
73 @set ${LINKS}; ${_LINKS_SCRIPT}
74 .endif
76 .PHONY: all clean cleandir install
78 install-misc: install-conf install-fw
80 install-conf: ${MODULE_CONF}
81 .if !empty(MODULE_CONF)
82 ${INSTALL} -d -m 755 "${DESTDIR}/kernel/${MODULE_TYPE}"
83 ${INSTALL} -m 644 ${MODULE_CONF} "${DESTDIR}/kernel/${MODULE_TYPE}/${MODULE}.conf"
84 .endif
86 install-fw: ${MODULE_FW}
87 .if !empty(MODULE_FW)
88 ${INSTALL} -d -m 755 "${DESTDIR}/kernel/firmware/${MODULE}"
89 .for x in ${MODULE_FW}
90 ${INSTALL} -m 644 ${x} "${DESTDIR}/kernel/firmware/${MODULE}"
91 .endfor
92 .endif
94 .PHONY: install-misc install-conf install-fw
96 ${MODULE}: ${OBJS}
97 ${LD} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
98 ${CTFCONVERT} -L VERSION ${.TARGET}
100 .SUFFIXES: .o
102 .c.o:
103 @mkdir -p ${.TARGET:H}
104 ${CC} ${CFLAGS} -c -o ${.TARGET} ${.IMPSRC}