#
#
#

prefix=..
exec_prefix=../../compiler
g_includes=-I/usr/local/include
g_libraries=-L/usr/lib

CCX=gcc
#COB=${exec_prefix}/htcobol
COB=htcobol
ASM=as
RM=rm -f

COPYBOOKS= -I../copybooks -I.
INCLUDES= -I/usr/local/include
LIBS=${g_libraries} -L../../lib -lhtcobol -ldb -ldl -lm
LDFLAGS=
#COBFLAGS=-P -g -D -t ${COPYBOOKS}
COBFLAGS=-P ${COPYBOOKS}
ASMFLAGS=-D
CCXFLAGS=-g ${INCLUDES}

SRC1 = test15.cob 
SRC2 = test15a.cob
SRC3 = test15b.c
SRC4 = test15d.c 
SRC5 = test15a.cob
SRC6 = test15e.cob
SRC7 = test15f.c
SRC8 = test15g.cob
SRC9 = test15h.cob
SRC10 = test15i.cob
SRC11 = test15j.cob
SRC12 = test15k.cob
SRC13 = test15l.c

OBJS1 = $(SRC1:.cob=.o) $(SRC2:.cob=.o) $(SRC3:.c=.o)
OBJS2 = $(SRC4:.c=.o) $(SRC5:.cob=.o)
OBJS3 = $(SRC6:.cob=.o) $(SRC7:.c=.o)
OBJS4 = $(SRC8:.cob=.o) $(SRC9:.cob=.o)
OBJS5 = $(SRC10:.cob=.o) $(SRC11:.cob=.o) $(SRC7:.c=.o)
OBJS6 = $(SRC12:.cob=.o) $(SRC13:.c=.o)

PROG1 = test15
PROG2 = test15d
PROG3 = test15e
PROG4 = test15g
PROG5 = test15i
PROG6 = test15k
PROGS = $(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5) $(PROG6)


include ${prefix}/config/C.rules.in
include ${prefix}/config/COB.rules.in
include ${prefix}/config/COB.build.tmpl.in

all: ${PROGS}

${PROG1}: ${OBJS1}
	$(CCX) -g -o $@ ${OBJS1} $(LDFLAGS) $(LIBS)
#	strip $@

${PROG2}: ${OBJS2}
	$(CCX) -g -o $@ ${OBJS2} $(LDFLAGS) $(LIBS)
#	strip $@

${PROG3}: ${OBJS3}
	$(CCX) -g -o $@ ${OBJS3} $(LDFLAGS) $(LIBS)
#	strip $@

${PROG4}: ${OBJS4}
	$(CCX) -g -o $@ ${OBJS4} $(LDFLAGS) $(LIBS)
#	strip $@

${PROG5}: ${OBJS5}
	$(CCX) -g -o $@ ${OBJS5} $(LDFLAGS) $(LIBS)
#	strip $@

${PROG6}: ${OBJS6}
	$(CCX) -g -o $@ ${OBJS6} $(LDFLAGS) $(LIBS)
#	strip $@


clean:
	@${RM} ${OBJS1} $(PROG1) $(PROG1)*lis ${PROG1}*txt ${PROG1}*s \
	${OBJS2} $(PROG2) $(PROG2)*lis ${PROG2}*txt ${PROG2}*s \
	${OBJS3} $(PROG3) $(PROG3)*lis ${PROG3}*txt ${PROG3}*s \
	${OBJS4} $(PROG4) $(PROG4)*lis ${PROG4}*txt ${PROG4}*s \
	${OBJS5} $(PROG5) $(PROG5)*lis ${PROG5}*txt ${PROG5}*s \
	${OBJS6} $(PROG6) $(PROG6)*lis ${PROG6}*txt ${PROG6}*s \
	core *run.err.trace.txt *run.trace.txt temp*cob \
	*.lis *.s *.trace.txt *.i
