# ----------------------------------------------------------------------------
# - Makefile                                                                 -
# - aleph standard object library 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		= $(ASTDLIB)
SOLIB		= $(ARLIB:.a=.so)
TARGET		= $(ARLIB) $(SOLIB)
INCLUDE		= -I. -I$(ASYSINC)

HPPSRCS		= $(wildcard *.hpp)

CPPSRCS		= Real.cpp         \
		  Cons.cpp         \
		  List.cpp         \
		  Queue.cpp        \
		  Stack.cpp        \
		  Input.cpp        \
		  Object.cpp       \
		  String.cpp       \
		  Strvec.cpp       \
		  Vector.cpp       \
		  Buffer.cpp       \
		  System.cpp       \
		  Output.cpp       \
		  Method.cpp       \
		  Library.cpp      \
		  Integer.cpp      \
		  Boolean.cpp      \
		  Iterator.cpp     \
		  Terminal.cpp     \
		  Character.cpp    \
		  HashTable.cpp    \
		  NameTable.cpp    \
		  Exception.cpp    \
		  InputTerm.cpp    \
		  InputFile.cpp    \
		  OutputTerm.cpp   \
		  OutputFile.cpp   \
		  InputString.cpp  \
		  OutputString.cpp

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

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

all: build
.PHONY: all

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

include $(RULEFILE)

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

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

# rule: libastd.a
# build the library archive

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

# rule: libastd.so
# build the library shared library

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

# rule: install
# install the libraries and include files

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