#
# GRX test programs makefile for Mingw
# Uses GNU make.
#
.SUFFIXES: .exe
.PHONY: clean install uninstall

GRXVW32=y

include ../makedefs.grx

INCDIR=  -I../include
GRX20 = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a

ifeq ($(HAVE_LIBTIFF),y)
  ADDON_LIBS += -ltiff
endif

ifeq ($(HAVE_LIBJPEG),y)
  ADDON_LIBS += -ljpeg
endif

ifeq ($(HAVE_LIBPNG),y)
  ADDON_LIBS += -lpng
endif

ifeq ($(NEED_ZLIB),y)
  ADDON_LIBS += -lz
endif

LIBS= $(GRX20) $(ADDON_LIBS)

PROGS=  arctest.exe     \
	bb1test.exe     \
	blittest.exe    \
	circtest.exe    \
	cliptest.exe    \
	colorops.exe    \
	curstest.exe    \
	fontdemo.exe    \
	fonttest.exe    \
	imgtest.exe     \
	jpgtest.exe     \
	keys.exe        \
	life.exe        \
	linetest.exe    \
	mousetst.exe    \
	pcirctst.exe    \
	pnmtest.exe     \
	pngtest.exe     \
	rgbtest.exe     \
	sbctest.exe     \
	scroltst.exe    \
	textpatt.exe    \
	winclip.exe     \
	wintest.exe

all: 	$(PROGS) \
	demogrx.exe \
	speedtst.exe \
	polytest.exe \
	memtest.exe


demogrx.exe: demogrx.o gfaz.o $(GRX20)
	$(CC) $(LDOPT) -o demogrx.exe demogrx.o gfaz.o $(LIBS) -lm -mwindows

speedtst.exe: speedtst.o $(GRX20)
	$(CC) $(LDOPT) -o speedtst.exe speedtst.o $(LIBS) -lm -mwindows -mconsole

memtest.exe: memtest.o $(GRX20)
	$(CC) $(LDOPT) -o memtest.exe memtest.o $(LIBS) -lm -mwindows -mconsole

polytest.exe: polytest.o $(GRX20)
	$(CC) $(LDOPT) -o polytest.exe polytest.o $(LIBS) -lm -mwindows -mconsole

$(PROGS): %.exe : %.o $(GRX20)
	$(CC) $(LDOPT) -o $*.exe $*.o $(LIBS) -lm -mwindows

.c.o:
	$(CC) -c $(CCOPT) $(INCDIR) $*.c -o $*.o

.c.s:
	$(CC) -S $(CCOPT) $(INCDIR) $*.c

clean:
ifeq ($(HAVE_UNIX_TOOLS),y)
	rm -f *.o *.exe
else
	if exist *.o del *.o
	if exist *.exe del *.exe
endif

depend.new:
	$(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new

include depend.gnu
