# Generic Makefile for a single executable program # Last edited on 2023-03-18 16:27:31 by stolfi PROG := exemplo SHELL := /bin/sh # Localização da biblioteca GL: GLLIB := /usr/lib # Localização das bibliotecas X11 (supõe-se que inclui ICE): X11INC := /usr/X11R6/include X11LIB := /usr/X11R6/lib ###################################################################### # "No user-serviceable parts inside!" # You should not have to change anything below this line. # Get list of source files (excluding ${PROG}.c): HFILES := ${shell shopt -s nullglob; ls *.h Makefile | egrep -v '^(junk[.]h|Makefile)$$'} CFILES := ${shell shopt -s nullglob; ls *.c Makefile | egrep -v '^(junk[.]c|${PROG}[.]c|Makefile)$$'} # Derived object files (excluding ${PROG}.o): HOFILES := ${subst .h,.ho,${HFILES}} OFILES := ${subst .c,.o,${CFILES}} # Make targets: .PHONY: \ depend \ all \ build build-prog check \ archive clean all: build # Directories to search for #include files: IFLAGS := -I. # File with dependencies between sources: DEPFILE := Deps.make # This file must be present to run "make"; # create an empty one if necessary. #--------------------------------------------------------------------- # "make depend" recreates the source dependency file ${DEPFILE}. depend: /bin/rm -f ${DEPFILE} extract_ho_deps ${IFLAGS} -I/usr/include \ ${HFILES} ${CFILES} ${PROG}.c \ | egrep -v ': /usr/include' \ > ${DEPFILE} #--------------------------------------------------------------------- # "make build" assumes that the dependencies in ${DEPFILE} # are up-to-date. build: ${HOFILES} build-prog build-prog: ${PROG} # Get OpenGL libraries is requested: ifeq "/${USEGL}" "/YES" GL_LIBRARIES := \ ${GLLIB}/libglut.so \ ${GLLIB}/libGLU.so \ ${GLLIB}/libGL.so else GL_LIBRARIES := endif # Get X11 libraries if requested: ifeq "/${USEX11}" "/YES" X11_LIBRARIES := \ ${X11LIB}/libX11.so \ ${X11LIB}/libXext.so \ ${X11LIB}/libXmu.so \ ${X11LIB}/libXt.so \ ${X11LIB}/libXi.so \ ${X11LIB}/libSM.so \ ${X11LIB}/libICE.so else X11_LIBRARIES := endif LIBRARIES := \ ${GL_LIBRARIES} \ ${X11_LIBRARIES} \ ${OTHERLIBS} CC := /usr/bin/gcc CFLAGS := \ -ggdb -O -ffloat-store -frounding-math \ -Wall -Wpointer-arith -Wmissing-prototypes \ -fpcc-struct-return LDFLAGS := \ -ggdb %.o: %.c ${CC} -c ${CFLAGS} ${EXTRACFLAGS} ${IFLAGS} $*.c %.ho: %.h ${CC} -o $*.ho -c ${CFLAGS} ${IFLAGS} -x c $*.h \ || /bin/rm -f $*.ho ${PROG}: ${PROG}.o ${OFILES} ${LIBRARIES} -rm -f ${PROG} ${CC} -o ${PROG} ${LDFLAGS} ${PROG}.o \ ${OFILES} \ ${LIBRARIES} -lm -lrt # Include specific dependencies extracted by "make depend" include ${DEPFILE} #--------------------------------------------------------------------- # "make archive" creates a tarball of sources and executable. TARGZ := ${PROG}.tgz archive: tar -cvzf ${TARGZ} \ 00-README Makefile \ ${PROG} ${PROGS} \ ${HFILES} ${CFILES} ${PROG}.c #--------------------------------------------------------------------- # "make check" runs the tests in the "tests" subdirectory. TESTDIR := tests check: ${PROG} if [[ -d ${TESTDIR} ]]; then \ ( cd ${TESTDIR} && ${MAKE} all ) ; \ else \ echo "** directory ${TESTDIR} not found" ; \ fi #--------------------------------------------------------------------- # "make clean" deletes all derived files. clean: -/bin/rm -f *.o *.ho *.a core ${PROG} if [[ -d ${TESTDIR} ]]; then ( cd ${TESTDIR} && ${MAKE} clean ) fi