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