# Copyright (c) 2005-2008 Andre Merzky (andre@merzky.net) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # # Now, this is probably not the right way to do it (tm), but it saves us fom # a major restructuring of the source tree, again. # # saga-lite is a shared library which contains # - the saga engine # - all available packages # - all available adaptors # that whole bunch is linked into one giant shared lib. So, we use the static # engine lib, the static package libs, etc. # # Actually, we do _not_ really use the engine lib, as we want to replace # engine.o with a version which knows about the available adaptors (which are # only available after the engine built, as the dynamic adaptors link against # the engine itself: thats the sole reason for this hack in the first place). # # So, we fetch the engine.cpp source, recompile it with a special define which # uses the now available dynamic adaptor list (which gets created by this very # makefile on the fly, btw), then link this, all other engine objects, the packges, # and the adaptors into our libsaga_lite. SAGA_ROOT = ../ ADAPTOR_DATA_IN = static_adaptor_data.hpp.in ADAPTOR_DATA = dynamic_adaptor_data.hpp ADAPTOR_LIST = dynamic_adaptor.list CSAD_SRC = create_static_adaptor_data.cpp CSAD_OBJ = create_static_adaptor_data.o CSAD_BIN = create_static_adaptor_data MY_ENGINE_SRC = engine.cpp MY_ENGINE_PRE = engine.ii MY_ENGINE_OBJ = engine.o LITE_SRC = $(wildcard $(SAGA_ROOT)/saga/impl/engine/*.cpp) SAGA_LIB_OBJ := $(filter-out $(SAGA_ROOT)/saga/impl/engine/engine.o,$(LITE_SRC:%.cpp=%.o)) SAGA_LIB_OBJ += $(MY_ENGINE_OBJ) SAGA_OBJ = $(CSAD_OBJ) ENGINE_ORIG_SRC = $(SAGA_ROOT)/saga/impl/engine/engine.cpp SAGA_LIB = saga-lite SAGA_USE_STATIC_LIBS = yes USE_LIBS = 1 ifndef USE_LIBS SAGA_ADD_LIB_OBJ += $(wildcard $(SAGA_ROOT)/saga/saga/packages/*/adaptors/*.o) SAGA_ADD_LIB_OBJ += $(wildcard $(SAGA_ROOT)/saga/saga/packages/*/*.o) SAGA_ADD_LIB_OBJ += $(wildcard $(SAGA_ROOT)/saga/impl/packages/*/*.o) SAGA_ADD_LIB_OBJ += $(wildcard $(SAGA_ROOT)/adaptors/*/*/*.o) # SAGA_ADD_LIB_OBJ := $(filter-out %task_get_result.o,$(SAGA_S_LIBS)) endif include $(SAGA_ROOT)/saga/impl/engine/engine.objs.mk include $(SAGA_ROOT)/make/saga.mk # get all external adaptor dependencies SAGA_ADD_MAKE_INCLUDE = $(wildcard $(SAGA_ROOT)/adaptors/*/config/saga.config.*.c.mk) ifneq "x$(SAGA_ADD_MAKE_INCLUDE)" "x" include $(SAGA_ADD_MAKE_INCLUDE) $(warning SAGA_ADD_MAKE_INCLUDE: $(SAGA_LDFLAGS_EXT)) endif # only clean in this directory SAGA_CLEAN_TGT = $(SAGA_LIBNAME) $(SAGA_ARCNAME) $(MY_ENGINE_OBJ) $(CSAD_OBJ) $(CSAD_BIN) $(ADAPTOR_DATA) # needed by the engine rebuild SAGA_CPPDEFS += -DBUILD_SAGA_LITE=1 -DSAGA_HAVE_DYNAMIC_ADAPTOR_DATA=1 SAGA_CPPINCS += -I$(SAGA_PWD) # add packages and adaptors ifdef USE_LIBS SAGA_S_LIBS += $(wildcard $(SAGA_ROOT)/saga/impl/packages/*/libsaga_package_*.a) SAGA_S_LIBS += $(wildcard $(SAGA_ROOT)/adaptors/*/*/libsaga_adaptor*.a) endif clean:: @$(RM) $(ADAPTOR_DATA) $(CSAD_BIN) engine.cpp all:: lite $(CSAD_BIN): $(CSAD_OBJ) @$(ECHO) " binlinking $(CSAD_BIN)" @$(SAGA_LD) -o $@ $< $(ADAPTOR_DATA): $(CSAD_BIN) @$(ECHO) " creating dynamic adaptor data" @$(SAGA_ROOT)/config/saga-run.sh $(SAGA_PWD)/$(CSAD_BIN) \ $(SAGA_ROOT)/config/$(ADAPTOR_LIST) \ $(SAGA_ROOT)/lite/$(ADAPTOR_DATA_IN) \ $(SAGA_ROOT)/lite/$(ADAPTOR_DATA) $(MY_ENGINE_SRC): $(ENGINE_ORIG_SRC) @$(ECHO) " copying engine sources" @$(CP) $(ENGINE_ORIG_SRC) $(SAGA_PWD) $(MY_ENGINE_PRE): $(ADAPTOR_DATA) .PHONY: lite lite: $(SAGA_ARC_NAME) $(SAGA_ARC_NAME):: $(MY_ENGINE_OBJ) @$(ECHO) " building saga-lite : $(SAGA_LIB_OBJ)" @$(ECHO) " building saga-lite : $(SAGA_LDFLAGS)" p: @echo MY_ENGINE_SRC: $(ENGINE_ORIG_SRC)