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.*e[lb]/mips/:C/armeb/arm/:C/powerpc64/powerpc/} 17.endif 18 19# Set any local definitions first. Place this early, but it needs 20# MACHINE_CPUARCH to be defined. 21.sinclude <local.sys.mk> 22 23# If the special target .POSIX appears (without prerequisites or 24# commands) before the first noncomment line in the makefile, make shall 25# process the makefile as specified by the Posix 1003.2 specification. 26# make(1) sets the special macro %POSIX in this case (to the actual 27# value "1003.2", for what it's worth). 28# 29# The rules below use this macro to distinguish between Posix-compliant 30# and default behaviour. 31 32.if defined(%POSIX) 33.SUFFIXES: .o .c .y .l .a .sh .f 34.else 35.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh 36.endif 37 38AR ?= ar 39.if defined(%POSIX) 40ARFLAGS ?= -rv 41.else 42ARFLAGS ?= rl 43.endif 44RANLIB ?= ranlib 45 46AS ?= as 47AFLAGS ?= 48ACFLAGS ?= 49 50.if defined(%POSIX) 51CC ?= c89 52CFLAGS ?= -O 53.else 54CC ?= cc 55.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 56CFLAGS ?= -O -pipe 57.else 58CFLAGS ?= -O2 -pipe 59.endif 60.if defined(NO_STRICT_ALIASING) 61CFLAGS += -fno-strict-aliasing 62.endif 63.endif 64PO_CFLAGS ?= ${CFLAGS} 65 66# C Type Format data is required for DTrace 67CTFFLAGS ?= -L VERSION 68 69CTFCONVERT ?= ctfconvert 70CTFMERGE ?= ctfmerge 71DTRACE ?= dtrace 72.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 73CTFFLAGS += -g 74.else 75# XXX: What to do here? Is removing the CFLAGS part completely ok here? 76# For now comment it out to not compile with -g unconditionally. 77#CFLAGS += -g 78.endif 79 80CXX ?= c++ 81CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 82PO_CXXFLAGS ?= ${CXXFLAGS} 83 84CPP ?= cpp 85 86.if empty(.MAKEFLAGS:M-s) 87ECHO ?= echo 88ECHODIR ?= echo 89.else 90ECHO ?= true 91.if ${.MAKEFLAGS:M-s} == "-s" 92ECHODIR ?= echo 93.else 94ECHODIR ?= true 95.endif 96.endif 97 98.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 99_+_ ?= 100.else 101_+_ ?= + 102.endif 103 104.if defined(%POSIX) 105FC ?= fort77 106FFLAGS ?= -O 1 107.else 108FC ?= f77 109FFLAGS ?= -O 110.endif 111EFLAGS ?= 112 113INSTALL ?= install 114 115LEX ?= lex 116LFLAGS ?= 117 118LD ?= ld 119LDFLAGS ?= 120 121LINT ?= lint 122LINTFLAGS ?= -cghapbx 123LINTKERNFLAGS ?= ${LINTFLAGS} 124LINTOBJFLAGS ?= -cghapbxu -i 125LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 126LINTLIBFLAGS ?= -cghapbxu -C ${LIB} 127 128MAKE ?= make 129 130OBJC ?= cc 131OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 132 133OBJCOPY ?= objcopy 134 135PC ?= pc 136PFLAGS ?= 137 138RC ?= f77 139RFLAGS ?= 140 141SHELL ?= sh 142 143YACC ?= yacc 144.if defined(%POSIX) 145YFLAGS ?= 146.else 147YFLAGS ?= -d 148.endif 149 150.if defined(%POSIX) 151 152# Posix 1003.2 mandated rules 153# 154# Quoted directly from the Posix 1003.2 draft, only the macros 155# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 156# ${.PREFIX}, resp. 157 158# SINGLE SUFFIX RULES 159.c: 160 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 161 ${CTFCONVERT_CMD} 162 163.f: 164 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 165 ${CTFCONVERT_CMD} 166 167.sh: 168 cp -f ${.IMPSRC} ${.TARGET} 169 chmod a+x ${.TARGET} 170 171# DOUBLE SUFFIX RULES 172 173.c.o: 174 ${CC} ${CFLAGS} -c ${.IMPSRC} 175 ${CTFCONVERT_CMD} 176 177.f.o: 178 ${FC} ${FFLAGS} -c ${.IMPSRC} 179 ${CTFCONVERT_CMD} 180 181.y.o: 182 ${YACC} ${YFLAGS} ${.IMPSRC} 183 ${CC} ${CFLAGS} -c y.tab.c 184 rm -f y.tab.c 185 mv y.tab.o ${.TARGET} 186 ${CTFCONVERT_CMD} 187 188.l.o: 189 ${LEX} ${LFLAGS} ${.IMPSRC} 190 ${CC} ${CFLAGS} -c lex.yy.c 191 rm -f lex.yy.c 192 mv lex.yy.o ${.TARGET} 193 ${CTFCONVERT_CMD} 194 195.y.c: 196 ${YACC} ${YFLAGS} ${.IMPSRC} 197 mv y.tab.c ${.TARGET} 198 199.l.c: 200 ${LEX} ${LFLAGS} ${.IMPSRC} 201 mv lex.yy.c ${.TARGET} 202 203.c.a: 204 ${CC} ${CFLAGS} -c ${.IMPSRC} 205 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 206 rm -f ${.PREFIX}.o 207 208.f.a: 209 ${FC} ${FFLAGS} -c ${.IMPSRC} 210 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 211 rm -f ${.PREFIX}.o 212 213.else 214 215# non-Posix rule set 216 217.sh: 218 cp -fp ${.IMPSRC} ${.TARGET} 219 chmod a+x ${.TARGET} 220 221.c.ln: 222 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 223 touch ${.TARGET} 224 225.cc.ln .C.ln .cpp.ln .cxx.ln: 226 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 227 touch ${.TARGET} 228 229.c: 230 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 231 ${CTFCONVERT_CMD} 232 233.c.o: 234 ${CC} ${CFLAGS} -c ${.IMPSRC} 235 ${CTFCONVERT_CMD} 236 237.cc .cpp .cxx .C: 238 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 239 240.cc.o .cpp.o .cxx.o .C.o: 241 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} 242 243.m.o: 244 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} 245 ${CTFCONVERT_CMD} 246 247.p.o: 248 ${PC} ${PFLAGS} -c ${.IMPSRC} 249 ${CTFCONVERT_CMD} 250 251.e .r .F .f: 252 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 253 -o ${.TARGET} 254 255.e.o .r.o .F.o .f.o: 256 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} 257 258.S.o: 259 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 260 ${CTFCONVERT_CMD} 261 262.asm.o: 263 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 264 ${CTFCONVERT_CMD} 265 266.s.o: 267 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 268 ${CTFCONVERT_CMD} 269 270# XXX not -j safe 271.y.o: 272 ${YACC} ${YFLAGS} ${.IMPSRC} 273 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 274 rm -f y.tab.c 275 ${CTFCONVERT_CMD} 276 277.l.o: 278 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 279 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 280 rm -f ${.PREFIX}.tmp.c 281 ${CTFCONVERT_CMD} 282 283# XXX not -j safe 284.y.c: 285 ${YACC} ${YFLAGS} ${.IMPSRC} 286 mv y.tab.c ${.TARGET} 287 288.l.c: 289 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 290 291.s.out .c.out .o.out: 292 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 293 ${CTFCONVERT_CMD} 294 295.f.out .F.out .r.out .e.out: 296 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 297 ${LDLIBS} -o ${.TARGET} 298 rm -f ${.PREFIX}.o 299 ${CTFCONVERT_CMD} 300 301# XXX not -j safe 302.y.out: 303 ${YACC} ${YFLAGS} ${.IMPSRC} 304 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 305 rm -f y.tab.c 306 ${CTFCONVERT_CMD} 307 308.l.out: 309 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 310 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 311 rm -f ${.PREFIX}.tmp.c 312 ${CTFCONVERT_CMD} 313 314# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. 315__MAKE_CONF?=/etc/make.conf 316.if exists(${__MAKE_CONF}) 317.include "${__MAKE_CONF}" 318.endif 319 320.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 321SHELL= ${__MAKE_SHELL} 322.SHELL: path=${__MAKE_SHELL} 323.endif 324 325# Default executable format 326# XXX hint for bsd.port.mk 327OBJFORMAT?= elf 328 329.if !defined(.PARSEDIR) 330# We are not bmake, which is more aggressive about searching .PATH 331# It is sometime necessary to curb its enthusiasm with .NOPATH 332# The following allows us to quietly ignore .NOPATH when not using bmake. 333.NOTMAIN: .NOPATH 334.NOPATH: 335 336# Toggle on warnings 337.WARN: dirsyntax 338.endif 339 340.endif 341 342.if defined(.PARSEDIR) 343# Tell bmake to expand -V VAR by default 344.MAKE.EXPAND_VARIABLES= yes 345 346# Tell bmake the makefile preference 347.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 348 349# By default bmake does *not* use set -e 350# when running target scripts, this is a problem for many makefiles here. 351# So define a shell that will do what FreeBSD expects. 352.ifndef WITHOUT_SHELL_ERRCTL 353.SHELL: name=sh \ 354 quiet="set -" echo="set -v" filter="set -" \ 355 hasErrCtl=yes check="set -e" ignore="set +e" \ 356 echoFlag=v errFlag=e \ 357 path=${__MAKE_SHELL:U/bin/sh} 358.endif 359 360.endif 361 362.include <bsd.compat.mk> 363.include <bsd.cpu.mk> 364