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