12340Sbde# from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 250476Speter# $FreeBSD$ 31638Srgrimes 42340Sbdeunix ?= We run FreeBSD, not UNIX. 578347Sobrien.FreeBSD ?= true 61638Srgrimes 7209024Simp.if !defined(%POSIX) 8209024Simp# 9209024Simp# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with 10215149Sdim# the same MACHINE_ARCH can run each other's binaries, so it necessarily 11215149Sdim# has word size and endian swizzled in. However, support files for 12215149Sdim# these machines often are shared amongst all combinations of size 13215149Sdim# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used 14215149Sdim# for something different in FreeBSD. 15209024Simp# 16239272SgonzoMACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/} 17209024Simp.endif 18209024Simp 19241298Smarcel# Set any local definitions first. Place this early, but it needs 20241298Smarcel# MACHINE_CPUARCH to be defined. 21241298Smarcel.sinclude <local.sys.mk> 22241298Smarcel 2319343Ssteve# If the special target .POSIX appears (without prerequisites or 2419343Ssteve# commands) before the first noncomment line in the makefile, make shall 2519343Ssteve# process the makefile as specified by the Posix 1003.2 specification. 2619343Ssteve# make(1) sets the special macro %POSIX in this case (to the actual 2719343Ssteve# value "1003.2", for what it's worth). 2819343Ssteve# 2919343Ssteve# The rules below use this macro to distinguish between Posix-compliant 3019343Ssteve# and default behaviour. 3119343Ssteve 3219343Ssteve.if defined(%POSIX) 3319343Ssteve.SUFFIXES: .o .c .y .l .a .sh .f 3419343Ssteve.else 35117173Sru.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh 3619343Ssteve.endif 371638Srgrimes 382340SbdeAR ?= ar 3919343Ssteve.if defined(%POSIX) 4019343SsteveARFLAGS ?= -rv 4119343Ssteve.else 42270484SdesARFLAGS ?= -crD 4319343Ssteve.endif 442340SbdeRANLIB ?= ranlib 45270484Sdes.if !defined(%POSIX) 46270484SdesRANLIBFLAGS ?= -D 47270484Sdes.endif 481638Srgrimes 492340SbdeAS ?= as 502340SbdeAFLAGS ?= 51217100SkibACFLAGS ?= 521638Srgrimes 5319343Ssteve.if defined(%POSIX) 5419343SsteveCC ?= c89 55125445SbdeCFLAGS ?= -O 5619343Ssteve.else 572340SbdeCC ?= cc 58209024Simp.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 59177865SobrienCFLAGS ?= -O -pipe 60173375Scognet.else 61177865SobrienCFLAGS ?= -O2 -pipe 6219343Ssteve.endif 63173850Sjb.if defined(NO_STRICT_ALIASING) 64173850SjbCFLAGS += -fno-strict-aliasing 65173375Scognet.endif 66173850Sjb.endif 67202807SsepotvinPO_CFLAGS ?= ${CFLAGS} 681638Srgrimes 69179184Sjb# C Type Format data is required for DTrace 70179184SjbCTFFLAGS ?= -L VERSION 71179184Sjb 72179184SjbCTFCONVERT ?= ctfconvert 73179184SjbCTFMERGE ?= ctfmerge 74212422SrpauloDTRACE ?= dtrace 75179184Sjb.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 76179184SjbCTFFLAGS += -g 77179184Sjb.else 78206082Snetchild# XXX: What to do here? Is removing the CFLAGS part completely ok here? 79206082Snetchild# For now comment it out to not compile with -g unconditionally. 80206082Snetchild#CFLAGS += -g 81179184Sjb.endif 82179184Sjb 832419SpaulCXX ?= c++ 84204024SmarcelCXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 85202807SsepotvinPO_CXXFLAGS ?= ${CXXFLAGS} 861638Srgrimes 872340SbdeCPP ?= cpp 881638Srgrimes 89125119Sru.if empty(.MAKEFLAGS:M-s) 902340SbdeECHO ?= echo 912340SbdeECHODIR ?= echo 922340Sbde.else 932340SbdeECHO ?= true 942340Sbde.if ${.MAKEFLAGS:M-s} == "-s" 952340SbdeECHODIR ?= echo 962340Sbde.else 972340SbdeECHODIR ?= true 982340Sbde.endif 992340Sbde.endif 1001638Srgrimes 101251748Ssjg.if defined(.PARSEDIR) 102251748Ssjg# _+_ appears to be a workaround for the special src .MAKE not working. 103251748Ssjg# setting it to + interferes with -N 104133369Sharti_+_ ?= 105251748Ssjg.elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 106251748Ssjg# the check above matches only a single -n, so -n -n will result 107251748Ssjg# in _+_ = + 108251748Ssjg_+_ ?= 109133369Sharti.else 110133369Sharti_+_ ?= + 111133369Sharti.endif 112133369Sharti 11319343Ssteve.if defined(%POSIX) 11419343SsteveFC ?= fort77 11519343SsteveFFLAGS ?= -O 1 11619343Ssteve.else 1172340SbdeFC ?= f77 1182340SbdeFFLAGS ?= -O 11919343Ssteve.endif 1202340SbdeEFLAGS ?= 1211638Srgrimes 1225257SacheINSTALL ?= install 1235257Sache 1242340SbdeLEX ?= lex 1252340SbdeLFLAGS ?= 1261638Srgrimes 1272340SbdeLD ?= ld 1282340SbdeLDFLAGS ?= 1291638Srgrimes 1302340SbdeLINT ?= lint 13192813SruLINTFLAGS ?= -cghapbx 13292491SmarkmLINTKERNFLAGS ?= ${LINTFLAGS} 13392491SmarkmLINTOBJFLAGS ?= -cghapbxu -i 134120485SmarkmLINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 13592491SmarkmLINTLIBFLAGS ?= -cghapbxu -C ${LIB} 1361638Srgrimes 1372340SbdeMAKE ?= make 1381638Srgrimes 139234575Simp.if !defined(%POSIX) 140234575SimpNM ?= nm 141234575Simp 14236054SbdeOBJC ?= cc 14336054SbdeOBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 14436054Sbde 145244236SemasteOBJCOPY ?= objcopy 146244236Semaste 1472340SbdePC ?= pc 1482340SbdePFLAGS ?= 1491638Srgrimes 1502340SbdeRC ?= f77 1512340SbdeRFLAGS ?= 152244366Semaste.endif 1531638Srgrimes 1542340SbdeSHELL ?= sh 1552340Sbde 1562340SbdeYACC ?= yacc 15719343Ssteve.if defined(%POSIX) 15819343SsteveYFLAGS ?= 15919343Ssteve.else 1602340SbdeYFLAGS ?= -d 16119343Ssteve.endif 1622340Sbde 16319343Ssteve.if defined(%POSIX) 164129163Sbde 16519343Ssteve# Posix 1003.2 mandated rules 16619343Ssteve# 16719343Ssteve# Quoted directly from the Posix 1003.2 draft, only the macros 16819343Ssteve# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 16919343Ssteve# ${.PREFIX}, resp. 17019343Ssteve 17119343Ssteve# SINGLE SUFFIX RULES 17211613Sbde.c: 17319481Salex ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 174228137Sfjoe ${CTFCONVERT_CMD} 17519343Ssteve 17619343Ssteve.f: 17719481Salex ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 178228137Sfjoe ${CTFCONVERT_CMD} 17919343Ssteve 18019343Ssteve.sh: 181211243Swill cp -f ${.IMPSRC} ${.TARGET} 18219343Ssteve chmod a+x ${.TARGET} 18319343Ssteve 18419343Ssteve# DOUBLE SUFFIX RULES 18519343Ssteve 18619343Ssteve.c.o: 18719481Salex ${CC} ${CFLAGS} -c ${.IMPSRC} 188228137Sfjoe ${CTFCONVERT_CMD} 18919343Ssteve 19019343Ssteve.f.o: 19119481Salex ${FC} ${FFLAGS} -c ${.IMPSRC} 192228137Sfjoe ${CTFCONVERT_CMD} 19319343Ssteve 19419343Ssteve.y.o: 19519481Salex ${YACC} ${YFLAGS} ${.IMPSRC} 19619481Salex ${CC} ${CFLAGS} -c y.tab.c 19739208Sobrien rm -f y.tab.c 19819343Ssteve mv y.tab.o ${.TARGET} 199228137Sfjoe ${CTFCONVERT_CMD} 20019343Ssteve 20119343Ssteve.l.o: 20219481Salex ${LEX} ${LFLAGS} ${.IMPSRC} 20319481Salex ${CC} ${CFLAGS} -c lex.yy.c 20439208Sobrien rm -f lex.yy.c 20519343Ssteve mv lex.yy.o ${.TARGET} 206228137Sfjoe ${CTFCONVERT_CMD} 20719343Ssteve 20819343Ssteve.y.c: 20919481Salex ${YACC} ${YFLAGS} ${.IMPSRC} 21019343Ssteve mv y.tab.c ${.TARGET} 21119343Ssteve 21219343Ssteve.l.c: 21319481Salex ${LEX} ${LFLAGS} ${.IMPSRC} 21419343Ssteve mv lex.yy.c ${.TARGET} 21519343Ssteve 21619343Ssteve.c.a: 21719481Salex ${CC} ${CFLAGS} -c ${.IMPSRC} 21819481Salex ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 21939208Sobrien rm -f ${.PREFIX}.o 22019343Ssteve 22119343Ssteve.f.a: 22219481Salex ${FC} ${FFLAGS} -c ${.IMPSRC} 22319481Salex ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 22439208Sobrien rm -f ${.PREFIX}.o 22519343Ssteve 22619343Ssteve.else 22719343Ssteve 22819343Ssteve# non-Posix rule set 22919343Ssteve 23011613Sbde.sh: 231211243Swill cp -fp ${.IMPSRC} ${.TARGET} 23211613Sbde chmod a+x ${.TARGET} 23311613Sbde 234103713Smarkm.c.ln: 235103713Smarkm ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 236103713Smarkm touch ${.TARGET} 237103713Smarkm 238103713Smarkm.cc.ln .C.ln .cpp.ln .cxx.ln: 239103713Smarkm ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 240103713Smarkm touch ${.TARGET} 241103713Smarkm 24277817Sobrien.c: 24377817Sobrien ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 244228137Sfjoe ${CTFCONVERT_CMD} 24577817Sobrien 2461638Srgrimes.c.o: 2471638Srgrimes ${CC} ${CFLAGS} -c ${.IMPSRC} 248228137Sfjoe ${CTFCONVERT_CMD} 2491638Srgrimes 25077817Sobrien.cc .cpp .cxx .C: 25177817Sobrien ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 25277817Sobrien 25336673Sdt.cc.o .cpp.o .cxx.o .C.o: 2541844Swollman ${CXX} ${CXXFLAGS} -c ${.IMPSRC} 2551844Swollman 25636054Sbde.m.o: 25736054Sbde ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} 258228137Sfjoe ${CTFCONVERT_CMD} 25936054Sbde 2601638Srgrimes.p.o: 2611638Srgrimes ${PC} ${PFLAGS} -c ${.IMPSRC} 262228137Sfjoe ${CTFCONVERT_CMD} 2631638Srgrimes 26477818Sobrien.e .r .F .f: 26577818Sobrien ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 26677818Sobrien -o ${.TARGET} 26777818Sobrien 2681638Srgrimes.e.o .r.o .F.o .f.o: 2691638Srgrimes ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} 2701638Srgrimes 2713292Srgrimes.S.o: 272217100Skib ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 273228137Sfjoe ${CTFCONVERT_CMD} 2743292Srgrimes 275117173Sru.asm.o: 276217100Skib ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 277228137Sfjoe ${CTFCONVERT_CMD} 278117173Sru 279117173Sru.s.o: 2801638Srgrimes ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 281228137Sfjoe ${CTFCONVERT_CMD} 2821638Srgrimes 28316068Sphk# XXX not -j safe 2841638Srgrimes.y.o: 28516068Sphk ${YACC} ${YFLAGS} ${.IMPSRC} 28616068Sphk ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 28739208Sobrien rm -f y.tab.c 288228137Sfjoe ${CTFCONVERT_CMD} 2891638Srgrimes 2901638Srgrimes.l.o: 29115959Sphk ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 29215959Sphk ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 29339208Sobrien rm -f ${.PREFIX}.tmp.c 294228137Sfjoe ${CTFCONVERT_CMD} 2951638Srgrimes 29621582Ssteve# XXX not -j safe 2971638Srgrimes.y.c: 29821582Ssteve ${YACC} ${YFLAGS} ${.IMPSRC} 29921582Ssteve mv y.tab.c ${.TARGET} 3001638Srgrimes 3011638Srgrimes.l.c: 30215959Sphk ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 3031638Srgrimes 3041638Srgrimes.s.out .c.out .o.out: 30511613Sbde ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 306228137Sfjoe ${CTFCONVERT_CMD} 3071638Srgrimes 3081638Srgrimes.f.out .F.out .r.out .e.out: 30911613Sbde ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 3101638Srgrimes ${LDLIBS} -o ${.TARGET} 31139208Sobrien rm -f ${.PREFIX}.o 312228137Sfjoe ${CTFCONVERT_CMD} 3131638Srgrimes 31416068Sphk# XXX not -j safe 3151638Srgrimes.y.out: 31616068Sphk ${YACC} ${YFLAGS} ${.IMPSRC} 31716068Sphk ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 31839208Sobrien rm -f y.tab.c 319228137Sfjoe ${CTFCONVERT_CMD} 3201638Srgrimes 3211638Srgrimes.l.out: 32215959Sphk ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 32315959Sphk ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 32439208Sobrien rm -f ${.PREFIX}.tmp.c 325228137Sfjoe ${CTFCONVERT_CMD} 3261844Swollman 327129163Sbde# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. 32892546Simp__MAKE_CONF?=/etc/make.conf 32992546Simp.if exists(${__MAKE_CONF}) 33092546Simp.include "${__MAKE_CONF}" 3311844Swollman.endif 33236609Sjb 333173075Syar.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 334173075SyarSHELL= ${__MAKE_SHELL} 335173075Syar.SHELL: path=${__MAKE_SHELL} 336173075Syar.endif 337173075Syar 338241298Smarcel.if !defined(.PARSEDIR) 339241298Smarcel# We are not bmake, which is more aggressive about searching .PATH 340241298Smarcel# It is sometime necessary to curb its enthusiasm with .NOPATH 341241298Smarcel# The following allows us to quietly ignore .NOPATH when not using bmake. 342241298Smarcel.NOTMAIN: .NOPATH 343241298Smarcel.NOPATH: 344241298Smarcel 345145681Sharti# Toggle on warnings 346145681Sharti.WARN: dirsyntax 347241298Smarcel.endif 348145681Sharti 349129163Sbde.endif 350129163Sbde 351254980Ssjg.if defined(.PARSEDIR) 352254980Ssjg# Tell bmake to expand -V VAR by default 353254980Ssjg.MAKE.EXPAND_VARIABLES= yes 354254980Ssjg 355254980Ssjg# Tell bmake the makefile preference 356254980Ssjg.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 357254980Ssjg 358254980Ssjg# By default bmake does *not* use set -e 359254980Ssjg# when running target scripts, this is a problem for many makefiles here. 360254980Ssjg# So define a shell that will do what FreeBSD expects. 361254980Ssjg.ifndef WITHOUT_SHELL_ERRCTL 362254980Ssjg.SHELL: name=sh \ 363254980Ssjg quiet="set -" echo="set -v" filter="set -" \ 364254980Ssjg hasErrCtl=yes check="set -e" ignore="set +e" \ 365254980Ssjg echoFlag=v errFlag=e \ 366254980Ssjg path=${__MAKE_SHELL:U/bin/sh} 367254980Ssjg.endif 368254980Ssjg 369254980Ssjg.endif 370254980Ssjg 371129163Sbde.include <bsd.cpu.mk> 372