1415bccaaSBruce Evans# from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 27f3dea24SPeter Wemm# $FreeBSD$ 3afe61c15SRodney W. Grimes 4415bccaaSBruce Evansunix ?= We run FreeBSD, not UNIX. 53f5a93f6SDavid E. O'Brien.FreeBSD ?= true 6afe61c15SRodney W. Grimes 76fc3ead1SWarner Losh.if !defined(%POSIX) 86fc3ead1SWarner Losh# 96fc3ead1SWarner Losh# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with 10bd4473b8SDimitry Andric# the same MACHINE_ARCH can run each other's binaries, so it necessarily 11bd4473b8SDimitry Andric# has word size and endian swizzled in. However, support files for 12bd4473b8SDimitry Andric# these machines often are shared amongst all combinations of size 13bd4473b8SDimitry Andric# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used 14bd4473b8SDimitry Andric# for something different in FreeBSD. 156fc3ead1SWarner Losh# 164da573d9SOleksandr TymoshenkoMACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/} 176fc3ead1SWarner Losh.endif 186fc3ead1SWarner Losh 190815243cSMarcel Moolenaar# Set any local definitions first. Place this early, but it needs 200815243cSMarcel Moolenaar# MACHINE_CPUARCH to be defined. 210815243cSMarcel Moolenaar.sinclude <local.sys.mk> 220815243cSMarcel Moolenaar 232be2be74SSteve Price# If the special target .POSIX appears (without prerequisites or 242be2be74SSteve Price# commands) before the first noncomment line in the makefile, make shall 252be2be74SSteve Price# process the makefile as specified by the Posix 1003.2 specification. 262be2be74SSteve Price# make(1) sets the special macro %POSIX in this case (to the actual 272be2be74SSteve Price# value "1003.2", for what it's worth). 282be2be74SSteve Price# 292be2be74SSteve Price# The rules below use this macro to distinguish between Posix-compliant 302be2be74SSteve Price# and default behaviour. 312be2be74SSteve Price 322be2be74SSteve Price.if defined(%POSIX) 332be2be74SSteve Price.SUFFIXES: .o .c .y .l .a .sh .f 342be2be74SSteve Price.else 35d58e932fSRuslan Ermilov.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh 362be2be74SSteve Price.endif 37afe61c15SRodney W. Grimes 38415bccaaSBruce EvansAR ?= ar 392be2be74SSteve Price.if defined(%POSIX) 402be2be74SSteve PriceARFLAGS ?= -rv 412be2be74SSteve Price.else 42bffa4488SEitan AdlerARFLAGS ?= cru 432be2be74SSteve Price.endif 44415bccaaSBruce EvansRANLIB ?= ranlib 45afe61c15SRodney W. Grimes 46415bccaaSBruce EvansAS ?= as 47415bccaaSBruce EvansAFLAGS ?= 485ada7d99SKonstantin BelousovACFLAGS ?= 49afe61c15SRodney W. Grimes 502be2be74SSteve Price.if defined(%POSIX) 512be2be74SSteve PriceCC ?= c89 52d17387acSBruce EvansCFLAGS ?= -O 532be2be74SSteve Price.else 54415bccaaSBruce EvansCC ?= cc 556fc3ead1SWarner Losh.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 5620c46652SDavid E. O'BrienCFLAGS ?= -O -pipe 57cdc162feSOlivier Houchard.else 5820c46652SDavid E. O'BrienCFLAGS ?= -O2 -pipe 59cfb5b325SJohn Birrell.endif 60cfb5b325SJohn Birrell.if defined(NO_STRICT_ALIASING) 61cfb5b325SJohn BirrellCFLAGS += -fno-strict-aliasing 62d17387acSBruce Evans.endif 63cdc162feSOlivier Houchard.endif 64424b4e66SStephane E. PotvinPO_CFLAGS ?= ${CFLAGS} 65afe61c15SRodney W. Grimes 66770ac3b2SJohn Birrell# C Type Format data is required for DTrace 67770ac3b2SJohn BirrellCTFFLAGS ?= -L VERSION 68770ac3b2SJohn Birrell 69770ac3b2SJohn BirrellCTFCONVERT ?= ctfconvert 70770ac3b2SJohn BirrellCTFMERGE ?= ctfmerge 719a1d1150SRui PauloDTRACE ?= dtrace 72770ac3b2SJohn Birrell.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 73770ac3b2SJohn BirrellCTFFLAGS += -g 74770ac3b2SJohn Birrell.else 7521edb039SAlexander Leidinger# XXX: What to do here? Is removing the CFLAGS part completely ok here? 7621edb039SAlexander Leidinger# For now comment it out to not compile with -g unconditionally. 7721edb039SAlexander Leidinger#CFLAGS += -g 78770ac3b2SJohn Birrell.endif 79770ac3b2SJohn Birrell 80443dced5SPaul RichardsCXX ?= c++ 8196f2d85eSMarcel MoolenaarCXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 82424b4e66SStephane E. PotvinPO_CXXFLAGS ?= ${CXXFLAGS} 83afe61c15SRodney W. Grimes 84415bccaaSBruce EvansCPP ?= cpp 85afe61c15SRodney W. Grimes 8665d2bdc6SRuslan Ermilov.if empty(.MAKEFLAGS:M-s) 87415bccaaSBruce EvansECHO ?= echo 88415bccaaSBruce EvansECHODIR ?= echo 89415bccaaSBruce Evans.else 90415bccaaSBruce EvansECHO ?= true 91415bccaaSBruce Evans.if ${.MAKEFLAGS:M-s} == "-s" 92415bccaaSBruce EvansECHODIR ?= echo 93415bccaaSBruce Evans.else 94415bccaaSBruce EvansECHODIR ?= true 95415bccaaSBruce Evans.endif 96415bccaaSBruce Evans.endif 97afe61c15SRodney W. Grimes 98acabf29aSHartmut Brandt.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 99acabf29aSHartmut Brandt_+_ ?= 100acabf29aSHartmut Brandt.else 101acabf29aSHartmut Brandt_+_ ?= + 102acabf29aSHartmut Brandt.endif 103acabf29aSHartmut Brandt 1042be2be74SSteve Price.if defined(%POSIX) 1052be2be74SSteve PriceFC ?= fort77 1062be2be74SSteve PriceFFLAGS ?= -O 1 1072be2be74SSteve Price.else 108415bccaaSBruce EvansFC ?= f77 109415bccaaSBruce EvansFFLAGS ?= -O 1102be2be74SSteve Price.endif 111415bccaaSBruce EvansEFLAGS ?= 112afe61c15SRodney W. Grimes 113c7499507SAndrey A. ChernovINSTALL ?= install 114c7499507SAndrey A. Chernov 115415bccaaSBruce EvansLEX ?= lex 116415bccaaSBruce EvansLFLAGS ?= 117afe61c15SRodney W. Grimes 118415bccaaSBruce EvansLD ?= ld 119415bccaaSBruce EvansLDFLAGS ?= 120afe61c15SRodney W. Grimes 121415bccaaSBruce EvansLINT ?= lint 122bd42830fSRuslan ErmilovLINTFLAGS ?= -cghapbx 123766f7d6eSMark MurrayLINTKERNFLAGS ?= ${LINTFLAGS} 124766f7d6eSMark MurrayLINTOBJFLAGS ?= -cghapbxu -i 12534d81580SMark MurrayLINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 126766f7d6eSMark MurrayLINTLIBFLAGS ?= -cghapbxu -C ${LIB} 127afe61c15SRodney W. Grimes 128415bccaaSBruce EvansMAKE ?= make 129afe61c15SRodney W. Grimes 1306f1d6967SWarner Losh.if !defined(%POSIX) 1316f1d6967SWarner LoshNM ?= nm 1326f1d6967SWarner Losh.endif 1336f1d6967SWarner Losh 13470a6e331SBruce EvansOBJC ?= cc 13570a6e331SBruce EvansOBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 13670a6e331SBruce Evans 137*e97696b5SEd MasteOBJCOPY ?= objcopy 138*e97696b5SEd Maste 139415bccaaSBruce EvansPC ?= pc 140415bccaaSBruce EvansPFLAGS ?= 141afe61c15SRodney W. Grimes 142415bccaaSBruce EvansRC ?= f77 143415bccaaSBruce EvansRFLAGS ?= 144415bccaaSBruce Evans 145415bccaaSBruce EvansSHELL ?= sh 146415bccaaSBruce Evans 147415bccaaSBruce EvansYACC ?= yacc 1482be2be74SSteve Price.if defined(%POSIX) 1492be2be74SSteve PriceYFLAGS ?= 1502be2be74SSteve Price.else 151415bccaaSBruce EvansYFLAGS ?= -d 1522be2be74SSteve Price.endif 1532be2be74SSteve Price 1542be2be74SSteve Price.if defined(%POSIX) 1558d962594SBruce Evans 1562be2be74SSteve Price# Posix 1003.2 mandated rules 1572be2be74SSteve Price# 1582be2be74SSteve Price# Quoted directly from the Posix 1003.2 draft, only the macros 1592be2be74SSteve Price# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 1602be2be74SSteve Price# ${.PREFIX}, resp. 1612be2be74SSteve Price 1622be2be74SSteve Price# SINGLE SUFFIX RULES 1632be2be74SSteve Price.c: 16432b97f0bSAlexander Langer ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 16578e7e3ecSMax Khon ${CTFCONVERT_CMD} 1662be2be74SSteve Price 1672be2be74SSteve Price.f: 16832b97f0bSAlexander Langer ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 16978e7e3ecSMax Khon ${CTFCONVERT_CMD} 1702be2be74SSteve Price 1712be2be74SSteve Price.sh: 1724be3feb2SWill Andrews cp -f ${.IMPSRC} ${.TARGET} 1732be2be74SSteve Price chmod a+x ${.TARGET} 1742be2be74SSteve Price 1752be2be74SSteve Price# DOUBLE SUFFIX RULES 1762be2be74SSteve Price 1772be2be74SSteve Price.c.o: 17832b97f0bSAlexander Langer ${CC} ${CFLAGS} -c ${.IMPSRC} 17978e7e3ecSMax Khon ${CTFCONVERT_CMD} 1802be2be74SSteve Price 1812be2be74SSteve Price.f.o: 18232b97f0bSAlexander Langer ${FC} ${FFLAGS} -c ${.IMPSRC} 18378e7e3ecSMax Khon ${CTFCONVERT_CMD} 1842be2be74SSteve Price 1852be2be74SSteve Price.y.o: 18632b97f0bSAlexander Langer ${YACC} ${YFLAGS} ${.IMPSRC} 18732b97f0bSAlexander Langer ${CC} ${CFLAGS} -c y.tab.c 188fc936cbdSDavid E. O'Brien rm -f y.tab.c 1892be2be74SSteve Price mv y.tab.o ${.TARGET} 19078e7e3ecSMax Khon ${CTFCONVERT_CMD} 1912be2be74SSteve Price 1922be2be74SSteve Price.l.o: 19332b97f0bSAlexander Langer ${LEX} ${LFLAGS} ${.IMPSRC} 19432b97f0bSAlexander Langer ${CC} ${CFLAGS} -c lex.yy.c 195fc936cbdSDavid E. O'Brien rm -f lex.yy.c 1962be2be74SSteve Price mv lex.yy.o ${.TARGET} 19778e7e3ecSMax Khon ${CTFCONVERT_CMD} 1982be2be74SSteve Price 1992be2be74SSteve Price.y.c: 20032b97f0bSAlexander Langer ${YACC} ${YFLAGS} ${.IMPSRC} 2012be2be74SSteve Price mv y.tab.c ${.TARGET} 2022be2be74SSteve Price 2032be2be74SSteve Price.l.c: 20432b97f0bSAlexander Langer ${LEX} ${LFLAGS} ${.IMPSRC} 2052be2be74SSteve Price mv lex.yy.c ${.TARGET} 2062be2be74SSteve Price 2072be2be74SSteve Price.c.a: 20832b97f0bSAlexander Langer ${CC} ${CFLAGS} -c ${.IMPSRC} 20932b97f0bSAlexander Langer ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 210fc936cbdSDavid E. O'Brien rm -f ${.PREFIX}.o 2112be2be74SSteve Price 2122be2be74SSteve Price.f.a: 21332b97f0bSAlexander Langer ${FC} ${FFLAGS} -c ${.IMPSRC} 21432b97f0bSAlexander Langer ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 215fc936cbdSDavid E. O'Brien rm -f ${.PREFIX}.o 2162be2be74SSteve Price 2172be2be74SSteve Price.else 2182be2be74SSteve Price 2192be2be74SSteve Price# non-Posix rule set 220415bccaaSBruce Evans 221a9076ea0SBruce Evans.sh: 2224be3feb2SWill Andrews cp -fp ${.IMPSRC} ${.TARGET} 223a9076ea0SBruce Evans chmod a+x ${.TARGET} 224afe61c15SRodney W. Grimes 2255741a42fSMark Murray.c.ln: 2265741a42fSMark Murray ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 2275741a42fSMark Murray touch ${.TARGET} 2285741a42fSMark Murray 2295741a42fSMark Murray.cc.ln .C.ln .cpp.ln .cxx.ln: 2305741a42fSMark Murray ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 2315741a42fSMark Murray touch ${.TARGET} 2325741a42fSMark Murray 233eb73cacdSDavid E. O'Brien.c: 234eb73cacdSDavid E. O'Brien ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 23578e7e3ecSMax Khon ${CTFCONVERT_CMD} 236eb73cacdSDavid E. O'Brien 237afe61c15SRodney W. Grimes.c.o: 238afe61c15SRodney W. Grimes ${CC} ${CFLAGS} -c ${.IMPSRC} 23978e7e3ecSMax Khon ${CTFCONVERT_CMD} 240afe61c15SRodney W. Grimes 241eb73cacdSDavid E. O'Brien.cc .cpp .cxx .C: 242eb73cacdSDavid E. O'Brien ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 243eb73cacdSDavid E. O'Brien 244c7cbe79eSDmitrij Tejblum.cc.o .cpp.o .cxx.o .C.o: 2453585b293SGarrett Wollman ${CXX} ${CXXFLAGS} -c ${.IMPSRC} 2463585b293SGarrett Wollman 24770a6e331SBruce Evans.m.o: 24870a6e331SBruce Evans ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} 24978e7e3ecSMax Khon ${CTFCONVERT_CMD} 25070a6e331SBruce Evans 251afe61c15SRodney W. Grimes.p.o: 252afe61c15SRodney W. Grimes ${PC} ${PFLAGS} -c ${.IMPSRC} 25378e7e3ecSMax Khon ${CTFCONVERT_CMD} 254afe61c15SRodney W. Grimes 2557b91cad9SDavid E. O'Brien.e .r .F .f: 2567b91cad9SDavid E. O'Brien ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 2577b91cad9SDavid E. O'Brien -o ${.TARGET} 2587b91cad9SDavid E. O'Brien 259afe61c15SRodney W. Grimes.e.o .r.o .F.o .f.o: 260afe61c15SRodney W. Grimes ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} 261afe61c15SRodney W. Grimes 262ea569569SRodney W. Grimes.S.o: 2635ada7d99SKonstantin Belousov ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 26478e7e3ecSMax Khon ${CTFCONVERT_CMD} 265ea569569SRodney W. Grimes 266d58e932fSRuslan Ermilov.asm.o: 2675ada7d99SKonstantin Belousov ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 26878e7e3ecSMax Khon ${CTFCONVERT_CMD} 269d58e932fSRuslan Ermilov 270d58e932fSRuslan Ermilov.s.o: 271e517d11eSDavid E. O'Brien ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 27278e7e3ecSMax Khon ${CTFCONVERT_CMD} 273e517d11eSDavid E. O'Brien 274006f5fe0SPoul-Henning Kamp# XXX not -j safe 275afe61c15SRodney W. Grimes.y.o: 276006f5fe0SPoul-Henning Kamp ${YACC} ${YFLAGS} ${.IMPSRC} 277006f5fe0SPoul-Henning Kamp ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 278fc936cbdSDavid E. O'Brien rm -f y.tab.c 27978e7e3ecSMax Khon ${CTFCONVERT_CMD} 280afe61c15SRodney W. Grimes 281afe61c15SRodney W. Grimes.l.o: 28250ef9020SPoul-Henning Kamp ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 28350ef9020SPoul-Henning Kamp ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 284fc936cbdSDavid E. O'Brien rm -f ${.PREFIX}.tmp.c 28578e7e3ecSMax Khon ${CTFCONVERT_CMD} 286afe61c15SRodney W. Grimes 287c3e3432cSSteve Price# XXX not -j safe 288afe61c15SRodney W. Grimes.y.c: 289c3e3432cSSteve Price ${YACC} ${YFLAGS} ${.IMPSRC} 290c3e3432cSSteve Price mv y.tab.c ${.TARGET} 291afe61c15SRodney W. Grimes 292afe61c15SRodney W. Grimes.l.c: 29350ef9020SPoul-Henning Kamp ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 294afe61c15SRodney W. Grimes 295afe61c15SRodney W. Grimes.s.out .c.out .o.out: 296a9076ea0SBruce Evans ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 29778e7e3ecSMax Khon ${CTFCONVERT_CMD} 298afe61c15SRodney W. Grimes 299afe61c15SRodney W. Grimes.f.out .F.out .r.out .e.out: 300a9076ea0SBruce Evans ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 301afe61c15SRodney W. Grimes ${LDLIBS} -o ${.TARGET} 302fc936cbdSDavid E. O'Brien rm -f ${.PREFIX}.o 30378e7e3ecSMax Khon ${CTFCONVERT_CMD} 304afe61c15SRodney W. Grimes 305006f5fe0SPoul-Henning Kamp# XXX not -j safe 306afe61c15SRodney W. Grimes.y.out: 307006f5fe0SPoul-Henning Kamp ${YACC} ${YFLAGS} ${.IMPSRC} 308006f5fe0SPoul-Henning Kamp ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 309fc936cbdSDavid E. O'Brien rm -f y.tab.c 31078e7e3ecSMax Khon ${CTFCONVERT_CMD} 311afe61c15SRodney W. Grimes 312afe61c15SRodney W. Grimes.l.out: 31350ef9020SPoul-Henning Kamp ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 31450ef9020SPoul-Henning Kamp ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 315fc936cbdSDavid E. O'Brien rm -f ${.PREFIX}.tmp.c 31678e7e3ecSMax Khon ${CTFCONVERT_CMD} 3173585b293SGarrett Wollman 3188d962594SBruce Evans# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. 3190af93efbSWarner Losh__MAKE_CONF?=/etc/make.conf 3200af93efbSWarner Losh.if exists(${__MAKE_CONF}) 3210af93efbSWarner Losh.include "${__MAKE_CONF}" 3223585b293SGarrett Wollman.endif 323a09e15f3SJohn Birrell 324a39cea66SYaroslav Tykhiy.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 325a39cea66SYaroslav TykhiySHELL= ${__MAKE_SHELL} 326a39cea66SYaroslav Tykhiy.SHELL: path=${__MAKE_SHELL} 327a39cea66SYaroslav Tykhiy.endif 328a39cea66SYaroslav Tykhiy 3292bdaf7e8SRuslan Ermilov# Default executable format 33066422f5bSPeter Wemm# XXX hint for bsd.port.mk 3312bdaf7e8SRuslan ErmilovOBJFORMAT?= elf 3328d962594SBruce Evans 3330815243cSMarcel Moolenaar# Tell bmake to expand -V VAR by default 3340815243cSMarcel Moolenaar.MAKE.EXPAND_VARIABLES= yes 3350815243cSMarcel Moolenaar 3360815243cSMarcel Moolenaar.if !defined(.PARSEDIR) 3370815243cSMarcel Moolenaar# We are not bmake, which is more aggressive about searching .PATH 3380815243cSMarcel Moolenaar# It is sometime necessary to curb its enthusiasm with .NOPATH 3390815243cSMarcel Moolenaar# The following allows us to quietly ignore .NOPATH when not using bmake. 3400815243cSMarcel Moolenaar.NOTMAIN: .NOPATH 3410815243cSMarcel Moolenaar.NOPATH: 3420815243cSMarcel Moolenaar 343dea3d870SHartmut Brandt# Toggle on warnings 344dea3d870SHartmut Brandt.WARN: dirsyntax 3450815243cSMarcel Moolenaar.endif 346dea3d870SHartmut Brandt 3478d962594SBruce Evans.endif 3488d962594SBruce Evans 34952dbe95fSRuslan Ermilov.include <bsd.compat.mk> 3508d962594SBruce Evans.include <bsd.cpu.mk> 351