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