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