changeset 230:1a3674836579

Provide flags for just-in-time compilation * src/configure.ac: add inst/private/get_vars.m as configured file * inst/private/get_vars.m.in: a function returning proper compiler or linker flags * inst/provate/generate_makefile.m: use flags * src/Makefile.in: add get_vars.m in the cleanall recipe
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Fri, 13 Jun 2014 18:45:40 +0200
parents 194f8c66b45a
children e3f57f92fa66
files inst/private/generate_makefile.m inst/private/get_vars.m.in src/Makefile.in src/configure.ac
diffstat 4 files changed, 45 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/inst/private/generate_makefile.m	Thu Jun 05 19:50:52 2014 +0200
+++ b/inst/private/generate_makefile.m	Fri Jun 13 18:45:40 2014 +0200
@@ -21,8 +21,8 @@
 
 STRING ="\n\
 DIR = @@PATH@@\n\
-CPPFLAGS+=\n\
-LIBS= -ldolfin\n\
+CPPFLAGS+=@@FF_CPPFLAGS@@ -g\n\
+LIBS+=@@FF_LIBS@@\n\
 MKOCTFILE = mkoctfile\n\
 FFC = ffc\n\
 \n\
@@ -35,16 +35,16 @@
 fun : @@UFL_NAME@@_Functional.oct\n\
 \n\
 @@UFL_NAME@@_FunctionSpace.oct: @@UFL_NAME@@.h @@UFL_NAME@@_FunctionSpace.cc\n\
-	$(MKOCTFILE) @@UFL_NAME@@_FunctionSpace.cc -I$(DIR) -I. $(LDFLAGS) $(CPPFLAGS) $(LIBS)\n\
+	CPPFLAGS='$(CPPFLAGS)' $(MKOCTFILE) @@UFL_NAME@@_FunctionSpace.cc -I$(DIR) -I. $(LDFLAGS) $(LIBS)\n\
 \n\
 @@UFL_NAME@@_BilinearForm.oct: @@UFL_NAME@@.h @@UFL_NAME@@_BilinearForm.cc\n\
-	$(MKOCTFILE) @@UFL_NAME@@_BilinearForm.cc -I$(DIR) -I. $(LDFLAGS) $(CPPFLAGS) $(LIBS)\n\
+	CPPFLAGS='$(CPPFLAGS)' $(MKOCTFILE) @@UFL_NAME@@_BilinearForm.cc -I$(DIR) -I. $(LDFLAGS) $(LIBS)\n\
 \n\
 @@UFL_NAME@@_LinearForm.oct: @@UFL_NAME@@.h @@UFL_NAME@@_LinearForm.cc\n\
-	$(MKOCTFILE) @@UFL_NAME@@_LinearForm.cc -I$(DIR) -I. $(LDFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBS)\n\
+	CPPFLAGS='$(CPPFLAGS)' $(MKOCTFILE) @@UFL_NAME@@_LinearForm.cc -I$(DIR) -I. $(LDFLAGS) $(LIBS)\n\
 \n\
 @@UFL_NAME@@_Functional.oct: @@UFL_NAME@@.h @@UFL_NAME@@_Functional.cc\n\
-	$(MKOCTFILE) @@UFL_NAME@@_Functional.cc -I$(DIR) -I. $(LDFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBS)\n\
+	CPPFLAGS='$(CPPFLAGS)' $(MKOCTFILE) @@UFL_NAME@@_Functional.cc -I$(DIR) -I. $(LDFLAGS) $(LIBS)\n\
 \n\
 @@UFL_NAME@@.h: @@UFL_NAME@@.ufl\n\
 	$(FFC) -l dolfin @@UFL_NAME@@.ufl\n\
@@ -61,6 +61,8 @@
 
 STRING =  strrep (STRING, "@@UFL_NAME@@", ufl_name);
 STRING =  strrep (STRING, "@@PATH@@", path);
+STRING = strrep (STRING, "@@FF_CPPFLAGS@@", get_vars ("CPPFLAGS"));
+STRING = strrep (STRING, "@@FF_LIBS@@", get_vars ("LIBS"));
 
 fid = fopen (sprintf ("Makefile_%s", ufl_name), 'w');
 if (fid >= 0)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inst/private/get_vars.m.in	Fri Jun 13 18:45:40 2014 +0200
@@ -0,0 +1,35 @@
+## Copyright (C) 2014 Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
+##
+## This program is free software; you can redistribute it and/or modify it under
+## the terms of the GNU General Public License as published by the Free Software
+## Foundation; either version 3 of the License, or (at your option) any later
+## version.
+##
+## This program 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. See the GNU General Public License for more
+## details.
+##
+## You should have received a copy of the GNU General Public License along with
+## this program; if not, see <http://www.gnu.org/licenses/>.
+
+
+## -*- texinfo -*-
+## function for internal usage only
+## @end deftypefn
+
+function var = get_vars (name)
+  persistent opts = {"CPPFLAGS",
+                     "LIBS"};
+  select = validatestring (name, opts, "get_vars", "name");
+  switch (select)
+    case "CPPFLAGS"
+      var = "@DENSE_CPPFLAGS@ @DOLFIN_CPPFLAGS@ @EIGEN_CPPFLAGS@";
+    case "LIBS"
+      tokens = strsplit (strtrim ("@EIGEN_LIBS@ @DOLFIN_LIBS@"));
+      var = strjoin (tokens, '" "');
+      var = ['"', var, '"'];
+    otherwise
+      error ("get_vars: the requested variable is not available.");
+  endswitch
+endfunction
\ No newline at end of file
--- a/src/Makefile.in	Thu Jun 05 19:50:52 2014 +0200
+++ b/src/Makefile.in	Fri Jun 13 18:45:40 2014 +0200
@@ -121,6 +121,7 @@
 	$(RM) *.o core octave-core *.oct *~ *.xml *.status *.log \
           octave-workspace configure *.pvd *.vtu
 	$(RM) -r autom4te.cache
+	$(RM) ../inst/private/get_vars.m
 	$(RM) Makefile
 
 
--- a/src/configure.ac	Thu Jun 05 19:50:52 2014 +0200
+++ b/src/configure.ac	Fri Jun 13 18:45:40 2014 +0200
@@ -62,5 +62,5 @@
   AC_MSG_ERROR([mkoctfile required to install $PACKAGE_NAME])
 fi
 
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile ../inst/private/get_vars.m])
 AC_OUTPUT