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