## @configure_input@ ## ## @file Makefile.in ## @brief Makefile template for libsbml Python bindings ## @author Mike Hucka ## @author Ben Kovitz ## @author Akiya Jouraku ## ## $Id: Makefile.in 9850 2009-07-18 10:33:19Z ajouraku $ ## $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/bindings/java/Makefile.in $ ## ## This file is part of libSBML. Please visit http://sbml.org for more ## information about SBML, and the latest version of libSBML. ## # ----------------------------------------------------------------------------- # 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/java sources = \ libsbml_wrap.cpp \ javadoc.i extra_sources = \ libsbml.i \ local.cpp \ local.i test_dir = test test_source_path = test/org/sbml/libsbml/test check_sources = AutoTestRunner.java $(wildcard $(test_source_path)/**/Test*.java) java_package = org.sbml.$(PACKAGE) jarfile = libsbmlj.jar jnifile = $(JNIBASENAME).$(JNIEXT) # There are two libraries to build: the shared JNI library, and the Jar file. libraries = $(jarfile) $(jnifile) # 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 = $(JAVA_CPPFLAGS) -I../swig SWIGFLAGS += $(JAVA_CPPFLAGS) -I../swig # # -L../../ option appears first in command-line to always link # with the libSBML's shared library file in the relative path. # extra_LDFLAGS = -L../../ $(JAVA_LDFLAGS) extra_LIBS = -lsbml 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 ifdef USE_SUN_CC extra_LIBS += -lCstd endif ifdef USE_LAYOUT SWIGFLAGS += -DUSE_LAYOUT extra_CPPFLAGS += -DUSE_LAYOUT endif # USE_LAYOUT # -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. # # Currently, we know that Java binding library causes crash when it is compiled by # GCC 4 with -O2 or higher optimization, and the problem can be avoided by adding # -fno-strict-aliasing option. ifeq (GCC,$(findstring GCC,$(shell $(CXX) -dumpversion | sed -e 's/^[34]\./GCC/' ))) CXXFLAGS += -fno-strict-aliasing endif # # By default, the compliance level of eclipse JDT compiler (ecj) is Java 1.4 which # doesn't support covariant return types. # To avoid the incompatible issue, "-5" option which sets the compliance level to Java # 1.5 is added if ecj is detected. # ifeq (1.5 compliance, $(findstring 1.5 compliance, $(shell ${JAVAC} -help 2>&1 | grep "1.5 compliance" ))) JAVAC_OPTION += -5 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.) # The next set of variable definitions are special to this file and not # hooks into `makefile-common-actions.mk'. The values depend in part on # Java conventions and the output of SWIG. outdir = java-files pkg_path = $(subst .,/,$(java_package)) outpath = $(outdir)/$(pkg_path) java_files = $(wildcard $(outpath)/*.java) class_files = $(java_files:.java=.class) # `distfiles' determines the files and directories included in a # distribution. The strategy here is that we include the output of SWIG # (both libsbml_wrap.cpp and the java files) but not the compiled class # files. distfiles = $(sources) $(extra_sources) $(check_sources) \ Makefile.in $(java_files) Java_binding_win32_expat.vcproj Java_binding_win32.vcproj \ createInclude.bat # `extra_clean' and `extra_distclean' determine the files and directories # removed during "make clean" and "make distclean". extra_clean = $(class_files) $(check_sources:.java=.class) test_copy1.xml \ test_write.xml TestFilenameFilter.class $(wildcard test.xml.*) out.xml extra_distclean = # ----------------------------------------------------------------------------- # Primary build actions # ----------------------------------------------------------------------------- # This whole setup is more or less custom and mostly doesn't use the common # build directives of `makefile-common-actions.mk'. .SUFFIXES: .SUFFIXES: .i .cpp .h .java .class .jar .o .obj .so .dylib # The default action is to remake everything. ifdef USE_JAVA all: Makefile check_swigfile_consistency $(MAKE) -$(MAKEFLAGS) $(libraries) else all: @echo @echo "Reconfigure libSBML using --with-java to enable Java support."; @echo @exit 1 endif # The rest here is for developers and maintainers. Recipients of the # library distributions shouldn't have to run SWIG because we provide the # wrapper file ready-made. swig_sources = \ $(extra_sources) \ ../swig/libsbml.h \ ../swig/libsbml.i ifdef USE_LAYOUT swig_sources += ../swig/layout.i endif main_sources = \ $(shell grep '%include sbml' ../swig/libsbml.i | grep -v 'libsbml-version.h' | cut -f2 -d' ' \ | cut -f2- -d'/' | sed -e '/\//s/^/..\/..\//;/\//!s/^/..\/..\/sbml\//') # MacOS X is different. We need to compile the .jnilib files using -bundle. ifeq "$(HOST_TYPE)" "darwin" platform_link_flags = -bundle endif # The dependencies that follow are an awful tangle. I wish I could find a # way to simplify this. The critical point is that we don't want to put a # list naming all the .java files explicitly in this Makefile, because any # change to the output of SWIG could cause a change in the .java files it # produces and render obsolete any list contained here. So we have to try # to wildcard the files, but that in itself is impossible until they're # generated by running SWIG. Ugh. # # Recreates 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 value. # check_swigfile_consistency: ifeq (yes, $(findstring yes,$(shell test -f libsbml_wrap.cpp && echo yes))) ifdef USE_LAYOUT ifneq (getListOfLayouts, $(findstring getListOfLayouts,$(shell grep getListOfLayouts libsbml_wrap.cpp))) $(MAKE) -$(MAKEFLAGS) recreate_java_files endif else ifeq (getListOfLayouts, $(findstring getListOfLayouts,$(shell grep getListOfLayouts libsbml_wrap.cpp))) $(MAKE) -$(MAKEFLAGS) recreate_java_files endif endif # USE_LAYOUT else $(MAKE) -$(MAKEFLAGS) recreate_java_files endif # ifeq (yes... $(jarfile): $(outpath)/libsbml.class $(CD) $(outdir) && \ "$(JAR)" -cvf ../$(jarfile) $(pkg_path)/*.class $(outpath)/libsbml.class: libsbml_wrap.cpp @if ! test -f "$(outpath)/libsbml.java"; then \ $(MAKE) -$(MAKEFLAGS) recreate_java_files; \ fi "$(JAVAC)" $(JAVAC_OPTION) -d $(outdir) $(outpath)/*.java # libsbml_wrap.cpp is a stand-in for the .java files. Its creation results # in the creation of the .java files too -- both are made by running swig. libsbml_wrap.cpp $(outpath): javadoc.i $(swig_sources) $(main_sources) ifdef USE_SWIG test -d $(outpath) || mkdir -p $(outpath) $(SWIG) $(SWIGFLAGS) $(sort $(default_includes) $(INCLUDES)) \ -c++ -java -package $(java_package) \ -outdir $(outpath) -o libsbml_wrap.cpp libsbml.i else @echo @echo "Reconfigure --with-swig in order to rebuild libsbml_wrap.cpp" @echo "and the files in the java-files directory." @echo @exit 1 endif javadoc.i: $(main_sources) $(swig_sources) ../swig/swigdoc.py ../swig/swigdoc.py java -I../.. -D../../../docs/src ../swig/libsbml.i javadoc.i # If USE_SWIG is *not* in effect, things get tricky. If the last run was # made with --enable-layout and this one 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 at the file to see what's inside. recreate_java_files:; ifdef USE_SWIG $(MAKE) -$(MAKEFLAGS) clean-swigfiles $(outpath) else ifdef USE_LAYOUT @if test -z "`grep getListOfLayouts libsbml_wrap.cpp`"; then \ echo ;\ echo "The existing libsbml_wrap.cpp file lacks the layout code."; \ echo "Reconfigure --with-swig --enable-layout to correct this."; \ echo ;\ exit 1; \ else \ $(MAKE) -$(MAKEFLAGS) $(outpath); \ fi else # not USE_LAYOUT @if test -n "`grep getListOfLayouts libsbml_wrap.cpp`"; then \ echo ;\ echo "The existing libsbml_wrap.cpp file contains the layout code."; \ echo "Reconfigure --with-swig to correct this."; \ echo ;\ exit 1; \ else \ $(MAKE) -$(MAKEFLAGS) $(outpath); \ fi endif # USE_LAYOUT endif #USE_SWIG clean-swigfiles: clean -rm -rf $(outdir) libsbml_wrap.cpp # ----------------------------------------------------------------------------- # Checking. # ----------------------------------------------------------------------------- check_classes = $(check_sources:.java=.class) ifeq "$(HOST_TYPE)" "cygwin" classpath = $(shell cygpath -wp $(jarfile):$(TOP_BUILDDIR)/src:$(test_dir):.) else classpath = $(jarfile):$(TOP_BUILDDIR)/src:$(test_dir):. endif $(check_classes): Makefile $(libraries) $(check_sources) "$(JAVAC)" $(JAVAC_OPTION) -g -classpath "$(classpath)" $(check_sources) ifdef USE_LIBCHECK check: check_swigfile_consistency $(check_classes) @echo @echo @echo Running Tests in $(thisdir) @echo ----------------------------------------------------------------- $(call libsbmlrun,"$(JAVA)" -classpath "$(classpath)" AutoTestRunner) @echo ----------------------------------------------------------------- @echo else check:; @echo Please first rerun 'configure' with the --with-check flag; exit 1 endif # ----------------------------------------------------------------------------- # Tags. # ----------------------------------------------------------------------------- tags: etags ctags # ----------------------------------------------------------------------------- # Installation. # ----------------------------------------------------------------------------- install: check_swigfile_consistency $(libraries) @list='$(libraries)'; for lib in $$list; do \ echo "$(INSTALL) $$lib $(DESTDIR)$(LIBDIR)"; \ $(INSTALL) $$lib $(DESTDIR)$(LIBDIR); \ done; uninstall: @list='$(libraries)'; for lib in $$list; do \ if test -f "$(DESTDIR)$(LIBDIR)/$$lib"; then \ echo rm "$(DESTDIR)$(LIBDIR)/$$lib"; \ rm $(DESTDIR)$(LIBDIR)/$$lib; \ fi; \ done; installcheck: # ----------------------------------------------------------------------------- # Creating distribution (for libSBML maintainers only) # ----------------------------------------------------------------------------- dist: check_swigfile_consistency libsbml_wrap.cpp $(outdir) dist-normal distcheck: distcheck-normal # ----------------------------------------------------------------------------- # Miscellaneous # ----------------------------------------------------------------------------- include @top_srcdir@/config/makefile-common-actions.mk # ----------------------------------------------------------------------------- # End. # -----------------------------------------------------------------------------