# macros --------------------------------------------------------------------
CC = gcc
LD = gcc
CFLAGS	= -m64 -Wall -Wextra -Wabi -pedantic -O3 -fomit-frame-pointer -funroll-loops -mmmx -msse -msse2 \
			-fmerge-all-constants -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-sm -fgcse-las \
			-funsafe-loop-optimizations -fsched-pressure -fsched-spec-load -fsched-spec-load-dangerous \
			-fsched-stalled-insns=0 -fsched-stalled-insns-dep -fsched2-use-superblocks -fipa-pta -fipa-matrix-reorg \
			-ftree-loop-linear -floop-interchange -floop-strip-mine -floop-block -fgraphite-identity -floop-parallelize-all \
			-fcheck-data-deps -ftree-loop-distribution -ftree-loop-im -ftree-loop-ivcanon -fivopts -fvect-cost-model \
			-fvariable-expansion-in-unroller -ffast-math -fbranch-target-load-optimize -fno-enforce-eh-specs \
			-fno-nonansi-builtins -fno-threadsafe-statics -msahf -maccumulate-outgoing-args \
			-fno-rtti -fno-exceptions -freorder-blocks-and-partition -fwhole-program -flto
LDFLAGS	= -m64 -s -static -static-libgcc -fwhole-program -flto
LIBS	= -mconsole

STRIP	= strip

OBJS =	obj/pngacidbath.o

# These will rebuild the entire project upon edit.
DEPS =	Makefile \
		src/version.h

# dependencies --------------------------------------------------------------
all: ./pngacidbath.exe

$(OBJS): $(DEPS)

# make rules ----------------------------------------------------------------
./pngacidbath.exe: $(OBJS)
	$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
	strip -s -g --strip-unneeded -x -X -v $@

./obj/%.o: ./src/%.cpp
	@echo $@
	@$(CC) -c $(CFLAGS) -std=c++0x -o $@ $<

clean:
	del /Q /S "pngacidbath.exe" obj