1## @configure_input@
2##
3## @file    Makefile.in
4## @brief   Makefile template for libSBML CSharp bindings
5##          This file is based on Makefile.in for SWIG Java bindings
6##          written by Michael Hucka and Ben Kovitz
7## @author  Akiya Jouraku
8##
9## <!--------------------------------------------------------------------------
10## This file is part of libSBML.  Please visit http://sbml.org for more
11## information about SBML, and the latest version of libSBML.
12##
13## Copyright (C) 2013-2018 jointly by the following organizations:
14##     1. California Institute of Technology, Pasadena, CA, USA
15##     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
16##     3. University of Heidelberg, Heidelberg, Germany
17##
18## Copyright (C) 2009-2013 jointly by the following organizations:
19##     1. California Institute of Technology, Pasadena, CA, USA
20##     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
21##
22## Copyright (C) 2006-2008 by the California Institute of Technology,
23##     Pasadena, CA, USA
24##
25## Copyright (C) 2002-2005 jointly by the following organizations:
26##     1. California Institute of Technology, Pasadena, CA, USA
27##     2. Japan Science and Technology Agency, Japan
28##
29## This library is free software; you can redistribute it and/or modify it
30## under the terms of the GNU Lesser General Public License as published by
31## the Free Software Foundation.  A copy of the license agreement is provided
32## in the file named "LICENSE.txt" included with this software distribution
33## and also available online as http://sbml.org/software/libsbml/license.html
34## ------------------------------------------------------------------------ -->
35
36
37# -----------------------------------------------------------------------------
38# Configuration variables
39# -----------------------------------------------------------------------------
40# Some of the following are substituted automatically by `configure'.  If
41# you are looking at "Makefile", do not edit these values; instead, run the
42# configure script at the top level of the src tree.  It will recreate
43# "Makefile".
44
45include @top_srcdir@/config/makefile-common-vars.mk
46
47# `srcdir' points to the current directory, but should be set by configure.
48# `subdir' must be set manually to the relative dir under srcdir.  Don't
49# set `subdir' to an absolute path, or some make actions will fail.
50
51srcdir            = @srcdir@
52thisdir           = src/bindings/csharp
53
54# -----------------------------------------------------------------------------
55# To avoid Windows specific encoding problem in SWIG/C#, additional directives
56# are used in SWIG interface file (local.i) only for Windows.
57# Thus, generated wrapper files (libsbml_wrap*.cpp and *.cs files) are different
58# between Windows and non-Windows platforms as follows:
59#
60# (Windows)
61#   1) libsbml_wrap-win.cpp
62#   2) csharp-files-win/*.cs
63#   -----------------------------------------------------------------------
64#    These files can be built by using one of Visual Studio solution files
65#    (CSharp_binding_win32-*.sln) in this directory.
66#   -----------------------------------------------------------------------
67#
68# (Other platforms)
69#   1) libsbml_wrap.cpp
70#   2) csharp-files/*.cs
71#   ------------------------------------------------------------------------
72#    These files can be built by running make with this Makefile.
73#    Currently, Mono is required to build C# DLL (by gmcs or mcs) and run an
74#    executable file (by mono).
75#
76#    (*NOTICE*)
77#      Currently (2008-07-25), runtime implementation of Portable.NET (ilrun)
78#      doesn't seem to work for libSBML C# binding.
79#      Although C# DLL can be built by cscc, a segmentation fault happens
80#      when an executable file is launched by ilrun.
81#  --------------------------------------------------------------------------
82#
83# -----------------------------------------------------------------------------
84sources           = \
85                     libsbml_wrap.cpp \
86                     libsbml_wrap.h
87
88extra_sources     = \
89                     libsbml.i \
90                     local.cpp \
91                     local.i \
92					 local-downcast-extension-layout.i \
93					 local-downcast-extension.i.in \
94					 local-downcast-astplugins.i.in \
95					 local-downcast-converters.i.in \
96					 local-downcast-converters-layout.i \
97					 local-downcast-namespaces-layout.i \
98					 local-downcast-namespaces.i.in \
99					 local-packages-layout.i \
100					 local-packages.i.in \
101					 local-downcast-extension-l3v2extendedmath.i \
102					 local-downcast-astplugins-l3v2extendedmath.i \
103					 local-downcast-namespaces-l3v2extendedmath.i \
104					 local-packages-l3v2extendedmath.i \
105
106test_dir          = test
107test_source_path  = $(test_dir)
108
109check_runner_source_cvt = TestRunner.cs Compiler.cs
110check_runner_source_man = TestRW.cs
111
112assembly_info_source    = Properties/AssemblyInfo.cs
113assembly_info_source_tr = Properties/AssemblyInfoTR.cs
114
115# Test*.cs are not implemented yet
116test_sources        = $(wildcard $(test_source_path)/**/Test*.cs)
117check_sources       = $(test_sources) $(check_runner_source_cvt) $(check_runner_source_man)
118
119assembly_name     = libsbmlcsP
120csproxy_lib       = ${assembly_name}.dll
121dllimport_name    = libsbmlcs
122dllimport_lib     = $(dllimport_name).$(CSHARP_EXT)
123
124sn_keyfile = libsbmlcs.snk
125
126# There are two libraries to build: the shared native library file used for
127# Platform Invocation Service, and the CSharp proxy class DLL file.
128
129libraries         = $(csproxy_lib) $(dllimport_lib)
130
131
132#############################################################################
133#
134# Generates $(dllimport_name).$(CSHARP_EXT) (C++ library for DllImport) with
135# an object file in this directory (libsbml_wrap.o) and other object files
136# in sub directories in 'src' directory (src/sbml, src/common, ... ) instead
137# of linking a shared library of libSBML (libsbml.$(SHAREDLIBEXT)).
138#
139
140#
141# All directories that contain *.{c,cpp} (implementation) files of libSBML need
142# to be listed in the following 'otherdirs' variable.
143#
144otherdirs = ../../sbml/common ../../sbml/util ../../sbml/xml \
145	    ../../sbml/math ../../sbml/validator ../../sbml/validator/constraints \
146	    ../../sbml/units ../../sbml/annotation ../../sbml/compress \
147            ../../sbml/ ../../sbml/extension
148
149
150ifdef USE_COMP
151  otherdirs += ../../sbml/packages/comp/common \
152               ../../sbml/packages/comp/extension \
153               ../../sbml/packages/comp/sbml \
154               ../../sbml/packages/comp/util \
155               ../../sbml/packages/comp/validator \
156               ../../sbml/packages/comp/validator/constraints
157endif
158ifdef USE_FBC
159  otherdirs += ../../sbml/packages/fbc/common \
160               ../../sbml/packages/fbc/extension \
161               ../../sbml/packages/fbc/sbml \
162               ../../sbml/packages/fbc/util \
163               ../../sbml/packages/fbc/validator \
164               ../../sbml/packages/fbc/validator/constraints
165endif
166ifdef USE_GROUPS
167  otherdirs += ../../sbml/packages/groups/common \
168               ../../sbml/packages/groups/extension \
169               ../../sbml/packages/groups/sbml \
170               ../../sbml/packages/groups/validator \
171               ../../sbml/packages/groups/validator/constraints
172endif
173ifdef USE_LAYOUT
174  otherdirs += ../../sbml/packages/layout/common \
175               ../../sbml/packages/layout/extension \
176               ../../sbml/packages/layout/sbml \
177               ../../sbml/packages/layout/util \
178               ../../sbml/packages/layout/validator \
179               ../../sbml/packages/layout/validator/constraints
180endif
181ifdef USE_QUAL
182  otherdirs += ../../sbml/packages/qual/common \
183               ../../sbml/packages/qual/extension \
184               ../../sbml/packages/qual/sbml \
185               ../../sbml/packages/qual/validator \
186               ../../sbml/packages/qual/validator/constraints
187endif
188ifdef USE_MULTI
189  otherdirs += ../../sbml/packages/multi/common \
190               ../../sbml/packages/multi/extension \
191               ../../sbml/packages/multi/sbml \
192               ../../sbml/packages/multi/validator \
193               ../../sbml/packages/multi/validator/constraints
194endif
195ifdef USE_RENDER
196  otherdirs += ../../sbml/packages/render/common \
197               ../../sbml/packages/render/extension \
198               ../../sbml/packages/render/sbml \
199               ../../sbml/packages/render/validator \
200               ../../sbml/packages/render/validator/constraints
201endif
202ifdef USE_L3V2EXTENDEDMATH
203  otherdirs += ../../sbml/packages/l3v2extendedmath/common \
204               ../../sbml/packages/l3v2extendedmath/extension \
205               ../../sbml/packages/l3v2extendedmath/validator \
206               ../../sbml/packages/l3v2extendedmath/validator/constraints
207endif
208
209objfiles  = libsbml_wrap.lo $(wildcard $(addsuffix /*.lo,$(otherdirs)))
210
211
212#############################################################################
213
214
215# Variables `subdirs', `headers', `sources', `libraries', `extra_CPPFLAGS',
216# `extra_CXXFLAGS', `extra_LDFLAGS' and `distfiles' are used by the default
217# rules in `makefile-common-actions.mk' included at the end.
218
219extra_CPPFLAGS    = $(CSHARP_CPPFLAGS) -I../swig
220SWIGFLAGS        += $(CSHARP_SWIGFLAGS) -I../swig
221SWIGFLAGS_WIN     = -DSWIGWIN -DSWIG_CSHARP_NO_WSTRING_HELPER
222
223extra_LDFLAGS     = $(CSHARP_LDFLAGS)
224
225extra_LIBS        = ../../libsbml.la
226
227ifdef USE_EXPAT
228  extra_CPPFLAGS += @EXPAT_CPPFLAGS@
229  extra_LDFLAGS  += @EXPAT_LDFLAGS@
230  extra_LIBS     += @EXPAT_LIBS@
231endif
232
233ifdef USE_XERCES
234  extra_CPPFLAGS += @XERCES_CPPFLAGS@
235  extra_LDFLAGS  += @XERCES_LDFLAGS@
236  extra_LIBS     += @XERCES_LIBS@
237endif
238
239ifdef USE_LIBXML
240  extra_CPPFLAGS += @LIBXML_CPPFLAGS@
241  extra_LDFLAGS  += @LIBXML_LDFLAGS@
242  extra_LIBS     += @LIBXML_LIBS@
243endif
244
245# SBML package plug-ins
246ifdef USE_COMP
247  SWIGFLAGS      += -DUSE_COMP
248  SWIGDOCDEFINES += --define USE_COMP
249endif # USE_COMP
250
251ifdef USE_FBC
252  SWIGFLAGS      += -DUSE_FBC
253  SWIGDOCDEFINES += --define USE_FBC
254endif # USE_FBC
255
256ifdef USE_GROUPS
257  SWIGFLAGS      += -DUSE_GROUPS
258  SWIGDOCDEFINES += --define USE_GROUPS
259endif # USE_GROUPS
260
261ifdef USE_LAYOUT
262  SWIGFLAGS      += -DUSE_LAYOUT
263  SWIGDOCDEFINES += --define USE_LAYOUT
264endif # USE_LAYOUT
265
266ifdef USE_QUAL
267  SWIGFLAGS      += -DUSE_QUAL
268  SWIGDOCDEFINES += --define USE_QUAL
269endif # USE_QUAL
270
271ifdef USE_MULTI
272  SWIGFLAGS      += -DUSE_MULTI
273  SWIGDOCDEFINES += --define USE_MULTI
274endif # USE_MULTI
275
276ifdef USE_RENDER
277  SWIGFLAGS      += -DUSE_RENDER
278  SWIGDOCDEFINES += --define USE_RENDER
279endif # USE_RENDER
280
281ifdef USE_L3V2EXTENDEDMATH
282  SWIGFLAGS      += -DUSE_L3V2EXTENDEDMATH
283  SWIGDOCDEFINES += --define USE_L3V2EXTENDEDMATH
284endif # USE_L3V2EXTENDEDMATH
285
286
287# -fno-strict-aliasing option is added to CXXFLAGS when using GCC.
288# As written in the SWIG Manual (section 20.2.4), SWIG generated code could cause
289# crash problems when compiled by GCC with -fstrict-aliasing option (automatically
290# enabled when using -O2 or higher optimization in GCC 3 or later) and the option
291# should be disabled by adding -fno-strict-aliasing option.
292#
293# Currently, we know that Java binding library causes crash when it is compiled by
294# GCC 4 with -O2 or higher optimization, and the problem can be avoided by adding
295# -fno-strict-aliasing option.
296
297ifeq (GCC,$(findstring GCC,$(shell $(CXX) -dumpversion | sed -e 's/^[34]\./GCC/' )))
298      CXXFLAGS += -fno-strict-aliasing
299endif
300
301# For Linux/Unix LD_LIBRARY_PATH *may* need to contain one or more library
302# paths to libsbml.so, libxerces-c.so and/or libexpat.so and/or the
303# libsbml.so _libsbml.so generated by this Makfile.  (For BSD/MacOS X
304# replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH.)
305
306# The next set of variable definitions are special to this file and not
307# hooks into `makefile-common-actions.mk'.  The values depend in part on
308# CSharp conventions and the output of SWIG.
309#
310outpath        = csharp-files
311outpath_win    = csharp-files-win
312csharp_files     = $(wildcard $(outpath)/*.cs)
313csharp_files_win = $(wildcard $(outpath_win)/*.cs)
314csharp_files_win += libsbml_wrap-win.cpp
315
316vs2005_files = \
317  $(assembly_info_source) $(assembly_info_source_tr)
318
319# `distfiles' determines the files and directories included in a
320# distribution.  The strategy here is that we include the output of SWIG
321# (libsbml_wrap.cpp, libsbml_wrap-win.cpp and the csharp files) but not the
322# compiled files.
323
324distfiles   = $(sources) $(extra_sources) $(check_sources) \
325  00README.txt Makefile.in $(csharp_files) $(csharp_files_win) \
326  $(vs2005_files) CMakeLists.txt Properties/AssemblyInfo.cs.in \
327  compile-native-files.cmake csdoc.i swig-binding.cmake.in
328
329tmpfiles = $(wildcard test*.xml*)
330
331# `extra_clean' and `extra_distclean' determine the files and directories
332# removed during "make clean" and "make distclean".
333
334extra_clean = $(csproxy_lib) $(dllimport_lib) $(check_runner_exe) \
335	      $(tmpfiles) $(sn_keyfile) $(wildcard test.xml.*) out.xml
336
337extra_distclean = libsbml_wrap-win.h local-downcast-extension.i \
338	local-downcast-namespaces.i local-packages.i csdoc.i
339
340# library distributions shouldn't have to run SWIG because we provide the
341# wrapper file ready-made.
342
343swig_sources =      \
344  $(extra_sources)  \
345  ../swig/libsbml.h \
346  ../swig/libsbml.i
347
348
349main_sources = \
350  $(shell grep '%include sbml' ../swig/libsbml.i | grep -v 'libsbml-version.h' \
351    | cut -f2- -d'/' | sed -e 's,^,../../sbml/,g')
352
353# MacOS X is different.  We need to compile the native library file using -bundle.
354
355ifeq "$(HOST_TYPE)" "darwin"
356  platform_link_flags = -bundle
357  # environment variable MACOSX_DEPLOYMENT_TARGET must be set to 10.3 or later
358  # to use -undefined dynamic_lookup.
359  macosx_version=$(shell sw_vers -productVersion | cut -d"." -f1,2)
360  export MACOSX_DEPLOYMENT_TARGET=${macosx_version}
361%.$(CSHARP_EXT): $(objfiles)
362	$(call link_dl_lib,$@)
363endif
364
365#
366# command line options for Mono
367#
368ifeq (Mono,$(findstring Mono,$(shell $(CSHARP_COMPILER) --version 2>&1)))
369  CSC_OPT_SHARED = -target:library
370  CSC_OPT_EXE    = -target:exe
371  CSC_OPT_OUTPUT = -out:
372  CSC_OPT_REF    = -r:
373  ifdef SN
374    CSC_OPT_KEYFILE = -keyfile:$(sn_keyfile)
375  endif
376endif
377
378#
379# command line options for Portable.NET
380#
381#  (*NOTICE*)
382#    Currently (2008-07-25), runtime implementation of Portable.NET (ilrun)
383#    doesn't seem to work for libSBML C# binding.
384#    Although C# DLL can be built by cscc, a segmentation fault happens
385#    when an executable file is launched by ilrun.
386#
387ifeq (cscc,$(findstring cscc,$(shell $(CSHARP_COMPILER) --version 2>&1)))
388  CSC_OPT_SHARED = -shared
389  CSC_OPT_EXE    =
390  CSC_OPT_OUTPUT = -o
391  CSC_OPT_REF    = -l
392  CSC_OPT_KEYFILE =
393endif
394
395
396# -----------------------------------------------------------------------------
397# Primary build actions
398# -----------------------------------------------------------------------------
399
400# This whole setup is more or less custom and mostly doesn't use the common
401# build directives of `makefile-common-actions.mk'.
402
403.SUFFIXES:
404.SUFFIXES: .i .cpp .h .cs .dll .o .obj .so .dylib .lo .la
405
406# The default action is to remake everything.
407
408ifdef USE_CSHARP
409  all: Makefile $(csproxy_lib) $(outpath)/libsbml.cs $(outpath_win)/libsbml.cs
410else
411  all:
412	@echo
413	@echo "Reconfigure libSBML using --with-csharp to enable CSharp support.";
414	@echo "(--with-cli-interpreter=path and/or --with-csharp-compiler=path may be required.)";
415	@echo
416	@exit 1
417endif
418
419# Until we improve swigdoc.py, the following warnings are spurious and annoying
420# and we don't need to see them.
421
422# the compile run disables the following warnings
423# -  105: duplicated using statement, due to the patch above
424# -  108: 'method name' hides inherited member 'base member name'. Use the
425#         new keyword if hiding was intended.
426# -  114: 'method name' hides inherited member 'base member name'. To make
427#         the current member override that implementation, add the override
428#         keyword. Otherwise add the new keyword.
429# - 1570: XML comment on 'class name' has badly formed XML.
430# - 1572: XML comment on 'method name' has a param tag for 'parameter name'
431#         but there is no parameter by that name.
432# - 1573: Parameter 'parameter name' has no matching param tag in the XML
433#         comment for 'method name' (but other parameters do).
434# - 1574: XML comment on 'method name' has cref attribute 'method name'
435#         that could not be resolved.
436# - 1591: Missing XML comment for publicly visible type or member 'method
437#         name'
438
439CSC_NOWARN = -nowarn:105,108,109,114,1570,1572,1573,1574,1591
440
441$(csproxy_lib): $(outpath)/libsbml.cs $(dllimport_lib)
442	-"$(SN)" -k $(sn_keyfile)
443	"$(CSHARP_COMPILER)" $(CSC_OPT_SHARED) $(CSC_NOWARN) \
444	$(CSC_OPT_OUTPUT)$(csproxy_lib) $(CSC_OPT_KEYFILE) $(outpath)/*.cs \
445	$(assembly_info_source)
446
447$(outpath)/libsbml.cs: libsbml_wrap.cpp
448
449$(outpath_win)/libsbml.cs: libsbml_wrap-win.cpp
450
451# Recreate SWIG files when one of the following conditions is true:
452#
453#  (1) libsbml_wrap.cpp does not exist
454#  (2) libsbml_wrap.cpp exists, but the file is not consistent with the
455#       current USE_LAYOUT, USE_COMP, etc., values.
456#
457# If the last run was made with a package flag like --enable-layout, and this
458# run isn't, or vice-versa, the swig wrap files will be wrong for this run.
459# However, you can't tell just by looking at file mod times, so you can't use
460# normal make dependencies.  So we do this grungy trick of looking inside
461# libsbml_wrap.cpp to see what's inside.
462#
463# The check_foo macros works as follows.  They return a non-empty string
464# "do_reswig" if re-swig'ing is called for, and this string is a phony make
465# target declared below.  When check_layout is used as a dependency of
466# libsbml_wrap.cpp via a call like this,
467#
468#  libsbml_wrap.cpp: $(shell $(call check_layout)) ...other dependencies...
469#   ...ACTIONS...
470#
471# what will happen is either check_layout will return nothing, in which
472# case the dependency is satisfied and no swig'ing needs to be done, or
473# it will return "do_reswig", a phony target that is never satisfied,
474# in which case the ...ACTIONS... will be executed.
475
476.PHONY: do_reswig
477
478ifdef USE_COMP
479  define check_comp
480    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
481    if test -z "`grep getListOfSubmodels libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
482  endef
483else
484  define check_comp
485    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
486    if test -n "`grep getListOfSubmodels libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
487  endef
488endif
489
490ifdef USE_FBC
491  define check_fbc
492    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
493    if test -z "`grep ListOfFluxBounds libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
494  endef
495else
496  define check_fbc
497    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
498    if test -n "`grep ListOfFluxBounds libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
499  endef
500endif
501
502ifdef USE_GROUPS
503  define check_groups
504    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
505    if test -z "`grep ListOfGroups libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
506  endef
507else
508  define check_groups
509    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
510    if test -n "`grep ListOfGroups libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
511  endef
512endif
513
514ifdef USE_LAYOUT
515  define check_layout
516    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
517    if test -z "`grep getListOfLayouts libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
518  endef
519else
520  define check_layout
521    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
522    if test -n "`grep getListOfLayouts libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
523  endef
524endif
525
526ifdef USE_QUAL
527  define check_qual
528    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
529    if test -z "`grep ListOfQualitativeSpecies libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
530  endef
531else
532  define check_qual
533    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
534    if test -n "`grep ListOfQualitativeSpecies libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
535  endef
536endif
537
538ifdef USE_MULTI
539  define check_multi
540    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
541    if test -z "`grep ListOfSpeciesFeatures libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
542  endef
543else
544  define check_multi
545    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
546    if test -n "`grep ListOfSpeciesFeatures libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
547  endef
548endif
549ifdef USE_RENDER
550  define check_render
551    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
552    if test -z "`grep ListOfGlobalRenderInformation libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
553  endef
554else
555  define check_render
556    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \
557    if test -n "`grep ListOfGlobalRenderInformation libsbml_wrap.cpp`"; then echo "do_reswig"; fi;
558  endef
559endif
560ifdef USE_L3V2EXTENDEDMATH
561  define check_l3v2extendedmath
562    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi;
563  endef
564else
565  define check_l3v2extendedmath
566    if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi;
567  endef
568endif
569
570
571# generate C# documentation
572csdoc.i: $(main_sources) $(swig_sources) ../swig/swigdoc.py $(wildcard ../swig/*.i)
573	../swig/swigdoc.py --language csharp --top ../../.. $(SWIGDOCDEFINES) \
574		--master ../swig/libsbml.i --output csdoc.i
575
576# libsbml_wrap.cpp (for non-Windows) and libsbml_wrap-win.cpp (for Windows)
577# stand-in for the .cs files.  Their creation results in the creation of the .cs
578# files too -- both are made by running swig.
579
580patch-swig-output:
581	@list='$(wildcard $(outpath)/*.cs)'; for file in $$list; do \
582	  echo 'using System;' > $(outpath)/.tmpfile; \
583	  echo 'using System.Runtime.InteropServices;' >> $(outpath)/.tmpfile; \
584	  echo ' ' >> $(outpath)/.tmpfile; \
585	  cat $$file >> $(outpath)/.tmpfile; \
586	  mv -f $(outpath)/.tmpfile $$file; \
587	done
588
589# for non-Windows
590libsbml_wrap.cpp $(outpath) : $(swig_sources) $(main_sources) csdoc.i \
591  $(shell $(call check_comp)) $(shell $(call check_fbc)) \
592  $(shell $(call check_layout)) $(shell $(call check_qual)) \
593  $(shell $(call check_groups)) $(shell $(call check_multi)) \
594  $(shell $(call check_render))
595	@top_srcdir@/config/chk_swig_version.sh || exit
596	test -d $(outpath) || mkdir -p $(outpath)
597	"$(SWIG)" $(SWIGFLAGS) $(sort $(default_includes) $(INCLUDES)) \
598		-c++ -csharp -namespace libsbmlcs -dllimport $(dllimport_name) \
599	        -outdir $(outpath) -o libsbml_wrap.cpp libsbml.i
600	make patch-swig-output
601
602# for Windows
603libsbml_wrap-win.cpp $(outpath_win) : $(swig_sources) $(main_sources) csdoc.i \
604  $(shell $(call check_comp)) $(shell $(call check_fbc)) $(shell $(call check_groups)) \
605  $(shell $(call check_layout)) $(shell $(call check_qual)) $(shell $(call check_multi)) \
606  $(shell $(call check_render))
607	@top_srcdir@/config/chk_swig_version.sh || exit
608	test -d $(outpath_win) || mkdir -p $(outpath_win)
609	"$(SWIG)" $(SWIGFLAGS) $(SWIGFLAGS_WIN) $(sort $(default_includes) $(INCLUDES)) \
610		-c++ -csharp -namespace libsbml -dllimport $(dllimport_name) \
611	        -outdir $(outpath_win) -o libsbml_wrap-win.cpp libsbml.i
612
613clean-swigfiles: clean
614	-rm -rf $(outpath) $(outpath_win) libsbml_wrap.cpp libsbml_wrap-win.cpp
615
616
617# -----------------------------------------------------------------------------
618# Checking.
619# -----------------------------------------------------------------------------
620
621check_runner_exe =  $(check_runner_exe_man) $(check_runner_exe_cvt)
622check_runner_exe_man = TestRW.exe
623check_runner_exe_cvt = TestRunner.exe
624
625$(check_runner_exe_man): Makefile $(csproxy_lib) $(check_runner_source_man)
626	"$(CSHARP_COMPILER)" $(CSC_OPT_EXE) $(CSC_OPT_OUTPUT)$(check_runner_exe_man) \
627	$(CSC_OPT_REF)$(csproxy_lib) $(check_runner_source_man)
628
629$(check_runner_exe_cvt): Makefile $(csproxy_lib) $(check_runner_source_cvt) $(test_sources)
630	"$(CSHARP_COMPILER)" $(CSC_OPT_EXE) $(CSC_OPT_OUTPUT)$(check_runner_exe_cvt) \
631	$(CSC_OPT_REF)$(csproxy_lib) $(check_runner_source_cvt) $(test_sources)
632
633testsbml_dir     = ../../../examples/sample-models/from-spec/level-2
634testdata_dir = ../../sbml/test/test-data
635testsbml_files = $(wildcard $(testsbml_dir)/*.xml)
636
637check: $(check_runner_exe) $(shell $(call check_layout)) \
638  $(shell $(call check_comp)) $(shell $(call check_fbc)) \
639  $(shell $(call check_qual)) $(shell $(call check_groups)) \
640  $(shell $(call check_multi)) $(shell $(call check_render)) \
641  $(shell $(call check_l3v2extendedmath))
642	@echo
643	@echo
644	@echo Running Tests in $(thisdir)
645	@echo -----------------------------------------------------------------
646	$(call libsbmlrun,"$(CSHARP_CILINTERPRETER)" $(check_runner_exe_man) $(testsbml_files))
647	$(call libsbmlrun,"$(CSHARP_CILINTERPRETER)" $(check_runner_exe_cvt) -d $(testdata_dir) -l ./libsbmlcsP.dll)
648	@echo -----------------------------------------------------------------
649	@echo
650
651#
652# 'make test-files' will reconstruct the test files.  This is not made part
653# of 'make check' (yet).
654#
655
656test-files:
657	$(call test_translator,c,xml math annotation sbml,test)
658
659
660# -----------------------------------------------------------------------------
661# Tags.
662# -----------------------------------------------------------------------------
663
664tags: etags ctags
665
666
667# -----------------------------------------------------------------------------
668# Installation.
669# -----------------------------------------------------------------------------
670
671install_prefix=$(DESTDIR)$(LIBDIR)/mono/$(assembly_name)
672
673install: $(libraries) $(shell $(call check_layout)) \
674  $(shell $(call check_comp)) $(shell $(call check_fbc)) \
675  $(shell $(call check_qual)) $(shell $(call check_groups)) \
676  $(shell $(call check_l3v2extendedmath))
677	-$(GACUTIL) -i $(csproxy_lib) -root $(DESTDIR)$(LIBDIR)
678	$(INSTALL_SH) $(csproxy_lib) $(install_prefix)/$(csproxy_lib)
679	$(INSTALL_SH) $(dllimport_lib) $(install_prefix)/$(dllimport_lib)
680	ln -sf ../../libsbml.$(SHAREDLIBEXT) $(install_prefix)/libsbml.$(SHAREDLIBEXT)
681
682uninstall:
683	-$(GACUTIL) -u $(assembly_name) -root $(DESTDIR)$(LIBDIR)
684	rm -f $(install_prefix)/$(csproxy_lib)
685	rm -f $(install_prefix)/$(dllimport_lib)
686	rm -f $(install_prefix)/libsbml.$(SHAREDLIBEXT)
687
688installcheck:
689
690
691# -----------------------------------------------------------------------------
692# Creating distribution (for libSBML maintainers only)
693# -----------------------------------------------------------------------------
694
695dist: libsbml_wrap.cpp libsbml_wrap-win.cpp $(outpath) $(outpath_win)
696ifneq "$(MAKEFLAGS)" ""
697	$(MAKE) -$(MAKEFLAGS) dist-normal
698else
699	$(MAKE) dist-normal
700endif
701
702
703distcheck: distcheck-normal
704
705
706# -----------------------------------------------------------------------------
707# Miscellaneous
708# -----------------------------------------------------------------------------
709
710include @top_srcdir@/config/makefile-common-actions.mk
711
712
713# -----------------------------------------------------------------------------
714# End.
715# -----------------------------------------------------------------------------
716