CC=clang++
CFLAGS=-c -DNDEBUG -O3 -target x86_64-w64-windows-msvc -Wall -Wno-sign-compare -m64 -march=native -std=c++17 -Isrc -Isrc/general -Isrc/learning
LDFLAGS=-static -Wall
SOURCES=$(wildcard src/general/*.cc src/*.cc)
OBJECTS=$(SOURCES:.cc=.o)
EXECUTABLE:=Winter.exe

all: $(SOURCES) $(EXECUTABLE)

target no_bmi: CFLAGS += -DNO_BMI
no_bmi: all

target ancient: CFLAGS=-c -DNDEBUG -O3 -target x86_64-w64-windows-msvc -Wall -Wno-sign-compare -m64 -DNO_BMI -std=c++17 -Isrc -Isrc/general -Isrc/learning
target ancient: LDFLAGS=-Wall -static
ancient: all

target older: CFLAGS=-c -DNDEBUG -O3 -target x86_64-w64-windows-msvc -Wall -Wno-sign-compare -m64 -msse4.1 -DNO_BMI -std=c++17 -Isrc -Isrc/general -Isrc/learning
target older: LDFLAGS=-Wall -static
older: all

target old: CFLAGS=-c -DNDEBUG -O3 -target x86_64-w64-windows-msvc -Wall -Wno-sign-compare -m64 -msse4.2 -DNO_BMI -std=c++17 -Isrc -Isrc/general -Isrc/learning
target old: LDFLAGS=-Wall -static
old: all

target new: CFLAGS=-c -DNDEBUG -O3 -target x86_64-w64-windows-msvc -Wall -Wno-sign-compare -m64 -mavx2 -mbmi -mbmi2 -std=c++17 -Isrc -Isrc/general -Isrc/learning
target new: LDFLAGS=-Wall -static
new: all

$(EXECUTABLE): $(OBJECTS) 
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cc.o:
	$(CC) $(CFLAGS) $< -o $@

clean: clean-src clean-general clean-learning

clean-src:
	rm src/*.o
	
clean-general:
	rm src/general/*.o
	
clean-learning:
	rm src/learning/*.o
