CC = @CC@
CXX=

CFLAGS = -g -O2
PARTIAL_CFLAGS = -gnata -I../gnat -I../common -I../gvd \
  -aO../obj -aO../common/obj $(CFLAGS) 
ALL_CFLAGS = -i @GTK_CFLAGS@ $(PARTIAL_CFLAGS) 
LINK_FLAGS = @GTK_LIBS@ @TARGET_LFLAGS@ \
  ../common/obj/libgvd_common.a ../obj/libgvd.a

all: parse parse_c test_parse test_parse_c
full_all: all test_canvas test_expect import_export task1 infinite input choice test_mdi aliasing structural

# Do the following only if a c++ compiler was found
ifneq (${CXX},)
all: parse_cpp test_parse_cpp template

parse_cpp: parse_cpp.cc parse_cpp_f.cc
	${CXX} -g -o $@ parse_cpp.cc parse_cpp_f.cc

template: template.cc
	${CXX} -g -o $@ template.cc

test_parse_cpp: parse_cpp force
	gnatmake -m test_parse_cpp $(ALL_CFLAGS) -largs $(LINK_FLAGS)
endif

static:

parse: force
	gnatmake -g -O0 parse

parse_c: parse_c.c
	$(CC) -g -o $@ $<

structural: structural.adb
	gnatmake -g structural

aliasing: aliasing.c
	$(CC) -g -o $@ $<

test_canvas: force
	gnatmake -m test_canvas $(ALL_CFLAGS) -largs $(LINK_FLAGS)

updating: force
	gnatmake -g -O0 updating

test_expect: force
	gnatmake test_expect $(PARTIAL_CFLAGS) -largs \
	../common/obj/libgvd_common.a @TARGET_LFLAGS@

test_parse: parse force
	gnatmake -m test_parse $(ALL_CFLAGS) -largs $(LINK_FLAGS)

test_parse_c: parse_c force
	gnatmake -m test_parse_c $(ALL_CFLAGS) -largs $(LINK_FLAGS)

test_history: force
	gnatmake -m test_history $(ALL_CFLAGS) -largs $(LINK_FLAGS)

test_mdi: force
	gnatmake -g test_mdi $(ALL_CFLAGS) -largs $(LINK_FLAGS)

infinite: force
	gnatmake -m infinite $(ALL_CFLAGS)

input: force
	gnatmake -g input

choice: force
	gnatmake -g choice

task1: task1.adb
	gnatmake -g task1

import_export: exported.ads imported.c import_export.adb 
	gcc -c -g imported.c
	gnatmake -g import_export -largs imported.o

install:

clean:
	-$(RM) *.o
	-$(RM) *.ali
	-$(RM) *~
	-$(RM) b~*
	-$(RM) parse parse_c parse_cpp test_canvas test_expect test_exported
	-$(RM) test_parse test_parse_c test_parse_cpp task1 tasking
	-${RM} infinite

mostlyclean: clean

distclean: mostlyclean
	-$(RM) Makefile

maintainer-clean: distclean

force:
