sys.mk revision 239272
126497Sache# from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 226497Sache# $FreeBSD: head/share/mk/sys.mk 239272 2012-08-15 03:21:56Z gonzo $ 326497Sache 426497Sacheunix ?= We run FreeBSD, not UNIX. 558310Sache.FreeBSD ?= true 626497Sache 726497Sache.if !defined(%POSIX) 8119610Sache# 9119610Sache# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with 10119610Sache# the same MACHINE_ARCH can run each other's binaries, so it necessarily 11119610Sache# has word size and endian swizzled in. However, support files for 12119610Sache# these machines often are shared amongst all combinations of size 13119610Sache# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used 14119610Sache# for something different in FreeBSD. 15119610Sache# 16119610SacheMACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/} 17119610Sache.endif 18119610Sache 19119610Sache# If the special target .POSIX appears (without prerequisites or 20119610Sache# commands) before the first noncomment line in the makefile, make shall 21119610Sache# process the makefile as specified by the Posix 1003.2 specification. 22119610Sache# make(1) sets the special macro %POSIX in this case (to the actual 23119610Sache# value "1003.2", for what it's worth). 24119610Sache# 25119610Sache# The rules below use this macro to distinguish between Posix-compliant 26119610Sache# and default behaviour. 27119610Sache 2826497Sache.if defined(%POSIX) 2935486Sache.SUFFIXES: .o .c .y .l .a .sh .f 3026497Sache.else 3126497Sache.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh 3226497Sache.endif 3326497Sache 3426497SacheAR ?= ar 35157184Sache.if defined(%POSIX) 36157184SacheARFLAGS ?= -rv 37157184Sache.else 38157184SacheARFLAGS ?= rl 39157184Sache.endif 40157184SacheRANLIB ?= ranlib 4158310Sache 42157184SacheAS ?= as 4358310SacheAFLAGS ?= 4458310SacheACFLAGS ?= 4558310Sache 46157184Sache.if defined(%POSIX) 4758310SacheCC ?= c89 4858310SacheCFLAGS ?= -O 4958310Sache.else 5058310SacheCC ?= cc 5126497Sache.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 5226497SacheCFLAGS ?= -O -pipe 5326497Sache.else 5435486SacheCFLAGS ?= -O2 -pipe 5526497Sache.endif 5635486Sache.if defined(NO_STRICT_ALIASING) 5726497SacheCFLAGS += -fno-strict-aliasing 5826497Sache.endif 5926497Sache.endif 6026497SachePO_CFLAGS ?= ${CFLAGS} 6126497Sache 6226497Sache# C Type Format data is required for DTrace 6326497SacheCTFFLAGS ?= -L VERSION 6426497Sache 6526497SacheCTFCONVERT ?= ctfconvert 6626497SacheCTFMERGE ?= ctfmerge 6726497SacheDTRACE ?= dtrace 6875406Sache.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 6926497SacheCTFFLAGS += -g 7058310Sache.else 7126497Sache# XXX: What to do here? Is removing the CFLAGS part completely ok here? 7226497Sache# For now comment it out to not compile with -g unconditionally. 7347558Sache#CFLAGS += -g 7426497Sache.endif 7526497Sache 7658310SacheCXX ?= c++ 7726497SacheCXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 7826497SachePO_CXXFLAGS ?= ${CXXFLAGS} 7926497Sache 8058310SacheCPP ?= cpp 8126497Sache 8226497Sache.if empty(.MAKEFLAGS:M-s) 8326497SacheECHO ?= echo 8426497SacheECHODIR ?= echo 8526497Sache.else 8626497SacheECHO ?= true 8758310Sache.if ${.MAKEFLAGS:M-s} == "-s" 8826497SacheECHODIR ?= echo 8926497Sache.else 9026497SacheECHODIR ?= true 9126497Sache.endif 9226497Sache.endif 9326497Sache 9426497Sache.if !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" 9526497Sache_+_ ?= 9626497Sache.else 9726497Sache_+_ ?= + 9858310Sache.endif 9926497Sache 10026497Sache.if defined(%POSIX) 10158310SacheFC ?= fort77 10226497SacheFFLAGS ?= -O 1 10326497Sache.else 10426497SacheFC ?= f77 10526497SacheFFLAGS ?= -O 10626497Sache.endif 10726497SacheEFLAGS ?= 10826497Sache 10926497SacheINSTALL ?= install 11026497Sache 11126497SacheLEX ?= lex 11226497SacheLFLAGS ?= 11326497Sache 11426497SacheLD ?= ld 11526497SacheLDFLAGS ?= 11626497Sache 11726497SacheLINT ?= lint 11826497SacheLINTFLAGS ?= -cghapbx 11958310SacheLINTKERNFLAGS ?= ${LINTFLAGS} 12058310SacheLINTOBJFLAGS ?= -cghapbxu -i 12158310SacheLINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 12258310SacheLINTLIBFLAGS ?= -cghapbxu -C ${LIB} 12358310Sache 12458310SacheMAKE ?= make 12558310Sache 12658310Sache.if !defined(%POSIX) 12726497SacheNM ?= nm 12826497Sache.endif 12926497Sache 13026497SacheOBJC ?= cc 13126497SacheOBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 13226497Sache 13326497SachePC ?= pc 13426497SachePFLAGS ?= 13526497Sache 13626497SacheRC ?= f77 13726497SacheRFLAGS ?= 13826497Sache 13926497SacheSHELL ?= sh 14026497Sache 14126497SacheYACC ?= yacc 14226497Sache.if defined(%POSIX) 14326497SacheYFLAGS ?= 14426497Sache.else 14526497SacheYFLAGS ?= -d 14626497Sache.endif 14758310Sache 14858310Sache.if defined(%POSIX) 14958310Sache 15026497Sache# Posix 1003.2 mandated rules 15126497Sache# 15226497Sache# Quoted directly from the Posix 1003.2 draft, only the macros 15326497Sache# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and 15426497Sache# ${.PREFIX}, resp. 15526497Sache 15675406Sache# SINGLE SUFFIX RULES 15726497Sache.c: 15826497Sache ${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