#               Unix Makefile for Bywater BASIC Interpreter

##---------------------------------------------------------------##
## NOTE: Modifications marked "JBV" were made by Jon B. Volkoff, ##
## 11/1995 (eidetics@cerf.net).                                  ##
##---------------------------------------------------------------##

srcdir = @srcdir@
VPATH = @srcdir@

CC = @CC@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

DEFS = @DEFS@

# Revised by JBV
#CFLAGS = -O
CFLAGS = -g -ansi

# Revised by JBV
#LDFLAGS = -s

prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin

SHELL = /bin/sh

CFILES=         bwbasic.c bwb_int.c bwb_tbl.c bwb_cmd.c bwb_prn.c\
                bwb_exp.c bwb_var.c bwb_inp.c bwb_fnc.c bwb_cnd.c\
                bwb_ops.c bwb_dio.c bwb_str.c bwb_elx.c bwb_mth.c\
		bwb_stc.c bwb_par.c bwx_tty.c

OFILES=         bwbasic.o bwb_int.o bwb_tbl.o bwb_cmd.o bwb_prn.o\
                bwb_exp.o bwb_var.o bwb_inp.o bwb_fnc.o bwb_cnd.o\
                bwb_ops.o bwb_dio.o bwb_str.o bwb_elx.o bwb_mth.o\
		bwb_stc.o bwb_par.o bwx_tty.o
 
HFILES=         bwbasic.h bwb_mes.h bwx_tty.h
 
MISCFILES=	COPYING INSTALL Makefile.in README bwbasic.doc\
		bwbasic.mak configure.in configure makefile.qcl\
		bwb_tcc.c bwx_iqc.c bwx_iqc.h

TESTFILES=	\
	abs.bas	      assign.bas    callfunc.bas  callsub.bas	chain1.bas\
	chain2.bas    dataread.bas  deffn.bas	  dim.bas	doloop.bas\
	dowhile.bas   elseif.bas    end.bas	  err.bas	fncallfn.bas\
	fornext.bas   function.bas  gosub.bas	  gotolabl.bas	ifline.bas\
	index.txt     input.bas	    lof.bas	  loopuntl.bas	main.bas\
	mlifthen.bas  on.bas	    onerr.bas	  onerrlbl.bas	ongosub.bas\
	opentest.bas  option.bas    putget.bas	  random.bas	selcase.bas\
	snglfunc.bas  stop.bas	    term.bas	  whilwend.bas	width.bas\
	writeinp.bas  pascaltr.bas

DISTFILES=	$(CFILES) $(HFILES) $(MISCFILES)

# Revised by JBV
#all: bwbasic
all: bwbasic renum

bwbasic:	$(OFILES)
		$(CC) $(OFILES) -lm -o $@ $(LDFLAGS)

# Added by JBV
renum:
	$(CC) renum.c -o renum

$(OFILES):      $(HFILES)

.c.o:
	$(CC) -c $(CPPFLAGS) -I$(srcdir) $(DEFS) $(CFLAGS) $<

install: all
	$(INSTALL_PROGRAM) bwbasic $(bindir)/bwbasic
	$(INSTALL_PROGRAM) renum $(bindir)/renum

uninstall:
	rm -f $(bindir)/bwbasic $(bindir)/renum

Makefile: Makefile.in config.status
	$(SHELL) config.status
config.status: configure
	$(SHELL) config.status --recheck
configure: configure.in
	cd $(srcdir); autoconf

TAGS:	$(CFILES)
	etags $(CFILES)

clean:
	rm -f *.o bwbasic renum core

mostlyclean: clean

distclean: clean
	rm -f Makefile config.status

realclean: distclean
	rm -f TAGS

# Version number changed from 2.10 to 2.20 by JBV
dist: $(DISTFILES)
	echo bwbasic-2.20 > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(DISTFILES) `cat .fname`
	mkdir `cat .fname`/bwbtest
	cd bwbtest; ln $(TESTFILES) ../`cat ../.fname`/bwbtest
	tar czhf `cat .fname`.tar.gz `cat .fname`
	rm -rf `cat .fname` .fname

# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
