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