# ----------------------------------------------------------------------------
# - Makefile                                                                 -
# - aleph engine makefile                                                    -
# ----------------------------------------------------------------------------
# - This program is  free software;  you can  redistribute it and/or  modify -
# - it provided that this copyright notice is kept intact.                   -
# -                                                                          -
# - This  program  is  distributed in the hope  that it  will be useful, but -
# - without  any   warranty;  without  even   the   implied    warranty   of -
# - merchantability  or fitness for a particular purpose. In not event shall -
# - the copyright holder be  liable for  any direct, indirect, incidental or -
# - special damages arising in any way out of the use of this software.      -
# ----------------------------------------------------------------------------
# - copyright (c) 1999-2000 amaury darsch                                    -
# ----------------------------------------------------------------------------

TOPDIR		= ../..
CNFDIR		= $(TOPDIR)/cnf
SITEFILE	= $(CNFDIR)/site.mak
RULEFILE	= $(CNFDIR)/rule.mak
include		  $(SITEFILE)

# ----------------------------------------------------------------------------
# source file generation                                                     -
# ----------------------------------------------------------------------------

ARLIB		= $(AENGLIB)
SOLIB		= $(ARLIB:.a=.so)
TARGET		= $(ARLIB) $(SOLIB)
INCLUDE		= -I. -I$(ASTDINC)

HPPSRCS		= $(wildcard *.hpp)
CPPSRCS		= If.cpp        \
		  For.cpp       \
		  Meta.cpp      \
		  Eval.cpp      \
		  Token.cpp     \
		  Lexer.cpp     \
		  Block.cpp     \
		  While.cpp     \
		  Class.cpp     \
		  Throw.cpp     \
		  Reader.cpp    \
		  Interp.cpp    \
		  Symbol.cpp    \
		  Lambda.cpp    \
		  Switch.cpp    \
		  Return.cpp    \
		  Closure.cpp   \
		  Binding.cpp   \
		  Lexical.cpp   \
		  Printer.cpp   \
		  Nameset.cpp   \
		  Logical.cpp   \
		  Reserved.cpp  \
		  Instance.cpp  \
		  Argument.cpp  \
		  Function.cpp  \
		  Localset.cpp  \
		  Operator.cpp  \
		  Predicate.cpp \
		  Globalset.cpp \
		  Qualified.cpp

# ----------------------------------------------------------------------------
# - project rules                                                            -
# ----------------------------------------------------------------------------

# rule: all
# this rule is the default rule which call the build rule

all: build
	@$(MKDIR) $(AENGINC)
	@for i in *.hpp; do \
	   $(CMP) $$i $(AENGINC)/$$i || $(CP) $$i $(AENGINC)/$$i; \
	 done
.PHONY: all

# include: rule.mak
# this rule includes the platform dependant rules

include $(RULEFILE)

# rule: build
# build the standard object library (libastd)

build: $(TARGET)
.PHONY: build

# rule: libaeng.a
# build the library archive

$(ARLIB): $(OBJECTS)
	$(AR) $@ $(OBJECTS)
	@$(MKDIR) $(LIBREL)
	@$(CP) $@ $(LIBREL)

# rule: libaeng.so
# build the library archive

$(SOLIB).$(SOFILE): $(OBJECTS)
	$(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBASTD)
	@$(MKDIR) $(LIBREL)
	@$(CP) $@ $(LIBREL)

# rule: install
# install the libraries and include files

install: installlib
	@$(MKDIR)         $(INCDIR)
	@$(CP) $(HPPSRCS) $(INCDIR)
.PHONY:install
