# uncomment this to enable the console
CONSOLE=-mconsole
#CONSOLE=

#PROF=-pg
PROF=

OPT=-O3

CFLAGS=-mwindows -D_FORTIFY_SOURCE=2 -fstack-protector $(PROF) $(OPT) $(IFLAGS) -m64 -msse -malign-double -mfpmath=sse
#CFLAGS=

all: ../ninox.exe ../videoshow.exe ../sercat.exe

version:
	perl increment.pl version.h
	perl makecommands.pl
	touch util.c

.c.o:
	gcc $(CFLAGS) -c $<

OBJ=stack.o usage.o globals.o scale.o fileio.o debayer.o \
	align.o process.o quality.o commands.o morphing.o subsample.o \
	hotpixels.o util.o tables.o streamfilter.o rotate.o gaincomp.o fft.o \
	fftutil.o transpose.o font.o display.o keyboard.o switches.o globals.o \
	ftacompress.o darkframe.o memory.o logfile.o

ninox.o: ninox.c version
	gcc $(CFLAGS) -c ninox.c

videoshow.o: videoshow.c version
	gcc $(CFLAGS) -c videoshow.c

sercat.o: sercat.c version
	gcc $(CFLAGS) -c sercat.c

../ninox.exe: version $(OBJ) ninox.o
	-rm nlib.a
	ar cqv nlib.a $(OBJ)
	gcc $(OPT) $(PROF) $(CONSOLE) -o ../ninox.exe ninox.o nlib.a -lSDL2 -lm -lz

../videoshow.exe: version nlib.a videoshow.o
	gcc $(OPT) $(PROF) $(CONSOLE) -o ../videoshow.exe videoshow.o nlib.a -lSDL2 -lm -lz

../sercat.exe: version nlib.a sercat.o
	gcc $(OPT) $(PROF) $(CONSOLE) -o ../sercat.exe sercat.o nlib.a -lSDL2 -lm -lz

clean:
	rm -f $(OBJ) ninox.o videoshow.o nlib.a
