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|hf)?/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 ?= -crD 39.endif 40RANLIB ?= ranlib 41.if !defined(%POSIX) 42RANLIBFLAGS ?= -D 43.endif 44 45AS ?= as 46AFLAGS ?= 47ACFLAGS ?= 48 49.if defined(%POSIX) 50CC ?= c89 51CFLAGS ?= -O 52.else 53CC ?= cc 54.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 55CFLAGS ?= -O -pipe 56.else 57CFLAGS ?= -O2 -pipe 58.endif 59.if defined(NO_STRICT_ALIASING) 60CFLAGS += -fno-strict-aliasing 61.endif 62.endif 63PO_CFLAGS ?= ${CFLAGS} 64 65# C Type Format data is required for DTrace 66CTFFLAGS ?= -L VERSION 67 68CTFCONVERT ?= ctfconvert 69CTFMERGE ?= ctfmerge 70 71# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle 72# read-only files as non-root by passing -f. 73CP ?= cp -f 74 75DTRACE ?= dtrace 76.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 77CTFFLAGS += -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 defined(.PARSEDIR) 99# _+_ appears to be a workaround for the special src .MAKE not working. 100# setting it to + interferes with -N 101_+_ ?= 102.elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 103# the check above matches only a single -n, so -n -n will result 104# in _+_ = + 105_+_ ?= 106.else 107_+_ ?= + 108.endif 109 110.if defined(%POSIX) 111FC ?= fort77 112FFLAGS ?= -O 1 113.else 114FC ?= f77 115FFLAGS ?= -O 116.endif 117EFLAGS ?= 118 119INSTALL ?= install 120 121LEX ?= lex 122LFLAGS ?= 123 124LD ?= ld 125LDFLAGS ?= # LDFLAGS is for CC, 126_LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD 127 128LINT ?= lint 129LINTFLAGS ?= -cghapbx 130LINTKERNFLAGS ?= ${LINTFLAGS} 131LINTOBJFLAGS ?= -cghapbxu -i 132LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 133LINTLIBFLAGS ?= -cghapbxu -C ${LIB} 134 135MAKE ?= make 136 137.if !defined(%POSIX) 138NM ?= nm 139 140OBJC ?= cc 141OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 142 143OBJCOPY ?= objcopy 144 145OBJDUMP ?= objdump 146 147PC ?= pc 148PFLAGS ?= 149 150RC ?= f77 151RFLAGS ?= 152.endif 153 154SHELL ?= sh 155 156.if !defined(%POSIX) 157SIZE ?= size 158.endif 159 160YACC ?= yacc 161.if defined(%POSIX) 162YFLAGS ?= 163.else 164YFLAGS ?= -d 165.endif 166 167.if defined(%POSIX) 168 169# Posix 1003.2 mandated rules 170# 171# Quoted directly from the Posix 1003.2 draft, only the macros 172# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 173# ${.PREFIX}, resp. 174 175# SINGLE SUFFIX RULES 176.c: 177 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 178 179.f: 180 ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} 181 182.sh: 183 cp -f ${.IMPSRC} ${.TARGET} 184 chmod a+x ${.TARGET} 185 186# DOUBLE SUFFIX RULES 187 188.c.o: 189 ${CC} ${CFLAGS} -c ${.IMPSRC} 190 191.f.o: 192 ${FC} ${FFLAGS} -c ${.IMPSRC} 193 194.y.o: 195 ${YACC} ${YFLAGS} ${.IMPSRC} 196 ${CC} ${CFLAGS} -c y.tab.c 197 rm -f y.tab.c 198 mv y.tab.o ${.TARGET} 199 200.l.o: 201 ${LEX} ${LFLAGS} ${.IMPSRC} 202 ${CC} ${CFLAGS} -c lex.yy.c 203 rm -f lex.yy.c 204 mv lex.yy.o ${.TARGET} 205 206.y.c: 207 ${YACC} ${YFLAGS} ${.IMPSRC} 208 mv y.tab.c ${.TARGET} 209 210.l.c: 211 ${LEX} ${LFLAGS} ${.IMPSRC} 212 mv lex.yy.c ${.TARGET} 213 214.c.a: 215 ${CC} ${CFLAGS} -c ${.IMPSRC} 216 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 217 rm -f ${.PREFIX}.o 218 219.f.a: 220 ${FC} ${FFLAGS} -c ${.IMPSRC} 221 ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 222 rm -f ${.PREFIX}.o 223 224.else 225 226# non-Posix rule set 227 228.sh: 229 cp -fp ${.IMPSRC} ${.TARGET} 230 chmod a+x ${.TARGET} 231 232.c.ln: 233 ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ 234 touch ${.TARGET} 235 236.cc.ln .C.ln .cpp.ln .cxx.ln: 237 ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ 238 touch ${.TARGET} 239 240.c: 241 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 242 ${CTFCONVERT_CMD} 243 244.c.o: 245 ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 246 ${CTFCONVERT_CMD} 247 248.cc .cpp .cxx .C: 249 ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 250 251.cc.o .cpp.o .cxx.o .C.o: 252 ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 253 254.m.o: 255 ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} 256 ${CTFCONVERT_CMD} 257 258.p.o: 259 ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET} 260 ${CTFCONVERT_CMD} 261 262.e .r .F .f: 263 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ 264 -o ${.TARGET} 265 266.e.o .r.o .F.o .f.o: 267 ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET} 268 269.S.o: 270 ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 271 ${CTFCONVERT_CMD} 272 273.asm.o: 274 ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ 275 -o ${.TARGET} 276 ${CTFCONVERT_CMD} 277 278.s.o: 279 ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} 280 ${CTFCONVERT_CMD} 281 282# XXX not -j safe 283.y.o: 284 ${YACC} ${YFLAGS} ${.IMPSRC} 285 ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} 286 rm -f y.tab.c 287 ${CTFCONVERT_CMD} 288 289.l.o: 290 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 291 ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} 292 rm -f ${.PREFIX}.tmp.c 293 ${CTFCONVERT_CMD} 294 295# XXX not -j safe 296.y.c: 297 ${YACC} ${YFLAGS} ${.IMPSRC} 298 mv y.tab.c ${.TARGET} 299 300.l.c: 301 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} 302 303.s.out .c.out .o.out: 304 ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} 305 ${CTFCONVERT_CMD} 306 307.f.out .F.out .r.out .e.out: 308 ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ 309 ${LDLIBS} -o ${.TARGET} 310 rm -f ${.PREFIX}.o 311 ${CTFCONVERT_CMD} 312 313# XXX not -j safe 314.y.out: 315 ${YACC} ${YFLAGS} ${.IMPSRC} 316 ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} 317 rm -f y.tab.c 318 ${CTFCONVERT_CMD} 319 320.l.out: 321 ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c 322 ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} 323 rm -f ${.PREFIX}.tmp.c 324 ${CTFCONVERT_CMD} 325 326# Pull in global settings. 327__MAKE_CONF?=/etc/make.conf 328.if exists(${__MAKE_CONF}) 329.include "${__MAKE_CONF}" 330.endif 331 332# Setup anything for the FreeBSD source build, if we're building 333# inside the source tree. Needs to be after make.conf, but before 334# local stuff. 335.sinclude <src.sys.mk> 336 337# Set any local definitions first. Place this early, but it needs 338# MACHINE_CPUARCH to be defined. 339.sinclude <local.sys.mk> 340 341.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 342SHELL= ${__MAKE_SHELL} 343.SHELL: path=${__MAKE_SHELL} 344.endif 345 346.if !defined(.PARSEDIR) 347# We are not bmake, which is more aggressive about searching .PATH 348# It is sometime necessary to curb its enthusiasm with .NOPATH 349# The following allows us to quietly ignore .NOPATH when not using bmake. 350.NOTMAIN: .NOPATH 351.NOPATH: 352 353# Toggle on warnings 354.WARN: dirsyntax 355.else # is bmake 356# Tell bmake to expand -V VAR by default 357.MAKE.EXPAND_VARIABLES= yes 358 359# Tell bmake the makefile preference 360.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 361 362# By default bmake does *not* use set -e 363# when running target scripts, this is a problem for many makefiles here. 364# So define a shell that will do what FreeBSD expects. 365.ifndef WITHOUT_SHELL_ERRCTL 366.SHELL: name=sh \ 367 quiet="set -" echo="set -v" filter="set -" \ 368 hasErrCtl=yes check="set -e" ignore="set +e" \ 369 echoFlag=v errFlag=e \ 370 path=${__MAKE_SHELL:U/bin/sh} 371.endif 372.endif # bmake 373 374.include <bsd.cpu.mk> 375 376.endif # ! Posix 377