[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.25

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

CVSweb <webmaster@jp.NetBSD.org>