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__ENV_ONLY_OPTIONS:= \ 33 ${__DEFAULT_NO_OPTIONS} \ 34 ${__DEFAULT_YES_OPTIONS} \ 35 ${__DEFAULT_DEPENDENT_OPTIONS:H} 36 37# early include for customization 38# see local.sys.mk below 39# Not included when building in fmake compatibility mode (still needed 40# for older system support) 41.if defined(.PARSEDIR) 42.sinclude <local.sys.env.mk> 43 44.include <bsd.mkopt.mk> 45 46.if ${MK_META_MODE} == "yes" 47.sinclude <meta.sys.mk> 48.elif ${MK_META_FILES} == "yes" && defined(.MAKEFLAGS) 49.if ${.MAKEFLAGS:M-B} == "" 50.MAKE.MODE= meta verbose 51.endif 52.endif 53.if ${MK_AUTO_OBJ} == "yes" 54# This needs to be done early - before .PATH is computed 55# Don't do this if just running 'make -V' or 'make showconfig' 56.if ${.MAKEFLAGS:M-V} == "" && !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 defined(.PARSEDIR) 146# _+_ appears to be a workaround for the special src .MAKE not working. 147# setting it to + interferes with -N 148_+_ ?= 149.elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 150# the check above matches only a single -n, so -n -n will result 151# in _+_ = + 152_+_ ?= 153.else 154_+_ ?= + 155.endif 156 157.if defined(%POSIX) 158FC ?= fort77 159FFLAGS ?= -O 1 160.else 161FC ?= f77 162FFLAGS ?= -O 163.endif 164EFLAGS ?= 165 166INSTALL ?= install 167 168LEX ?= lex 169LFLAGS ?= 170 171LD ?= ld 172LDFLAGS ?= # LDFLAGS is for CC, 173_LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD 174 175LINT ?= lint 176LINTFLAGS ?= -cghapbx 177LINTKERNFLAGS ?= ${LINTFLAGS} 178LINTOBJFLAGS ?= -cghapbxu -i 179LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 180LINTLIBFLAGS ?= -cghapbxu -C ${LIB} 181 182MAKE ?= make 183 184.if !defined(%POSIX) 185NM ?= nm 186NMFLAGS ?= 187 188OBJC ?= cc 189OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 190 191OBJCOPY ?= objcopy 192 193OBJDUMP ?= objdump 194 195PC ?= pc 196PFLAGS ?= 197 198RC ?= f77 199RFLAGS ?= 200.endif 201 202SHELL ?= sh 203 204.if !defined(%POSIX) 205SIZE ?= size 206.endif 207 208YACC ?= yacc 209.if defined(%POSIX) 210YFLAGS ?= 211.else 212YFLAGS ?= -d 213.endif 214 215.if defined(%POSIX) 216 217# Posix 1003.2 mandated rules 218# 219# Quoted directly from the Posix 1003.2 draft, only the macros 220# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 221# ${.PREFIX}, resp. 222 223# SINGLE SUFFIX RULES 224.c: 225 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 226 227.f: 228 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 229 230.sh: 231 cp -f ${.IMPSRC} ${.TARGET} 232 chmod a+x ${.TARGET} 233 234# DOUBLE SUFFIX RULES 235 236.c.o: 237 ${CC} ${CFLAGS} -c ${.IMPSRC} 238 239.f.o: 240 ${FC} ${FFLAGS} -c ${.IMPSRC} 241 242.y.o: 243 ${YACC} ${YFLAGS} ${.IMPSRC} 244 ${CC} ${CFLAGS} -c y.tab.c 245 rm -f y.tab.c 246 mv y.tab.o ${.TARGET} 247 248.l.o: 249 ${LEX} ${LFLAGS} ${.IMPSRC} 250 ${CC} ${CFLAGS} -c lex.yy.c 251 rm -f lex.yy.c 252 mv lex.yy.o ${.TARGET} 253 254.y.c: 255 ${YACC} ${YFLAGS} ${.IMPSRC} 256 mv y.tab.c ${.TARGET} 257 258.l.c: 259 ${LEX} ${LFLAGS} ${.IMPSRC} 260 mv lex.yy.c ${.TARGET} 261 262.c.a: 263 ${CC} ${CFLAGS} -c ${.IMPSRC} 264 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 265 rm -f ${.PREFIX}.o 266 267.f.a: 268 ${FC} ${FFLAGS} -c ${.IMPSRC} 269 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 270 rm -f ${.PREFIX}.o 271 272.else 273 274# non-Posix rule set 275 276.sh: 277 cp -fp ${.IMPSRC} ${.TARGET} 278 chmod a+x ${.TARGET} 279 280.c.ln: 281 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 282 touch ${.TARGET} 283 284.cc.ln .C.ln .cpp.ln .cxx.ln: 285 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 286 touch ${.TARGET} 287 288.c: 289 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 290 ${CTFCONVERT_CMD} 291 292.c.o: 293 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 294 ${CTFCONVERT_CMD} 295 296.cc .cpp .cxx .C: 297 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 298 299.cc.o .cpp.o .cxx.o .C.o: 300 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 301 302.m.o: 303 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} 304 ${CTFCONVERT_CMD} 305 306.p.o: 307 ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET} 308 ${CTFCONVERT_CMD} 309 310.e .r .F .f: 311 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 312 -o ${.TARGET} 313 314.e.o .r.o .F.o .f.o: 315 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET} 316 317.S.o: 318 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 319 ${CTFCONVERT_CMD} 320 321.asm.o: 322 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ 323 -o ${.TARGET} 324 ${CTFCONVERT_CMD} 325 326.s.o: 327 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 328 ${CTFCONVERT_CMD} 329 330# XXX not -j safe 331.y.o: 332 ${YACC} ${YFLAGS} ${.IMPSRC} 333 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 334 rm -f y.tab.c 335 ${CTFCONVERT_CMD} 336 337.l.o: 338 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 339 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 340 rm -f ${.PREFIX}.tmp.c 341 ${CTFCONVERT_CMD} 342 343# XXX not -j safe 344.y.c: 345 ${YACC} ${YFLAGS} ${.IMPSRC} 346 mv y.tab.c ${.TARGET} 347 348.l.c: 349 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 350 351.s.out .c.out .o.out: 352 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 353 ${CTFCONVERT_CMD} 354 355.f.out .F.out .r.out .e.out: 356 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 357 ${LDLIBS} -o ${.TARGET} 358 rm -f ${.PREFIX}.o 359 ${CTFCONVERT_CMD} 360 361# XXX not -j safe 362.y.out: 363 ${YACC} ${YFLAGS} ${.IMPSRC} 364 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 365 rm -f y.tab.c 366 ${CTFCONVERT_CMD} 367 368.l.out: 369 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 370 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 371 rm -f ${.PREFIX}.tmp.c 372 ${CTFCONVERT_CMD} 373 374# Pull in global settings. 375__MAKE_CONF?=/etc/make.conf 376.if exists(${__MAKE_CONF}) 377.include "${__MAKE_CONF}" 378.endif 379 380# late include for customization 381.sinclude <local.sys.mk> 382 383.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 384SHELL= ${__MAKE_SHELL} 385.SHELL: path=${__MAKE_SHELL} 386.endif 387 388# Tell bmake to expand -V VAR by default 389.MAKE.EXPAND_VARIABLES= yes 390 391# Tell bmake the makefile preference 392.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 393 394# By default bmake does *not* use set -e 395# when running target scripts, this is a problem for many makefiles here. 396# So define a shell that will do what FreeBSD expects. 397.ifndef WITHOUT_SHELL_ERRCTL 398__MAKE_SHELL?=/bin/sh 399.SHELL: name=sh \ 400 quiet="set -" echo="set -v" filter="set -" \ 401 hasErrCtl=yes check="set -e" ignore="set +e" \ 402 echoFlag=v errFlag=e \ 403 path=${__MAKE_SHELL} 404.endif 405 406.include <bsd.cpu.mk> 407 408.endif # ! Posix 409