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