#/****************************************************
# Programmierpraktikum WISE 24 - Compilation targets
#****************************************************/

INCDIR    = ..
DRIVERDIR = ../driver
# Add your header files
HEADERS   = $(INCDIR)/server.h

# Add your source files 
SRC = server.c
DRIVER_UNIT = $(DRIVERDIR)/unittests.c
DRIVER_BENCHMARK = $(DRIVERDIR)/speed_test.c

INCLUDE   = -I. -I$(INCDIR)
DSYS      = BSD42
COMPILER = gcc
DVERSION  =
CFLAGS = -O3 -Wall -mmmx -fPIC -combine
LDFLAGS= -lpthread -W
MINFLAGS = -O3 -mmmx -fPIC -lpthread -combine
MAXFLAGS_UBUNTU = -O3 -fPIC -lpthread
MAXFLAGS = -O3 -fPIC -lpthread -combine

harness_test: $(HEADERS)  
	$(COMPILER) $(MAXFLAGS_UBUNTU) $(INCLUDE) $(DRIVER_BENCHMARK) $(SRC) -o speed_test $(LDFLAGS)

unit_test: $(HEADERS)
	$(COMPILER) $(MAXFLAGS_UBUNTU) $(INCLUDE) $(DRIVER_UNIT) $(SRC) -o unit_test $(LDFLAGS)

all: unit_test harness_test
	
test: all
  ifeq ($(OS),Windows_NT)
	  ./unit_test.exe
	  ./speed_test.exe
  else #Linux
	  ./unit_test
	  ./speed_test
  endif

clean:
	- rm -f *.o *.so *.dyn XServer_* *.gcno *.gcda *.results *.exe
	- rm -f unit_test speed_test