# Makefile for generic C program # Last edited on 2007-04-16 21:14:16 by stolfi # Last edited on 2005-08-04 11:05:43 by rcapua PROGS := \ pre \ tab TO_CONVERT := \ matriz \ biblioteca.c \ resumo_saida \ biblioteca.h HFILES := \ sgc_lib.h HOFILES := ${subst .h,.ho,${HFILES}} LIBCFILES := \ sgc_lib.c PROGCFILES := \ ${addsuffix .c,${PROGS}} CFILES := ${LIBCFILES} ${PROGCFILES} LIBOFILES := ${subst .c,.o,${LIBCFILES}} SHELL = /bin/sh .PHONY: all build-prog clean depend install run-test all: uninstall build-all run-test install # Where to find Stolfi's includes and libraries JSPUB := /home/staff/stolfi/PUB # JSPUB := /rcapua/progs BIN := ${JSPUB}/${PLATFORM}/bin # ==================================================================== # Un-install uninstall: cd ${BIN} && rm -f ${PROGS} # ==================================================================== # Install install: cp -avu ${PROGS} ${BIN} # ==================================================================== # Cleanup clean: -/bin/rm -f *.o *.ho *.a core ${PROGS} build-all: for p in ${PROGS} ; do \ ${MAKE} PROG=$$p build-single ; \ done # ==================================================================== # Compiling, linking, building libraries JSLIB := ${JSPUB}/${PLATFORM}/lib JSINC := ${JSPUB}/include IFLAGS := \ -I. \ -I${JSINC} ######################################################################## # Sub-makefile - caller must define ${PROG} PROG := PROG.IS.UNDEFINED ifneq "/${PROG}" "/PROG.IS.UNDEFINED" CC := /usr/bin/gcc CFLAGS := \ -O -g\ -Wall -Wpointer-arith -Wmissing-prototypes \ -fpcc-struct-return -ffloat-store -frounding-math LDFLAGS := \ -lm -g LIBS := \ ${JSLIB}/libgeo.a \ ${JSLIB}/libjs.a %.o: %.c ${CC} ${CFLAGS} ${IFLAGS} -c $*.c %.ho: %.h ${CC} ${CFLAGS} ${IFLAGS} -o $*.ho -c -x c $*.h \ || /bin/rm -f $*.ho # ==================================================================== # Linking program build-single: ${PROG} ${PROG}: ${PROG}.o ${LIBOFILES} ${LIBS} ${CC} ${LDFLAGS} -o ${PROG} ${PROG}.o ${LIBOFILES} ${LIBS} -lrt -lm endif # End of ${PROG} sub-make ######################################################################## # # ==================================================================== # # Running tests # # run-test: ${PROG} # ${PROG} < testfile.dat > testfile.eps # ggv testfile.eps # ==================================================================== # Dependencies DEPFILE := Deps.make depend: /bin/rm -f ${DEPFILE} extract-ho-deps ${IFLAGS} -I/usr/include ${HFILES} ${CFILES} \ | egrep -v ': /usr/include' \ > ${DEPFILE} # Include specific dependencies extracted by "make depend" include ${DEPFILE}