
#
# Erlang Makefile 
#
# Requires gnumake
# 
# $Id: Makefile,v 1.43 2002/07/22 13:36:54 geoff Exp $
#
# $Source: /home/cvs/gerl/src/Makefile,v $
# $Revision: 1.43 $
# $Date: 2002/07/22 13:36:54 $
# $State: Exp $
#
# Author: Geoff Wong
# Copyright (C) 1996, 1997, 1998, 1999, 2000 Geoff Wong
# geoff@cs.rmit.edu.au
#

include ../gerl.mk

#
#
# Libs
#

SHLIBS=-L../lib -lerl

#
# The compiler source code
#

SRC = erlang.cc \
	erl_lex.cc \
    binary.cc \
	case.cc \
    define.cc \
	elist.cc \
	expr.cc \
	main.cc \
	basic.cc \
    catch.cc \
    error.cc \
	farity.cc \
	form.cc \
	guard.cc \
	function.cc \
	if.cc \
    list_comp.cc \
    namer.cc \
	match.cc \
	node.cc \
	pattern.cc \
    pragma.cc \
	program.cc \
	receive.cc \
    record.cc \
	str.cc \
	symbol.cc \
    unary.cc \
    tuple.cc \
    typestr.cc 

#
# `Shell' source code
#

SHSRC = gerl.cc erlangshell.cc namer.cc mangle.cc str.cc

#
# Define the object code
#

OBJ := $(SRC:%.cc=$(OBJPATH)/%.o)
SHOBJ := $(SHSRC:%.cc=$(OBJPATH)/%.o)

# Header files.

HDRS := $(shell echo *.h)

first: .depend
	$(MAKE) all

all: driver gerl

driver: $(OBJ)
	$(CXX) -o driver -g $(OBJ) $(DEFS) $(SHLIBS) $(LIBS)

gerl: $(SHOBJ)
	$(CXX) -o gerl -g -O $(SHOBJ) $(INCLUDE) $(SHLIBS) $(LIBS)

install: driver gerl
	mv driver ../bin
	mv gerl ../bin/gerl_runtime
	
tags: $(SRC)
	ctags $(SRC) 

clean:
	rm $(OBJ) $(SHOBJ)

veryclean:
	-rm driver gerl $(OBJ) $(SHOBJ)
	(cd erlib; make veryclean; cd ..)


# Depend stuff below (do not change!)
.depend: $(SRC) $(SHSRC) erlang.cc erl_lex.cc
	$(CXX) -MM $(SRC) $(INCLUDE) > .depend.tmp
	sed -e "s+^.*:+$(OBJPATH)/&+" .depend.tmp > .xdepend

.PHONY: 

-include .xdepend

erlang.cc: erlang.y
	$(YACC) -d -v erlang.y
	mv y.tab.c erlang.cc

erl_lex.cc: erlang.l
	lex erlang.l
	mv lex.yy.c erl_lex.cc

