SHELL = /bin/sh
@SET_MAKE@

.SUFFIXES:
.SUFFIXES: .c .o .ads .adb .ali

.PHONY:
.PHONY: clean-generic mostlyclean-generic \
	clean distclean mostlyclean maintainer-clean \
	force

target  = testgtk
src_dir = ../src
opengl_dir = $(src_dir)/opengl

CC = @CC@
GTKADA_CONFIG=gtkada-config
GNATFLAGS = @CFLAGS@ -gnata -gnatws
GNATFLAGS_DEVEL = @CFLAGS@ -g -gnatawu
TARGET_LFLAGS = @TARGET_LFLAGS@

GNATMAKE = gnatmake
GNATMAKELDFLAGS = -largs -L$(src_dir) -L$(opengl_dir) -lgtkada @GTK_LIBS@ \
		  $(TARGET_LFLAGS)

CP = cp -f

## This variable should be set to "True" if the opengl directories
## have been installed on the system.
HAVE_OPENGL=@HAVE_OPENGL@

ifeq ($(HAVE_OPENGL),True)
OPENGL_C_OBJECTS=lw.o
OPENGL_LIBS= @GL_LIBS@
else
OPENGL_C_OBJECTS=
OPENGL_LIBS=
endif

all: opengl/view_gl.adb $(OPENGL_C_OBJECTS) $(target) 

$(target)::
	@echo "-------------------------------------"
	@echo $(GNATMAKE) $(GNATFLAGS) $(target) '`'$(GTKADA_CONFIG)'`'
	@echo "-------------------------------------"
	@if [ -f $(src_dir)/.devel ]; then \
	   $(GNATMAKE) $(GNATFLAGS_DEVEL) $(target) -I$(src_dir) -I$(src_dir)/opengl -Iopengl -aO$(src_dir)/lib-obj -largs $(GNATMAKELDFLAGS) $(OPENGL_C_OBJECTS) $(OPENGL_LIBS); \
	else \
	   $(GNATMAKE) $(GNATFLAGS) $(target) -I$(src_dir) -I$(src_dir)/opengl -Iopengl -largs $(GNATMAKELDFLAGS) $(OPENGL_C_OBJECTS) $(OPENGL_LIBS); \
	fi

opengl/view_gl.adb:: opengl/view_gl.gpb Makefile
	gnatprep -r -c -DHAVE_GL=$(HAVE_OPENGL) -DWIN32=False \
	  opengl/view_gl.gpb opengl/view_gl.adb

lw.o: opengl/lw.c opengl/lw.h
	$(CC) -c opengl/lw.c -Iopengl @GTK_CFLAGS@

install: all
	@echo "Nothing to do --  just run the ./testgtk program"

clean:
	-${RM} *.o *.ali *~ testgtk b_testgtk.c b~testgtk.ad? core
	-${RM} opengl/view_gl.adb
	-${RM} .\#*

distclean: clean
	-${RM} Makefile

mostlyclean: clean
	-${RM} Makefile

maintainer-clean: clean
	-${RM} Makefile

force:

