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