# Last edited on 2007-07-11 21:56:16 by stolfi
# Makefile for libimg - an old set of image hacks

LIBNAME := libimg

include ../GENERIC-LIB.make

# Location of Stolfi's libraries
INC := ${HOME}/PUB/include
LIB := ${HOME}/PUB/${PLATFORM}/lib

HFILES := \
  frgb.h \
  float_image.h \
  float_pnm_image.h \
  float_pnm_image_buffer.h \
  float_image_geostereo.h \
  float_image_transform.h \
  float_image_trim.h \
  frgb_image.h \
  frgb_ops.h \
  frgb_path.h \
  frgb_inksep.h \
  yuvhacks.h \
  colorfield.h \
  colorfield_unif.h \
  colorfield_ramp.h \
  colorfield_wavy.h
  
HFILES_BUG := \
  colorfield_poly.h \
  float_image_align.h
  
CFILES := \
  frgb.c \
  float_image.c \
  float_pnm_image.c \
  float_pnm_image_buffer.c \
  float_image_geostereo.c \
  float_image_transform.c \
  float_image_trim.c \
  frgb_image.c \
  frgb_ops.c \
  frgb_path.c \
  frgb_inksep.c \
  yuvhacks.c \
  colorfield.c \
  colorfield_unif.c \
  colorfield_ramp.c \
  colorfield_wavy.c
  
CFILES_BUG := \
  colorfield_poly.c \
  float_image_align.c

HOFILES := ${subst .h,.ho,${HFILES}}

OFILES := ${subst .c,.o,${CFILES}}

LIBFILE = \
  ${LIBNAME}.a

.PHONY: all uninstall install check clean depend

# all: uninstall clean build install
all: uninstall build install
# all: build

uninstall:
	( cd ${INC} && rm -f ${HFILES} ${HOFILES} )
	( cd ${LIB} && rm -f ${LIBFILE} )

install: ${HFILES} ${HOFILES} ${LIBFILE}
	cp -p ${HFILES} ${INC}
	cp ${HOFILES} ${INC}
	cp -p ${LIBFILE} ${LIB}
  
build: ${LIBFILE}

check:
	cd tests && ${MAKE} all

clean:
	-/bin/rm -f *.o *.ho *.a core
  
IFLAGS := -I. -I${INC}

CFLAGS := \
  -ggdb -ffloat-store -frounding-math \
  -Wall  -Wpointer-arith -Wmissing-prototypes

%.o: %.c ;\
  /usr/bin/gcc -c ${CFLAGS} ${IFLAGS} ${IFLAGS} $*.c
  
%.ho: %.h ;\
  /usr/bin/gcc -o $*.ho -c ${CFLAGS} ${IFLAGS} ${IFLAGS} -x c $*.h \
  || /bin/rm -f $*.ho
  
${LIBFILE}: ${OFILES} ;\
  rm -f $*.a && ar crv $*.a ${OFILES} && ranlib $*.a

# ====================================================================
# 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}
