1 # $NetBSD: Makefile.inc,v 1.50 2025/09/20 06:36:50 mrg Exp $ 2 # 3 # Configuration variables (default values are below): 4 # 5 # S must be set to the top of the 'sys' tree. 6 # KERNDST may be set to the location of the directory where library 7 # objects are to be built. Defaults to ${.OBJDIR}/lib/kern. 8 # KERN_AS may be set to 'obj' to build a object from the library's 9 # object files. (Otherwise, a library will be built.) 10 # Defaults to 'obj' if OPT_MODULAR is set. Otherwise, 11 # 'library' is used as a default value. 12 # KERNMISCCPPFLAGS 13 # Miscellaneous cpp flags to be passed to the library's Makefile 14 # when building. 15 # KERNMISCMAKEFLAGS 16 # Miscellaneous flags to be passed to the library's Makefile when 17 # building. See library's Makefile for more details about 18 # supported flags and their default values. 19 20 # Default values: 21 KERNDST?= ${.OBJDIR}/lib/kern 22 .if !empty(OPT_MODULAR) 23 KERN_AS?= obj 24 .else 25 KERN_AS?= library 26 .endif 27 KERNDOTDIR?= ../../. 28 29 KERNDIR= ${S:S@^.@${KERNDOTDIR}@:q}/lib/libkern 30 .if (${KERN_AS} == "obj") 31 KERNLIB= ${KERNDST}/libkern.o 32 KERNLIB_PROF= ${KERNDST}/libkern.po 33 .else 34 KERNLIB= ${KERNDST}/libkern.a 35 KERNLIB_PROF= ${KERNDST}/libkern_p.a 36 .endif 37 38 LIBKERNLNBN= llib-lkern.ln 39 KERNLIBLN= ${KERNDST}/${LIBKERNLNBN} 40 41 LIBKERN_MD_FLAGS?= none 42 43 KERNMAKE= \ 44 cd ${KERNDST} && ${MAKE} -f ${KERNDIR:Q}/Makefile \ 45 KERNDIR=${KERNDIR:q} \ 46 CC=${CC:q} CFLAGS=${CFLAGS:q} CPUFLAGS= \ 47 AS=${AS:q} AFLAGS=${AFLAGS:q} \ 48 LORDER=${LORDER:q} \ 49 TSORT=${TSORT:q} \ 50 COPTS=${COPTS:q} \ 51 LD=${LD:q} STRIP=${STRIP:q} \ 52 AR=${AR:q} NM=${NM:q} \ 53 RANLIB=${RANLIB:q} SIZE=${SIZE:q} \ 54 MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH:q} \ 55 KERNCPPFLAGS=${CPPFLAGS:S@^-I.@-I${KERNDOTDIR}@g:q} \ 56 KERNMISCCPPFLAGS=${KERNMISCCPPFLAGS:q} \ 57 LINTFLAGS=${KERNLINTFLAGS:q} \ 58 LIBKERN_ARCH=${LIBKERN_ARCH:q} \ 59 COMMON_MACHINE_ARCH=${COMMON_MACHINE_ARCH:q} \ 60 LIBKERN_MD_FLAGS=${LIBKERN_MD_FLAGS:q} \ 61 ${KERNMISCMAKEFLAGS} 62 63 ${KERNLIB}: .NOTMAIN .MAKE __always_make_kernlib 64 @echo making sure the kern library is up to date... 65 .if (${KERN_AS} == "library") 66 @${KERNMAKE} libkern.a 67 .else 68 @${KERNMAKE} libkern.o 69 .endif 70 71 ${KERNLIB_PROF}: .NOTMAIN .MAKE __always_make_kernlib 72 @echo making sure the profiled kern library is up to date... 73 .if (${KERN_AS} == "library") 74 @${KERNMAKE} libkern_p.a 75 .else 76 @${KERNMAKE} libkern.po 77 .endif 78 79 ${KERNLIBLN}: .NOTMAIN .MAKE __always_make_kernlib 80 @echo making sure the kern lint library is up to date... 81 @${KERNMAKE} ${LIBKERNLNBN} 82 83 clean: .NOTMAIN cleankernlib 84 cleankernlib: .MAKE .NOTMAIN 85 @echo cleaning the kern library objects 86 @if [ -d "${KERNDST}" ]; then ${KERNMAKE} clean; fi 87 88 cleandir distclean: .NOTMAIN cleandirkernlib 89 cleandirkernlib: .MAKE .NOTMAIN 90 @echo cleandiring the kern library objects 91 @if [ -d "${KERNDST}" ]; then ${KERNMAKE} cleandir; fi 92 93 dependall depend: .NOTMAIN dependkernlib 94 dependkernlib: .NOTMAIN .MAKE __always_make_kernlib 95 @echo depending the kern library objects 96 @${KERNMAKE} depend 97 98 __always_make_kernlib: .NOTMAIN 99 @(mkdir -p ${KERNDST}) 100 101 .PHONY: __always_make_kernlib 102 .PHONY: cleankernlib cleandirkernlib dependkernlib 103 104 .include "${.PARSEDIR}/../../../common/lib/libc/Makefile.inc" 105