1 # $NetBSD: bsd.sys.mk,v 1.220 2012/09/23 19:20:44 joerg Exp $
3 # Build definitions used for NetBSD source tree builds.
5 .if
!defined
(_BSD_SYS_MK_
)
8 .if
${HOST_OSTYPE
:C
/\
-.
*//:U
} == "Minix"
9 HOST_CPP?
= /usr
/lib
/cpp
10 HOST_LDFLAGS?
= -static
13 .if
${MKREPRO
:Uno
} == "yes"
14 CPPFLAGS
+= -Wp
,-iremap
,${NETBSDSRCDIR}:/usr
/src
15 CPPFLAGS
+= -Wp
,-iremap
,${DESTDIR}/:/
16 CPPFLAGS
+= -Wp
,-iremap
,${X11SRCDIR}:/usr
/xsrc
19 # Enable c99 mode by default.
20 # This has the side effect of complaining for missing prototypes
21 # implicit type declarations and missing return statements.
22 .if defined
(HAVE_GCC
) || defined
(HAVE_LLVM
)
27 CFLAGS
+= ${${ACTIVE_CC} == "clang":?
-Wno-sign-compare
-Wno-pointer-sign
:}
29 CFLAGS
+= -Wall
-Wstrict-prototypes
-Wmissing-prototypes
-Wpointer-arith
30 #CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs
31 # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
32 # but our sources aren't up for it yet. Also, add -Wno-traditional because
33 # gcc includes #elif in the warnings, which is 'this code will not compile
34 # in a traditional environment' warning, as opposed to 'this code behaves
35 # differently in traditional and ansi environments' which is the warning
36 # we wanted, and now we don't get anymore.
37 CFLAGS
+= -Wno-sign-compare
38 CFLAGS
+= ${${ACTIVE_CC} != "clang":?
-Wno-traditional
:}
39 .if
!defined
(NOGCCERROR
)
40 # Set assembler warnings to be fatal
41 #CFLAGS+= -Wa,--fatal-warnings
42 # LSC Clang version 2.9 those not support this flag
43 CFLAGS
+= ${${HAVE_LLVM
:U
"0.0"} != "2.9":?
-Wa
,--fatal-warnings
:}
45 # Set linker warnings to be fatal
46 # XXX no proper way to avoid "FOO is a patented algorithm" warnings
47 # XXX on linking static libs
48 .if
(!defined
(MKPIC
) ||
${MKPIC} != "no") && \
49 (!defined
(LDSTATIC
) ||
${LDSTATIC} != "-static")
50 # XXX there are some strange problems not yet resolved
51 . if
!defined
(HAVE_GCC
) || defined
(HAVE_LLVM
)
52 LDFLAGS
+= -Wl
,--fatal-warnings
57 CFLAGS
+= -Wreturn-type
-Wswitch
-Wshadow
60 CFLAGS
+= -Wcast-qual
-Wwrite-strings
61 CFLAGS
+= -Wextra
-Wno-unused-parameter
62 # Readd -Wno-sign-compare to override -Wextra with clang
63 CFLAGS
+= -Wno-sign-compare
65 CXXFLAGS
+= -Wold-style-cast
66 CXXFLAGS
+= -Wctor-dtor-privacy
-Wnon-virtual-dtor
-Wreorder \
67 -Wno-deprecated
-Woverloaded-virtual
-Wsign-promo
-Wsynth
68 CXXFLAGS
+= ${${ACTIVE_CXX} == "gcc":?
-Wno-non-template-friend
-Wno-pmf-conversions
:}
70 .if
${WARNS} > 3 && (defined
(HAVE_GCC
) || defined
(HAVE_LLVM
))
72 CFLAGS
+= -Wold-style-definition
74 CFLAGS
+= -Wsign-compare
-Wformat
=2
75 CFLAGS
+= ${${ACTIVE_CC} == "clang":?
-Wno-error
=format-nonliteral
:}
76 CFLAGS
+= ${${ACTIVE_CC} == "gcc":?
-Wno-format-zero-length
:}
78 .if
${WARNS} > 3 && defined
(HAVE_LLVM
)
79 CFLAGS
+= ${${ACTIVE_CC} == "clang":?
-Wpointer-sign
-Wmissing-noreturn
:}
81 .if
(defined
(HAVE_GCC
) && ${HAVE_GCC} == 45 \
82 && (${MACHINE_ARCH} == "sh3eb" || \
83 ${MACHINE_ARCH} == "sh3el" || \
84 ${MACHINE_ARCH} == "m68k" || \
85 ${MACHINE_ARCH} == "m68000"))
86 # XXX GCC 4.5 for sh3 and m68k (which we compile with -Os) is extra noisy for
87 # cases it should be better with
88 CFLAGS
+= -Wno-uninitialized
92 CWARNFLAGS
+= ${CWARNFLAGS.
${ACTIVE_CC}}
94 CPPFLAGS
+= ${AUDIT
:D-D__AUDIT__
}
95 _NOWERROR
= ${defined
(NOGCCERROR
) ||
(${ACTIVE_CC} == "clang" && defined
(NOCLANGERROR
)):?yes
:no
}
96 CFLAGS
+= ${${_NOWERROR} == "no" :?
-Werror
:} ${CWARNFLAGS}
97 LINTFLAGS
+= ${DESTDIR
:D-d
${DESTDIR}/usr
/include}
99 .if
(${MACHINE_ARCH} == "alpha") || \
100 (${MACHINE_ARCH} == "hppa") || \
101 (${MACHINE_ARCH} == "ia64") || \
102 (${MACHINE_ARCH} == "mipsel") ||
(${MACHINE_ARCH} == "mipseb") || \
103 (${MACHINE_ARCH} == "mips64el") ||
(${MACHINE_ARCH} == "mips64eb")
109 .if
${USE_FORT
:Uno
} != "no"
111 .if
!defined
(KERNSRCDIR
) && !defined
(KERN
) # not for kernels nor kern modules
112 CPPFLAGS
+= -D_FORTIFY_SOURCE
=2
116 .if
(${USE_SSP
:Uno
} != "no") && (${BINDIR
:Ux
} != "/usr/mdec")
117 .if
${HAS_SSP} == "yes"
118 COPTS
+= -fstack-protector
-Wstack-protector
120 COPTS
+= ${${ACTIVE_CC} == "clang":?
-mllvm
-stack-protector-buffer-size
=1 :}
122 COPTS
+= ${${ACTIVE_CC} == "clang":?
--param ssp-buffer-size
=1 :}
123 .
endif # defined(__MINIX)
124 COPTS
+= ${${ACTIVE_CC} == "gcc":?
--param ssp-buffer-size
=1 :}
128 .if
${MKSOFTFLOAT
:Uno
} != "no"
133 .if
${MKIEEEFP
:Uno
} != "no"
134 .if
${MACHINE_ARCH} == "alpha"
140 .if
${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc"
141 CFLAGS
+= -Wa
,-Av8plus
144 .if
!defined
(NOGCCERROR
)
145 .if
(${MACHINE_ARCH} == "mips64el") ||
(${MACHINE_ARCH} == "mips64eb")
146 CPUFLAGS
+= -Wa
,--fatal-warnings
150 #.if ${MACHINE} == "sbmips"
151 #CFLAGS+= -mips64 -mtune=sb1
154 #.if (${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb") && \
155 # (defined(MKPIC) && ${MKPIC} == "no")
156 #CPUFLAGS+= -mno-abicalls -fno-PIC
161 .if
!defined
(LDSTATIC
) ||
${LDSTATIC} != "-static"
162 # Position Independent Executable flags
163 PIE_CFLAGS?
= -fPIC
-DPIC
164 PIE_LDFLAGS?
= -Wl
,-pie
-shared-libgcc
165 PIE_AFLAGS?
= -fPIC
-DPIC
168 # Helpers for cross-compiling
171 HOST_COMPILE.c?
=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c
172 HOST_COMPILE.
cc?
= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c
173 .if defined
(HOSTPROG_CXX
)
174 HOST_LINK.c?
= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
176 HOST_LINK.c?
= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
193 # HOST_SH must be an absolute path
196 ELF2ECOFF?
= elf2ecoff
203 # TOOL_* variables are defined in bsd.own.mk
205 .SUFFIXES
: .o .ln .lo .c .
cc .
cpp .
cxx .C .m
${YHEADER
:D.h
}
210 ${COMPILE.c
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
211 .if defined
(CTFCONVERT
)
212 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
217 ${LINT} ${LINTFLAGS} ${LINTFLAGS.
${.IMPSRC
:T
}} \
218 ${CPPFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
219 ${CPPFLAGS.
${.IMPSRC
:T
}:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
223 .
cc.o .
cpp.o .
cxx.o .C.o
:
225 ${COMPILE.
cc} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
228 # (Defined here rather than in <sys.mk> because `.m' is not just
229 # used for Objective C source)
232 ${COMPILE.m
} ${OBJCOPTS} ${OBJCOPTS.
${.IMPSRC
:T
}} ${.IMPSRC
}
233 .if defined
(CTFCONVERT
)
234 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
237 # Host-compiled C objects
238 # The intermediate step is necessary for Sun CC, which objects to calling
239 # object files anything but *.o
242 ${HOST_COMPILE.c
} -o
${.TARGET
}.o
${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
243 mv
${.TARGET
}.o
${.TARGET
}
246 .
cc.lo .
cpp.lo .
cxx.lo .C.lo
:
248 ${HOST_COMPILE.
cc} -o
${.TARGET
}.o
${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
249 mv
${.TARGET
}.o
${.TARGET
}
254 ${COMPILE.s
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
255 .if defined
(CTFCONVERT
)
256 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
261 ${COMPILE.S
} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
262 .if defined
(CTFCONVERT
)
263 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET
}
267 LFLAGS
+= ${LPREFIX.
${.IMPSRC
:T
}:D-P
${LPREFIX.
${.IMPSRC
:T
}}}
268 LFLAGS
+= ${LPREFIX
:D-P
${LPREFIX}}
272 ${LEX.l
} -o
${.TARGET
} ${.IMPSRC
}
275 YFLAGS
+= ${YPREFIX.
${.IMPSRC
:T
}:D-p
${YPREFIX.
${.IMPSRC
:T
}}} ${YHEADER.
${.IMPSRC
:T
}:D-d
}
276 YFLAGS
+= ${YPREFIX
:D-p
${YPREFIX}} ${YHEADER
:D-d
}
280 ${YACC.y
} -o
${.TARGET
} ${.IMPSRC
}
283 .if empty
(.MAKEFLAGS
:M-n
)
284 .y.h
: ${.TARGET
:.h
=.c
}
289 OBJCOPYLIBFLAGS?
=${"${.TARGET:M*.po}" != "":?
-X
:-x
}
291 .
endif # !defined(_BSD_SYS_MK_)