## @configure_input@ ## ## @file Makefile.in ## @brief Makefile template for libSBML Python bindings ## @author Mike Hucka ## @author Akija Jouraku ## ## # ----------------------------------------------------------------------------- # Configuration variables # ----------------------------------------------------------------------------- # Some of the following are substituted automatically by `configure'. If # you are looking at "Makefile", do not edit these values; instead, run the # configure script at the top level of the src tree. It will recreate # "Makefile". include @top_srcdir@/config/makefile-common-vars.mk # `srcdir' points to the current directory, but should be set by configure. # `subdir' must be set manually to the relative dir under srcdir. Don't # set `subdir' to an absolute path, or some make actions will fail. srcdir = @srcdir@ thisdir = src/bindings/python # In the normal core C++/C libSBML code, `sources' are used by the default # rules to determine what needs to be compiled. In these language # bindings, the variable is not used by default rules, and everything is # handled explicitly below. However, to maintain some resemblance to the # other libSBML build organization, we still use the name `sources'. sources = libsbml.py libsbml_wrap.cpp libsbml_wrap.h extra_sources = libsbml.i \ libsbml-doxygen.py \ local.cpp \ local.i \ local-downcast-extension-layout.cpp \ local-downcast-extension-l3v2extendedmath.cpp \ local-downcast-extension.cpp.in \ local-downcast-namespaces.cpp.in \ local-downcast-astplugins.cpp.in \ local-downcast-astplugins-l3v2extendedmath.cpp \ local-downcast-namespaces-layout.cpp \ local-downcast-namespaces-l3v2extendedmath.cpp \ local-downcast-converters.cpp.in \ local-downcast-converters-layout.cpp \ local-downcast-plugins-layout.cpp \ local-downcast-plugins-l3v2extendedmath.cpp \ local-downcast-plugins.cpp.in \ local-downcast-packages-layout.cpp \ local-downcast-packages-l3v2extendedmath.cpp \ local-downcast.cpp.in \ local-contrib.i \ pydoc-normal.i \ pydoc-doxygen.i # `libraries' is what we're building: a module for use with Python. # (The leading underscore in the name below is a Python convention.) libraries = _libsbml.$(PYTHON_EXT) # The SWIG interface files should not need to be regenerated for recipients # of the libSBML distributions; only developers should need to regenerate # them. The conditions for this are handled later below. swig_sources = ../swig/libsbml.h ../swig/libsbml.i local.i # If we're building 64-bit binaries, but are not running under 10.6, the # version of python will probably be 32 bit instead of 64 bit. ifdef USE_UNIVBINARY ifneq "$(MACOS_VERSION)" "10.6" ifneq "$(MACOS_VERSION)" "10.7" ifneq "$(MACOS_VERSION)" "10.8" ifneq "$(MACOS_VERSION)" "10.9" filtered_cflags = $(shell echo '$(CFLAGS)' | sed -e "s/-arch x86_64//g") filtered_cppflags = $(shell echo '$(CPPFLAGS)' | sed -e "s/-arch x86_64//g") filtered_cxxflags = $(shell echo '$(CXXFLAGS)' | sed -e "s/-arch x86_64//g") filtered_ldflags = $(shell echo '$(LDFLAGS)' | sed -e "s/-arch x86_64//g") CFLAGS := $(filtered_cflags) CPPFLAGS := $(filtered_cppflags) CXXFLAGS := $(filtered_cxxflags) LDFLAGS := $(filtered_ldflags) endif endif endif endif endif # Variables `subdirs', `headers', `sources', `libraries', `extra_CPPFLAGS', # `extra_CXXFLAGS', `extra_LDFLAGS' and `distfiles' are used by the default # rules in `makefile-common-actions.mk' included at the end. extra_CPPFLAGS += $(PYTHON_CPPFLAGS) -I../swig -I../../../include SWIGFLAGS += $(PYTHON_CPPFLAGS) -I../swig # SBML package plug-ins ifdef USE_COMP SWIGFLAGS += -DUSE_COMP SWIGDOCDEFINES += --define USE_COMP endif # USE_COMP ifdef USE_FBC SWIGFLAGS += -DUSE_FBC SWIGDOCDEFINES += --define USE_FBC endif # USE_FBC ifdef USE_GROUPS SWIGFLAGS += -DUSE_GROUPS SWIGDOCDEFINES += --define USE_GROUPS endif # USE_GROUPS ifdef USE_LAYOUT SWIGFLAGS += -DUSE_LAYOUT SWIGDOCDEFINES += --define USE_LAYOUT endif # USE_LAYOUT ifdef USE_QUAL SWIGFLAGS += -DUSE_QUAL SWIGDOCDEFINES += --define USE_QUAL endif # USE_QUAL ifdef USE_MULTI SWIGFLAGS += -DUSE_MULTI SWIGDOCDEFINES += --define USE_MULTI endif # USE_MULTI ifdef USE_RENDER SWIGFLAGS += -DUSE_RENDER SWIGDOCDEFINES += --define USE_RENDER endif # USE_RENDER ifdef USE_L3V2EXTENDEDMATH SWIGFLAGS += -DUSE_L3V2EXTENDEDMATH SWIGDOCDEFINES += --define USE_L3V2EXTENDEDMATH endif # USE_L3V2EXTENDEDMATH # On MacOS X, compilation generates a warning about `long double'. ifeq "$(HOST_TYPE)" "darwin" ifdef HAS_GCC_WNO_LONG_DOUBLE extra_CPPFLAGS += -Wno-long-double endif endif extra_LDFLAGS += $(PYTHON_LDFLAGS) extra_LIBS += ../../libsbml.la $(PYTHON_LIBS) ifdef USE_EXPAT extra_CPPFLAGS += @EXPAT_CPPFLAGS@ extra_LDFLAGS += @EXPAT_LDFLAGS@ extra_LIBS += @EXPAT_LIBS@ endif ifdef USE_XERCES extra_CPPFLAGS += @XERCES_CPPFLAGS@ extra_LDFLAGS += @XERCES_LDFLAGS@ extra_LIBS += @XERCES_LIBS@ endif ifdef USE_LIBXML extra_CPPFLAGS += @LIBXML_CPPFLAGS@ extra_LDFLAGS += @LIBXML_LDFLAGS@ extra_LIBS += @LIBXML_LIBS@ endif # -fno-strict-aliasing option is added to CXXFLAGS when using GCC. As # written in the SWIG Manual (section 20.2.4), SWIG generated code could # cause crash problems when compiled by GCC with -fstrict-aliasing option # (automatically enabled when using -O2 or higher optimization in GCC 3 or # later) and the option should be disabled by adding -fno-strict-aliasing # option. ifeq (GCC,$(findstring GCC,$(shell $(CXX) --version))) CXXFLAGS += -fno-strict-aliasing endif # `distfiles' determines the files and directories included in a distribution. # `distfiles_exclude' is used to filter out specific items, so that even if # they appear in `distfiles', they will not be copied in the distribution. distfiles = \ Makefile.in \ CMakeLists.txt \ add_version.cmake \ patch-python.cmake \ setup.py.cmake \ test.py \ local-doc-extras.i \ local-packages.i.in \ local-layout.i \ local-l3v2extendedmath.i \ setup.cfg \ setup.py.in \ doc-converter/argparse.py \ doc-converter/prettytable.py \ doc-converter/prettytable-0.7.2/COPYING \ doc-converter/prettytable-0.7.2/README \ doc-converter/prettytable-0.7.2/README-LIBSBML.txt \ doc-converter/prettytable-0.7.2/prettytable-0.7.2.zip \ doc-converter/rewrite_pydoc.py \ doc-converter/README.txt \ $(sources) \ $(extra_sources) \ $(python_test_files) python_test_path = test python_test_files = $(wildcard $(python_test_path)/**/Test*.py) extra_clean = \ build \ $(python_test_files:.py=.pyc) \ $(wildcard test.xml.*) extra_distclean = \ $(installed_files_list) \ libsbml.py \ libsbml.pyc \ libsbml-doxygen.py \ local-downcast-extension.i \ local-downcast-extension.cpp \ local-downcast-namespaces.i \ local-downcast-namespaces.cpp \ local-packages.i \ local-downcast-plugins.cpp \ local-downcast.cpp \ pydoc-doxygen.i \ pydoc-normal.i \ setup.py # We generate _libsbml.$(PYTHON_EXT) (C++ library for Python bindings) with # an object file in this directory (libsbml_wrap.o) and other object files # in sub directories in 'src' directory (src/sbml, src/common, ... ) instead # of linking a shared library of libSBML (libsbml.$(SHAREDLIBEXT)). # All directories that contain *.{c,cpp} (implementation) files of libSBML need # to be listed in the following 'otherdirs' variable. otherdirs = ../../sbml/common ../../sbml/util ../../sbml/xml \ ../../sbml/math ../../sbml/validator ../../sbml/validator/constraints \ ../../sbml/units ../../sbml/annotation ../../sbml/compress \ ../../sbml/ ../../sbml/extension ../../sbml/conversion ifdef USE_COMP otherdirs += ../../sbml/packages/comp/common \ ../../sbml/packages/comp/extension \ ../../sbml/packages/comp/sbml \ ../../sbml/packages/comp/util \ ../../sbml/packages/comp/validator \ ../../sbml/packages/comp/validator/constraints endif ifdef USE_FBC otherdirs += ../../sbml/packages/fbc/common \ ../../sbml/packages/fbc/extension \ ../../sbml/packages/fbc/sbml \ ../../sbml/packages/fbc/util \ ../../sbml/packages/fbc/validator \ ../../sbml/packages/fbc/validator/constraints endif ifdef USE_GROUPS otherdirs += ../../sbml/packages/groups/common \ ../../sbml/packages/groups/extension \ ../../sbml/packages/groups/sbml \ ../../sbml/packages/groups/validator \ ../../sbml/packages/groups/validator/constraints endif ifdef USE_LAYOUT otherdirs += ../../sbml/packages/layout/common \ ../../sbml/packages/layout/extension \ ../../sbml/packages/layout/sbml \ ../../sbml/packages/layout/util \ ../../sbml/packages/layout/validator \ ../../sbml/packages/layout/validator/constraints endif ifdef USE_QUAL otherdirs += ../../sbml/packages/qual/common \ ../../sbml/packages/qual/extension \ ../../sbml/packages/qual/sbml \ ../../sbml/packages/qual/validator \ ../../sbml/packages/qual/validator/constraints endif ifdef USE_MULTI otherdirs += ../../sbml/packages/multi/common \ ../../sbml/packages/multi/extension \ ../../sbml/packages/multi/sbml \ ../../sbml/packages/multi/validator \ ../../sbml/packages/multi/validator/constraints endif ifdef USE_RENDER otherdirs += ../../sbml/packages/render/common \ ../../sbml/packages/render/extension \ ../../sbml/packages/render/sbml \ ../../sbml/packages/render/validator \ ../../sbml/packages/render/validator/constraints endif ifdef USE_L3V2EXTENDEDMATH otherdirs += ../../sbml/packages/l3v2extendedmath/common \ ../../sbml/packages/l3v2extendedmath/extension \ ../../sbml/packages/l3v2extendedmath/validator \ ../../sbml/packages/l3v2extendedmath/validator/constraints endif objfiles = libsbml_wrap.lo $(wildcard $(addsuffix /*.lo,$(otherdirs))) # Environment variable MACOSX_DEPLOYMENT_TARGET must be set to 10.3 or later # to use -undefined dynamic_lookup. ifeq "$(HOST_TYPE)" "darwin" export MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION) %.so: $(objfiles) $(call link_dl_lib,$@) endif # The libSBML Python API library on MacOS X has to be built as a "bundle" # rather than a .dylib library. This is different from the default rules # used elsewhere in libSBML and requires the following special value for # `platform_link_flags'. The rest of the default rules for .so's will # behave properly once this is set. ifeq "$(HOST_TYPE)" "darwin" platform_link_flags = -bundle endif # For Linux/Unix LD_LIBRARY_PATH *may* need to contain one or more library # paths to libsbml.so, libxerces-c.so and/or libexpat.so and/or the # libsbml.so _libsbml.so generated by this Makfile. (For BSD/MacOS X # replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH.) # ----------------------------------------------------------------------------- # Primary build actions # ----------------------------------------------------------------------------- .SUFFIXES: .SUFFIXES: .i .cpp .py .pyc .pyo .o .obj .lo .la # The default action is to remake everything. ifdef USE_PYTHON all: Makefile libsbml.py libsbml_wrap.cpp $(libraries) else all: @echo @echo "Reconfigure libSBML using --with-python to enable Python support."; @echo @exit 1 endif setup.py: setup.py.in cd $(TOP_BUILDDIR) && $(SHELL) ./config.status $(thisdir)/setup.py # Rummage through ../swig/libsbml.i to figure out the core libSBML files that # are our dependencies. main_sources = \ $(shell grep '%include sbml' ../swig/libsbml.i | grep -v 'libsbml-version.h' \ | cut -f2- -d'/' | sed -e 's,^,../../sbml/,g') # Recreate SWIG files when one of the following conditions is true: # # (1) libsbml_wrap.cpp does not exist # (2) libsbml_wrap.cpp exists, but the file is not consistent with the # current USE_LAYOUT, USE_COMP, etc., values. # # If the last run was made with a package flag like --enable-layout, and this # run isn't, or vice-versa, the swig wrap files will be wrong for this run. # However, you can't tell just by looking at file mod times, so you can't use # normal make dependencies. So we do this grungy trick of looking inside # libsbml_wrap.cpp to see what's inside. # # The check_foo macros works as follows. They return a non-empty string # "do_reswig" if re-swig'ing is called for, and this string is a phony make # target declared below. When check_layout is used as a dependency of # libsbml_wrap.cpp via a call like this, # # libsbml_wrap.cpp: $(shell $(call check_layout)) ...other dependencies... # ...ACTIONS... # # what will happen is either check_layout will return nothing, in which # case the dependency is satisfied and no swig'ing needs to be done, or # it will return "do_reswig", a phony target that is never satisfied, # in which case the ...ACTIONS... will be executed. .PHONY: do_reswig ifdef USE_COMP define check_comp if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep getListOfSubmodels libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_comp if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep getListOfSubmodels libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_FBC define check_fbc if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep ListOfFluxBounds libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_fbc if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep ListOfFluxBounds libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_GROUPS define check_groups if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep ListOfGroups libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_groups if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep ListOfGroups libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_LAYOUT define check_layout if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep getListOfLayouts libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_layout if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep getListOfLayouts libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_QUAL define check_qual if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep ListOfQualitativeSpecies libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_qual if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep ListOfQualitativeSpecies libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_MULTI define check_multi if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep ListOfSpeciesFeatures libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_multi if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep ListOfSpeciesFeatures libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_RENDER define check_render if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -z "`grep ListOfGlobalRenderInformation libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef else define check_render if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ if test -n "`grep ListOfGlobalRenderInformation libsbml_wrap.cpp`"; then echo "do_reswig"; fi; endef endif ifdef USE_L3V2EXTENDEDMATH define check_l3v2extendedmath if test ! -f LibSBML_wrap.cxx; then echo "do_reswig"; exit; fi; endef else define check_l3v2extendedmath if test ! -f LibSBML_wrap.cxx; then echo "do_reswig"; exit; fi; endef endif libsbml.py: libsbml_wrap.cpp # Generate the documentation files. pydoc-normal.i is used to create the # help strings that are incorporated into the Python code, so that users # can use the interactive "help" function in Python. pydoc-doxygen.i: $(swig_sources) $(main_sources) ../swig/swigdoc.py \ doc-converter/rewrite_pydoc.py ../swig/libsbml.i touch ../../../docs/src/libsbml-converters.txt && ../swig/swigdoc.py --language python --top ../../.. $(SWIGDOCDEFINES) \ --extra ../../../docs/src/libsbml-converters.txt \ --master ../swig/libsbml.i --output pydoc-doxygen.i pydoc-normal.i: pydoc-doxygen.i ./doc-converter/rewrite_pydoc.py -f pydoc-doxygen.i -o pydoc-normal.i \ -i ../../../docs/src/common-text -g ../../../docs/src/common-graphics # Swig gets run twice, once with documentation strings whose format are # suitable for use within Python (e.g., for the 'help' command), and once # with documentation strings suitable for use with our Doxygen-based # document generation system in ../../../docs/src/. libsbml_wrap.cpp: pydoc-doxygen.i pydoc-normal.i $(swig_sources) \ $(main_sources) $(shell $(call check_layout)) $(shell $(call check_comp)) \ $(shell $(call check_fbc)) $(shell $(call check_qual)) \ $(shell $(call check_groups)) $(shell $(call check_multi)) \ $(shell $(call check_render)) $(shell $(call check_l3v2extendedmath)) @top_srcdir@/config/chk_swig_version.sh || exit mv pydoc-doxygen.i pydoc.i $(SWIG) $(SWIGFLAGS) $(sort $(default_includes) $(INCLUDES)) \ -DGENERATING_DOCS -c++ -python -o libsbml_wrap.cpp libsbml.i mv pydoc.i pydoc-doxygen.i mv libsbml.py libsbml-doxygen.py mv pydoc-normal.i pydoc.i $(SWIG) $(SWIGFLAGS) $(sort $(default_includes) $(INCLUDES)) \ -c++ -python -o libsbml_wrap.cpp libsbml.i mv pydoc.i pydoc-normal.i mv libsbml.py libsbml.pyc echo 'from __future__ import generators' > libsbml.py cat libsbml.pyc >> libsbml.py if $(SWIG) -version | grep -q '1.3.39' ; then \ mv libsbml_wrap.cpp libsbml_wrap.cpp.org; \ sed -e \ 's/PyBytes_AsStringAndSize(str, \&cstr, \&len);/PyBytes_AsStringAndSize(str, \&cstr, (Py_ssize_t*)\&len);/' \ libsbml_wrap.cpp.org > libsbml_wrap.cpp; \ fi # ----------------------------------------------------------------------------- # Checking. # ----------------------------------------------------------------------------- test_subdir_path = test/sbml:test/xml:test/annotation:test/math:test/layout check: $(libraries) $(shell $(call check_layout)) \ $(shell $(call check_fbc)) $(shell $(call check_comp)) \ $(shell $(call check_qual)) $(shell $(call check_groups)) \ $(shell $(call check_multi)) $(shell $(call check_render)) \ $(shell $(call check_l3v2extendedmath)) @echo @echo @echo Running Tests in $(thisdir) @echo ----------------------------------------------------------------- $(call libsbmlrun, env PYTHONPATH=.:$(test_subdir_path) $(PYTHON) ./test.py) @echo ----------------------------------------------------------------- @echo All tests passed @echo # # 'make test-files' will reconstruct the test files. This is not made part # of 'make check' (yet). # test-files: $(call test_translator,p,xml math annotation sbml,test) # ----------------------------------------------------------------------------- # Tags. # ----------------------------------------------------------------------------- tags: etags ctags # ----------------------------------------------------------------------------- # Installation. # ----------------------------------------------------------------------------- # Take account of DESDIR if it was assigned when the make was invoked ifneq "$(DESTDIR)" "" root = --root "$(DESTDIR)" endif installed_files_list = installed-files.txt # In order to avoid MACOSX_DEPLOYMENT_TARGET mismatch error on Mac OS X, # environment variable MACOSX_DEPLOYMENT_TARGET is set to '' at # install-time. Python distutils sets proper value to # MACOSX_DEPLOYMENT_TARGET if the environment variable is set to ''. ifeq (, $(shell $(PYTHON) setup.py install --help | grep "\--install-layout.*known values: deb")) install-cmd = setup.py install --record $(installed_files_list) --skip-build --prefix=$(prefix) $(root) else install-cmd = setup.py install --record $(installed_files_list) --skip-build --prefix=$(prefix) --install-layout=deb $(root) endif install: setup.py create-build-dir ifeq "$(HOST_TYPE)" "darwin" env MACOSX_DEPLOYMENT_TARGET='' $(PYTHON) $(install-cmd) else $(PYTHON) $(install-cmd) endif create-build-dir: $(libraries) mkdir -p build build/libsbml echo "libsbml" > build/libsbml.pth cp $(libraries) build/libsbml cp libsbml.py build/libsbml/__init__.py installcheck: uninstall: for i in `cat $(installed_files_list)`; do \ d=`dirname $$i`; f=`echo $$i | sed 's,.*/,,'`; \ find $$d -name "$$f" -o -name "libsbml.pth" | xargs -t /bin/rm -f ; \ done ; \ # ----------------------------------------------------------------------------- # Creating distribution (for libSBML maintainers only) # ----------------------------------------------------------------------------- dist: libsbml_wrap.cpp dist-normal distcheck: distcheck-normal # ----------------------------------------------------------------------------- # Miscellaneous # ----------------------------------------------------------------------------- include @top_srcdir@/config/makefile-common-actions.mk # ----------------------------------------------------------------------------- # End. # -----------------------------------------------------------------------------