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