## @configure_input@ ## ## @file Makefile.in ## @brief Makefile template for libSBML CSharp bindings ## This file is based on Makefile.in for SWIG Java bindings ## written by Michael Hucka and Ben Kovitz ## @author Akiya Jouraku ## ## $Id: Makefile.in 9850 2009-07-18 10:33:19Z ajouraku $ ## $URL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/bindings/csharp/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/csharp # ----------------------------------------------------------------------------- # To avoid Windows specific encoding problem in SWIG/C#, additional directives # are used in SWIG interface file (local.i) only for Windows. # Thus, generated wrapper files (libsbml_wrap*.cpp and *.cs files) are different # between Windows and non-Windows platforms as follows: # # (Windows) # 1) libsbml_wrap-win.cpp # 2) csharp-files-win/*.cs # ----------------------------------------------------------------------- # These files can be built by using one of Visual Studio solution files # (CSharp_binding_win32-*.sln) in this directory. # ----------------------------------------------------------------------- # # (Other platforms) # 1) libsbml_wrap.cpp # 2) csharp-files/*.cs # ------------------------------------------------------------------------ # These files can be built by running make with this Makefile. # Currently, Mono is required to build C# DLL (by gmcs or mcs) and run an # executable file (by mono). # # (*NOTICE*) # Currently (2008-07-25), runtime implementation of Portable.NET (ilrun) # doesn't seem to work for libSBML C# binding. # Although C# DLL can be built by cscc, a segmentation fault happens # when an executable file is launched by ilrun. # -------------------------------------------------------------------------- # # ----------------------------------------------------------------------------- sources = \ libsbml_wrap.cpp extra_sources = \ libsbml.i \ local.cpp \ local.i test_dir = test test_source_path = $(test_dir) check_runner_source_cvt = TestRunner.cs Compiler.cs check_runner_source_man = TestRW.cs assembly_info_source = Properties/AssemblyInfo.cs assembly_info_source_tr = Properties/AssemblyInfoTR.cs # Test*.cs are not implemented yet check_sources = $(wildcard $(test_source_path)/**/Test*.cs) check_sources += $(check_runner_source_cvt) $(check_runner_source_man) assembly_name = libsbmlcsP csproxy_lib = ${assembly_name}.dll dllimport_name = libsbmlcs dllimport_lib = $(dllimport_name).$(CSHARP_EXT) sn_keyfile = libsbmlcs.snk # There are two libraries to build: the shared native library file used for # Platform Invocation Service, and the CSharp proxy class DLL file. libraries = $(csproxy_lib) $(dllimport_lib) # 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 = $(CSHARP_CPPFLAGS) -I../swig SWIGFLAGS += $(CSHARP_SWIGFLAGS) -I../swig SWIGFLAGS_WIN = -DSWIGWIN -DSWIG_CSHARP_NO_WSTRING_HELPER # # -L../../ option appears first in command-line to always link # with the libSBML's shared library file in the relative path. # extra_LDFLAGS = -L../../ $(CSHARP_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 # 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 # CSharp conventions and the output of SWIG. # outpath = csharp-files outpath_win = csharp-files-win csharp_files = $(wildcard $(outpath)/*.cs) csharp_files_win = $(wildcard $(outpath_win)/*.cs) csharp_files_win += libsbml_wrap-win.cpp vs2005_files = \ CSharp_binding_win32-xerces.sln CSharp_binding_win32-xerces.vcproj \ CSharp_binding_win32-expat.sln CSharp_binding_win32-expat.vcproj \ CSharp_binding_win32-libxml.sln CSharp_binding_win32-libxml.vcproj \ CSharp_binding_TestRW.csproj CSharp_binding_cspDLL.csproj \ LibSBMLCSTestRunner-vs2005.csproj LibSBMLCSTestRunner-vs2005.sln \ $(assembly_info_source) $(assembly_info_source_tr) vs2003_files = \ CSharp_binding_win32-xerces-vs2003.sln CSharp_binding_win32-xerces-vs2003.vcproj \ CSharp_binding_win32-expat-vs2003.sln CSharp_binding_win32-expat-vs2003.vcproj \ CSharp_binding_win32-libxml-vs2003.sln CSharp_binding_win32-libxml-vs2003.vcproj \ CSharp_binding_TestRW-vs2003.csproj CSharp_binding_cspDLL-vs2003.csproj win_bat_files = createInclude.bat runTestRunner.bat runTestRW.bat # `distfiles' determines the files and directories included in a # distribution. The strategy here is that we include the output of SWIG # (libsbml_wrap.cpp, libsbml_wrap-win.cpp and the csharp files) but not the # compiled files. distfiles = $(sources) $(extra_sources) $(check_sources) \ 00README.txt Makefile.in $(csharp_files) $(csharp_files_win) \ $(vs2003_files) $(vs2005_files) $(win_bat_files) tmpfiles = $(wildcard test*.xml*) # `extra_clean' and `extra_distclean' determine the files and directories # removed during "make clean" and "make distclean". extra_clean = $(csproxy_lib) $(dllimport_lib) $(check_runner_exe) $(tmpfiles) $(sn_keyfile) \ $(wildcard test.xml.*) out.xml extra_distclean = # 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 native library file using -bundle. ifeq "$(HOST_TYPE)" "darwin" platform_link_flags = -bundle endif # # command line options for Mono # ifeq (Mono,$(findstring Mono,$(shell $(CSHARP_COMPILER) --version 2>&1))) CSC_OPT_SHARED = -target:library CSC_OPT_EXE = -target:exe CSC_OPT_OUTPUT = -out: CSC_OPT_REF = -r: ifdef SN CSC_OPT_KEYFILE = -keyfile:$(sn_keyfile) endif endif # # command line options for Portable.NET # # (*NOTICE*) # Currently (2008-07-25), runtime implementation of Portable.NET (ilrun) # doesn't seem to work for libSBML C# binding. # Although C# DLL can be built by cscc, a segmentation fault happens # when an executable file is launched by ilrun. # ifeq (cscc,$(findstring cscc,$(shell $(CSHARP_COMPILER) --version 2>&1))) CSC_OPT_SHARED = -shared CSC_OPT_EXE = CSC_OPT_OUTPUT = -o CSC_OPT_REF = -l CSC_OPT_KEYFILE = endif # ----------------------------------------------------------------------------- # 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 .cs .dll .o .obj .so .dylib # The default action is to remake everything. ifdef USE_CSHARP all: Makefile check_swigfile_consistency $(MAKE) -$(MAKEFLAGS) $(csproxy_lib) ifdef USE_SWIG $(MAKE) -$(MAKEFLAGS) $(outpath_win)/libsbml.cs endif # USE_SWIG else all: @echo @echo "Reconfigure libSBML using --with-csharp to enable CSharp support."; @echo "(--with-cli-interpreter=path" and/or --with-csharp-compiler=path may be required.)"; @echo @exit 1 endif # The rest here is for developers and maintainers. Recipients of 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 .cs files explicitly in this Makefile, because any # change to the output of SWIG could cause a change in the .cs 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_csharp_files endif else ifeq (getListOfLayouts, $(findstring getListOfLayouts,$(shell grep getListOfLayouts libsbml_wrap.cpp))) $(MAKE) -$(MAKEFLAGS) recreate_csharp_files endif endif # USE_LAYOUT else $(MAKE) -$(MAKEFLAGS) recreate_csharp_files endif # ifeq (yes... $(csproxy_lib): $(outpath)/libsbml.cs $(dllimport_lib) -"$(SN)" -k $(sn_keyfile) "$(CSHARP_COMPILER)" $(CSC_OPT_SHARED) $(CSC_OPT_OUTPUT)$(csproxy_lib) $(CSC_OPT_KEYFILE) $(outpath)/*.cs \ $(assembly_info_source) $(outpath)/libsbml.cs: libsbml_wrap.cpp @if ! test -f "$(outpath)/libsbml.cs"; then \ $(MAKE) -$(MAKEFLAGS) recreate_csharp_files; \ fi $(outpath_win)/libsbml.cs: libsbml_wrap-win.cpp @if ! test -f "$(outpath_win)/libsbml.cs"; then \ $(MAKE) -$(MAKEFLAGS) recreate_csharp_files; \ fi # libsbml_wrap.cpp (for non-Windows) and libsbml_wrap-win.cpp (for Windows) # stand-in for the .cs files. Their creation results in the creation of the .cs # files too -- both are made by running swig. # for non-Windows libsbml_wrap.cpp $(outpath) : $(swig_sources) $(main_sources) ifdef USE_SWIG test -d $(outpath) || mkdir -p $(outpath) $(SWIG) $(SWIGFLAGS) $(sort $(default_includes) $(INCLUDES)) \ -c++ -csharp -namespace libsbml -dllimport $(dllimport_name) \ -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 csharp-files directory." @echo @exit 1 endif # for Windows libsbml_wrap-win.cpp $(outpath_win) : $(swig_sources) $(main_sources) ifdef USE_SWIG test -d $(outpath_win) || mkdir -p $(outpath_win) $(SWIG) $(SWIGFLAGS) $(SWIGFLAGS_WIN) $(sort $(default_includes) $(INCLUDES)) \ -c++ -csharp -namespace libsbml -dllimport $(dllimport_name) \ -outdir $(outpath_win) -o libsbml_wrap-win.cpp libsbml.i else @echo @echo "Reconfigure --with-swig in order to rebuild libsbml_wrap.cpp" @echo "and the files in the csharp-files directory." @echo @exit 1 endif # 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_csharp_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 $(outpath) $(outpath_win) libsbml_wrap.cpp libsbml_wrap-win.cpp # ----------------------------------------------------------------------------- # Checking. # ----------------------------------------------------------------------------- check_runner_exe = $(check_runner_exe_man) $(check_runner_exe_cvt) check_runner_exe_man = TestRW.exe check_runner_exe_cvt = TestRunner.exe $(check_runner_exe_man): Makefile $(csproxy_lib) $(check_runner_source_man) "$(CSHARP_COMPILER)" $(CSC_OPT_EXE) $(CSC_OPT_OUTPUT)$(check_runner_exe_man) \ $(CSC_OPT_REF)$(csproxy_lib) $(check_runner_source_man) $(check_runner_exe_cvt): Makefile $(csproxy_lib) $(check_runner_source_cvt) "$(CSHARP_COMPILER)" $(CSC_OPT_EXE) $(CSC_OPT_OUTPUT)$(check_runner_exe_cvt) \ $(CSC_OPT_REF)$(csproxy_lib) $(check_runner_source_cvt) testsbml_dir = ../../../examples/sample-models/from-spec/level-2 testdata_dir = ../../sbml/test/test-data testsbml_files = $(wildcard $(testsbml_dir)/*.xml) ifdef USE_LIBCHECK check: check_swigfile_consistency $(check_runner_exe_man) $(check_runner_exe_cvt) @echo @echo @echo Running Tests in $(thisdir) @echo ----------------------------------------------------------------- $(call libsbmlrun,"$(CSHARP_CILINTERPRETER)" $(check_runner_exe_man) $(testsbml_files)) $(call libsbmlrun,"$(CSHARP_CILINTERPRETER)" $(check_runner_exe_cvt) ./test $(testdata_dir) ./libsbmlcsP.dll) @echo ----------------------------------------------------------------- @echo else check:; @echo Please first rerun 'configure' with the --with-check flag; exit 1 endif # ----------------------------------------------------------------------------- # Tags. # ----------------------------------------------------------------------------- tags: etags ctags # ----------------------------------------------------------------------------- # Installation. # ----------------------------------------------------------------------------- install_prefix=$(DESTDIR)$(LIBDIR)/mono/$(assembly_name) install: check_swigfile_consistency $(libraries) -$(GACUTIL) -i $(csproxy_lib) -root $(DESTDIR)$(LIBDIR) $(INSTALL_SH) $(csproxy_lib) $(install_prefix)/$(csproxy_lib) $(INSTALL_SH) $(dllimport_lib) $(install_prefix)/$(dllimport_lib) ln -sf ../../libsbml.$(SHAREDLIBEXT) $(install_prefix)/libsbml.$(SHAREDLIBEXT) uninstall: -$(GACUTIL) -u $(assembly_name) -root $(DESTDIR)$(LIBDIR) rm -f $(install_prefix)/$(csproxy_lib) rm -f $(install_prefix)/$(dllimport_lib) rm -f $(install_prefix)/libsbml.$(SHAREDLIBEXT) installcheck: # ----------------------------------------------------------------------------- # Creating distribution (for libSBML maintainers only) # ----------------------------------------------------------------------------- dist: check_swigfile_consistency libsbml_wrap.cpp libsbml_wrap-win.cpp $(outpath) $(outpath_win) $(MAKE) -$(MAKEFLAGS) dist-normal distcheck: distcheck-normal # ----------------------------------------------------------------------------- # Miscellaneous # ----------------------------------------------------------------------------- include @top_srcdir@/config/makefile-common-actions.mk # ----------------------------------------------------------------------------- # End. # -----------------------------------------------------------------------------