# makefile for gmlObject
# 2007-09-24 - [rb] creation


dylib = libgmlobject.so

sources = general/gml_DynamicArray_I.cpp \
          general/gml_Errors.cpp \
          general/gml_List.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_Class.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_Entity.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_gmlObject.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_Method.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_Obj_Init.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_Obj_LibInit.cpp \
          tclBindings/gmlTcl_Object/gmlTcl_Object.cpp

src_path = src
dst_path = build

objects = $(addprefix $(dst_path)/, $(sources:.cpp=.o))

dirs = $(sort $(dir $(sources)))
dst_dirs = $(addprefix $(dst_path)/, $(dirs))
src_dirs = $(addprefix $(src_path)/, $(dirs))


tcl_path = /Library/Frameworks/Tcl.framework/Versions/Current/PrivateHeaders \
           $(src_path)/generic


# compilation flags ##########################################################

CPPFLAGS = -ansi -pedantic -Wall -O3 
CPPFLAGS += -DNO_CONST=1 -DUSE_NON_CONST=1
CPPFLAGS += -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk

CXXFLAGS += $(patsubst %,-I%, $(tcl_path) $(src_dirs))

VPATH = $(src_path)

LDFLAGS = -dynamiclib
LDLIBS = -framework Tcl


# targets ####################################################################

.PHONY: all clean test

all: $(dst_dirs) $(dylib)

$(dst_dirs):
	mkdir -p $@
	
$(dylib): $(objects)
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@
	
clean:
	-rm -rf $(dst_path)
	-rm -f $(dylib)

$(dst_path)/%.o : %.cpp
	$(COMPILE.cpp) $(OUTPUT_OPTION) $<

test: all
	@echo "load $(dylib); method Class test {} { puts \"seems ok\" }; Class instance; instance test" | tclsh


# dependencies ###############################################################
  
$(objects): makefile
