xref: /netbsd-src/share/mk/bsd.sys.mk (revision 69b6d498973bb4d7230c2d3c12bd9a032738ec8e)
1#	$NetBSD: bsd.sys.mk,v 1.120 2005/07/09 18:45:16 christos Exp $
2#
3# Build definitions used for NetBSD source tree builds.
4
5.if !defined(_BSD_SYS_MK_)
6_BSD_SYS_MK_=1
7
8.if defined(WARNS)
9.if ${WARNS} > 0
10CFLAGS+=	-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
11#CFLAGS+=	-Wmissing-declarations -Wredundant-decls -Wnested-externs
12# Add -Wno-sign-compare.  -Wsign-compare is included in -Wall as of GCC 3.3,
13# but our sources aren't up for it yet. Also, add -Wno-traditional because
14# gcc includes #elif in the warnings, which is 'this code will not compile
15# in a traditional environment' warning, as opposed to 'this code behaves
16# differently in traditional and ansi environments' which is the warning
17# we wanted, and now we don't get anymore.
18CFLAGS+=	-Wno-sign-compare -Wno-traditional
19.if !defined(HAVE_GCC3) || (${HAVE_GCC3} == "no")
20CFLAGS+=	-Wno-uninitialized
21.endif
22.endif
23.if ${WARNS} > 1
24CFLAGS+=	-Wreturn-type -Wswitch -Wshadow
25.endif
26.if ${WARNS} > 2
27CFLAGS+=	-Wcast-qual -Wwrite-strings
28.endif
29.if ${WARNS} > 3 && ${MACHINE_ARCH} != "vax"
30CFLAGS+=	-std=c99
31.endif
32.endif
33
34.if defined(WFORMAT) && defined(FORMAT_AUDIT)
35.if ${WFORMAT} > 1
36CFLAGS+=	-Wnetbsd-format-audit -Wno-format-extra-args
37.endif
38.endif
39
40CPPFLAGS+=	${AUDIT:D-D__AUDIT__}
41CFLAGS+=	${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
42LINTFLAGS+=	${DESTDIR:D-d ${DESTDIR}/usr/include}
43
44.if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no")
45COPTS+=		-msoft-float
46FOPTS+=		-msoft-float
47.endif
48
49.if defined(MKIEEEFP) && (${MKIEEEFP} != "no")
50.if ${MACHINE_ARCH} == "alpha"
51CFLAGS+=	-mieee
52FFLAGS+=	-mieee
53.endif
54.endif
55
56.if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
57CFLAGS+=	-Wa,-Av8plus
58.endif
59
60CFLAGS+=	${CPUFLAGS}
61AFLAGS+=	${CPUFLAGS}
62
63# Helpers for cross-compiling
64HOST_CC?=	cc
65HOST_CFLAGS?=	-O
66HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
67HOST_LINK.c?=	${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
68
69HOST_CXX?=	c++
70HOST_CXXFLAGS?=	-O
71
72HOST_CPP?=	cpp
73HOST_CPPFLAGS?=
74
75HOST_LD?=	ld
76HOST_LDFLAGS?=
77
78HOST_AR?=	ar
79HOST_RANLIB?=	ranlib
80
81HOST_LN?=	ln
82
83.if !empty(HOST_CYGWIN)
84HOST_SH?=	/usr/bin/bash
85.else
86HOST_SH?=	sh
87.endif
88
89ELF2ECOFF?=	elf2ecoff
90MKDEP?=		mkdep
91OBJCOPY?=	objcopy
92OBJDUMP?=	objdump
93STRIP?=		strip
94
95AWK?=		awk
96
97TOOL_ASN1_COMPILE?=	asn1_compile
98TOOL_CAP_MKDB?=		cap_mkdb
99TOOL_CAT?=		cat
100TOOL_CKSUM?=		cksum
101TOOL_COMPILE_ET?=	compile_et
102TOOL_CONFIG?=		config
103TOOL_CRUNCHGEN?=	crunchgen
104TOOL_CTAGS?=		ctags
105TOOL_DB?=		db
106TOOL_EQN?=		eqn
107TOOL_FGEN?=		fgen
108TOOL_GENASSYM?=		genassym
109TOOL_GENCAT?=		gencat
110TOOL_GROFF?=		groff
111TOOL_HEXDUMP?=		hexdump
112TOOL_INDXBIB?=		indxbib
113TOOL_INSTALLBOOT?=	installboot
114TOOL_INSTALL_INFO?=	install-info
115TOOL_M4?=		m4
116TOOL_MAKEFS?=		makefs
117TOOL_MAKEINFO?=		makeinfo
118TOOL_MAKEWHATIS?=	/usr/libexec/makewhatis
119TOOL_MDSETIMAGE?=	mdsetimage
120TOOL_MENUC?=		menuc
121TOOL_MKCSMAPPER?=	mkcsmapper
122TOOL_MKESDB?=		mkesdb
123TOOL_MKLOCALE?=		mklocale
124TOOL_MKMAGIC?=		file
125TOOL_MKTEMP?=		mktemp
126TOOL_MSGC?=		msgc
127TOOL_MTREE?=		mtree
128TOOL_PAX?=		pax
129TOOL_PIC?=		pic
130TOOL_PREPMKBOOTIMAGE?=	prep-mkbootimage
131TOOL_PWD_MKDB?=		pwd_mkdb
132TOOL_REFER?=		refer
133TOOL_ROFF_ASCII?=	nroff
134TOOL_ROFF_DVI?=		${TOOL_GROFF} -Tdvi
135TOOL_ROFF_HTML?=	${TOOL_GROFF} -Tlatin1 -mdoc2html
136TOOL_ROFF_PS?=		${TOOL_GROFF} -Tps
137TOOL_ROFF_RAW?=		${TOOL_GROFF} -Z
138TOOL_RPCGEN?=		rpcgen
139TOOL_SOELIM?=		soelim
140TOOL_STAT?=		stat
141TOOL_SPARKCRC?=		sparkcrc
142TOOL_SUNLABEL?=		sunlabel
143TOOL_TBL?=		tbl
144TOOL_UUDECODE?=		uudecode
145TOOL_VGRIND?=		vgrind -f
146TOOL_ZIC?=		zic
147
148.SUFFIXES:	.o .ln .lo .c .m ${YHEADER:D.h}
149
150# C
151.c.o:
152	${_MKTARGET_COMPILE}
153	${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
154
155.c.ln:
156	${_MKTARGET_COMPILE}
157	${LINT} ${LINTFLAGS} \
158	    ${CPPFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
159	    ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
160	    -i ${.IMPSRC}
161
162# C++
163.cc.o .cpp.o .cxx.o .C.o:
164	${_MKTARGET_COMPILE}
165	${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
166
167# Objective C
168# (Defined here rather than in <sys.mk> because `.m' is not just
169#  used for Objective C source)
170.m.o:
171	${_MKTARGET_COMPILE}
172	${COMPILE.m} ${.IMPSRC}
173
174# Host-compiled C objects
175# The intermediate step is necessary for Sun CC, which objects to calling
176# object files anything but *.o
177.c.lo:
178	${_MKTARGET_COMPILE}
179	${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
180	mv ${.TARGET}.o ${.TARGET}
181
182# Assembly
183.s.o:
184	${_MKTARGET_COMPILE}
185	${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
186
187.S.o:
188	${_MKTARGET_COMPILE}
189	${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
190
191# Lex
192LPREFIX?=	yy
193LFLAGS+=	-P${LPREFIX}
194
195.l.c:
196	${_MKTARGET_LEX}
197	${LEX.l} -o${.TARGET} ${.IMPSRC}
198
199# Yacc
200YFLAGS+=	${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d}
201
202.y.c:
203	${_MKTARGET_YACC}
204	${YACC.y} -o ${.TARGET} ${.IMPSRC}
205
206.ifdef YHEADER
207.y.h: ${.TARGET:.h=.c}
208.endif
209
210.endif	# !defined(_BSD_SYS_MK_)
211