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# Turn CTF conversion off by default for now. This default could be 63# changed later if DTrace becomes popular. 64.if !defined(WITH_CTF) 65NO_CTF = 1 66.endif 67 68# C Type Format data is required for DTrace 69CTFFLAGS ?= -L VERSION 70 71CTFCONVERT ?= ctfconvert 72CTFMERGE ?= ctfmerge 73DTRACE ?= dtrace 74.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 75CTFFLAGS += -g 76.else 77# XXX: What to do here? Is removing the CFLAGS part completely ok here? 78# For now comment it out to not compile with -g unconditionally. 79#CFLAGS += -g 80.endif 81 82CXX ?= c++ 83CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 84PO_CXXFLAGS ?= ${CXXFLAGS} 85 86CPP ?= cpp 87 88.if empty(.MAKEFLAGS:M-s) 89ECHO ?= echo 90ECHODIR ?= echo 91.else 92ECHO ?= true 93.if ${.MAKEFLAGS:M-s} == "-s" 94ECHODIR ?= echo 95.else 96ECHODIR ?= true 97.endif 98.endif 99 100.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 101_+_ ?= 102.else 103_+_ ?= + 104.endif 105 106.if defined(%POSIX) 107FC ?= fort77 108FFLAGS ?= -O 1 109.else 110FC ?= f77 111FFLAGS ?= -O 112.endif 113EFLAGS ?= 114 115INSTALL ?= install 116 117LEX ?= lex 118LFLAGS ?= 119 120LD ?= ld 121LDFLAGS ?= 122 123LINT ?= lint 124LINTFLAGS ?= -cghapbx 125LINTKERNFLAGS ?= ${LINTFLAGS} 126LINTOBJFLAGS ?= -cghapbxu -i 127LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 128LINTLIBFLAGS ?= -cghapbxu -C ${LIB} 129 130MAKE ?= make 131 132OBJC ?= cc 133OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 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 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 162 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 163 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 164 165.f: 166 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 167 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 168 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 169 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 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 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 180 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 181 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 182 183.f.o: 184 ${FC} ${FFLAGS} -c ${.IMPSRC} 185 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 186 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 187 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 188 189.y.o: 190 ${YACC} ${YFLAGS} ${.IMPSRC} 191 ${CC} ${CFLAGS} -c y.tab.c 192 rm -f y.tab.c 193 mv y.tab.o ${.TARGET} 194 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 195 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 196 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 197 198.l.o: 199 ${LEX} ${LFLAGS} ${.IMPSRC} 200 ${CC} ${CFLAGS} -c lex.yy.c 201 rm -f lex.yy.c 202 mv lex.yy.o ${.TARGET} 203 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 204 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 205 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 206 207.y.c: 208 ${YACC} ${YFLAGS} ${.IMPSRC} 209 mv y.tab.c ${.TARGET} 210 211.l.c: 212 ${LEX} ${LFLAGS} ${.IMPSRC} 213 mv lex.yy.c ${.TARGET} 214 215.c.a: 216 ${CC} ${CFLAGS} -c ${.IMPSRC} 217 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 218 rm -f ${.PREFIX}.o 219 220.f.a: 221 ${FC} ${FFLAGS} -c ${.IMPSRC} 222 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 223 rm -f ${.PREFIX}.o 224 225.else 226 227# non-Posix rule set 228 229.sh: 230 cp -fp ${.IMPSRC} ${.TARGET} 231 chmod a+x ${.TARGET} 232 233.c.ln: 234 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 235 touch ${.TARGET} 236 237.cc.ln .C.ln .cpp.ln .cxx.ln: 238 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 239 touch ${.TARGET} 240 241.c: 242 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 243 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 244 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 245 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 246 247.c.o: 248 ${CC} ${CFLAGS} -c ${.IMPSRC} 249 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 250 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 251 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 252 253.cc .cpp .cxx .C: 254 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 255 256.cc.o .cpp.o .cxx.o .C.o: 257 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} 258 259.m.o: 260 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} 261 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 262 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 263 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 264 265.p.o: 266 ${PC} ${PFLAGS} -c ${.IMPSRC} 267 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 268 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 269 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 270 271.e .r .F .f: 272 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 273 -o ${.TARGET} 274 275.e.o .r.o .F.o .f.o: 276 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} 277 278.S.o: 279 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 280 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 281 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 282 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 283 284.asm.o: 285 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} 286 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 287 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 288 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 289 290.s.o: 291 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 292 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 293 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 294 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 295 296# XXX not -j safe 297.y.o: 298 ${YACC} ${YFLAGS} ${.IMPSRC} 299 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 300 rm -f y.tab.c 301 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 302 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 303 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 304 305.l.o: 306 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 307 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 308 rm -f ${.PREFIX}.tmp.c 309 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 310 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 311 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 312 313# XXX not -j safe 314.y.c: 315 ${YACC} ${YFLAGS} ${.IMPSRC} 316 mv y.tab.c ${.TARGET} 317 318.l.c: 319 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 320 321.s.out .c.out .o.out: 322 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 323 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 324 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 325 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 326 327.f.out .F.out .r.out .e.out: 328 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 329 ${LDLIBS} -o ${.TARGET} 330 rm -f ${.PREFIX}.o 331 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 332 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 333 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 334 335# XXX not -j safe 336.y.out: 337 ${YACC} ${YFLAGS} ${.IMPSRC} 338 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 339 rm -f y.tab.c 340 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 341 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 342 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 343 344.l.out: 345 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 346 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 347 rm -f ${.PREFIX}.tmp.c 348 @[ -z "${CTFCONVERT}" -o -n "${NO_CTF}" ] || \ 349 (${ECHO} ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ 350 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}) 351 352# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. 353__MAKE_CONF?=/etc/make.conf 354.if exists(${__MAKE_CONF}) 355.include "${__MAKE_CONF}" 356.endif 357 358.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 359SHELL= ${__MAKE_SHELL} 360.SHELL: path=${__MAKE_SHELL} 361.endif 362 363# Default executable format 364# XXX hint for bsd.port.mk 365OBJFORMAT?= elf 366 367# Toggle on warnings 368.WARN: dirsyntax 369 370.endif 371 372.include <bsd.compat.mk> 373.include <bsd.cpu.mk> 374