MODULES = ../modules/
OBJECTS = ../modules/
OPT     = -O3 -Wall -I. -I$(MODULES) 
LINKOPT = -lm
PROG1 = cbga
PROG2 = cbpnn
PROG3 = cbcross

DEPENDS1 = $(OBJECTS)cb.o $(OBJECTS)sa.o $(OBJECTS)memctrl.o $(OBJECTS)random.o $(OBJECTS)interfc.o $(OBJECTS)file.o $(OBJECTS)sortcb.o $(OBJECTS)sort.o $(OBJECTS)solution.o $(OBJECTS)heap.o $(OBJECTS)stack.o $(OBJECTS)pnn.o

DEPENDS2 = $(OBJECTS)cb.o $(OBJECTS)sa.o $(OBJECTS)memctrl.o $(OBJECTS)random.o $(OBJECTS)interfc.o $(OBJECTS)file.o $(OBJECTS)sortcb.o $(OBJECTS)sort.o $(OBJECTS)solution.o $(OBJECTS)heap.o $(OBJECTS)stack.o pnnfast.o

DEPENDS3 = $(OBJECTS)cb.o $(OBJECTS)memctrl.o $(OBJECTS)random.o $(OBJECTS)file.o $(OBJECTS)interfc.o $(OBJECTS)sortcb.o $(OBJECTS)sort.o $(OBJECTS)solution.o cross.o pnnfast.o 

all: $(PROG1) 
#$(PROG2)
#$(PROG3)   

# Genetic algorithm - CBGA
$(PROG1): $(PROG1).o $(DEPENDS1) 
	gcc -o $(PROG1) $(LINKOPT) $(PROG1).o $(DEPENDS1) 
$(PROG1).o: $(PROG1).c
	gcc $(OPT) -c $(PROG1).c -o $(PROG1).o

# Fast exact PNN - CBPNNF 
$(PROG2): $(PROG2).o $(DEPENDS2) 
	gcc -o $(PROG2) $(OPT) $(PROG2).o $(DEPENDS2) 
$(PROG2).o: $(PROG2).c
	gcc $(OPT) -c $(PROG2).c -o $(PROG2).o

# Crossover for GA - CBCROSS 
$(PROG3): $(PROG3).o $(DEPENDS3) 
	gcc -o $(PROG3) $(OPT) $(PROG3).o $(DEPENDS3)
$(PROG3).o: $(PROG3).c
	gcc $(OPT) -c $(PROG3).c -o $(PROG3).o

# Modules 
%.o: %.c
	gcc $(OPT) -c $< -o $@

$(OBJECTS)%.o: $(MODULES)%.c
	gcc $(OPT) -c $< -o $@

clean: 
	rm *.o $(PROG1) $(MODULES)*.o
