# Makefile fopr the dbf2pg-utility
# Maarten Boekhold (M.Boekhold@et.tudelft.nl) 1995

# Set this to your C-compiler
CC=gcc

# for BSDI use /usr/bin/ar rc
AR=/usr/bin/ar rcs

# Set this to whatever your compiler accepts. Nothing special is needed
#CFLAGS=-O2 -Wall
CFLAGS=-g3 -Wall

# Set this to your postgreSQL installation-path
SQLINC=-I/usr/local/pgsql/include
SQLLIBDIR=-L/usr/local/pgsql/lib
SQLLIB=-lpq

# Set this if your system needs extra libraries
#
# For Solaris use:
#EXTRALIBS=-lsocket -lnsl
EXTRALIBS=

# You should not have to change this unless your system doesn't have gzip
# or doesn't have it in the standard place (/usr/local/bin for ex.).
# Anyways, it is not needed for just a simple compile and install
RM=/bin/rm -f
GZIP=/bin/gzip
TAR=/bin/tar

VERSION=3.0


OBJS=dbf.o endian.o libdbf.a dbf2pg.o

all: dbf2pg

libdbf.a: dbf.o endian.o
	$(AR) libdbf.a dbf.o endian.o

dbf2pg: dbf2pg.o libdbf.a
	$(CC) $(CFLAGS) -L. $(SQLLIBDIR) -o $@ dbf2pg.o $(SQLLIB) \
		-ldbf $(EXTRALIBS)
	
dbf.o: dbf.c dbf.h
	$(CC) $(CFLAGS) -c -o $@ dbf.c

endian.o: endian.c
	$(CC) $(CFLAGS) -c -o $@ endian.c

dbf2pg.o: dbf2pg.c dbf.h
	$(CC) $(CFLAGS) $(DEFINES) -DVERSION=\"$(VERSION)\" $(SQLINC) -c \
		-o $@ dbf2pg.c

clean:
	$(RM) $(OBJS) dbf2pg

# the 'expand' is just for me, I use a tabstop of 4 for my editor, which
# makes lines in the README very long and ugly for people using 8, so
# I just expand them to spaces

dist:
	-expand -4 README.tab > README
	(cd .. ; $(TAR) cf dbf2pg-$(VERSION).tar dbf2pg-$(VERSION)/*.[ch] \
	dbf2pg-$(VERSION)/Makefile dbf2pg-$(VERSION)/README \
	dbf2pg-$(VERSION)/*.1 ; \
	$(GZIP) -9 dbf2pg-$(VERSION).tar)
