# $Id: gmakefile,v 1.24 2005/11/05 02:06:14 phil Exp $

# (GNU) Makefile for test programs under Unix/X11 and Win32
#
# Unix:
#       edit Unix defs to fit your compiler/library environment, then
#       gmake -f gmakefile
# or if GNU make is the default:
#       make -f gmakefile
#
# OS X (Carbon)
#       make -f gmakefile OSX=1
#
# Win32 (Cygwin)
#       make -f gmakefile WIN32=1
#
# Win32 (MINGW):
#       mingw32-make -f gmakefile WIN32=1

DISP_DEFS=-DTEST_DIS=DIS_VR48 -DTEST_RES=RES_HALF # -DDEBUG_VT11

ifeq ($(WIN32),)
ifeq ($(OSX),)
#Unix environments
X11BASE=/usr/X11R6
X11LIBDIR=$(X11BASE)/lib
X11INCDIR=$(X11BASE)/include
LIBS=-L$(X11LIBDIR) -lXt -lX11 -lm
OSFLAGS=-I$(X11INCDIR)
DRIVER=x11.o
EXT=
else
DRIVER=carbon.o
LIBS=-framework Carbon
endif
else
#Win32 environments
LIBS=-lgdi32
OSFLAGS=
DRIVER=win32.o
EXT=.exe
endif

#PROF=-g # -pg
OPT=-O2
CFLAGS=$(OPT) $(PROF) $(OSFLAGS) $(DISP_DEFS)
CC=gcc -Wunused
LDFLAGS=$(PROF)

ALL=    munch$(EXT) vt11$(EXT)
ALL:    $(ALL)

# munching squares; see README file for
# how to use console switches

MUNCH=$(DRIVER) xy.o test.o
munch$(EXT): $(MUNCH)
        $(CC) $(LDFLAGS) -o munch$(EXT) $(MUNCH) $(LIBS)

VT11=$(DRIVER) vt11.o vttest.o xy.o
vt11$(EXT): $(VT11)
        $(CC) $(LDFLAGS) -o vt11$(EXT) $(VT11) $(LIBS)

xy.o: xy.h ws.h
vt11.o: xy.h vt11.h
x11.o: ws.h xy.h
carbon.o: ws.h
win32.o: ws.h
test.o: xy.h vt11.h
vttest.o: xy.h vt11.h vtmacs.h

clean:
ifeq ($(WIN32),)
        rm -f *.o *~ .#*
else
        if exist *.o del /q *.o
        if exist *~ del /q *~
        if exist .#* del /q .#*
endif

clobber: clean
ifeq ($(WIN32),)
        rm -f $(ALL)
else
        if exist *.exe del /q *.exe
endif