## @configure_input@
##
## \file    Makefile.PL
## \brief   Perl-specific SWIG directives for wrapping libSBML API
## \author  TBI {xtof,raim}@tbi.univie.ac.at
##
## $Id: Makefile.PL.in 9850 2009-07-18 10:33:19Z ajouraku $
## $HeadURL: https://sbml.svn.sourceforge.net/svnroot/sbml/trunk/libsbml/src/bindings/perl/Makefile.PL.in $

##
## Copyright 2004 TBI
##
## This library is free software; you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published
## by the Free Software Foundation; either version 2.1 of the License, or
## any later version.
##
## This library is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
## MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
## documentation provided hereunder is on an "as is" basis, and the
## California Institute of Technology and Japan Science and Technology
## Corporation have no obligations to provide maintenance, support,
## updates, enhancements or modifications.  In no event shall the
## California Institute of Technology or the Japan Science and Technology
## Corporation be liable to any party for direct, indirect, special,
## incidental or consequential damages, including lost profits, arising
## out of the use of this software and its documentation, even if the
## California Institute of Technology and/or Japan Science and Technology
## Corporation have been advised of the possibility of such damage.  See
## the GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library; if not, write to the Free Software Foundation,
## Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## The original code contained here was initially developed by:
##
##     Christoph Flamm and Rainer Machne
##     Institut fuer Theoretische Chemie
##     Universitaet Wien
##     Waehringerstrasse 17/3/308
##     A-1090 Wien, Austria


use ExtUtils::MakeMaker;
use Config;

WriteMakefile(
              NAME        => "LibSBML",
	      PREFIX      => "@prefix@",
              MAKEFILE    => 'Makefile-perl',
              INSTALLDIRS => "site",
              LIBS        => "@XERCES_LDFLAGS@ @EXPAT_LDFLAGS@ @LIBXML_LDFLAGS@ @XERCES_LIBS@ @EXPAT_LIBS@ @LIBXML_LIBS@ @ZLIB_LIBS@ @BZ2_LIBS@ @LIBS@ -lm",
              LDDLFLAGS   => "@LDFLAGS@ $Config{lddlflags}",
	      CC          => "@CXX@",
              LD          => "@CXX@",
	      CCFLAGS     => "@PERL_CPPFLAGS@ @CXXFLAGS@",
              INC         => "-I../swig -I../.. -I../../../include",
              MYEXTLIB    => "../../libsbml.a",
              macro       => {USE_SWIG => q[@USE_SWIG@]},
              OBJECT      => "LibSBML_wrap.o",
	      MAN1PODS    => {},
	      MAN3PODS    => {},
              AUTHOR      => "Christoph Flamm <xtof@tbi.univie.ac.at>",
              VERSION     => "@PACKAGE_VERSION@",
);

package MY;
sub postamble {
	return <<'MAKE_FRAG';

extra_sources  = \
  LibSBML.i \
  local.cpp \
  local.i   \
  list_of_fix.i \
  list_get_fix.i

swig_sources =      \
  $(extra_sources)  \
  ../swig/libsbml.h \
  ../swig/libsbml.i

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\//')

LibSBML.pm: LibSBML_wrap.cxx

LibSBML_wrap.cxx: LibSBML.pod $(swig_sources)
ifndef USE_SWIG
	$(NOECHO) $(ECHO) "Reconfigure --with-swig in order to rebuild LibSBML_wrap.cxx"
	exit 1
else
	@SWIG@ @SWIGFLAGS@ -c++ -perl5 -proxy -I../../../include LibSBML.i
endif

LibSBML.pod: $(main_sources) ../swig/libsbml.i ../swig/swigdoc.py
	../swig/swigdoc.py perl -I../.. -D../../../docs/src ../swig/libsbml.i LibSBML.pod

MYPACKLIST = $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist
#MYPERLLOCAL = $(INSTALLARCHLIB)/perllocal.pod
myuninstall:
	$(NOECHO) dirs=`cat $(MYPACKLIST) | xargs -n 1 dirname`; \
	$(PERLRUN) -MExtUtils::Install -e \
	  'uninstall('\''$(MYPACKLIST)'\',1,0')'; \
	for d in $$dirs; do \
          if test -d $$d && test -n "`find $$d -maxdepth 0 -empty`"; then \
	    echo rmdir $$d; \
	    rmdir $$d; \
          fi; \
        done; 
MAKE_FRAG
}
# End of file
