#
# Adonis Project :
#  Utility TCL libraries
#  written by L. Demailly
#
# Description : Tcl <-> C binary data/struct
#               Makefile
#
# see included INSTALL file
#
# This is the oldTcl/Makefile if you have tcl7.5 you'd
# probably better stay in the directory above

RM= rm -f
AR = ar
RANLIB = ranlib

CC = gcc
#CDEBUGFLAGS = -O -g -Wmissing-prototypes -Wall -ansi -pedantic
CDEBUGFLAGS = -O -s -Wmissing-prototypes -Wall -ansi -pedantic
# Flags:
# sunos needs -DNO_MEMMOVE
# no tclx : add -DNO_TCLX
# no ltoa() : add -DNEED_LTOA
DEFINES= -D_HPUX_SOURCE -DVERIFYSTRUCT
# debugging:
#DEFINES= -DVERIFYSTRUC -DUNSET_DEBUG # -DDEBUG
# regular (faster without -DVERIFYSTRUCT)
#DEFINES= -DVERIFYSTRUCT 
#INCLPATH = -I/usr/local/include/tcl -I/usr/local/include
INCLPATH = -I/usr/local/include
#INCLPATH = -I/usr/local/adonis/include
#INCLPATH = -I/usr/include/tcl

CFLAGS = $(CDEBUGFLAGS) $(INCLPATH) $(DEFINES)
LDFLAGS= $(CFLAGS) -L/usr/local/lib
#LDFLAGS= $(CFLAGS) -L/usr/local/adonis/lib
#LDFLAGS= $(CFLAGS) -L/usr/local/lib -L/usr/local/lib/tcl

OBJSLIB =  bindata.o mathcorr.o mathfft.o applinit.o

#OBJECTS =  $(OBJSLIB) tclXAppInit.o
OBJECTS =  $(OBJSLIB) tclXAppInit.o

TCLLIBS= -ltclx -ltcl
# for tcl(x)7.5
#TCLLIBS= -ltclx -ltcl7.5

#SYSLIBS = -lm
# dynamic library loader lib -ldld needed for hpux...
SYSLIBS = -ldld -lm

TARGETS = libtclbin.a tclbintest

all: $(TARGETS)

libtclbin.a: $(OBJSLIB)
	$(RM) $@
	$(AR) r $@ $(OBJSLIB)
	$(RANLIB) $@

tclbintest: $(OBJECTS)
	$(CC) $(LDFLAGS) $(OBJECTS) $(TCLLIBS) $(SYSLIBS) -o $@

test: tclbintest
	echo "cd ../tests; source all" | ./tclbintest

check:	clean
	$(MAKE) $(OBJECTS) clean CC="gcc" CDEBUGFLAGS="-O -ansi -pedantic -Wall -Wtraditional -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Winline -fsyntax-only" DEFINES="-D_HPUX_SOURCE -DTCL_MEM_DEBUG"

clean: 
	$(RM) $(OBJECTS) core $(TARGETS) *~ #*

depend:
	makedepend $(INCLPATH) *.c

# DO NOT DELETE THIS LINE -- make depend depends on it.
