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