1## @configure_input@ 2## 3## @file Makefile.in 4## @brief Makefile template for libSBML Ruby bindings 5## @author Alex Gutteridge 6## @author Mike Hucka 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/ruby 53 54# `sources' are used by the default rules to determine what needs to be 55# compiled. 56 57sources = libsbml_wrap.cpp libsbml_wrap.h 58extra_sources = libsbml.i \ 59 local-packages.i.in \ 60 local-layout.i \ 61 local-l3v2extendedmath.i \ 62 local.cpp \ 63 local.i \ 64 local-downcast-astplugins-l3v2extendedmath.cpp \ 65 local-downcast-astplugins.cpp.in \ 66 local-downcast-extension-layout.cpp \ 67 local-downcast-extension-l3v2extendedmath.cpp \ 68 local-downcast-extension.cpp.in \ 69 local-downcast-namespaces.cpp.in \ 70 local-downcast-namespaces-layout.cpp \ 71 local-downcast-namespaces-l3v2extendedmath.cpp \ 72 local-downcast-converters.cpp.in \ 73 local-downcast-converters-layout.cpp \ 74 local-downcast-plugins-layout.cpp \ 75 local-downcast-plugins-l3v2extendedmath.cpp \ 76 local-downcast-plugins.cpp.in \ 77 local-downcast-packages-layout.cpp \ 78 local-downcast-packages-l3v2extendedmath.cpp \ 79 local-downcast.cpp.in 80 81# The SWIG interface files should not need to be regenerated for recipients 82# of the libSBML distributions; only developers should need to regenerate 83# them. The conditions for this are handled later below. 84 85swig_sources = $(extra_sources) ../swig/libsbml.h ../swig/libsbml.i 86 87# What we're building is a module for use with ruby. 88 89# The libSBML Ruby API library on MacOS X has to be built as a "bundle" 90# rather than a .dylib library. 91 92ifeq "$(HOST_TYPE)" "darwin" 93 platform_link_flags = -bundle 94 libraries = libSBML.bundle 95 96 # Environment variable MACOSX_DEPLOYMENT_TARGET must be set to 10.3 or later 97 # to use -undefined dynamic_lookup. 98 99 macosx_version = $(shell sw_vers -productVersion | cut -d"." -f1,2) 100 export MACOSX_DEPLOYMENT_TARGET=${macosx_version} 101else 102 libraries = libSBML.$(SHAREDLIBEXT) 103endif 104 105# If we're building 64-bit binaries, but are not running under 10.6, the 106# version of ruby will probably be 32 bit instead of 64 bit. 107 108ifdef USE_UNIVBINARY 109 ifneq "$(MACOS_VERSION)" "10.6" 110 ifneq "$(MACOS_VERSION)" "10.7" 111 ifneq "$(MACOS_VERSION)" "10.8" 112 ifneq "$(MACOS_VERSION)" "10.9" 113 114 filtered_cflags = $(shell echo '$(CFLAGS)' | sed -e "s/-arch x86_64//g") 115 filtered_cppflags = $(shell echo '$(CPPFLAGS)' | sed -e "s/-arch x86_64//g") 116 filtered_cxxflags = $(shell echo '$(CXXFLAGS)' | sed -e "s/-arch x86_64//g") 117 filtered_ldflags = $(shell echo '$(LDFLAGS)' | sed -e "s/-arch x86_64//g") 118 119 CFLAGS := $(filtered_cflags) 120 CPPFLAGS := $(filtered_cppflags) 121 CXXFLAGS := $(filtered_cxxflags) 122 LDFLAGS := $(filtered_ldflags) 123 endif 124 endif 125 endif 126 endif 127endif 128 129# Variables `subdirs', `headers', `sources', `libraries', `extra_CPPFLAGS', 130# `extra_CXXFLAGS', `extra_LDFLAGS' and `distfiles' are used by the default 131# rules in `makefile-common-actions.mk' included at the end. 132 133extra_CPPFLAGS += $(RUBY_CPPFLAGS) -I../swig -I../.. 134SWIGFLAGS += $(RUBY_CPPFLAGS) -I../swig 135 136# SBML package plug-ins 137ifdef USE_COMP 138 SWIGFLAGS += -DUSE_COMP 139 SWIGDOCDEFINES += --define USE_COMP 140endif # USE_COMP 141 142ifdef USE_FBC 143 SWIGFLAGS += -DUSE_FBC 144 SWIGDOCDEFINES += --define USE_FBC 145endif # USE_FBC 146 147ifdef USE_GROUPS 148 SWIGFLAGS += -DUSE_GROUPS 149 SWIGDOCDEFINES += --define USE_GROUPS 150endif # USE_GROUPS 151 152ifdef USE_LAYOUT 153 SWIGFLAGS += -DUSE_LAYOUT 154 SWIGDOCDEFINES += --define USE_LAYOUT 155endif # USE_LAYOUT 156 157ifdef USE_QUAL 158 SWIGFLAGS += -DUSE_QUAL 159 SWIGDOCDEFINES += --define USE_QUAL 160endif # USE_QUAL 161 162ifdef USE_MULTI 163 SWIGFLAGS += -DUSE_MULTI 164 SWIGDOCDEFINES += --define USE_MULTI 165endif # USE_MULTI 166 167ifdef USE_RENDER 168 SWIGFLAGS += -DUSE_RENDER 169 SWIGDOCDEFINES += --define USE_RENDER 170endif # USE_RENDER 171 172ifdef USE_L3V2EXTENDEDMATH 173 SWIGFLAGS += -DUSE_L3V2EXTENDEDMATH 174 SWIGDOCDEFINES += --define USE_L3V2EXTENDEDMATH 175endif # USE_L3V2EXTENDEDMATH 176 177 178# On MacOS X, compilation generates a warning about `long double'. 179 180ifeq "$(HOST_TYPE)" "darwin" 181 ifdef HAS_GCC_WNO_LONG_DOUBLE 182 extra_CPPFLAGS += -Wno-long-double 183 endif 184endif 185 186extra_LDFLAGS += $(RUBY_LDFLAGS) 187extra_LIBS += $(RUBY_LIBS) 188 189ifdef USE_EXPAT 190 extra_CPPFLAGS += @EXPAT_CPPFLAGS@ 191 extra_LDFLAGS += @EXPAT_LDFLAGS@ 192 extra_LIBS += @EXPAT_LIBS@ 193endif 194 195ifdef USE_XERCES 196 extra_CPPFLAGS += @XERCES_CPPFLAGS@ 197 extra_LDFLAGS += @XERCES_LDFLAGS@ 198 extra_LIBS += @XERCES_LIBS@ 199endif 200 201ifdef USE_LIBXML 202 extra_CPPFLAGS += @LIBXML_CPPFLAGS@ 203 extra_LDFLAGS += @LIBXML_LDFLAGS@ 204 extra_LIBS += @LIBXML_LIBS@ 205endif 206 207# -fno-strict-aliasing option is added to CXXFLAGS when using GCC. 208# As written in the SWIG Manual (section 20.2.4), SWIG generated code could cause 209# crash problems when compiled by GCC with -fstrict-aliasing option (automatically 210# enabled when using -O2 or higher optimization in GCC 3 or later) and the option 211# should be disabled by adding -fno-strict-aliasing option. 212 213ifeq (GCC,$(findstring GCC,$(shell $(CXX) --version))) 214 CXXFLAGS += -fno-strict-aliasing 215endif 216 217# We generates a C++ library for Ruby bindings with an object file in this 218# directory (libsbml_wrap.o) and other object files in sub directories in 219# 'src' directory (src/sbml, src/common, ... ) instead of linking a shared 220# library of libSBML (libsbml.$(SHAREDLIBEXT)). 221 222# All directories that contain *.{c,cpp} (implementation) files of libSBML 223# need to be listed in the following 'otherdirs' variable. 224 225otherdirs = ../../sbml/common ../../sbml/util ../../sbml/xml \ 226 ../../sbml/math ../../sbml/validator ../../sbml/validator/constraints \ 227 ../../sbml/units ../../sbml/annotation ../../sbml/compress \ 228 ../../sbml/ ../../sbml/extension ../../sbml/conversion 229 230 231ifdef USE_COMP 232 otherdirs += ../../sbml/packages/comp/common \ 233 ../../sbml/packages/comp/extension \ 234 ../../sbml/packages/comp/sbml \ 235 ../../sbml/packages/comp/util \ 236 ../../sbml/packages/comp/validator \ 237 ../../sbml/packages/comp/validator/constraints 238endif 239ifdef USE_FBC 240 otherdirs += ../../sbml/packages/fbc/common \ 241 ../../sbml/packages/fbc/extension \ 242 ../../sbml/packages/fbc/sbml \ 243 ../../sbml/packages/fbc/util \ 244 ../../sbml/packages/fbc/validator \ 245 ../../sbml/packages/fbc/validator/constraints 246endif 247ifdef USE_GROUPS 248 otherdirs += ../../sbml/packages/groups/common \ 249 ../../sbml/packages/groups/extension \ 250 ../../sbml/packages/groups/sbml \ 251 ../../sbml/packages/groups/validator \ 252 ../../sbml/packages/groups/validator/constraints 253endif 254ifdef USE_LAYOUT 255 otherdirs += ../../sbml/packages/layout/common \ 256 ../../sbml/packages/layout/extension \ 257 ../../sbml/packages/layout/sbml \ 258 ../../sbml/packages/layout/util \ 259 ../../sbml/packages/layout/validator \ 260 ../../sbml/packages/layout/validator/constraints 261endif 262ifdef USE_QUAL 263 otherdirs += ../../sbml/packages/qual/common \ 264 ../../sbml/packages/qual/extension \ 265 ../../sbml/packages/qual/sbml \ 266 ../../sbml/packages/qual/validator \ 267 ../../sbml/packages/qual/validator/constraints 268endif 269ifdef USE_MULTI 270 otherdirs += ../../sbml/packages/multi/common \ 271 ../../sbml/packages/multi/extension \ 272 ../../sbml/packages/multi/sbml \ 273 ../../sbml/packages/multi/validator \ 274 ../../sbml/packages/multi/validator/constraints 275endif 276ifdef USE_RENDER 277 otherdirs += ../../sbml/packages/render/common \ 278 ../../sbml/packages/render/extension \ 279 ../../sbml/packages/render/sbml \ 280 ../../sbml/packages/render/validator \ 281 ../../sbml/packages/render/validator/constraints 282endif 283ifdef USE_L3V2EXTENDEDMATH 284 otherdirs += ../../sbml/packages/l3v2extendedmath/common \ 285 ../../sbml/packages/l3v2extendedmath/extension \ 286 ../../sbml/packages/l3v2extendedmath/validator \ 287 ../../sbml/packages/l3v2extendedmath/validator/constraints 288endif 289 290objfiles = libsbml_wrap.lo $(wildcard $(addsuffix /*.lo,$(otherdirs))) 291 292# Files for test system. 293 294test_dir = test 295check_sources = test.rb $(wildcard $(test_dir)/**/Test*.rb) $(wildcard ruby/**/**/**/**/*.rb) $(wildcard ruby/**/**/**/*.rb) $(wildcard ruby/**/**/*.rb) $(wildcard ruby/**/*.rb) 296 297# `distfiles' determines the files and directories included in a 298# distribution. `distfiles_exclude' is used to filter out specific items, 299# so that even if they appear in `distfiles', they will not be copied in 300# the distribution. 301 302distfiles = Makefile.in \ 303 CMakeLists.txt \ 304 $(check_sources) \ 305 $(extra_sources) \ 306 README.txt \ 307 $(sources) 308 309# `extra_clean' and `extra_distclean' determine the files and directories 310# removed during "make clean" and "make distclean". 311 312extra_clean = build $(wildcard test.xml.*) 313extra_distclean = \ 314 local-downcast-extension.i local-downcast-extension.cpp \ 315 local-downcast-namespaces.i local-downcast-namespaces.cpp \ 316 local-packages.i local-downcast-plugins.cpp local-downcast.cpp 317 318# For Linux/Unix LD_LIBRARY_PATH *may* need to contain one or more library 319# paths to libsbml.so, libxerces-c.so and/or libexpat.so and/or the 320# libSBML.so generated by this Makfile. (For BSD/MacOS X replace 321# LD_LIBRARY_PATH with DYLD_LIBRARY_PATH.) 322 323 324# ----------------------------------------------------------------------------- 325# Primary build actions 326# ----------------------------------------------------------------------------- 327 328.SUFFIXES: 329.SUFFIXES: .i .cpp .o .obj .lo .la 330 331# The default action is to remake everything. 332 333ifdef USE_RUBY 334 all: Makefile libsbml_wrap.cpp $(libraries) 335else 336 all: 337 @echo 338 @echo "Reconfigure libSBML using --with-ruby to enable Ruby support."; 339 @echo 340 @exit 1 341endif 342 343# Rummage through ../swig/libsbml.i to figure out the core libSBML files that 344# are our dependencies. 345 346main_sources = \ 347 $(shell grep '%include sbml' ../swig/libsbml.i | grep -v 'libsbml-version.h' \ 348 | cut -f2- -d'/' | sed -e 's,^,../../sbml/,g') 349 350# Recreate SWIG files when one of the following conditions is true: 351# 352# (1) libsbml_wrap.cpp does not exist 353# (2) libsbml_wrap.cpp exists, but the file is not consistent with the 354# current USE_LAYOUT, USE_COMP, etc., values. 355# 356# If the last run was made with a package flag like --enable-layout, and this 357# run isn't, or vice-versa, the swig wrap files will be wrong for this run. 358# However, you can't tell just by looking at file mod times, so you can't use 359# normal make dependencies. So we do this grungy trick of looking inside 360# libsbml_wrap.cpp to see what's inside. 361# 362# The check_foo macros works as follows. They return a non-empty string 363# "do_reswig" if re-swig'ing is called for, and this string is a phony make 364# target declared below. When check_layout is used as a dependency of 365# libsbml_wrap.cpp via a call like this, 366# 367# libsbml_wrap.cpp: $(shell $(call check_layout)) ...other dependencies... 368# ...ACTIONS... 369# 370# what will happen is either check_layout will return nothing, in which 371# case the dependency is satisfied and no swig'ing needs to be done, or 372# it will return "do_reswig", a phony target that is never satisfied, 373# in which case the ...ACTIONS... will be executed. 374 375.PHONY: do_reswig 376 377ifdef USE_COMP 378 define check_comp 379 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 380 if test -z "`grep getListOfSubmodels libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 381 endef 382else 383 define check_comp 384 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 385 if test -n "`grep getListOfSubmodels libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 386 endef 387endif 388 389ifdef USE_FBC 390 define check_fbc 391 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 392 if test -z "`grep ListOfFluxBounds libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 393 endef 394else 395 define check_fbc 396 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 397 if test -n "`grep ListOfFluxBounds libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 398 endef 399endif 400 401ifdef USE_GROUPS 402 define check_groups 403 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 404 if test -z "`grep ListOfGroups libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 405 endef 406else 407 define check_groups 408 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 409 if test -n "`grep ListOfGroups libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 410 endef 411endif 412 413ifdef USE_LAYOUT 414 define check_layout 415 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 416 if test -z "`grep getListOfLayouts libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 417 endef 418else 419 define check_layout 420 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 421 if test -n "`grep getListOfLayouts libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 422 endef 423endif 424 425ifdef USE_QUAL 426 define check_qual 427 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 428 if test -z "`grep ListOfQualitativeSpecies libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 429 endef 430else 431 define check_qual 432 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 433 if test -n "`grep ListOfQualitativeSpecies libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 434 endef 435endif 436 437ifdef USE_MULTI 438 define check_multi 439 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 440 if test -z "`grep ListOfSpeciesFeatures libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 441 endef 442else 443 define check_multi 444 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 445 if test -n "`grep ListOfSpeciesFeatures libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 446 endef 447endif 448ifdef USE_RENDER 449 define check_render 450 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 451 if test -z "`grep ListOfGlobalRenderInformation libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 452 endef 453else 454 define check_render 455 if test ! -f libsbml_wrap.cpp; then echo "do_reswig"; exit; fi; \ 456 if test -n "`grep ListOfGlobalRenderInformation libsbml_wrap.cpp`"; then echo "do_reswig"; fi; 457 endef 458endif 459ifdef USE_L3V2EXTENDEDMATH 460 define check_l3v2extendedmath 461 if test ! -f LibSBML_wrap.cxx; then echo "do_reswig"; exit; fi; 462 endef 463else 464 define check_l3v2extendedmath 465 if test ! -f LibSBML_wrap.cxx; then echo "do_reswig"; exit; fi; 466 endef 467endif 468 469libsbml_wrap.cpp: $(swig_sources) $(main_sources) \ 470 $(shell $(call check_comp)) $(shell $(call check_fbc)) \ 471 $(shell $(call check_layout)) $(shell $(call check_qual)) \ 472 $(shell $(call check_groups)) $(shell $(call check_multi)) \ 473 $(shell $(call check_render)) $(shell $(call check_l3v2extendedmath)) 474 @top_srcdir@/config/chk_swig_version.sh || exit 475 $(SWIG) $(SWIGFLAGS) $(sort $(default_includes) $(INCLUDES)) \ 476 -c++ -ruby -o libsbml_wrap.cpp libsbml.i 477 478 479# ----------------------------------------------------------------------------- 480# Checking. 481# ----------------------------------------------------------------------------- 482 483check: $(libraries) $(shell $(call check_layout)) \ 484 $(shell $(call check_comp)) $(shell $(call check_fbc)) \ 485 $(shell $(call check_qual)) $(shell $(call check_groups)) \ 486 $(shell $(call check_multi)) $(shell $(call check_render)) \ 487 $(shell $(call check_l3v2extendedmath)) 488 @echo 489 @echo 490 @echo Running Tests in $(thisdir) 491 @echo ----------------------------------------------------------------- 492 $(call libsbmlrun, $(RUBY) -I./ -I./ruby test.rb) 493 @echo ----------------------------------------------------------------- 494 @echo 495 496# 497# 'make test-files' will reconstruct the test files. This is not made part 498# of 'make check' (yet). 499# 500 501test-files: 502 $(call test_translator,r,xml math annotation sbml,test) 503 504 505# ----------------------------------------------------------------------------- 506# Installation. 507# ----------------------------------------------------------------------------- 508 509install: 510 archdir=$(RUBY_INSTALL_DIR); \ 511 for i in $(libraries); do \ 512 $(MKINSTALLDIRS) $(DESTDIR)$$archdir; \ 513 $(INSTALL_SH) $$i $(DESTDIR)$$archdir/$$i; \ 514 done ; \ 515 516installcheck: 517 518uninstall: 519 -archdir=$(RUBY_INSTALL_DIR); \ 520 for i in $(libraries); do \ 521 rm $(DESTDIR)$$archdir/$$i; \ 522 done ; \ 523 524 525# ----------------------------------------------------------------------------- 526# Creating distribution (for libSBML maintainers only) 527# ----------------------------------------------------------------------------- 528 529dist: libsbml_wrap.cpp dist-normal 530 531distcheck: distcheck-normal 532 533 534 535# ----------------------------------------------------------------------------- 536# Miscellaneous 537# ----------------------------------------------------------------------------- 538 539include @top_srcdir@/config/makefile-common-actions.mk 540 541 542 543# ----------------------------------------------------------------------------- 544# End. 545# ----------------------------------------------------------------------------- 546