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)?/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 ?= cru 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 130.if !defined(%POSIX) 131NM ?= nm 132 133OBJC ?= cc 134OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 135 136OBJCOPY ?= objcopy 137 138PC ?= pc 139PFLAGS ?= 140 141RC ?= f77 142RFLAGS ?= 143.endif 144 145SHELL ?= sh 146 147YACC ?= yacc 148.if defined(%POSIX) 149YFLAGS ?= 150.else 151YFLAGS ?= -d 152.endif 153 154.if defined(%POSIX) 155 156# Posix 1003.2 mandated rules 157# 158# Quoted directly from the Posix 1003.2 draft, only the macros 159# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 160# ${.PREFIX}, resp. 161 162# SINGLE SUFFIX RULES 163.c: 164 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 165 ${CTFCONVERT_CMD} 166 167.f: 168 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 169 ${CTFCONVERT_CMD} 170 171.sh: 172 cp -f ${.IMPSRC} ${.TARGET} 173 chmod a+x ${.TARGET} 174 175# DOUBLE SUFFIX RULES 176 177.c.o: 178 ${CC} ${CFLAGS} -c ${.IMPSRC} 179 ${CTFCONVERT_CMD} 180 181.f.o: 182 ${FC} ${FFLAGS} -c ${.IMPSRC} 183 ${CTFCONVERT_CMD} 184 185.y.o: 186 ${YACC} ${YFLAGS} ${.IMPSRC} 187 ${CC} ${CFLAGS} -c y.tab.c 188 rm -f y.tab.c 189 mv y.tab.o ${.TARGET} 190 ${CTFCONVERT_CMD} 191 192.l.o: 193 ${LEX} ${LFLAGS} ${.IMPSRC} 194 ${CC} ${CFLAGS} -c lex.yy.c 195 rm -f lex.yy.c 196 mv lex.yy.o ${.TARGET} 197 ${CTFCONVERT_CMD} 198 199.y.c: 200 ${YACC} ${YFLAGS} ${.IMPSRC} 201 mv y.tab.c ${.TARGET} 202 203.l.c: 204 ${LEX} ${LFLAGS} ${.IMPSRC} 205 mv lex.yy.c ${.TARGET} 206 207.c.a: 208 ${CC} ${CFLAGS} -c ${.IMPSRC} 209 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 210 rm -f ${.PREFIX}.o 211 212.f.a: 213 ${FC} ${FFLAGS} -c ${.IMPSRC} 214 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 215 rm -f ${.PREFIX}.o 216 217.else 218 219# non-Posix rule set 220 221.sh: 222 cp -fp ${.IMPSRC} ${.TARGET} 223 chmod a+x ${.TARGET} 224 225.c.ln: 226 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 227 touch ${.TARGET} 228 229.cc.ln .C.ln .cpp.ln .cxx.ln: 230 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 231 touch ${.TARGET} 232 233.c: 234 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 235 ${CTFCONVERT_CMD} 236 237.c.o: 238 ${CC} ${CFLAGS} -c ${.IMPSRC} 239 ${CTFCONVERT_CMD} 240 241.cc .cpp .cxx .C: 242 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 243 244.cc.o .cpp.o .cxx.o .C.o: 245 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} 246 247.m.o: 248 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} 249 ${CTFCONVERT_CMD} 250 251.p.o: 252 ${PC} ${PFLAGS} -c ${.IMPSRC} 253 ${CTFCONVERT_CMD} 254 255.e .r .F .f: 256 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 257 -o ${.TARGET} 258 259.e.o .r.o .F.o .f.o: 260 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} 261 262.S.o: 263 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 264 ${CTFCONVERT_CMD} 265 266.asm.o: 267 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 268 ${CTFCONVERT_CMD} 269 270.s.o: 271 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 272 ${CTFCONVERT_CMD} 273 274# XXX not -j safe 275.y.o: 276 ${YACC} ${YFLAGS} ${.IMPSRC} 277 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 278 rm -f y.tab.c 279 ${CTFCONVERT_CMD} 280 281.l.o: 282 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 283 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 284 rm -f ${.PREFIX}.tmp.c 285 ${CTFCONVERT_CMD} 286 287# XXX not -j safe 288.y.c: 289 ${YACC} ${YFLAGS} ${.IMPSRC} 290 mv y.tab.c ${.TARGET} 291 292.l.c: 293 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 294 295.s.out .c.out .o.out: 296 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 297 ${CTFCONVERT_CMD} 298 299.f.out .F.out .r.out .e.out: 300 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 301 ${LDLIBS} -o ${.TARGET} 302 rm -f ${.PREFIX}.o 303 ${CTFCONVERT_CMD} 304 305# XXX not -j safe 306.y.out: 307 ${YACC} ${YFLAGS} ${.IMPSRC} 308 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 309 rm -f y.tab.c 310 ${CTFCONVERT_CMD} 311 312.l.out: 313 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 314 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 315 rm -f ${.PREFIX}.tmp.c 316 ${CTFCONVERT_CMD} 317 318# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. 319__MAKE_CONF?=/etc/make.conf 320.if exists(${__MAKE_CONF}) 321.include "${__MAKE_CONF}" 322.endif 323 324.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 325SHELL= ${__MAKE_SHELL} 326.SHELL: path=${__MAKE_SHELL} 327.endif 328 329# Default executable format 330# XXX hint for bsd.port.mk 331OBJFORMAT?= elf 332 333# Tell bmake to expand -V VAR by default 334.MAKE.EXPAND_VARIABLES= yes 335 336.if !defined(.PARSEDIR) 337# We are not bmake, which is more aggressive about searching .PATH 338# It is sometime necessary to curb its enthusiasm with .NOPATH 339# The following allows us to quietly ignore .NOPATH when not using bmake. 340.NOTMAIN: .NOPATH 341.NOPATH: 342 343# Toggle on warnings 344.WARN: dirsyntax 345.endif 346 347.endif 348 349.include <bsd.compat.mk> 350.include <bsd.cpu.mk> 351