# SHSQL
# 

CC = gcc
CFLAGS = -DSHSQL -Wall
BIN = ../bin

SQLOBJ = shsqlconfig.o api.o sqlcom.o sqldel.o sqlins.o sqlsel.o sqlupd.o indexlook.o \
	tablelock.o recordlock.o sequence.o general.o

TDOBJ = condex.o err.o fieldmap.o glroutines.o tdhkit.o value_subst.o variable.o value.o containswords.o

# Note: shsql requires its own copy of certain TDH files such as condex.c and tdhkit.c
# Other TDH files are present in this directory by way of soft links, for convenience in distributing
# the software.

default: libshsql  shsql  shsql_join  shsql_create shsql_alter tabmaint buildix tabdef shsql_fldsel tabo catofs dataedit dbcat 


# LIBSHSQL - shsql API library
libshsql: $(SQLOBJ) $(TDOBJ)
	rm -rf ../lib/libshsql.a
	ar r ../lib/libshsql.a $(SQLOBJ) $(TDOBJ)

# TEST1 - 
test1:	test1.o  $(SQLOBJ) $(TDOBJ)
	$(CC) test1.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/test1

# SIMPLE - example shsql program
simple:	simple.o $(SQLOBJ) $(TDOBJ)
	$(CC) simple.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/simple

# CTEST1 - another example shsql program
ctest1: ctest1.o $(SQLOBJ) $(TDOBJ)
	$(CC) ctest1.o $(SQLOBJ) $(TDOBJ) -o ../sqlexampledb/testruns/ctest1

# SHSQL - command line SQL tool
shsql:	shsql.o $(SQLOBJ) $(TDOBJ)
	$(CC) shsql.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/shsql

# SHSQL_JOIN - join tool invoked by shsql - generally never invoked directly
shsql_join: shsql_join.o $(SQLOBJ) $(TDOBJ)
	$(CC) shsql_join.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/shsql_join

# SHSQL_CREATE - executive for creating databases, tables, and indexes
shsql_create: shsql_create.o $(SQLOBJ) $(TDOBJ)
	$(CC) shsql_create.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/shsql_create

# SHSQL_ALTER - executive for implementing ALTER
shsql_alter: shsql_alter.o $(SQLOBJ) $(TDOBJ)
	$(CC) shsql_alter.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/shsql_alter

# TABMAINT - executive for packing tables and updating indexes
tabmaint: tabmaint.o $(SQLOBJ) $(TDOBJ)
	$(CC) tabmaint.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/tabmaint

# BUILDIX - actually build index files
buildix: buildix.o $(SQLOBJ) $(TDOBJ) 
	$(CC) buildix.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/buildix

# TABDEF - display fields (columns) for a table
tabdef: tabdef.o $(SQLOBJ) $(TDOBJ)
	$(CC) tabdef.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/tabdef

# DBCAT - cat a shsql data table 
dbcat: dbcat.o $(SQLOBJ) $(TDOBJ)
	$(CC) dbcat.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/dbcat

# DATAEDIT - wrapper for invoking text editor on data table file
dataedit: dataedit.o $(SQLOBJ) $(TDOBJ)
	$(CC) dataedit.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/dataedit

# SHSQL_FLDSEL - select fields - this needs to be kept separate from tdh fldsel
shsql_fldsel: fldsel.o $(SQLOBJ) $(TDOBJ)
	$(CC) fldsel.o $(SQLOBJ) $(TDOBJ) -o $(BIN)/shsql_fldsel

# TABO - nice outputter
tabo: tabo.o glroutines.o
	$(CC) tabo.o glroutines.o -o $(BIN)/tabo

# CATOFS - view files w/ begining line byte location 
catofs: catofs.o
	$(CC) catofs.o -o $(BIN)/catofs

clean:
	rm -rf *.o 
