# Makefile for Astro Lib & DarkCal Program
# (this is for gnu make, which assumes gcc)
# remember that TAB chars (not spaces) are required before the cmd lines!

LIBOBJS = Astro.o AstroOps.o DateOps.o DateCalendars.o DateOpsIntl.o PlanetData.o Lunar.o Pluto.o MathOps.o RiseSet.o Vsop.o

LIB = Astro.a
DC_BASE = DarkCal
LS_BASE = LunarSummary
UT_BASE = utest

# Lose the ".exe" for linux
EXE_EXT = .exe

DC = $(DC_BASE)$(EXE_EXT)
LS = $(LS_BASE)$(EXE_EXT)
UT = $(UT_BASE)$(EXE_EXT)

CXX = x86_64-w64-mingw32-c++
AR = x86_64-w64-mingw32-ar

#DEBUG = -g
CPPFLAGS = $(DEBUG) -ffast-math
# The fast-math option allows GCC to violate some ANSI or IEEE rules and/or
# specifications in the interest of optimizing code for speed.  For example,
# it allows the compiler to assume arguments to the sqrt() function are
# non-negative numbers and that no floating-point values are NaNs.

# Bad things will happen if this assumption proves false...

#LDFLAGS = -lstdc++
#LDFLAGS = -static-libstdc++
LDFLAGS = -static

ALL_X = $(LIB) $(DC) $(UT) $(LS)

all: $(ALL_X)

clean:
	rm -f $(ALL_X) $(wildcard *.o)

$(LIBOBJS): Makefile

$(LIB) : $(LIBOBJS)
	$(AR) -r $(LIB) $(LIBOBJS)

$(DC): $(DC_BASE).o ConfigFile.o $(LIB) Makefile
	$(CXX) -o $(DC) $(DC_BASE).o ConfigFile.o $(LIB) $(LDFLAGS)

$(LS): $(LS_BASE).o $(LIB) Makefile
	$(CXX) -o $(LS) $(LS_BASE).o $(LIB) $(LDFLAGS)

$(UT): $(UT_BASE).o $(LIB) Makefile
	$(CXX) -o $(UT) $(UT_BASE).o $(LIB) $(LDFLAGS)

Astro.o: Astro.h

AstroOps.o: AstroOps.h Astro.h DateOps.h

ConfigFile.o: ConfigFile.h

$(DC_BASE).o: Astro.h AstroOps.h PlanetData.h DateOps.h RiseSet.h ConfigFile.h

DateCalendars.o : DateCalendars.h DateOps.h

DateOps.o: DateOps.h

DateOpsIntl.o: DateOps.h

PlanetData.o: PlanetData.h AstroOps.h MathOps.h Lunar.h Pluto.h Vsop.h

Lunar.o: Lunar.h LunarTerms.h DateOps.h Astro.h

Pluto.o: Pluto.h PlutoTerms.h

MathOps.o: MathOps.h Astro.h AstroOps.h

RiseSet.o: RiseSet.h Astro.h AstroOps.h PlanetData.h Vsop.h

Vsop.o: Vsop.h VsopData.cpp
