# Flags for the compiler to create the object files
# -g : generate output for the debugger
# -Wall: provide warnings for all suspect operations
# -c: generate a .o object file (to be combined later to create executable)
CFLAGS = -g -Wall -c

# Flags for the compiler to generate the executable program
OFLAGS = -o

# Name of the C compiler
# g++ - GNU C/C++ compiler
CC = g++

# Rules to compile each file
all: test_schema schema_gen data_gen data_rdr

# Compiles the schema.c file 
schema.o: error.h schema.h schema.c
	$(CC) $(CFLAGS) schema.c

# Compiles the predicat.c file
predicate.o: predicate.h error.h predicate.c
	$(CC) $(CFLAGS) predicate.c

# Compiles the tuple.o file
tuple.o: tuple.h tuple.c
	$(CC) $(CFLAGS) tuple.c

scan_iterator.o: tuple.h iterator.h schema.h error.h scan_iterator.c
	$(CC) $(CFLAGS) scan_iterator.c

# Compiles the data_gen.c file
data_gen.o: schema.h tuple.h data_gen.c
	$(CC) $(CFLAGS) data_gen.c

# Compiles the test_schema.c file
test_schema.o: schema.h test_schema.c
	$(CC) $(CFLAGS) test_schema.c

# Compiles the schema_gen.c file
schema_gen.o: schema.h schema_gen.c
	$(CC) $(CFLAGS) schema_gen.c

# Compiles the data_rdf.c file
data_rdr.o: data_rdr.c tuple.h schema.h error.h iterator.h scan_iterator.h
	$(CC) $(CFLAGS) data_rdr.c

# Compiles the test_schema executable program
test_schema: test_schema.o schema.o
	$(CC) test_schema.o schema.o $(OFLAGS) test_schema

# Compiles the schema_gen executable program
schema_gen: schema_gen.o
	$(CC) schema_gen.o $(OFLAGS) schema_gen

# Compiles the data_gen executable program 
data_gen: schema.o data_gen.o
	$(CC) data_gen.o schema.o $(OFLAGS) data_gen

# Compiles the data_rdr executable program
data_rdr: data_rdr.o schema.o predicate.o scan_iterator.o tuple.o
	$(CC) data_rdr.o schema.o predicate.o scan_iterator.o tuple.o \
	$(OFLAGS) data_rdr

clean:
	/bin/rm -rf *.o

delete:
	/bin/rm -rf *.o *~ schema_gen test_schema data_gen data_rdr
