############################################################

include makefile.env
include mkflags
include mk.inf

############################################################
.SUFFIXES: .o .C .c  .cpp

C++FLAGS = $(DEBUG) $(ARCH)

.c.o:
	$(CC1) $(ALL_INCLUDES) $(C++FLAGS) -c $(*F).c  -o $*.o

.C.o:
	$(CC) $(ALL_INCLUDES) $(C++FLAGS) -c $(*F).C   -o $*.o

.cpp.o:
	$(CC) $(ALL_INCLUDES) $(C++FLAGS) -c $(*F).cpp -o $*.o


all: $(TARGET).out

$(TARGET).f:
	cp $(WSDIR)/sys/data/sample.f $(TARGET).f

$(TARGET).out: $(OBJS) $(TARGET).f
	@if [ x$(WSDIR) = x ]; then \
		set -x; \
		$(CC) $(C++FLAGS) -o $(TARGET).out $(OBJS) $(ALL_LIBS2) $(EXTLIB); \
	else \
		set -x; \
		$(CC) $(C++FLAGS) -o $(TARGET).out $(OBJS) $(ALL_LIBS) $(EXTLIB); \
	fi
	/lib/cpp -I$(BD)/appl/dbox -DPCAT -P $(TARGET).f $(TARGET).fsn.tmp
	$(BD)/etc/databox -l -n $(TARGET).fsn.tmp $(TARGET).fsn
	rm -f $(TARGET).fsn.tmp
	cp	$(TARGET).out _t
	$(BD)/tool/gnu/i386-unknown-gnu/bin/strip --strip-unneeded _t
	$(BD)/etc/mkbtf -o$(TARGET).bz -a0x8003 -c -t$(TARGET) -f0x40 9.0x163._t 7.0x1000.$(TARGET).fsn
	rm -f _t
	$(BD)/tool/gnu/i386-unknown-gnu/bin/nm -n $(TARGET).out > $(TARGET).map
	
clean:
	rm -f $(TARGET).out *.o log.txt $(TARGET).fsn $(TARGET).bz


