1 1.149 wiz # $NetBSD: sys.mk,v 1.149 2023/12/29 09:17:37 wiz Exp $ 2 1.30 mikel # @(#)sys.mk 8.2 (Berkeley) 3/21/94 3 1.111 christos # 4 1.111 christos # This file contains the basic rules for make(1) and is read first 5 1.111 christos # Do not put conditionals that are set on different files here and 6 1.111 christos # expect them to work. 7 1.1 cgd 8 1.30 mikel unix?= We run NetBSD. 9 1.1 cgd 10 1.80 lukem .SUFFIXES: .a .o .ln .s .S .c .cc .cpp .cxx .C .f .F .r .p .l .y .sh 11 1.1 cgd 12 1.1 cgd .LIBS: .a 13 1.1 cgd 14 1.22 christos AR?= ar 15 1.149 wiz ARFLAGS?= r 16 1.22 christos RANLIB?= ranlib 17 1.140 christos MV?= mv -f 18 1.22 christos 19 1.22 christos AS?= as 20 1.22 christos AFLAGS?= 21 1.106 joerg COMPILE.s?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} -c 22 1.146 christos LINK.s?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDSTATIC} ${LDFLAGS} 23 1.101 joerg _ASM_TRADITIONAL_CPP= -x assembler-with-cpp 24 1.106 joerg COMPILE.S?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} ${_ASM_TRADITIONAL_CPP} -c 25 1.146 christos LINK.S?= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${LDSTATIC} ${LDFLAGS} 26 1.146 christos COMPILE_LINK.S?=${LINK.S} ${CPPFLAGS} 27 1.22 christos 28 1.22 christos CC?= cc 29 1.107 chs .if ${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb" 30 1.97 uwe # -O2 is too -falign-* zealous for low-memory sh3 machines 31 1.97 uwe DBG?= -Os -freorder-blocks 32 1.107 chs .elif ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m68000" 33 1.125 tsutsui # -freorder-blocks (enabled by -O2) produces much bigger code 34 1.125 tsutsui DBG?= -O2 -fno-reorder-blocks 35 1.117 matt .elif ${MACHINE_ARCH} == "coldfire" 36 1.117 matt DBG?= -O1 37 1.44 mycroft .else 38 1.107 chs DBG?= -O2 39 1.44 mycroft .endif 40 1.130 chs .if ${MKDTRACE:Uno} != "no" 41 1.130 chs DTRACE_OPTS?= -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-ipa-sra -fno-ipa-icf 42 1.130 chs .endif 43 1.57 sjg CFLAGS?= ${DBG} 44 1.87 lukem LDFLAGS?= 45 1.130 chs COMPILE.c?= ${CC} ${CFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c 46 1.146 christos LINK.c?= ${CC} ${CFLAGS} ${LDSTATIC} ${LDFLAGS} 47 1.146 christos COMPILE_LINK.c?=${LINK.c} ${CPPFLAGS} 48 1.22 christos 49 1.100 darran # C Type Format data is required for DTrace 50 1.116 yamt CTFFLAGS ?= -g -L VERSION 51 1.128 chs CTFMFLAGS ?= -t -g -L VERSION 52 1.144 christos OBJECT_TARGET ?= -o ${.TARGET}${defined(CTFCONVERT):?.o:} 53 1.145 christos EXEC_TARGET ?= -o ${.TARGET} 54 1.144 christos CTFCONVERT_RUN ?= ${defined(CTFCONVERT):?${CTFCONVERT} ${CTFFLAGS} -o ${.TARGET} ${.TARGET}.o && rm -f ${.TARGET}.o:} 55 1.100 darran 56 1.41 tv CXX?= c++ 57 1.133 maya # Strip flags unsupported by C++ compilers 58 1.133 maya # Remove -Wsystem-headers because C++ headers aren't clean of warnings 59 1.132 maya 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} 60 1.89 christos 61 1.135 christos # Use the sources, as the seed... Normalize all paths... 62 1.98 joerg __ALLSRC1= ${empty(DESTDIR):?${.ALLSRC}:${.ALLSRC:S|^${DESTDIR}|^destdir|}} 63 1.98 joerg __ALLSRC2= ${empty(MAKEOBJDIR):?${__ALLSRC1}:${__ALLSRC1:S|^${MAKEOBJDIR}|^obj|}} 64 1.98 joerg __ALLSRC3= ${empty(NETBSDSRCDIR):?${__ALLSRC2}:${__ALLSRC2:S|^${NETBSDSRCDIR}|^src|}} 65 1.131 christos __ALLSRC4= ${empty(X11SRCDIR):?${__ALLSRC3}:${__ALLSRC3:S|^${X11SRCDIR}|^xsrc|}} 66 1.135 christos # Skip paths that contain relative components and can't be normalized, sort.. 67 1.135 christos __INITSEED= ${__ALLSRC4:N*/../*:O} 68 1.135 christos 69 1.135 christos __BUILDSEED= ${BUILDSEED}/${__INITSEED}/${.TARGET} 70 1.105 joerg _CXXSEED?= ${BUILDSEED:D-frandom-seed=${__BUILDSEED:hash}} 71 1.98 joerg 72 1.137 christos COMPILE.cc?= ${CXX} ${_CXXSEED} ${CXXFLAGS} ${DTRACE_OPTS} ${CPPFLAGS} -c 73 1.146 christos LINK.cc?= ${CXX} ${CXXFLAGS} ${LDSTATIC} ${LDFLAGS} 74 1.146 christos COMPILE_LINK.cc?=${LINK.cc} ${CPPFLAGS} 75 1.34 lukem 76 1.34 lukem OBJC?= ${CC} 77 1.34 lukem OBJCFLAGS?= ${CFLAGS} 78 1.34 lukem COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c 79 1.146 christos LINK.m?= ${OBJC} ${OBJCFLAGS} ${LDSTATIC} ${LDFLAGS} 80 1.146 christos LINK.m?= ${LINK.m} ${CPPFLAGS} 81 1.3 mycroft 82 1.22 christos CPP?= cpp 83 1.75 lukem CPPFLAGS?= 84 1.1 cgd 85 1.22 christos FC?= f77 86 1.30 mikel FFLAGS?= -O 87 1.22 christos RFLAGS?= 88 1.22 christos COMPILE.f?= ${FC} ${FFLAGS} -c 89 1.146 christos LINK.f?= ${FC} ${FFLAGS} ${LDSTATIC} ${LDFLAGS} 90 1.146 christos COMPILE_LINK.f?=${LINK.f} ${CPPFLAGS} 91 1.22 christos COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c 92 1.146 christos LINK.F?= ${FC} ${FFLAGS} ${LDSTATIC} ${LDFLAGS} 93 1.146 christos COMPILE_LINK.F?=${LINK.F} ${CPPFLAGS} 94 1.22 christos COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c 95 1.146 christos LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDSTATIC} ${LDFLAGS} 96 1.146 christos COMPILE_LINK.r?=${LINK.r} 97 1.29 thorpej 98 1.29 thorpej INSTALL?= install 99 1.22 christos 100 1.79 lukem LD?= ld 101 1.79 lukem 102 1.22 christos LEX?= lex 103 1.22 christos LFLAGS?= 104 1.22 christos LEX.l?= ${LEX} ${LFLAGS} 105 1.22 christos 106 1.22 christos LINT?= lint 107 1.139 christos LINTFLAGS?= -chapbrxzgFS 108 1.22 christos 109 1.36 gwr LORDER?= lorder 110 1.36 gwr 111 1.22 christos MAKE?= make 112 1.22 christos 113 1.36 gwr NM?= nm 114 1.36 gwr 115 1.22 christos PC?= pc 116 1.22 christos PFLAGS?= 117 1.22 christos COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c 118 1.22 christos LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} 119 1.22 christos 120 1.22 christos SHELL?= sh 121 1.36 gwr 122 1.36 gwr SIZE?= size 123 1.36 gwr 124 1.36 gwr TSORT?= tsort -q 125 1.22 christos 126 1.22 christos YACC?= yacc 127 1.40 tv YFLAGS?= 128 1.22 christos YACC.y?= ${YACC} ${YFLAGS} 129 1.1 cgd 130 1.15 jtc # C 131 1.14 jtc .c: 132 1.146 christos ${COMPILE_LINK.c} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 133 1.15 jtc .c.o: 134 1.144 christos ${COMPILE.c} ${.IMPSRC} ${OBJECT_TARGET} 135 1.144 christos ${CTFCONVERT_RUN} 136 1.15 jtc .c.a: 137 1.15 jtc ${COMPILE.c} ${.IMPSRC} 138 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 139 1.76 lukem rm -f ${.PREFIX}.o 140 1.21 cgd .c.ln: 141 1.83 lukem ${LINT} ${LINTFLAGS} \ 142 1.148 christos ${CPPFLAGS:C/-([IDUW]) */-\1/Wg:M-[IDUW]*} \ 143 1.83 lukem -i ${.IMPSRC} 144 1.14 jtc 145 1.15 jtc # C++ 146 1.55 jdolecek .cc .cpp .cxx .C: 147 1.146 christos ${COMPILE_LINK.cc} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 148 1.55 jdolecek .cc.o .cpp.o .cxx.o .C.o: 149 1.144 christos ${COMPILE.cc} ${.IMPSRC} ${OBJECT_TARGET} 150 1.144 christos ${CTFCONVERT_RUN} 151 1.55 jdolecek .cc.a .cpp.a .cxx.a .C.a: 152 1.15 jtc ${COMPILE.cc} ${.IMPSRC} 153 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 154 1.76 lukem rm -f ${.PREFIX}.o 155 1.14 jtc 156 1.15 jtc # Fortran/Ratfor 157 1.15 jtc .f: 158 1.146 christos ${COMPILE_LINK.f} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 159 1.15 jtc .f.o: 160 1.144 christos ${COMPILE.f} ${.IMPSRC} ${OBJECT_TARGET} 161 1.144 christos ${CTFCONVERT_RUN} 162 1.15 jtc .f.a: 163 1.15 jtc ${COMPILE.f} ${.IMPSRC} 164 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 165 1.76 lukem rm -f ${.PREFIX}.o 166 1.14 jtc 167 1.15 jtc .F: 168 1.146 christos ${COMPILE_LINK.F} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 169 1.15 jtc .F.o: 170 1.144 christos ${COMPILE.F} ${.IMPSRC} ${OBJECT_TARGET} 171 1.144 christos ${CTFCONVERT_RUN} 172 1.15 jtc .F.a: 173 1.15 jtc ${COMPILE.F} ${.IMPSRC} 174 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 175 1.76 lukem rm -f ${.PREFIX}.o 176 1.14 jtc 177 1.15 jtc .r: 178 1.146 christos ${COMPILE_LINK.r} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 179 1.15 jtc .r.o: 180 1.144 christos ${COMPILE.r} ${.IMPSRC} ${OBJECT_TARGET} 181 1.144 christos ${CTFCONVERT_RUN} 182 1.15 jtc .r.a: 183 1.15 jtc ${COMPILE.r} ${.IMPSRC} 184 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 185 1.76 lukem rm -f ${.PREFIX}.o 186 1.9 jtc 187 1.15 jtc # Pascal 188 1.15 jtc .p: 189 1.146 christos ${COMPILE_LINK.p} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 190 1.1 cgd .p.o: 191 1.144 christos ${COMPILE.p} ${.IMPSRC} ${OBJECT_TARGET} 192 1.144 christos ${CTFCONVERT_RUN} 193 1.15 jtc .p.a: 194 1.15 jtc ${COMPILE.p} ${.IMPSRC} 195 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 196 1.76 lukem rm -f ${.PREFIX}.o 197 1.1 cgd 198 1.15 jtc # Assembly 199 1.15 jtc .s: 200 1.146 christos ${COMPILE_LINK.s} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 201 1.1 cgd .s.o: 202 1.144 christos ${COMPILE.s} ${.IMPSRC} ${OBJECT_TARGET} 203 1.144 christos ${CTFCONVERT_RUN} 204 1.15 jtc .s.a: 205 1.15 jtc ${COMPILE.s} ${.IMPSRC} 206 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 207 1.76 lukem rm -f ${.PREFIX}.o 208 1.15 jtc .S: 209 1.146 christos ${COMPILE_LINK.S} ${EXEC_TARGET} ${.IMPSRC} ${LDLIBS} 210 1.8 brezak .S.o: 211 1.144 christos ${COMPILE.S} ${.IMPSRC} ${OBJECT_TARGET} 212 1.144 christos ${CTFCONVERT_RUN} 213 1.15 jtc .S.a: 214 1.15 jtc ${COMPILE.S} ${.IMPSRC} 215 1.76 lukem ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o 216 1.76 lukem rm -f ${.PREFIX}.o 217 1.1 cgd 218 1.15 jtc # Lex 219 1.15 jtc .l: 220 1.15 jtc ${LEX.l} ${.IMPSRC} 221 1.146 christos ${COMPILE_LINK.c} ${EXEC_TARGET} lex.yy.c ${LDLIBS} -ll 222 1.15 jtc rm -f lex.yy.c 223 1.15 jtc .l.c: 224 1.15 jtc ${LEX.l} ${.IMPSRC} 225 1.138 christos ${MV} lex.yy.c ${.TARGET} 226 1.1 cgd .l.o: 227 1.15 jtc ${LEX.l} ${.IMPSRC} 228 1.144 christos ${COMPILE.c} ${OBJECT_TARGET} lex.yy.c 229 1.144 christos ${CTFCONVERT_RUN} 230 1.1 cgd rm -f lex.yy.c 231 1.1 cgd 232 1.15 jtc # Yacc 233 1.15 jtc .y: 234 1.15 jtc ${YACC.y} ${.IMPSRC} 235 1.146 christos ${COMPILE_LINK.c} ${EXEC_TARGET} y.tab.c ${LDLIBS} 236 1.15 jtc rm -f y.tab.c 237 1.38 tv .y.c: 238 1.15 jtc ${YACC.y} ${.IMPSRC} 239 1.138 christos ${MV} y.tab.c ${.TARGET} 240 1.15 jtc .y.o: 241 1.15 jtc ${YACC.y} ${.IMPSRC} 242 1.144 christos ${COMPILE.c} ${OBJECT_TARGET} y.tab.c 243 1.144 christos ${CTFCONVERT_RUN} 244 1.1 cgd rm -f y.tab.c 245 1.1 cgd 246 1.15 jtc # Shell 247 1.15 jtc .sh: 248 1.15 jtc rm -f ${.TARGET} 249 1.15 jtc cp ${.IMPSRC} ${.TARGET} 250 1.79 lukem chmod a+x ${.TARGET} 251