1# from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 2# $FreeBSD$ 3 4unix ?= We run FreeBSD, not UNIX. 5.FreeBSD ?= true 6 7.if !defined(%POSIX) 8# 9# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with 10# the same MACHINE_ARCH can run each other's binaries, so it necessarily 11# has word size and endian swizzled in. However, support files for 12# these machines often are shared amongst all combinations of size 13# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used 14# for something different in FreeBSD. 15# 16MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc64/powerpc/} 17.endif 18 19 20# Some options we need now 21__DEFAULT_NO_OPTIONS= \ 22 DIRDEPS_CACHE \ 23 META_MODE \ 24 META_FILES \ 25 26 27__DEFAULT_DEPENDENT_OPTIONS= \ 28 AUTO_OBJ/META_MODE \ 29 STAGING/META_MODE \ 30 SYSROOT/META_MODE 31 32__ENV_ONLY_OPTIONS:= \ 33 ${__DEFAULT_NO_OPTIONS} \ 34 ${__DEFAULT_YES_OPTIONS} \ 35 ${__DEFAULT_DEPENDENT_OPTIONS:H} 36 37# early include for customization 38# see local.sys.mk below 39# Not included when building in fmake compatibility mode (still needed 40# for older system support) 41.if defined(.PARSEDIR) 42.sinclude <local.sys.env.mk> 43 44.include <bsd.mkopt.mk> 45 46.if ${MK_META_MODE} == "yes" 47.sinclude <meta.sys.mk> 48.elif ${MK_META_FILES} == "yes" && defined(.MAKEFLAGS) 49.if ${.MAKEFLAGS:M-B} == "" 50.MAKE.MODE= meta verbose 51.endif 52.endif 53.if ${MK_AUTO_OBJ} == "yes" 54# This needs to be done early - before .PATH is computed 55# Don't do this if just running 'make -V' (but do when inspecting .OBJDIR) or 56# 'make showconfig' (during makeman which enables all options when meta mode 57# is not expected) 58.if (${.MAKEFLAGS:M-V} == "" || ${.MAKEFLAGS:M.OBJDIR} != "") && \ 59 !make(showconfig) 60.sinclude <auto.obj.mk> 61.endif 62.endif 63.else # bmake 64.include <bsd.mkopt.mk> 65.endif 66 67# If the special target .POSIX appears (without prerequisites or 68# commands) before the first noncomment line in the makefile, make shall 69# process the makefile as specified by the Posix 1003.2 specification. 70# make(1) sets the special macro %POSIX in this case (to the actual 71# value "1003.2", for what it's worth). 72# 73# The rules below use this macro to distinguish between Posix-compliant 74# and default behaviour. 75 76.if defined(%POSIX) 77.SUFFIXES: .o .c .y .l .a .sh .f 78.else 79.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh 80.endif 81 82AR ?= ar 83.if defined(%POSIX) 84ARFLAGS ?= -rv 85.else 86ARFLAGS ?= -crD 87.endif 88RANLIB ?= ranlib 89.if !defined(%POSIX) 90RANLIBFLAGS ?= -D 91.endif 92 93AS ?= as 94AFLAGS ?= 95ACFLAGS ?= 96 97.if defined(%POSIX) 98CC ?= c89 99CFLAGS ?= -O 100.else 101CC ?= cc 102.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 103CFLAGS ?= -O -pipe 104.else 105CFLAGS ?= -O2 -pipe 106.endif 107.if defined(NO_STRICT_ALIASING) 108CFLAGS += -fno-strict-aliasing 109.endif 110.endif 111PO_CFLAGS ?= ${CFLAGS} 112 113# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle 114# read-only files as non-root by passing -f. 115CP ?= cp -f 116 117CPP ?= cpp 118 119# C Type Format data is required for DTrace 120CTFFLAGS ?= -L VERSION 121 122CTFCONVERT ?= ctfconvert 123CTFMERGE ?= ctfmerge 124 125.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 126CTFFLAGS += -g 127.endif 128 129CXX ?= c++ 130CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 131PO_CXXFLAGS ?= ${CXXFLAGS} 132 133DTRACE ?= dtrace 134DTRACEFLAGS ?= -C -x nolibs 135 136.if empty(.MAKEFLAGS:M-s) 137ECHO ?= echo 138ECHODIR ?= echo 139.else 140ECHO ?= true 141.if ${.MAKEFLAGS:M-s} == "-s" 142ECHODIR ?= echo 143.else 144ECHODIR ?= true 145.endif 146.endif 147 148.if ${.MAKEFLAGS:M-N} 149# bmake -N is supposed to skip executing anything but it does not skip 150# exeucting '+' commands. The '+' feature is used where .MAKE 151# is not safe for the entire target. -N is intended to skip building sub-makes 152# so it executing '+' commands is not right. Work around the bug by not 153# setting '+' when -N is used. 154_+_ ?= 155.else 156_+_ ?= + 157.endif 158 159.if defined(%POSIX) 160FC ?= fort77 161FFLAGS ?= -O 1 162.else 163FC ?= f77 164FFLAGS ?= -O 165.endif 166EFLAGS ?= 167 168INSTALL ?= install 169 170LEX ?= lex 171LFLAGS ?= 172 173LD ?= ld 174LDFLAGS ?= # LDFLAGS is for CC, 175_LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD 176 177LINT ?= lint 178LINTFLAGS ?= -cghapbx 179LINTKERNFLAGS ?= ${LINTFLAGS} 180LINTOBJFLAGS ?= -cghapbxu -i 181LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 182LINTLIBFLAGS ?= -cghapbxu -C ${LIB} 183 184MAKE ?= make 185 186.if !defined(%POSIX) 187NM ?= nm 188NMFLAGS ?= 189 190OBJC ?= cc 191OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 192 193OBJCOPY ?= objcopy 194 195OBJDUMP ?= objdump 196 197PC ?= pc 198PFLAGS ?= 199 200RC ?= f77 201RFLAGS ?= 202.endif 203 204SHELL ?= sh 205 206.if !defined(%POSIX) 207SIZE ?= size 208.endif 209 210YACC ?= yacc 211.if defined(%POSIX) 212YFLAGS ?= 213.else 214YFLAGS ?= -d 215.endif 216 217.if defined(%POSIX) 218 219# Posix 1003.2 mandated rules 220# 221# Quoted directly from the Posix 1003.2 draft, only the macros 222# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 223# ${.PREFIX}, resp. 224 225# SINGLE SUFFIX RULES 226.c: 227 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 228 229.f: 230 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 231 232.sh: 233 cp -f ${.IMPSRC} ${.TARGET} 234 chmod a+x ${.TARGET} 235 236# DOUBLE SUFFIX RULES 237 238.c.o: 239 ${CC} ${CFLAGS} -c ${.IMPSRC} 240 241.f.o: 242 ${FC} ${FFLAGS} -c ${.IMPSRC} 243 244.y.o: 245 ${YACC} ${YFLAGS} ${.IMPSRC} 246 ${CC} ${CFLAGS} -c y.tab.c 247 rm -f y.tab.c 248 mv y.tab.o ${.TARGET} 249 250.l.o: 251 ${LEX} ${LFLAGS} ${.IMPSRC} 252 ${CC} ${CFLAGS} -c lex.yy.c 253 rm -f lex.yy.c 254 mv lex.yy.o ${.TARGET} 255 256.y.c: 257 ${YACC} ${YFLAGS} ${.IMPSRC} 258 mv y.tab.c ${.TARGET} 259 260.l.c: 261 ${LEX} ${LFLAGS} ${.IMPSRC} 262 mv lex.yy.c ${.TARGET} 263 264.c.a: 265 ${CC} ${CFLAGS} -c ${.IMPSRC} 266 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 267 rm -f ${.PREFIX}.o 268 269.f.a: 270 ${FC} ${FFLAGS} -c ${.IMPSRC} 271 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 272 rm -f ${.PREFIX}.o 273 274.else 275 276# non-Posix rule set 277 278.sh: 279 cp -fp ${.IMPSRC} ${.TARGET} 280 chmod a+x ${.TARGET} 281 282.c.ln: 283 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 284 touch ${.TARGET} 285 286.cc.ln .C.ln .cpp.ln .cxx.ln: 287 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 288 touch ${.TARGET} 289 290.c: 291 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 292 ${CTFCONVERT_CMD} 293 294.c.o: 295 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 296 ${CTFCONVERT_CMD} 297 298.cc .cpp .cxx .C: 299 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 300 301.cc.o .cpp.o .cxx.o .C.o: 302 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 303 304.m.o: 305 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} 306 ${CTFCONVERT_CMD} 307 308.p.o: 309 ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET} 310 ${CTFCONVERT_CMD} 311 312.e .r .F .f: 313 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 314 -o ${.TARGET} 315 316.e.o .r.o .F.o .f.o: 317 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET} 318 319.S.o: 320 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 321 ${CTFCONVERT_CMD} 322 323.asm.o: 324 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ 325 -o ${.TARGET} 326 ${CTFCONVERT_CMD} 327 328.s.o: 329 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 330 ${CTFCONVERT_CMD} 331 332# XXX not -j safe 333.y.o: 334 ${YACC} ${YFLAGS} ${.IMPSRC} 335 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 336 rm -f y.tab.c 337 ${CTFCONVERT_CMD} 338 339.l.o: 340 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 341 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 342 rm -f ${.PREFIX}.tmp.c 343 ${CTFCONVERT_CMD} 344 345# XXX not -j safe 346.y.c: 347 ${YACC} ${YFLAGS} ${.IMPSRC} 348 mv y.tab.c ${.TARGET} 349 350.l.c: 351 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 352 353.s.out .c.out .o.out: 354 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 355 ${CTFCONVERT_CMD} 356 357.f.out .F.out .r.out .e.out: 358 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 359 ${LDLIBS} -o ${.TARGET} 360 rm -f ${.PREFIX}.o 361 ${CTFCONVERT_CMD} 362 363# XXX not -j safe 364.y.out: 365 ${YACC} ${YFLAGS} ${.IMPSRC} 366 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 367 rm -f y.tab.c 368 ${CTFCONVERT_CMD} 369 370.l.out: 371 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 372 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 373 rm -f ${.PREFIX}.tmp.c 374 ${CTFCONVERT_CMD} 375 376# Pull in global settings. 377__MAKE_CONF?=/etc/make.conf 378.if exists(${__MAKE_CONF}) 379.include "${__MAKE_CONF}" 380.endif 381 382# late include for customization 383.sinclude <local.sys.mk> 384 385.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 386SHELL= ${__MAKE_SHELL} 387.SHELL: path=${__MAKE_SHELL} 388.endif 389 390# Tell bmake to expand -V VAR by default 391.MAKE.EXPAND_VARIABLES= yes 392 393# Tell bmake the makefile preference 394.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 395 396# Tell bmake to always pass job tokens, regardless of target depending on 397# .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make. 398.MAKE.ALWAYS_PASS_JOB_QUEUE= yes 399 400# By default bmake does *not* use set -e 401# when running target scripts, this is a problem for many makefiles here. 402# So define a shell that will do what FreeBSD expects. 403.ifndef WITHOUT_SHELL_ERRCTL 404__MAKE_SHELL?=/bin/sh 405.SHELL: name=sh \ 406 quiet="set -" echo="set -v" filter="set -" \ 407 hasErrCtl=yes check="set -e" ignore="set +e" \ 408 echoFlag=v errFlag=e \ 409 path=${__MAKE_SHELL} 410.endif 411 412.include <bsd.cpu.mk> 413 414.endif # ! Posix 415