# Generic Makefile for a single executable program # Last edited on 2023-03-18 16:27:40 by stolfi # PROG := ex_ini PROG := ex_yuv # TEST := frupq TEST := arara IN_NAME := data/${TEST} OT_NAME := out/${TEST} # LUM := 0.299 0.587 0.114 LUM := 0.319 0.567 0.114 SHELL := /bin/bash # 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 # Make targets: .PHONY: all run show all: build run show #--------------------------------------------------------------------- # Comandos para executar o programa e mostrar os resultados: run: ${PROG} ${IN_NAME}.ppm /bin/rm -f ${OT_NAME}/*.ppm ${OT_NAME}/*.pgm ${PROG} ${IN_NAME} ${OT_NAME} show: ${OT_NAME}-YVA.ppm display -title '%f' 0-TEST-GAMMA-*.pgm 0-TEST-LUM.ppm ${IN_NAME}.ppm ${OT_NAME}*.p?m #====================================================================== # "NO USER-SERVICEABLE PARTS INSIDE" # (You should not have to change anything below this line) .PHONY: \ depend \ build build-prog check \ archive clean #--------------------------------------------------------------------- # General declarations # 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}} # 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: depend ${PROG} # Get OpenGL libraries is requested: ifeq "/${USE_GL}" "/YES" GL_LIBRARIES := \ ${GLLIB}/libglut.so \ ${GLLIB}/libGLU.so \ ${GLLIB}/libGL.so else GL_LIBRARIES := endif # Get X11 libraries if requested: ifeq "/${USE_X11}" "/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