# SWIG support # # Contributed by: # "Peter J. MASON" # # Not independently tested. .PHONY : install-swig #.PHONY : install-swig.target #install-swig :: install-swig.target # Make sure we can find SWIG input files # vpath %.i $(SRCDIR) $(SRCDIRS) # Allow user to specify SWIG binary location # ifeq "$(origin SWIG)" "undefined" SWIG := swig endif # Stop redundant makeit checks on SWIG input files # %.i : # List makeit subdirectory and current directory in include search path # ifeq "$(filter -I.,$(CPPFLAGS))" "" override CPPFLAGS += -I. endif ifeq "$(filter -I./$(MK),$(CPPFLAGS))" "" override CPPFLAGS += -I./$(MK) endif # Process options and form commandline args # SWIG_OPTIONS include "python", "shadow", "c++" # ifeq "$(origin SWIG_FLAGS)" "undefined" SWIG_FLAGS := endif ifneq "$(filter python,$(SWIG_OPTIONS))" "" override REQUIRE += python SWIG_FLAGS += -python # Build up the shared object name # If "shadow" specified then name has 'c' in the middle # _swig_SHLIB := $(LIBRARY) ifneq "$(filter shadow,$(SWIG_OPTIONS))" "" override _swig_SHADOW := YES SWIG_FLAGS += -shadow _swig_SHLIB := $(addsuffix c,$(_swig_SHLIB)) endif _swig_SHLIB := $(addsuffix module,$(_swig_SHLIB)) endif ifneq "$(filter c++,$(SWIG_OPTIONS))" "" override REQUIRE += cc SWIG_FLAGS += -c++ endif # Module name is taken from LIBRARY variable supplied to us, # SWIG_FLAGS += -module $(LIBRARY) # Calculate language src # _swig_real_SRC := $(filter-out $(EXCLUDE),$(filter %.i,$(SRCFILES))) _swig_generated_SRC := $(filter-out $(EXCLUDE), \ $(addprefix $(MK)/,$(_swig_generated_SRC))) # Generate stems for src # _swig_real_SRC_STEMS := $(basename $(_swig_real_SRC)) _swig_generated_SRC_STEMS := $(notdir $(basename $(_swig_generated_SRC))) # Let C/C++ module know about generated src files # _cc_generated_SRC += $(addsuffix _wrap.cc, \ $(_swig_real_SRC_STEMS) $(_swig_generated_SRC_STEMS)) $(MK)/$(LIBRARY)_wrap.cc \ $(MK)/$(LIBRARY).py : $(LIBRARY).i $(SWIG) $(SWIG_FLAGS) -o $@ $< # Setup library by different name # $(LIBDIR)/$(_swig_SHLIB)$(SHLEXT) : $(RM) $@ ln -s lib$(LIBRARY)$(SHLEXT) $@ $(LIBDIR)/$(LIBRARY).py : $(MK)/$(LIBRARY).py $(INSTALL.LIB) $(MK)/$(LIBRARY).py $@ #install-lib.always :: install-swig #install-swig :: install-swig.target #install-swig.target :: $(LIBDIR)/$(_swig_SHLIB)$(SHLEXT) $(LIBDIR)/$(LIBRARY).py install : install-swig install-swig :: install-lib install-swig :: $(LIBDIR)/$(_swig_SHLIB)$(SHLEXT) $(LIBDIR)/$(LIBRARY).py