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

GRXVLNX=y

include  ../makedefs.grx

INCDIR=  -I../include

CCOPT +=

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

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

ADDON_LIBS =

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

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

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

ifeq ($(NEED_LIBRT),y)
  ADDON_LIBS += -lrt
endif

LIBS= $(MGRX) $(ADDON_LIBS) -lm

PROGS=	arctest     \
	bb1test     \
	blittest    \
	circtest    \
	cliptest    \
	colorops    \
	curstest    \
	fontdemo    \
	fonttest    \
	gradtest    \
	jpgtest     \
	keys        \
	life        \
	life_db     \
	linetest    \
	memtest     \
	mousetst    \
	patrtest    \
	pcirctst    \
	pixmtest    \
	pnmtest     \
	pngtest     \
	polytest    \
	polytedb    \
	rgbtest     \
	sbctest     \
	scroltst    \
	speedtst    \
	textpatt    \
	winclip     \
	wintest     \
	biggtest    \
	cusptest    \
	clrtable    \
	i18ntest    \
	wrsztest

all:    $(PROGS) demomgrx demointl

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

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

$(PROGS): % : %.o

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

setsuid: $(PROGS) demomgrx demointl
ifeq ($(SET_SUIDROOT),y)
	chown root $(PROGS) demomgrx demointl
	chmod $(EXECBITS) $(PROGS) demomgrx demointl
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
