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