1 # $NetBSD: Makefile,v 1.89 2021/02/25 13:41:58 christos Exp $ 2 3 HOSTLIB= nbcompat 4 5 .include <bsd.hostinit.mk> 6 7 SRCS= atoll.c basename.c cdbr.c cdbw.c dirname.c \ 8 dprintf.c fgetln.c flock.c fparseln.c fpurge.c \ 9 getcap.c getline.c getmode.c getopt_long.c gettemp.c \ 10 heapsort.c getsubopt.c \ 11 issetugid.c lchflags.c lchmod.c lchown.c libyywrap.c \ 12 md2.c md2hl.c md4c.c md4hl.c md5c.c md5hl.c \ 13 mi_vector_hash.c mkdtemp.c \ 14 mkstemp.c pread.c putc_unlocked.c pwcache.c pwrite.c \ 15 pw_scan.c \ 16 raise_default_signal.c rb.c reallocarr.c reallocarray.c \ 17 rmd160.c rmd160hl.c \ 18 regcomp.c regerror.c regexec.c regfree.c \ 19 setenv.c setgroupent.c \ 20 setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \ 21 sha256hl.c sha384hl.c sha512hl.c snprintb.c snprintf.c \ 22 stat_flags.c strlcat.c strlcpy.c strmode.c \ 23 strcasecmp.c strncasecmp.c strndup.c strnlen.c \ 24 strsep.c strsuftoll.c strtoll.c \ 25 strtoi.c strtou.c \ 26 unvis.c vis.c err.c errx.c errc.c verr.c verrx.c verrc.c \ 27 vwarn.c vwarnx.c vwarnc.c warn.c warnx.c warnc.c \ 28 fts.c glob.c efun.c 29 30 BUILD_OSTYPE!= uname -s 31 32 # Disable use of pre-compiled headers on Darwin. 33 .if ${BUILD_OSTYPE} == "Darwin" 34 CPPFLAGS+= -no-cpp-precomp 35 .endif 36 37 # -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and 38 # other file ops, on many systems, without changing function names. 39 40 CPPFLAGS+= -I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \ 41 -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 42 43 .PATH: ${.CURDIR}/../../lib/libc/cdb \ 44 ${.CURDIR}/../../lib/libc/gen \ 45 ${.CURDIR}/../../lib/libc/hash \ 46 ${.CURDIR}/../../lib/libc/hash/md2 \ 47 ${.CURDIR}/../../lib/libc/hash/md5 \ 48 ${.CURDIR}/../../lib/libc/hash/rmd160 \ 49 ${.CURDIR}/../../lib/libc/hash/sha1 \ 50 ${.CURDIR}/../../lib/libc/hash/sha2 \ 51 ${.CURDIR}/../../lib/libc/md \ 52 ${.CURDIR}/../../lib/libc/regex \ 53 ${.CURDIR}/../../lib/libc/stdio \ 54 ${.CURDIR}/../../lib/libc/stdlib \ 55 ${.CURDIR}/../../lib/libc/string \ 56 ${.CURDIR}/../../lib/libutil \ 57 ${.CURDIR}/../../common/lib/libc/cdb \ 58 ${.CURDIR}/../../common/lib/libc/gen \ 59 ${.CURDIR}/../../common/lib/libc/string \ 60 ${.CURDIR}/../../common/lib/libc/hash/rmd160 \ 61 ${.CURDIR}/../../common/lib/libc/hash/sha1 \ 62 ${.CURDIR}/../../common/lib/libc/hash/sha2 \ 63 ${.CURDIR}/../../common/lib/libc/md \ 64 ${.CURDIR}/../../common/lib/libc/stdlib \ 65 ${.CURDIR}/../../common/lib/libutil \ 66 ${.CURDIR}/../../external/bsd/flex/dist/src 67 68 DPSRCS+= defs.mk 69 CLEANFILES+= config.log config.status configure.lineno *.stamp 70 CLEANDIRFILES+= defs.mk config.cache confdefs.h 71 72 # Get components of Berkeley DB. 73 _CURDIR:= ${.CURDIR} 74 .CURDIR:= ${_CURDIR}/../../lib/libc 75 .include "${.CURDIR}/db/Makefile.inc" 76 .CURDIR:= ${_CURDIR} 77 78 SRCS:= ${SRCS:M*.c} 79 80 CONFIGURE_ARGS= --cache-file=config.cache 81 .if ${MAKEVERBOSE} == 0 82 CONFIGURE_ARGS+=--silent 83 .endif 84 85 config.cache: include/.stamp configure nbtool_config.h.in defs.mk.in 86 rm -f ${.TARGET} 87 CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \ 88 ${HOST_SH} ${.CURDIR}/configure ${CONFIGURE_ARGS} 89 90 defs.mk: config.cache 91 @touch ${.TARGET} 92 93 INCFILES= nbtool_config.h 94 INCSUBDIRS= sys machine rpc arpa 95 CLEANDIRFILES+= ${INCFILES} 96 97 # CLEANDIRFILES may not contain directory names 98 cleandir: cleandir.include 99 cleandir.include: .PHONY 100 rm -rf include 101 102 include/.stamp: 103 mkdir -p ${INCSUBDIRS:@d@ include/$d @} 104 @touch ${.TARGET} 105 106 # Install rules 107 108 HOST_LIBDIR= ${TOOLDIR}/lib 109 HOST_INCSDIR= ${TOOLDIR}/include 110 HOST_SHAREDIR= ${TOOLDIR}/share 111 112 install: .PHONY install.lib includes install.defs.mk 113 114 # Install lib${HOSTLIB}.a in ${TOOLDIR}/lib 115 install.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a 116 ${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a 117 ${_MKTARGET_INSTALL} 118 ${HOST_INSTALL_DIR} ${HOST_LIBDIR} 119 ${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET} 120 121 .for _f in ${INCFILES} 122 HOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f} 123 ${HOST_INCSDIR}/compat/${_f}: ${_f} 124 ${_MKTARGET_INSTALL} 125 ${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET} 126 .endfor 127 128 .for _d in ${INCSUBDIRS} 129 HOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d} 130 ${HOST_INCSDIR}/compat/${_d}: 131 ${_MKTARGET_INSTALL} 132 ${HOST_INSTALL_DIR} ${.TARGET} 133 .endfor 134 135 # Install include files in ${TOOLDIR}/include/compat 136 includes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES} 137 @(cd include && find . -name '*.h' -print | while read f ; do \ 138 ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \ 139 done) 140 141 142 # Install defs.mk in ${TOOLDIR}/share/compat 143 install.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk 144 ${HOST_SHAREDIR}/compat/defs.mk: defs.mk 145 ${_MKTARGET_INSTALL} 146 ${HOST_INSTALL_DIR} ${HOST_SHAREDIR} 147 ${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat 148 ${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET} 149 150 # bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS 151 152 HOST_CPPFLAGS:= ${CPPFLAGS} 153 CPPFLAGS:= # empty 154 155 .include <bsd.hostlib.mk> 156 157 # Use uninstalled copy of host-mkdep 158 HOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR} 159 HOST_MKDEP= ${HOST_MKDEP_OBJ}/host-mkdep 160 MKDEP= ${HOST_MKDEP} 161 162 # Use uninstalled copy of the install program 163 INSTALL_OBJ!= cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR} 164 INSTALL= ${INSTALL_OBJ}/xinstall 165 166 # Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing 167 # configure.ac. See more detailed instructions in configure.ac. 168 regen: 169 cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf 170 cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader 171