# $NetBSD: sys.mk,v 1.149 2023/12/29 09:17:37 wiz Exp $
# @(#)sys.mk 8.2 (Berkeley) 3/21/94
#
# This file contains the basic rules for make(1) and is read first
# Do not put conditionals that are set on different files here and
# expect them to work.
CC?= cc
if ${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb"
# -O2 is too -falign-* zealous for low-memory sh3 machines
DBG?= -Os -freorder-blocks
elif ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m68000"
# -freorder-blocks (enabled by -O2) produces much bigger code
DBG?= -O2 -fno-reorder-blocks
elif ${MACHINE_ARCH} == "coldfire"
DBG?= -O1
else
DBG?= -O2
endif
if ${MKDTRACE:Uno} != "no"
DTRACE_OPTS?= -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-ipa-sra -fno-ipa-icf
endif
CFLAGS?= ${DBG}
LDFLAGS?=
COMPILE.c?= ${CC} ${CFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c
LINK.c?= ${CC} ${CFLAGS} ${LDSTATIC} ${LDFLAGS}
COMPILE_LINK.c?=${LINK.c} ${CPPFLAGS}
# C Type Format data is required for DTrace
CTFFLAGS ?= -g -L VERSION
CTFMFLAGS ?= -t -g -L VERSION
OBJECT_TARGET ?= -o ${.TARGET}${defined(CTFCONVERT):?.o:}
EXEC_TARGET ?= -o ${.TARGET}
CTFCONVERT_RUN ?= ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} -o ${.TARGET} ${.TARGET}.o && rm -f ${.TARGET}.o:}
CXX?= c++
# Strip flags unsupported by C++ compilers
# Remove -Wsystem-headers because C++ headers aren't clean of warnings
CXXFLAGS?= ${CFLAGS:N-Wno-traditional:N-Wstrict-prototypes:N-Wmissing-prototypes:N-Wno-pointer-sign:N-ffreestanding:N-std=gnu[0-9][0-9]:N-Wold-style-definition:N-Wno-format-zero-length:N-Wsystem-headers}
# Use the sources, as the seed... Normalize all paths...
__ALLSRC1= ${empty(DESTDIR):?${.ALLSRC}:${.ALLSRC:S|^${DESTDIR}|^destdir|}}
__ALLSRC2= ${empty(MAKEOBJDIR):?${__ALLSRC1}:${__ALLSRC1:S|^${MAKEOBJDIR}|^obj|}}
__ALLSRC3= ${empty(NETBSDSRCDIR):?${__ALLSRC2}:${__ALLSRC2:S|^${NETBSDSRCDIR}|^src|}}
__ALLSRC4= ${empty(X11SRCDIR):?${__ALLSRC3}:${__ALLSRC3:S|^${X11SRCDIR}|^xsrc|}}
# Skip paths that contain relative components and can't be normalized, sort..
__INITSEED= ${__ALLSRC4:N*/../*:O}