[BACK]Return to bsd.kmodule.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

Annotation of src/share/mk/bsd.kmodule.mk, Revision 1.27

1.27    ! matt        1: #      $NetBSD: bsd.kmodule.mk,v 1.26 2010/12/11 18:42:33 martin Exp $
1.14      elad        2:
                      3: # We are not building this with PIE
                      4: MKPIE=no
1.1       ad          5:
                      6: .include <bsd.init.mk>
                      7: .include <bsd.klinks.mk>
1.7       ad          8: .include <bsd.sys.mk>
1.1       ad          9:
                     10: ##### Basic targets
                     11: clean:         cleankmod
                     12: realinstall:   kmodinstall
                     13:
                     14: KERN=          $S/kern
                     15:
1.6       ad         16: CFLAGS+=       -ffreestanding ${COPTS}
1.1       ad         17: CPPFLAGS+=     -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch
                     18: CPPFLAGS+=     -isystem ${S}/../common/include
                     19: CPPFLAGS+=     -D_KERNEL -D_LKM -D_MODULE
1.27    ! matt       20: CPPFLAGS+=     -std=gnu99
1.1       ad         21:
                     22: # XXX until the kernel is fixed again...
1.11      gmcgarry   23: .if (defined(HAVE_GCC) && ${HAVE_GCC} == 4) || defined(HAVE_PCC)
1.1       ad         24: CFLAGS+=       -fno-strict-aliasing -Wno-pointer-sign
                     25: .endif
                     26:
1.24      jmmv       27: # XXX This is a workaround for platforms that have relative relocations
                     28: # that, when relocated by the module loader, result in addresses that
                     29: # overflow the size of the relocation (e.g. R_PPC_REL24 in powerpc).
                     30: # The real solution to this involves generating trampolines for those
                     31: # relocations inside the loader and removing this workaround, as the
                     32: # resulting code would be much faster.
                     33: .if ${MACHINE_CPU} == "arm"
                     34: CFLAGS+=       -mlong-calls
                     35: .elif ${MACHINE_CPU} == "powerpc"
                     36: CFLAGS+=       -mlongcall
                     37: .endif
                     38:
1.1       ad         39: _YKMSRCS=      ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
                     40: DPSRCS+=       ${_YKMSRCS}
                     41: CLEANFILES+=   ${_YKMSRCS}
1.7       ad         42:
1.21      skrll      43: .if exists($S/../sys/modules/xldscripts/kmodule)
                     44: KMODSCRIPT=    $S/../sys/modules/xldscripts/kmodule
1.7       ad         45: .else
1.12      mrg        46: KMODSCRIPT=    ${DESTDIR}/usr/libdata/ldscripts/kmodule
1.7       ad         47: .endif
1.1       ad         48:
                     49: OBJS+=         ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
                     50: PROG?=         ${KMOD}.kmod
                     51:
                     52: ##### Build rules
                     53: realall:       ${PROG}
                     54:
                     55: ${OBJS} ${LOBJS}: ${DPSRCS}
                     56:
                     57: ${PROG}: ${OBJS} ${DPADD}
                     58:        ${_MKTARGET_LINK}
1.26      martin     59:        ${CC} ${LDFLAGS} -nostdlib -r -Wl,-T,${KMODSCRIPT},-d \
1.22      matt       60:                -o ${.TARGET} ${OBJS}
1.1       ad         61:
                     62: ##### Install rules
                     63: .if !target(kmodinstall)
1.7       ad         64: .if !defined(KMODULEDIR)
                     65: _OSRELEASE!=   ${HOST_SH} $S/conf/osrelease.sh
1.9       he         66: # Ensure these are recorded properly in METALOG on unprived installes:
1.18      rmind      67: _INST_DIRS=    ${DESTDIR}/stand/${MACHINE}
                     68: _INST_DIRS+=   ${DESTDIR}/stand/${MACHINE}/${_OSRELEASE}
                     69: _INST_DIRS+=   ${DESTDIR}/stand/${MACHINE}/${_OSRELEASE}/modules
                     70: KMODULEDIR=    ${DESTDIR}/stand/${MACHINE}/${_OSRELEASE}/modules/${KMOD}
1.10      dyoung     71: .endif
                     72: _PROG:=                ${KMODULEDIR}/${PROG} # installed path
1.1       ad         73:
                     74: .if ${MKUPDATE} == "no"
                     75: ${_PROG}! ${PROG}                                      # install rule
                     76: .if !defined(BUILD) && !make(all) && !make(${PROG})
                     77: ${_PROG}!      .MADE                                   # no build at install
                     78: .endif
                     79: .else
                     80: ${_PROG}: ${PROG}                                      # install rule
                     81: .if !defined(BUILD) && !make(all) && !make(${PROG})
                     82: ${_PROG}:      .MADE                                   # no build at install
                     83: .endif
                     84: .endif
                     85:        ${_MKTARGET_INSTALL}
1.16      hubertf    86:        dirs=${_INST_DIRS:Q}; \
                     87:        for d in $$dirs; do \
1.9       he         88:                ${INSTALL_DIR} $$d; \
                     89:        done
1.7       ad         90:        ${INSTALL_DIR} ${KMODULEDIR}
1.15      ad         91:        ${INSTALL_FILE} -o ${KMODULEOWN} -g ${KMODULEGRP} -m ${KMODULEMODE} \
1.1       ad         92:                ${.ALLSRC} ${.TARGET}
                     93:
                     94: kmodinstall::  ${_PROG}
                     95: .PHONY:                kmodinstall
                     96: .PRECIOUS:     ${_PROG}                                # keep if install fails
                     97:
                     98: .undef _PROG
                     99: .endif # !target(kmodinstall)
                    100:
                    101: ##### Clean rules
                    102: cleankmod: .PHONY
                    103:        rm -f a.out [Ee]rrs mklog core *.core \
                    104:                ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
                    105:
                    106: ##### Custom rules
                    107: lint: ${LOBJS}
                    108: .if defined(LOBJS) && !empty(LOBJS)
                    109:        ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
                    110: .endif
                    111:
                    112: ##### Pull in related .mk logic
1.19      apb       113: LINKSOWN?= ${KMODULEOWN}
                    114: LINKSGRP?= ${KMODULEGRP}
                    115: LINKSMODE?= ${KMODULEMODE}
1.1       ad        116: .include <bsd.man.mk>
                    117: .include <bsd.links.mk>
                    118: .include <bsd.dep.mk>
                    119:
                    120: .-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc"
                    121: .-include "$S/arch/${MACHINE}/include/Makefile.inc"

CVSweb <webmaster@jp.NetBSD.org>