1# $Id: Generic.mk,v 1.14 2020/04/17 21:08:17 sjg Exp $ 2# 3 4# some reasonable defaults 5.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h 6.SUFFIXES: .sh .m4 7 8.LIBS: .a 9 10tools = \ 11 ar \ 12 lorder \ 13 ranlib \ 14 tsort 15 16.for t in ${tools} 17${t:tu} := ${t:${M_whence}} 18.endfor 19 20# need to make sure this is set 21MACHINE_ARCH.${MACHINE} ?= ${MACHINE} 22.if empty(MACHINE_ARCH) 23MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}} 24.endif 25 26.if !empty(TSORT) 27TSORT += -q 28.endif 29 30ARFLAGS?= rl 31 32AS?= as 33AFLAGS?= 34.if ${MACHINE_ARCH} == "sparc64" 35AFLAGS+= -Wa,-Av9a 36.endif 37COMPILE.s?= ${CC} ${AFLAGS} -c 38LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} 39COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp 40LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} 41 42CC?= cc 43DBG?= -O2 44CFLAGS?= ${DBG} 45COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c 46LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} 47 48CXX?= c++ 49CXXFLAGS?= ${CFLAGS} 50COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c 51LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} 52 53OBJC?= ${CC} 54OBJCFLAGS?= ${CFLAGS} 55COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c 56LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} 57 58CPP?= cpp 59CPPFLAGS?= 60 61FC?= f77 62FFLAGS?= -O 63RFLAGS?= 64COMPILE.f?= ${FC} ${FFLAGS} -c 65LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} 66COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c 67LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} 68COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c 69LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} 70 71INSTALL?= install 72 73LEX?= lex 74LFLAGS?= 75LEX.l?= ${LEX} ${LFLAGS} 76 77LD?= ld 78LDFLAGS?= 79 80LINT?= lint 81LINTFLAGS?= -chapbxzF 82 83NM?= nm 84 85PC?= pc 86PFLAGS?= 87COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c 88LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} 89 90SIZE?= size 91 92YACC?= yacc 93YFLAGS?= 94YACC.y?= ${YACC} ${YFLAGS} 95 96# C 97.c: 98 ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 99.c.o: 100 ${COMPILE.c} ${.IMPSRC} 101.c.a: 102 ${COMPILE.c} ${.IMPSRC} 103 ${AR} ${ARFLAGS} $@ $*.o 104 rm -f $*.o 105.c.ln: 106 ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC} 107 108# C++ 109${CXX_SUFFIXES}: 110 ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 111${CXX_SUFFIXES:%=%.o}: 112 ${COMPILE.cc} ${.IMPSRC} 113${CXX_SUFFIXES:%=%.a}: 114 ${COMPILE.cc} ${.IMPSRC} 115 ${AR} ${ARFLAGS} $@ $*.o 116 rm -f $*.o 117 118# Fortran/Ratfor 119.f: 120 ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 121.f.o: 122 ${COMPILE.f} ${.IMPSRC} 123.f.a: 124 ${COMPILE.f} ${.IMPSRC} 125 ${AR} ${ARFLAGS} $@ $*.o 126 rm -f $*.o 127 128.F: 129 ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 130.F.o: 131 ${COMPILE.F} ${.IMPSRC} 132.F.a: 133 ${COMPILE.F} ${.IMPSRC} 134 ${AR} ${ARFLAGS} $@ $*.o 135 rm -f $*.o 136 137.r: 138 ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 139.r.o: 140 ${COMPILE.r} ${.IMPSRC} 141.r.a: 142 ${COMPILE.r} ${.IMPSRC} 143 ${AR} ${ARFLAGS} $@ $*.o 144 rm -f $*.o 145 146# Pascal 147.p: 148 ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 149.p.o: 150 ${COMPILE.p} ${.IMPSRC} 151.p.a: 152 ${COMPILE.p} ${.IMPSRC} 153 ${AR} ${ARFLAGS} $@ $*.o 154 rm -f $*.o 155 156# Assembly 157.s: 158 ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 159.s.o: 160 ${COMPILE.s} ${.IMPSRC} 161.s.a: 162 ${COMPILE.s} ${.IMPSRC} 163 ${AR} ${ARFLAGS} $@ $*.o 164 rm -f $*.o 165.S: 166 ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 167.S.o: 168 ${COMPILE.S} ${.IMPSRC} 169.S.a: 170 ${COMPILE.S} ${.IMPSRC} 171 ${AR} ${ARFLAGS} $@ $*.o 172 rm -f $*.o 173 174# Lex 175.l: 176 ${LEX.l} ${.IMPSRC} 177 ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll 178 rm -f lex.yy.c 179.l.c: 180 ${LEX.l} ${.IMPSRC} 181 mv lex.yy.c ${.TARGET} 182.l.o: 183 ${LEX.l} ${.IMPSRC} 184 ${COMPILE.c} -o ${.TARGET} lex.yy.c 185 rm -f lex.yy.c 186 187# Yacc 188.y: 189 ${YACC.y} ${.IMPSRC} 190 ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} 191 rm -f y.tab.c 192.y.c: 193 ${YACC.y} ${.IMPSRC} 194 mv y.tab.c ${.TARGET} 195.y.o: 196 ${YACC.y} ${.IMPSRC} 197 ${COMPILE.c} -o ${.TARGET} y.tab.c 198 rm -f y.tab.c 199 200# Shell 201.sh: 202 rm -f ${.TARGET} 203 cp ${.IMPSRC} ${.TARGET} 204 205