CXXFLAGS = -g -march=native -std=c++17 -Wall -pedantic -fopenmp -O3 -Wno-ignored-attributes -pthread

all: spir_test0 spir_test1

spir_test1.o:
	g++ -O3 -Wall   -c -o spir_test1.o spir_test.cpp -DPARTY=1

spir_test0.o:
	g++ -O3 -Wall   -c -o spir_test0.o spir_test.cpp -DPARTY=0

spir_test0: spir_test0.o libspir_cxx.a
	g++ -o $@ $^  -DPARTY=0 -lpthread -ldl

spir_test1: spir_test1.o libspir_cxx.a
	g++ -o $@ $^  -DPARTY=1  -lpthread -ldl

libspir_cxx.a: spir.o ../target/release/libspiral_spir.a
	cp ../target/release/libspiral_spir.a $@
	ar r $@ $<

../target/release/libspiral_spir.a: $(wildcard ../src/*.rs)
	RUSTFLAGS="-C target-cpu=native" cargo build --release

clean:
	-rm -f libspir_cxx.a spir.o spir_test.o spir_test0 spir_test1 spir_test1.o spir_test0.o
