Makefile revision 1.93
11.93Sjakllsch#	$NetBSD: Makefile,v 1.93 2024/10/31 15:05:48 jakllsch Exp $
21.67Schristos
31.67SchristosHOSTLIB=	nbcompat
41.63Schristos
51.83Schristos.include <bsd.hostinit.mk>
61.1Stv
71.59SjoergSRCS=		atoll.c basename.c cdbr.c cdbw.c dirname.c \
81.68Schristos		dprintf.c fgetln.c flock.c fparseln.c fpurge.c \
91.58Sjoerg		getcap.c getline.c getmode.c getopt_long.c gettemp.c \
101.86Schristos		heapsort.c getsubopt.c \
111.39Selad		issetugid.c lchflags.c lchmod.c lchown.c libyywrap.c \
121.54Sroy		md2.c md2hl.c md4c.c md4hl.c md5c.c md5hl.c \
131.54Sroy		mi_vector_hash.c mkdtemp.c \
141.22Sthorpej		mkstemp.c pread.c putc_unlocked.c pwcache.c pwrite.c \
151.51Slukem		pw_scan.c \
161.89Schristos		raise_default_signal.c rb.c reallocarr.c reallocarray.c \
171.89Schristos		rmd160.c rmd160hl.c \
181.81Saymeric		regcomp.c regerror.c regexec.c regfree.c \
191.51Slukem		setenv.c setgroupent.c \
201.34Selad		setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
211.93Sjakllsch		sha256hl.c sha384hl.c sha512hl.c \
221.93Sjakllsch		shquote.c \
231.93Sjakllsch		snprintb.c snprintf.c \
241.71Sapb		stat_flags.c strlcat.c strlcpy.c strmode.c \
251.85Schristos		strcasecmp.c strncasecmp.c strndup.c strnlen.c \
261.69Sapb		strsep.c strsuftoll.c strtoll.c \
271.73Schristos		strtoi.c strtou.c \
281.72Schristos		unvis.c vis.c err.c errx.c errc.c verr.c verrx.c verrc.c \
291.72Schristos		vwarn.c vwarnx.c vwarnc.c warn.c warnx.c warnc.c \
301.72Schristos		fts.c glob.c efun.c
311.21Sthorpej
321.21SthorpejBUILD_OSTYPE!=  uname -s
331.21Sthorpej
341.21Sthorpej# Disable use of pre-compiled headers on Darwin.
351.21Sthorpej.if ${BUILD_OSTYPE} == "Darwin"
361.90SchristosHOST_CPPFLAGS+=	-no-cpp-precomp
371.21Sthorpej.endif
381.6Stv
391.6Stv# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
401.6Stv# other file ops, on many systems, without changing function names.
411.6Stv
421.90SchristosHOST_CPPFLAGS+=	-I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
431.47Sdogcow		-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
441.3Stv
451.57Sjoerg.PATH:		${.CURDIR}/../../lib/libc/cdb \
461.57Sjoerg		${.CURDIR}/../../lib/libc/gen \
471.9Sbjh21		${.CURDIR}/../../lib/libc/hash \
481.39Selad		${.CURDIR}/../../lib/libc/hash/md2 \
491.38Selad		${.CURDIR}/../../lib/libc/hash/md5 \
501.38Selad		${.CURDIR}/../../lib/libc/hash/rmd160 \
511.38Selad		${.CURDIR}/../../lib/libc/hash/sha1 \
521.34Selad		${.CURDIR}/../../lib/libc/hash/sha2 \
531.9Sbjh21		${.CURDIR}/../../lib/libc/md \
541.81Saymeric		${.CURDIR}/../../lib/libc/regex \
551.15Sthorpej		${.CURDIR}/../../lib/libc/stdio \
561.6Stv		${.CURDIR}/../../lib/libc/stdlib \
571.4Slukem		${.CURDIR}/../../lib/libc/string \
581.44Schristos		${.CURDIR}/../../lib/libutil \
591.70Sjoerg		${.CURDIR}/../../common/lib/libc/cdb \
601.87Sthorpej		${.CURDIR}/../../common/lib/libc/gen \
611.40Schristos		${.CURDIR}/../../common/lib/libc/string \
621.46Smrg		${.CURDIR}/../../common/lib/libc/hash/rmd160 \
631.40Schristos		${.CURDIR}/../../common/lib/libc/hash/sha1 \
641.46Smrg		${.CURDIR}/../../common/lib/libc/hash/sha2 \
651.40Schristos		${.CURDIR}/../../common/lib/libc/md \
661.45Sthorpej		${.CURDIR}/../../common/lib/libc/stdlib \
671.69Sapb		${.CURDIR}/../../common/lib/libutil \
681.77Schristos		${.CURDIR}/../../external/bsd/flex/dist/src
691.1Stv
701.6StvDPSRCS+=	defs.mk
711.43SchristosCLEANFILES+=	config.log config.status configure.lineno *.stamp
721.61SapbCLEANDIRFILES+=	defs.mk config.cache confdefs.h
731.3Stv
741.3Stv# Get components of Berkeley DB.
751.3Stv_CURDIR:=	${.CURDIR}
761.3Stv.CURDIR:=	${_CURDIR}/../../lib/libc
771.3Stv.include "${.CURDIR}/db/Makefile.inc"
781.3Stv.CURDIR:=	${_CURDIR}
791.3Stv
801.54SroySRCS:=		${SRCS:M*.c}
811.1Stv
821.88SlukemCONFIGURE_ARGS=	--cache-file=config.cache
831.88Slukem.if ${MAKEVERBOSE} == 0
841.88SlukemCONFIGURE_ARGS+=--silent
851.88Slukem.endif
861.88Slukem
871.42Swizconfig.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
881.20Slukem	rm -f ${.TARGET}
891.90Schristos	CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} CPPFLAGS=${HOST_CPPFLAGS:Q} \
901.90Schristos		LDFLAGS=${HOST_LDFLAGS:Q} \
911.88Slukem		${HOST_SH} ${.CURDIR}/configure ${CONFIGURE_ARGS}
921.20Slukem
931.20Slukemdefs.mk: config.cache
941.20Slukem	@touch ${.TARGET}
951.1Stv
961.61SapbINCFILES=	nbtool_config.h
971.66SchristosINCSUBDIRS=	sys machine rpc arpa
981.61SapbCLEANDIRFILES+= ${INCFILES}
991.61Sapb
1001.61Sapb# CLEANDIRFILES may not contain directory names
1011.61Sapbcleandir:	cleandir.include
1021.61Sapbcleandir.include: .PHONY
1031.61Sapb		rm -rf include
1041.61Sapb
1051.13Stvinclude/.stamp:
1061.61Sapb	mkdir -p ${INCSUBDIRS:@d@ include/$d @}
1071.20Slukem	@touch ${.TARGET}
1081.6Stv
1091.61Sapb# Install rules
1101.61Sapb
1111.61SapbHOST_LIBDIR=	${TOOLDIR}/lib
1121.61SapbHOST_INCSDIR=	${TOOLDIR}/include
1131.66SchristosHOST_SHAREDIR= ${TOOLDIR}/share
1141.61Sapb
1151.64Schristosinstall:	.PHONY install.lib includes install.defs.mk
1161.61Sapb
1171.61Sapb# Install lib${HOSTLIB}.a in ${TOOLDIR}/lib
1181.61Sapbinstall.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a
1191.61Sapb${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a
1201.61Sapb	${_MKTARGET_INSTALL}
1211.61Sapb	${HOST_INSTALL_DIR} ${HOST_LIBDIR}
1221.61Sapb	${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
1231.61Sapb
1241.64Schristos.for _f in ${INCFILES}
1251.64SchristosHOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f}
1261.64Schristos${HOST_INCSDIR}/compat/${_f}: ${_f}
1271.64Schristos	${_MKTARGET_INSTALL}
1281.64Schristos	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1291.64Schristos.endfor
1301.64Schristos
1311.61Sapb.for _d in ${INCSUBDIRS}
1321.64SchristosHOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
1331.64Schristos${HOST_INCSDIR}/compat/${_d}:
1341.64Schristos	${_MKTARGET_INSTALL}
1351.64Schristos	${HOST_INSTALL_DIR} ${.TARGET}
1361.61Sapb.endfor
1371.64Schristos
1381.64Schristos# Install include files in ${TOOLDIR}/include/compat
1391.64Schristosincludes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
1401.76Schristos	@(cd include && find . -name '*.h' -print | while read f ; do \
1411.66Schristos	    ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
1421.66Schristos	done)
1431.66Schristos
1441.61Sapb
1451.61Sapb# Install defs.mk in ${TOOLDIR}/share/compat
1461.61Sapbinstall.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
1471.61Sapb${HOST_SHAREDIR}/compat/defs.mk: defs.mk
1481.61Sapb	${_MKTARGET_INSTALL}
1491.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
1501.61Sapb	${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
1511.61Sapb	${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
1521.61Sapb
1531.61Sapb# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
1541.6Stv
1551.90SchristosHOST_CPPFLAGS+=	${CPPFLAGS}
1561.1Stv
1571.1Stv.include <bsd.hostlib.mk>
1581.60Sapb
1591.60Sapb# Use uninstalled copy of host-mkdep
1601.60SapbHOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
1611.60SapbHOST_MKDEP=	${HOST_MKDEP_OBJ}/host-mkdep
1621.60SapbMKDEP=		${HOST_MKDEP}
1631.60Sapb
1641.61Sapb# Use uninstalled copy of the install program
1651.61SapbINSTALL_OBJ!=	cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
1661.61SapbINSTALL=	${INSTALL_OBJ}/xinstall
1671.61Sapb
1681.60Sapb# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
1691.60Sapb# configure.ac.  See more detailed instructions in configure.ac.
1701.60Sapbregen:
1711.92Slukem	${_MKMSG_REGEN} configure nbtool_config.h.in
1721.92Slukem	cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoreconf \
1731.92Slukem		${${MAKEVERBOSE} >= 2 :? -v :}
174