#
# GRX test programs makefile for LINUX/console. Uses GNU make.
#
.PHONY : clean setsuid

GRXVLNX=y

include  ../makedefs.grx

INCDIR=  -I../include

CCOPT += -pipe

# Enable this line for static linked test progs (default)
GRX20 = ../lib/$(GRX_LIB_SUBDIR)/libgrx20.a
# or this if you've already installed the shared libs
#GRX20 = -L../lib/$(GRX_LIB_SUBDIR) -lgrx20

ifeq ($(SET_SUIDROOT),y)
EXECBITS = 4755
else
EXECBITS = 0755
endif

ADDON_LIBS =

ifeq ($(USE_SVGALIB_DRIVER),y)
  ADDON_LIBS += -lvga
endif

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) -lm

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

all:    $(PROGS) demogrx

demogrx: demogrx.o gfaz.o $(GRX20)
	$(CC) $(LDOPT) -o demogrx demogrx.o gfaz.o $(LIBS)
	chmod $(EXECBITS) demogrx

$(PROGS): % : %.o $(GRX20)

clean:
	rm -f *.o $(PROGS) demogrx

setsuid: $(PROGS) demogrx
ifeq ($(SET_SUIDROOT),y)
	chown root $(PROGS) demogrx
	chmod $(EXECBITS) $(PROGS) demogrx
else
	@echo "Nothing to do, SET_SUIDROOT is not set to 'y' in makedefs.grx"
endif

.o:
	$(CC) $(LDOPT) -o $* $*.o $(LIBS)
	chmod $(EXECBITS) $*

.oo:
	$(CC) $(LDOPT) -o $* $*.o $(LIBS)
	$(STRIP) $*

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

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

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

include depend.gnu
