# Last edited on 2007-01-03 23:41:38 by stolfi

LIBNAME = libjs

HFILES := \
  bool.h \
  sign.h \
  nat.h \
  affirm.h \
  jsstring.h \
  jsmath.h \
  jstime.h \
  jsrandom.h \
  jsfile.h \
  js.h \
  vec.h \
  interval.h \
  set32.h \
  box.h \
  ioprotos.h \
  timefunc.h \
  fget.h \
  nget.h \
  filefmt.h \
  intheap.h \
  intmerge_extra.h \
  intsort.h \
  intsort_extra.h \
  tbfind.h \
  argparser.h \
  indexing.h

CFILES := \
  affirm.c \
  bool.c \
  nat.c \
  jsstring.c \
  jsmath.c \
  jstime.c \
  jsrandom.c \
  jsfile.c \
  js.c \
  vec.c \
  interval.c \
  set32.c \
  box.c \
  timefunc.c \
  fget.c \
  nget.c \
  filefmt.c \
  intheap.c \
  intmerge.c \
  intmerge_extra.c \
  intsort_ins.c \
  intsort_bins.c \
  intsort_heap.c \
  intsort_merge.c \
  intsort_extra.c \
  tbfind.c \
  argparser.c \
  indexing.c
  
HOFILES := ${subst .h,.ho,${HFILES}}
OFILES := ${subst .c,.o,${CFILES}}

LIBFILE := \
  ${LIBNAME}.a
  
.PHONY: all clean uninstall install check

# all: clean uninstall install
# all: clean uninstall install check
# all: uninstall install check
all: uninstall install

# ====================================================================
# Compiling, linking, building libraries

INC = ${HOME}/PUB/include
LIB = ${HOME}/PUB/${PLATFORM}/lib

CC := /usr/bin/gcc 

IFLAGS := \
  -I. -I${INC}

CFLAGS := \
  -ggdb \
  -Wall -Wpointer-arith -Wmissing-prototypes

%.o: %.c 
	${CC} ${CFLAGS} ${IFLAGS} -o $@ -c $<

%.ho: %.h 
	${CC} ${CFLAGS} ${IFLAGS} -o $@ -c -x c $<   || /bin/rm -f $@
  
${LIBFILE}: ${OFILES}
	rm -f $*.a && ar crv $*.a ${OFILES} && ranlib $*.a

# ====================================================================
# Installing and uninstalling in the export directories:

install: ${HOFILES} ${LIBFILE}
	cp -p ${HFILES} ${INC}
	cp ${HOFILES} ${INC}
	cp -p ${LIBFILE} ${LIB}
  
uninstall:
	cd ${INC} && /bin/rm -f ${HFILES} ${HOFILES}
	cd ${LIB} && /bin/rm -f ${LIBFILE}

# ====================================================================
# Cleanup:

clean:
	-/bin/rm -f *.o *.ho *.a core
	cd tests && make clean

# ====================================================================
# Running the tests:

check:
	cd tests && make all

# ====================================================================
# Dependencies:

DEPFILE := Deps.make

depend: 
	/bin/rm -f ${DEPFILE}
	extract-ho-deps ${IFLAGS} -I/usr/include ${HFILES} ${CFILES} \
          | egrep -v ': /usr/include' \
          > ${DEPFILE}
	cd tests && make depend

# Include specific dependencies extracted by "make depend"
include ${DEPFILE}
  
  
