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