# Makefile fopr the dbf2msql-utility
# Maarten Boekhold (boekhold@cindy.et.tudelft.nl) 1995

# Set this to your C-compiler
CC=gcc

# set this to your install-program (what does Solaris have
# in /usr/sbin/install? SYSV install?)
INSTALL=/usr/sbin/install

AR=/usr/bin/ar

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

# Set this to your Minerva (mSQL) installation-path
MSQLINC=-I/usr/local/Minerva/include
MSQLLIB=-L/usr/local/Minerva/lib

# Set this to where you want the binary (no man-page yet, don't know
# how to write them)
INSTALLDIR=/usr/local/bin

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

OBJS=dbf.o endian.o libdbf.a dbf2msql.o msql2dbf.o

all: dbf2msql msql2dbf

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

dbf2msql: dbf2msql.o libdbf.a
	$(CC) $(CFLAGS) -s -L. $(MSQLLIB) -o $@ dbf2msql.o -lmsql -ldbf \
		$(EXTRALIBS)
	
msql2dbf: msql2dbf.o libdbf.a
	$(CC) $(CFLAGS) -s -L. $(MSQLLIB) -o $@ msql2dbf.o -lmsql -ldbf \
		$(EXTRALIBS)

dbf.o: dbf.c dbf.h
	$(CC) $(CFLAGS) -c -o $@ dbf.c

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

dbf2msql.o: dbf2msql.c dbf.h
	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" $(MSQLINC) -c -o $@ dbf2msql.c

msql2dbf.o: msql2dbf.c dbf.h
	$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" $(MSQLINC) -c -o $@ msql2dbf.c

install: dbf2msql
	$(INSTALL) -f $(INSTALLDIR) -m 0775 dbf2msql
	$(INSTALL) -f $(INSTALLDIR) -m 0755 msql2dbf

clean:
	$(RM) $(OBJS) dbf2msql

# 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 dbf2msql-$(VERSION).tar dbf2msql-$(VERSION)/*.[ch] \
	dbf2msql-$(VERSION)/Makefile dbf2msql-$(VERSION)/README ; \
	$(GZIP) -9 dbf2msql-$(VERSION).tar)
