# -*- coding: utf-8 -*-
#Compiler
MKOCTFILE?=mkoctfile
#Common warning flags for C and C++
FLAGSCOMW=-Wall -Wextra -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings
#Common optimization flags for C and C++
FLAGSCOMO=-O3 -funroll-loops -fno-common -fshort-enums
#Flags for C
CFLAGS+=-std=c99 -pedantic $(FLAGSCOMW) -Wconversion -Wmissing-prototypes
CFLAGS+=-Wstrict-prototypes -Wnested-externs $(FLAGSCOMO)
#Flags for C++
CXXFLAGS+=$(FLAGSCOMW) $(FLAGSCOMO)
#Flags for the linker
LDFLAGS+=-lproj
#Export flags for compilers and linker
export CFLAGS CXXFLAGS

.PHONY: all
all: compile

.PHONY: compile
compile:
	$(MKOCTFILE) -c projwrap.c -o projwrap.o
	$(MKOCTFILE) -c geodgeoc.c -o geodgeoc.o
	$(MKOCTFILE) -s _op_fwd.cc projwrap.o $(LDFLAGS)
	$(MKOCTFILE) -s _op_inv.cc projwrap.o $(LDFLAGS)
	$(MKOCTFILE) -s _op_transform.cc projwrap.o $(LDFLAGS)
	$(MKOCTFILE) -s _op_geod2geoc.cc geodgeoc.o
	$(MKOCTFILE) -s _op_geoc2geod.cc geodgeoc.o

.PHONY: clean
clean:
	rm -rf *.o

.PHONY: cleanall
cleanall:
	rm -rf *~ *.o *.oct
