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