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