view inst/private/generate_makefile.m @ 208:8932e9cd8dd1

CPPFLAGS do not overrirde existing flags.
author gedeone-octave <marcovass89@hotmail.it>
date Tue, 18 Feb 2014 15:21:43 +0000
parents 22de20d78e27
children 1a3674836579
line wrap: on
line source

## Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net>
##
## 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 output = generate_makefile (ufl_name, path)

STRING ="\n\
DIR = @@PATH@@\n\
CPPFLAGS+=\n\
LIBS= -ldolfin\n\
MKOCTFILE = mkoctfile\n\
FFC = ffc\n\
\n\
OCTFILES = @@UFL_NAME@@_FunctionSpace.oct @@UFL_NAME@@_BilinearForm.oct @@UFL_NAME@@_LinearForm.oct\n\
\n\
all : $(OCTFILES)\n\
fs : @@UFL_NAME@@_FunctionSpace.oct\n\
rhs : @@UFL_NAME@@_BilinearForm.oct\n\
lhs : @@UFL_NAME@@_LinearForm.oct\n\
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\
\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\
\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\
\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\
\n\
@@UFL_NAME@@.h: @@UFL_NAME@@.ufl\n\
	$(FFC) -l dolfin @@UFL_NAME@@.ufl\n\
\n\
.PHONY: clean\n\
\n\
clean:\n\
	 rm -f @@UFL_NAME@@_FunctionSpace.o @@UFL_NAME@@_FunctionSpace.cc @@UFL_NAME@@.h\n\
	 rm -f @@UFL_NAME@@_BilinearForm.o @@UFL_NAME@@_BilinearForm.cc\n\
	 rm -f @@UFL_NAME@@_LinearForm.o @@UFL_NAME@@_LinearForm.cc\n\
	 rm -f @@UFL_NAME@@_Functional.o @@UFL_NAME@@_Functional.cc\n\
	 rm -f Makefile_@@UFL_NAME@@\n\
";

STRING =  strrep (STRING, "@@UFL_NAME@@", ufl_name);
STRING =  strrep (STRING, "@@PATH@@", path);

fid = fopen (sprintf ("Makefile_%s", ufl_name), 'w');
if (fid >= 0)
  fputs (fid, STRING);
  output = fclose (fid);
else
  error ("cannot open file");
  output = 1;
endif

endfunction