1 # $NetBSD: bsd.sys.mk,v 1.188 2009/12/14 01:00:46 matt Exp $
3 # Build definitions used for NetBSD source tree builds.
5 .if
!defined
(_BSD_SYS_MK_
)
10 CFLAGS
+= -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.
18 CFLAGS
+= -Wno-sign-compare
-Wno-traditional
19 .if
!defined
(NOGCCERROR
)
20 # Set assembler warnings to be fatal
21 CFLAGS
+= -Wa
,--fatal-warnings
23 # Set linker warnings to be fatal
24 # XXX no proper way to avoid "FOO is a patented algorithm" warnings
25 # XXX on linking static libs
26 .if
(!defined
(MKPIC
) ||
${MKPIC} != "no") && \
27 (!defined
(LDSTATIC
) ||
${LDSTATIC} != "-static")
28 LDFLAGS
+= -Wl
,--fatal-warnings
32 CFLAGS
+= -Wreturn-type
-Wswitch
-Wshadow
35 CFLAGS
+= -Wcast-qual
-Wwrite-strings
36 CFLAGS
+= -Wextra
-Wno-unused-parameter
38 CXXFLAGS
+= -Wold-style-cast
39 CXXFLAGS
+= -Wctor-dtor-privacy
-Wnon-virtual-dtor
-Wreorder \
40 -Wno-deprecated
-Wno-non-template-friend \
41 -Woverloaded-virtual
-Wno-pmf-conversions
-Wsign-promo
-Wsynth
43 .if
${WARNS} > 3 && defined
(HAVE_GCC
) && ${HAVE_GCC} >= 3
44 CFLAGS
+= -Wsign-compare
49 CPPFLAGS
+= ${AUDIT
:D-D__AUDIT__
}
50 CFLAGS
+= ${CWARNFLAGS} ${NOGCCERROR
:D
:U-Werror
}
51 LINTFLAGS
+= ${DESTDIR
:D-d
${DESTDIR}/usr
/include}
53 .if
(${MACHINE_ARCH} == "alpha") || \
54 (${MACHINE_ARCH} == "hppa") || \
55 (${MACHINE_ARCH} == "ia64") || \
56 (${MACHINE_ARCH} == "mipsel") ||
(${MACHINE_ARCH} == "mipseb") || \
57 (${MACHINE_ARCH} == "mips64el") ||
(${MACHINE_ARCH} == "mips64eb")
63 .if defined
(USE_FORT
) && (${USE_FORT} != "no")
65 .if
!defined
(KERNSRCDIR
) && !defined
(KERN
) # not for kernels nor kern modules
66 CPPFLAGS
+= -D_FORTIFY_SOURCE
=2
70 .if defined
(USE_SSP
) && (${USE_SSP} != "no") && (${BINDIR
:Ux
} != "/usr/mdec")
71 .if
${HAS_SSP} == "yes"
72 COPTS
+= -fstack-protector
-Wstack-protector
--param ssp-buffer-size
=1
76 .if defined
(MKSOFTFLOAT
) && (${MKSOFTFLOAT} != "no")
81 .if defined
(MKIEEEFP
) && (${MKIEEEFP} != "no")
82 .if
${MACHINE_ARCH} == "alpha"
88 .if
${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
92 .if
!defined
(NOGCCERROR
)
93 .if
(${MACHINE_ARCH} == "mips64el") ||
(${MACHINE_ARCH} == "mips64eb")
94 CPUFLAGS
+= -Wa
,--fatal-warnings
98 #.if ${MACHINE} == "sbmips"
99 #CFLAGS+= -mips64 -mtune=sb1
102 #.if (${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") && \
103 # (defined(MKPIC) && ${MKPIC} == "no")
104 #CPUFLAGS+= -mno-abicalls -fno-PIC
109 # Position Independent Executable flags
110 PIE_CFLAGS?
= -fPIC
-DPIC
111 PIE_LDFLAGS?
= -Wl
,-pie
-shared-libgcc
112 PIE_AFLAGS?
= -fPIC
-DPIC
114 # Helpers for cross-compiling
117 HOST_COMPILE.c?
=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
118 HOST_COMPILE.
cc?
= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c
119 .if defined
(HOSTPROG_CXX
)
120 HOST_LINK.c?
= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
122 HOST_LINK.c?
= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
139 # HOST_SH must be an absolute path
142 ELF2ECOFF?
= elf2ecoff
149 # TOOL_* variables are defined in bsd.own.mk
151 .SUFFIXES
: .o .ln .lo .c .
cc .
cpp .
cxx .C .m
${YHEADER
:D.h
}
156 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
160 ${LINT} ${LINTFLAGS} \
161 ${CPPFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
162 ${CPPFLAGS.
${.IMPSRC
:T
}:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
166 .
cc.o .
cpp.o .
cxx.o .C.o
:
168 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
171 # (Defined here rather than in <sys.mk> because `.m' is not just
172 # used for Objective C source)
175 ${COMPILE.m
} ${OBJCOPTS} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
}
177 # Host-compiled C objects
178 # The intermediate step is necessary for Sun CC, which objects to calling
179 # object files anything but *.o
182 ${HOST_COMPILE.c
} -o
${.TARGET
}.o
${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
183 mv
${.TARGET
}.o
${.TARGET
}
186 .
cc.lo .
cpp.lo .
cxx.lo .C.lo
:
188 ${HOST_COMPILE.
cc} -o
${.TARGET
}.o
${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
189 mv
${.TARGET
}.o
${.TARGET
}
194 ${COMPILE.s
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
198 ${COMPILE.S
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
201 LFLAGS
+= ${LPREFIX.
${.IMPSRC
:T
}:D-P
${LPREFIX.
${.IMPSRC
:T
}}}
202 LFLAGS
+= ${LPREFIX
:D-P
${LPREFIX}}
206 ${LEX.l
} -o
${.TARGET
} ${.IMPSRC
}
209 YFLAGS
+= ${YPREFIX.
${.IMPSRC
:T
}:D-p
${YPREFIX.
${.IMPSRC
:T
}}} ${YHEADER.
${.IMPSRC
:T
}:D-d
}
210 YFLAGS
+= ${YPREFIX
:D-p
${YPREFIX}} ${YHEADER
:D-d
}
214 ${YACC.y
} -o
${.TARGET
} ${.IMPSRC
}
217 .if empty
(.MAKEFLAGS
:M-n
)
218 .y.h
: ${.TARGET
:.h
=.c
}
222 .
endif # !defined(_BSD_SYS_MK_)