1 # $NetBSD: bsd.sys.mk,v 1.186 2009/11/30 16:13:23 uebayasi Exp $
3 # Build definitions used for NetBSD source tree builds.
5 .if
!defined
(_MINIX_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
20 CFLAGS
+= -Wno-traditional
22 .if
!defined
(NOGCCERROR
) && !empty
(CC
:Mgcc
)
23 # Set assembler warnings to be fatal
24 CFLAGS
+= -Wa
,--fatal-warnings
26 # Set linker warnings to be fatal
27 # XXX no proper way to avoid "FOO is a patented algorithm" warnings
28 # XXX on linking static libs
29 .if
(!defined
(MKPIC
) ||
${MKPIC} != "no") && \
30 (!defined
(LDSTATIC
) ||
${LDSTATIC} != "-static") \
32 LDFLAGS
+= -Wl
,--fatal-warnings
36 CFLAGS
+= -Wreturn-type
-Wswitch
-Wshadow
39 CFLAGS
+= -Wcast-qual
-Wwrite-strings
40 CFLAGS
+= -Wextra
-Wno-unused-parameter
42 CXXFLAGS
+= -Wold-style-cast
43 CXXFLAGS
+= -Wctor-dtor-privacy
-Wnon-virtual-dtor
-Wreorder \
44 -Wno-deprecated
-Wno-non-template-friend \
45 -Woverloaded-virtual
-Wno-pmf-conversions
-Wsign-promo
-Wsynth
47 .if
${WARNS} > 3 && defined
(HAVE_GCC
) && ${HAVE_GCC} >= 3
48 CFLAGS
+= -Wsign-compare
53 # XXX: Temporarily disabled for MINIX
54 # CPPFLAGS+= ${AUDIT:D-D__AUDIT__}
55 # CFLAGS+= ${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
56 # LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include}
58 .if
(${MACHINE_ARCH} == "alpha") || \
59 (${MACHINE_ARCH} == "hppa") || \
60 (${MACHINE_ARCH} == "ia64") || \
61 (${MACHINE_ARCH} == "mipsel") ||
(${MACHINE_ARCH} == "mipseb") || \
62 (${MACHINE_ARCH} == "mips64el") ||
(${MACHINE_ARCH} == "mips64eb")
68 .if defined
(NBSD_LIBC
) && (${NBSD_LIBC} != "no")
69 CPPFLAGS
+= -D__NBSD_LIBC
72 .if defined
(USE_FORT
) && (${USE_FORT} != "no")
74 .if
!defined
(KERNSRCDIR
) && !defined
(KERN
) # not for kernels nor kern modules
75 CPPFLAGS
+= -D_FORTIFY_SOURCE
=2
79 .if defined
(USE_SSP
) && (${USE_SSP} != "no") && (${BINDIR
:Ux
} != "/usr/mdec")
80 .if
${HAS_SSP} == "yes"
81 COPTS
+= -fstack-protector
-Wstack-protector
--param ssp-buffer-size
=1
85 .if defined
(MKSOFTFLOAT
) && (${MKSOFTFLOAT} != "no")
90 .if defined
(MKIEEEFP
) && (${MKIEEEFP} != "no")
91 .if
${MACHINE_ARCH} == "alpha"
97 .if
${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
104 # Position Independent Executable flags
105 PIE_CFLAGS?
= -fPIC
-DPIC
106 PIE_LDFLAGS?
= -Wl
,-pie
-shared-libgcc
107 PIE_AFLAGS?
= -fPIC
-DPIC
109 # Helpers for cross-compiling
113 HOST_COMPILE.c?
=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
114 HOST_COMPILE.
cc?
= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c
115 .if defined
(HOSTPROG_CXX
)
116 HOST_LINK.c?
= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
118 HOST_LINK.c?
= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
136 # HOST_SH must be an absolute path
139 ELF2ECOFF?
= elf2ecoff
146 # TOOL_* variables are defined in bsd.own.mk
148 .SUFFIXES
: .o .ln .lo .c .
cc .
cpp .
cxx .C .m
${YHEADER
:D.h
}
153 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
157 ${LINT} ${LINTFLAGS} \
158 ${CPPFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
159 ${CPPFLAGS.
${.IMPSRC
:T
}:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
163 .
cc.o .
cpp.o .
cxx.o .C.o
:
165 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
168 # (Defined here rather than in <sys.mk> because `.m' is not just
169 # used for Objective C source)
172 ${COMPILE.m
} ${OBJCOPTS} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
}
174 # Host-compiled C objects
175 # The intermediate step is necessary for Sun CC, which objects to calling
176 # object files anything but *.o
179 ${HOST_COMPILE.c
} -o
${.TARGET
}.o
${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
180 mv
${.TARGET
}.o
${.TARGET
}
183 .
cc.lo .
cpp.lo .
cxx.lo .C.lo
:
185 ${HOST_COMPILE.
cc} -o
${.TARGET
}.o
${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
186 mv
${.TARGET
}.o
${.TARGET
}
191 ${COMPILE.s
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
195 ${COMPILE.S
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
198 LFLAGS
+= ${LPREFIX.
${.IMPSRC
:T
}:D-P
${LPREFIX.
${.IMPSRC
:T
}}}
199 LFLAGS
+= ${LPREFIX
:D-P
${LPREFIX}}
203 ${LEX.l
} -o
${.TARGET
} ${.IMPSRC
}
206 YFLAGS
+= ${YPREFIX.
${.IMPSRC
:T
}:D-p
${YPREFIX.
${.IMPSRC
:T
}}} ${YHEADER.
${.IMPSRC
:T
}:D-d
}
207 YFLAGS
+= ${YPREFIX
:D-p
${YPREFIX}} ${YHEADER
:D-d
}
212 ${YACC.y
} -o
${.TARGET
} ${.IMPSRC
} 2> /dev
/null
216 ${YACC.y
} -o
${.TARGET
} ${.IMPSRC
}
220 .y.h
: ${.TARGET
:.h
=.c
}
223 .
endif # !defined(_MINIX_SYS_MK_)