xref: /netbsd-src/tools/compat/defs.mk.in (revision 97766c5b60b25639ea74b10b834be35d551438ac)
1#	$NetBSD: defs.mk.in,v 1.17 2023/06/03 09:10:13 lukem Exp $
2#
3# Makefile fragment for building with libnbcompat and associated
4# include files.  It can also be used for building just with
5# the include files, without the library.
6#
7# This can be used when the library and include files have been installed
8# into TOOLDIR (by "make install" in the src/tools/compat directory),
9# or when they have not been installed into TOOLDIR but reside
10# in the .OBJDIR associated with src/tools/compat.
11#
12# Variables:
13#
14# COMPATLIB_UNINSTALLED:
15#		If "yes", then use the files from the .OBJDIR of
16#		NETBSDSRCDIR/tools/compat.  Otherwise, use the files
17#		from TOOLDIR.
18#
19# COMPATLIB_NO_LIB:
20#		If "yes" then do not use the library (but still use
21#		the include files).
22#
23# Examples:
24#
25# * Use uninstalled copy of libnbcompat and associated *.h files:
26#
27#	COMPATLIB_UNINSTALLED= yes
28#	COMPATOBJ!=	cd ${NETBSDSRCDIR}/tools/compat && ${PRINTOBJDIR}
29#	.-include	"${COMPATOBJ}/defs.mk"
30#
31# * Use TOOLDIR copy of libnbcompat and associated *.h files:
32#
33#	.-include	"${TOOLDIR}/share/compat/defs.mk"
34#
35# * Use TOOLDIR copy of compat *.h files, but do not use libnbcompat.a:
36#
37#	COMPATLIB_NO_LIB= yes
38#	.-include	"${TOOLDIR}/share/compat/defs.mk"
39#
40# The use of ".-include" instead of ".include" above is because it's
41# expected that the file might not exist during "make obj" or "make clean".
42#
43
44.include <bsd.own.mk>
45
46# Use the installed (TOOLDIR) version of the library and headers by default
47COMPATLIB_UNINSTALLED ?= no
48# Use library and includes by default.
49COMPATLIB_NO_LIB ?= no
50
51.if "${COMPATLIB_UNINSTALLED}" == "yes"
52# The library lives in the .OBJDIR.
53#
54# Some include files live directly in the .OBJDIR, while others
55# live in subdirectories of .OBJDIR/include.
56#
57COMPATOBJ:=	${.PARSEDIR}
58COMPATLIBDIR=	${COMPATOBJ}
59COMPATINCFLAGS=	-I${COMPATOBJ} -I${COMPATOBJ}/include
60.else
61# The library lives in TOOLDIR/lib.
62#
63# All include files live in TOOLDIR/include/comnpat, and its subdirectories.
64#
65COMPATLIBDIR=	${TOOLDIR}/lib
66COMPATINCFLAGS=	-I${TOOLDIR}/include/compat
67.endif
68
69HOSTEXEEXT=	@EXEEXT@
70HOST_BSHELL=	@BSHELL@
71
72BUILD_OSTYPE!=  uname -s
73
74HOST_CFLAGS+=	@CC_NO_CPP_PRECOMP@
75
76# Override HOST_CC support for <bsd.own.mk> CC_* warnings
77#
78CC_WNO_ADDRESS_OF_PACKED_MEMBER=@CC_WNO_ADDRESS_OF_PACKED_MEMBER@ @CC_WNO_ERROR_ADDRESS_OF_PACKED_MEMBER@
79CC_WNO_CAST_FUNCTION_TYPE=@CC_WNO_CAST_FUNCTION_TYPE@
80CC_WNO_FORMAT_OVERFLOW=@CC_WNO_FORMAT_OVERFLOW@
81CC_WNO_FORMAT_TRUNCATION=@CC_WNO_FORMAT_TRUNCATION@
82CC_WNO_IMPLICIT_FALLTHROUGH=@CC_WNO_IMPLICIT_FALLTHROUGH@
83CC_WNO_MAYBE_UNINITIALIZED=@CC_WNO_MAYBE_UNINITIALIZED@
84CC_WNO_RETURN_LOCAL_ADDR=@CC_WNO_RETURN_LOCAL_ADDR@
85CC_WNO_STRINGOP_OVERFLOW=@CC_WNO_STRINGOP_OVERFLOW@
86CC_WNO_STRINGOP_TRUNCATION=@CC_WNO_STRINGOP_TRUNCATION@
87
88HOST_CPPFLAGS+=	${COMPATINCFLAGS} -I${NETBSDSRCDIR}/tools/compat \
89		-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
90
91.if "${COMPATLIB_NO_LIB}" != "yes"
92DPADD+=		${COMPATLIBDIR}/libnbcompat.a
93LDADD+=		-L${COMPATLIBDIR} -lnbcompat @LIBS@
94.endif # ! COMPATLIB_NO_LIB
95