##################################################################################
## THOR Basic++                                                     		##
## A free Basic for the Atari 8 Bit series               			##
## (c) 2015 THOR Software, Thomas Richter                           		##
## This is based on Atari Basic, as developed by				##
## Paul Laughton and Kathleen O'Brien, Shepardson Microsystems			##
## as found in: The Atari BASIC SOURCE BOOK	by Bill Wilkinson		##
## Compute! Publications (1983)							##
## THOR Os									##
## A free operating system for the Atari 8 bit series				##
## (c) 2003 THOR Software, Thomas Richter					##
## $Id: makefile,v 1.12 2015/09/07 07:39:41 thor Exp $				##
##										##
## Makefile for this project							##
##################################################################################

.PHONY:		all clean

MAKEILE		=	makefile
ASM		=	ca65
AFLAGS		=	-W1 -g --cpu 6502 -I../osrom -t atari
RM		=	rm
LN		=	ld65
BASCONFIG	=	basic.conf
LNFLAGS		=	--dbgfile basic.debug
ECHO		=	echo
CC		=	cc
DIR		=	basic++/


SOURCES		=	basicmain basicparser basicexecution basicexpression basicoperators basicstatements \
			basicmath basicio basicstack basicmemory basicerror \
			syntax statementvector operatorvector constants vectors
HEADER		=	basicmain basicparser basicexecution basicexpression basicoperators basicstatements \
			basicmath basicio basicstack basicmemory basicerror \
			syntax statementvector operatorvector vectors constants basicmacros

BASOBJECTS	=	$(foreach file,$(SOURCES),$(file).o)
INCLUDES	=	$(foreach file,$(HEADER),$(file).i)
BASASM		=	$(foreach file,$(SOURCES),$(file).asm)

all	:	basdist

%.o	: 	%.asm %.i
	@ $(ECHO) "Assembling" $*.asm
	@ $(ASM) $(AFLAGS) $*.asm -o $*.o

basdist	:	$(BASOBJECTS) $(INCLUDES) $(BASCONFIG)
	@ $(ECHO) "Linking..."
	@ $(LN) $(LNFLAGS) -C $(BASCONFIG) $(BASOBJECTS) -o basdist

clean	:
	@ $(RM) -f *.o *.dump basdist basic++.tgz

distrib:	basic++.tgz

basic++.tgz:
	@ make clean
	cd .. && tar -czf $(DIR)basic++.tgz $(DIR)*.asm $(DIR)*.i $(DIR)makefile $(DIR)README $(DIR)*.conf

