# $Id: /mirror/trunk/languages/cola/config/makefiles/root.in 28688 2008-06-23T00:33:41.905243Z coke  $

# Makefile for languages/cola

# Set up commands
PERL          = @perl@
RM_F          = @rm_f@
CHMOD         = @chmod@
CC            = @cc@
DEBUG         = @cc_debug@
YACC          = @yacc@
LEX           = @lex@
RECONFIGURE   = $(PERL) @build_dir@/tools/dev/reconfigure.pl
#CONDITIONED_LINE(darwin):
#CONDITIONED_LINE(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
#CONDITIONED_LINE(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@

# Set up extensions
O             = @o@
EXE           = @exe@

# Set up directories
BUILD_DIR     = @build_dir@

# Libraries:  Ordinarily, no special libraries are needed
# for cola, but one of the following settings might be helpful
# in some cases.
# Use the same libraries as Parrot:
# LIBS = @libs@
# You might need these for some versions of flex and/or yacc:
# LIBS = -ll -ly
# Ordinarily, no special libraries are needed for cola.
LIBS    =

# These manual settings might be helpful in some situations.
# Visual C++
# CC = cl
#
# GCC
# CC = gcc -Wall -pedantic
#
# GCC with Electric Fence
# CC = gcc -efence -Wall -pedantic
# LIBS = -lefence

HEADERS = cola.h parser.h

default :
	$(MAKE) colacc$(EXE)
	-$(CHMOD) 775 colacc$(EXE)

help :
	@echo ""
	@echo "Following targets are available for the user:"
	@echo ""
	@echo "  default  :         build 'colacc'"
	@echo "                     This is the default."
	@echo ""
	@echo "  test:              run the test suite"
	@echo ""
	@echo "  clean:             clean up temporary files"
	@echo ""
	@echo "  realclean:         clean up generated files"
	@echo ""
	@echo "  superclean:       clean up generated files, also the flex/bison files"
	@echo ""
	@echo "  help:              print this help message"

# regenerate the Makefile
Makefile: config/makefiles/root.in
	cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=cola

nogen : gen$(O) semant$(O) sym$(O) type$(O)
	$(CC) $(DEBUG) -c parser.c
	$(CC) $(DEBUG) -c lexer.c
	$(CC) $(DEBUG) -o colacc$(EXE) parser$(O) lexer$(O) gen$(O) semant$(O) sym$(O) type$(O) $(LIBS)

clean :
	$(RM_F) \
  core \
  "*.obj" "*.pdb" "*.ilk" \
  "*$(O)" \
  parser.output \
  colacc$(EXE) \
  a.pir a.pbc a.pasm

realclean: clean
	$(RM_F) Makefile

# Don't run this target unless you have bison and flex installed.
# These programs are needed for regenerating the removed files.
superclean: realclean
	$(RM_F) parser.h
	$(RM_F) lexer.c parser.c

publish :
	$(PERL) publish.pl < MANIFEST

dist :
	$(PERL) distribution.pl < MANIFEST

parser.c : cola.y
	$(YACC) -d -o parser.c cola.y

lexer.c : cola.l $(HEADERS)
	$(LEX) cola.l

lexer$(O) : lexer.c $(HEADERS)
	$(CC) $(DEBUG) -c lexer.c

parser$(O) : parser.c $(HEADERS)
	$(CC) $(DEBUG) -c parser.c

semant$(O) : semant.c $(HEADERS)
	$(CC) $(DEBUG) -c semant.c

sym$(O) : sym.c $(HEADERS)
	$(CC) $(DEBUG) -c sym.c

type$(O) : type.c $(HEADERS)
	$(CC) $(DEBUG) -c type.c

gen$(O) : gen.c $(HEADERS)
	$(CC) $(DEBUG) -c gen.c

colacc$(EXE) : parser$(O) lexer$(O) gen$(O) semant$(O) sym$(O) type$(O)
	$(CC) $(DEBUG) -o colacc$(EXE) parser$(O) lexer$(O) gen$(O) semant$(O) sym$(O) type$(O) $(LIBS)

test: default
	cd .. && $(PERL) t/harness --languages=cola

