Makefile system


Sections:


Makefile

############################################################################
# $Id: Makefile 2909 2009-12-08 20:01:05Z scholz $
#############################################################################
#
# This file is part of magpar.
#
# Copyright (C) 2002-2009 Werner Scholz
#
# www:   http://www.magpar.net/
# email: magpar(at)magpar.net
#
# magpar 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 2 of the License, or
# (at your option) any later version.
#
# magpar 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 magpar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#############################################################################

magpar_exe  = magpar.exe
magpar_revh = magpar_revision.h
magpar_verh = magpar_version.h

all: $(magpar_exe)

# (de)activate libraries, library versions, set paths, compiler flags, etc.
# imported from Makefile.in and Makefile.in.$HOSTNAME
include Makefile.in

# read list of files and other settings
include Makefile.files

magpar_rev=$(shell awk '{print $$3}' $(magpar_revh)|sed  "s/\"//"g)
magpar_ver=$(shell awk '{print $$3}' $(magpar_verh)|sed  "s/\"//"g)

$(magpar_revh): FORCE
	@r_old=$(magpar_rev); \
	if [ -d .svn ] && which svnversion >& /dev/null && svn -u status >& /dev/null; then \
	  r_new=`svnversion`; \
	else \
	  r_old2=`echo $$r_old|sed  "s/_mod//"g`; \
	  r_new=""$$r_old2"_mod"; \
	fi; \
	if [ "$$r_new" == "exported" ]; then \
	  r_old2=`echo $$r_old|sed  "s/_mod//"g`; \
	  r_new=""$$r_old2"_mod"; \
	fi; \
	if [ "$$r_new" != "$$r_old" ]; then \
	  echo '#define MAGPAR_REVISION "'$$r_new'"' > $@ ; \
	  echo "Recreated $@ for revision $$r_new"; \
	fi

# all *.c depend on grid*.h and the Makefile (due to #define) !
$(magparobj): %.o: %.c $(griddata) Makefile Makefile.in

$(magpar_exe): $(magparobj)
	-$(CLINKER) $(magparobj) -o $(magpar_exe) $(TAO_LIB) $(PETSC_TS_LIB)
	@echo ""; echo "Built magpar version $(magpar_ver) revision $(magpar_rev)"
#	strip $(magpar_exe)

tags: FORCE
	ctags `find . -name "*.c" -o -name "*.h"`

doxygen: $(magpar_revh) FORCE
	-rm -f ../doc/html/*
	ENABLED_SECTIONS="$(ENABLED_SECTIONS) changelog"; export ENABLED_SECTIONS; \
	PROJECT_NUMBER="Version $(magpar_ver) Build $(magpar_rev)";   export PROJECT_NUMBER; \
	GENERATE_HTML="YES";    export GENERATE_HTML; \
	GENERATE_LATEX="NO";    export GENERATE_LATEX; \
	EXTRACT_ALL="YES";      export EXTRACT_ALL; \
	SOURCE_BROWSER="YES";   export SOURCE_BROWSER; \
	VERBATIM_HEADERS="YES"; export VERBATIM_HEADERS; \
	HAVE_DOT="YES";         export HAVE_DOT; \
	CALL_GRAPH="YES";       export CALL_GRAPH; \
	CALLER_GRAPH="YES";     export CALLER_GRAPH; \
	MAGPAR_HOME=$(MAGPAR_HOME); export MAGPAR_HOME; \
	ALIASES=$(DOXYGEN_ALIASES); export ALIASES; \
	(set; echo $$MAGPAR_HOME; doxygen --version; doxygen Doxyfile; echo ""; echo "Documentation complete!") \
	>& make_doxygen.log

doxygen_ng: $(magpar_revh) FORCE
	-rm -f ../doc/html/*
	ENABLED_SECTIONS="$(ENABLED_SECTIONS) changelog"; export ENABLED_SECTIONS; \
	PROJECT_NUMBER="version $(magpar_ver) build $(magpar_rev)";   export PROJECT_NUMBER; \
	GENERATE_HTML="YES";    export GENERATE_HTML; \
	GENERATE_LATEX="NO";    export GENERATE_LATEX; \
	EXTRACT_ALL="YES";      export EXTRACT_ALL; \
	SOURCE_BROWSER="YES";   export SOURCE_BROWSER; \
	VERBATIM_HEADERS="YES"; export VERBATIM_HEADERS; \
	HAVE_DOT="NO";          export HAVE_DOT; \
	CALL_GRAPH="NO";        export CALL_GRAPH; \
	CALLER_GRAPH="NO";      export CALLER_GRAPH; \
	MAGPAR_HOME=$(MAGPAR_HOME); export MAGPAR_HOME; \
	ALIASES=$(DOXYGEN_ALIASES); export ALIASES; \
	(doxygen --version; doxygen Doxyfile; echo ""; echo "Documentation complete!") \
	>& make_doxygen.log

# cannot use $(MAKE) here: otherwise current make waits for submake to finish
doxygenb: FORCE
	make doxygen >& make_doxygenb.log &

doxygen_latex: $(magpar_revh) FORCE
	-rm -f ../doc/latex/* AAA
	ln -s doc AAA
	ENABLED_SECTIONS="$(ENABLED_SECTIONS)"; export ENABLED_SECTIONS; \
	PROJECT_NUMBER="version $(magpar_ver) build $(magpar_rev)";   export PROJECT_NUMBER; \
	GENERATE_HTML="NO";    export GENERATE_HTML; \
	GENERATE_LATEX="YES";  export GENERATE_LATEX; \
	EXTRACT_ALL="NO";      export EXTRACT_ALL; \
	SOURCE_BROWSER="NO";   export SOURCE_BROWSER; \
	VERBATIM_HEADERS="NO"; export VERBATIM_HEADERS; \
	HAVE_DOT="NO";         export HAVE_DOT; \
	CALL_GRAPH="NO";       export CALL_GRAPH; \
	CALLER_GRAPH="NO";     export CALLER_GRAPH; \
	ALIASES=$(DOXYGEN_ALIASES); export ALIASES; \
	doxygen Doxyfile >& make_doxygenlatex.log
	rm AAA
	(cd ../doc/latex; $(MAKE)) >> make_doxygenlatex.log; true
	mv ../doc/latex/refman.pdf ../doc/magpar.pdf; rm -r -f ../doc/latex/

linkcheck: FORCE
	-cd ../doc/html/; linkchecker index.html >& ../../src/make_linkchecker.log
	(echo ""; echo "===== Errors and Warnings ====="; \
	  grep Warning make_linkchecker.log; grep Error make_linkchecker.log \
	) > make_linkchecker2.log

alloptcheck: FORCE
	grep "PetscOption" `find . -name "*.c"`|awk -F "\"" '{print $$2}'|sort|uniq > make_options_code.log
	(for i in `find . -name "allopt_*" | grep -v "\.svn"`; do grep "^-" $$i; done)|awk '{print $$1}' >> make_options_code.log
	sort make_options_code.log|uniq > x_t; mv x_t make_options_code.log
	grep "PetscOption" `find . -name "*.c"`|grep "-"|sed 's/:[^\"]*\"/\t\t/'|sed 's/\".*//'|sort|uniq > make_options_allopt.log
	(for i in `find . -name "allopt*" | grep -v "\.svn"`; do grep "^-" $$i; done)|awk '{print $$1}'|sort|uniq > make_options_allopt.log;diff -B make_options_code.log make_options_allopt.log > make_options.log

bakclean: FORCE
	-rm -f -v `find . -name "~*"`
	-rm -f -v `find . -name ".#*"`

oclean: FORCE
	-rm -f `find . -name "*.o"` $(magpar_exe)

distclean: bakclean oclean
	-rm -f *.exe *.log

varinfo: $(magpar_revh) FORCE
	@echo "HOSTNAME         = $(HOSTNAME)"
	@echo "MAGPAR_HOME      = $(MAGPAR_HOME)"
	@echo "UNIPROC          = $(UNIPROC)"
	@echo "uni              = $(uni)"
	@echo "EXCH             = $(EXCH)"
	@echo "PRECISION        = $(PRECISION)"
	@echo "CC               = $(CC)"
	@echo "CXX              = $(CXX)"
	@echo "F77              = $(F77)"
	@echo "FC               = $(FC)"
	@echo "F90              = $(F90)"
	@echo "CFLAGS           = $(CFLAGS)"
	@echo "OPTFLAGS         = $(OPTFLAGS)"
	@echo "C_CLINKER_SLFLAG = $(C_CLINKER_SLFLAG)"
	@echo "EXTERNAL_LIB     = $(EXTERNAL_LIB)"
	@echo "ENABLED_SECTIONS = $(ENABLED_SECTIONS)"
	@echo "dyn              = $(dyn)"
	@echo "SVNSERVER        = $(SVNSERVER)"
	@echo "magpar_ver       = $(magpar_ver)"
	@echo "magpar_rev       = $(magpar_rev)"
	@echo
	@echo "Libraries:"
	@echo "PD               = $(PD)"
	@echo "PETSC_VERSION    = $(PETSC_VERSION)"
	@echo "PETSC_ARCH       = $(PETSC_ARCH)"
	@echo "PETSC_DIR        = $(PETSC_DIR)"
	@echo "TAO_DIR          = $(TAO_DIR)"
	@echo "METIS_DIR        = $(METIS_DIR)"
	@echo "SUNDIALS_VERSION = $(SUNDIALS_VERSION)"
	@echo "SUNDIALS_DIR     = $(SUNDIALS_DIR)"
	@echo "ATLAS_DIR        = $(ATLAS_DIR)"
	@echo "MPI_DIR          = $(MPI_DIR)"
	@echo "PNG_DIR          = $(PNG_DIR)"
	@echo "ZLIB_DIR         = $(ZLIB_DIR)"

testall: FORCE
	@echo "--------------------------------------------------------------------"
	$(MAKE) distclean
	@echo "--------------------------------------------------------------------"
	for i in 3.0.0 2.3.3; do \
	  for j in 230; do \
	    $(MAKE) PETSC_VERSION=$$i SUNDIALS_VERSION=$$j test; \
	  done; \
	done

test: distclean FORCE
	@echo "--------------------------------------------------------------------"
	for i in test1 test2 test3 test4 test5 test6; do \
	  $(MAKE) $$i ; \
	done; \
	$(MAKE)

test1: $(magpar_revh) FORCE
	@echo "--------------------------------------------------------------------"
	-$(MAKE) oclean
	-$(MAKE) SUNDIALS_VERSION=FALSE PNG_DIR=FALSE varinfo $(magpar_exe) >& make_$(magpar_rev)_$@.log
	-mv $(magpar_exe) magpar_$(magpar_rev)_$@.exe
test2: $(magpar_revh) FORCE
	@echo "--------------------------------------------------------------------"
	-$(MAKE) oclean
	-$(MAKE) TAO_DIR=FALSE ZLIB_DIR=FALSE PNG_DIR=FALSE varinfo $(magpar_exe) >& make_$(magpar_rev)_$@.log
	-mv $(magpar_exe) magpar_$(magpar_rev)_$@.exe
test3: $(magpar_revh) FORCE
	@echo "--------------------------------------------------------------------"
	-$(MAKE) oclean
	-$(MAKE) ADDONS=FALSE varinfo $(magpar_exe) >& make_$(magpar_rev)_$@.log
	-mv $(magpar_exe) magpar_$(magpar_rev)_$@.exe
test4: $(magpar_revh) FORCE
	@echo "--------------------------------------------------------------------"
	-$(MAKE) oclean
	-$(MAKE) ADDONS=FALSE TAO_DIR=FALSE ZLIB_DIR=FALSE PNG_DIR=FALSE varinfo $(magpar_exe) >& make_$(magpar_rev)_$@.log
	-mv $(magpar_exe) magpar_$(magpar_rev)_$@.exe
test5: $(magpar_revh) FORCE
	@echo "--------------------------------------------------------------------"
	-$(MAKE) oclean
	-$(MAKE) ADDONS=TRUE MFP=TRUE varinfo $(magpar_exe) >& make_$(magpar_rev)_$@.log
	-mv $(magpar_exe) magpar_$(magpar_rev)_$@.exe
test6: $(magpar_revh) FORCE
	@echo "--------------------------------------------------------------------"
	-$(MAKE) oclean
	-$(MAKE) varinfo $(magpar_exe) >& make_$(magpar_rev)_$@.log
	-mv $(magpar_exe) magpar_$(magpar_rev)_$@.exe

FORCE:

Makefile.in

#############################################################################
# $Id: Makefile.in 2890 2009-12-03 20:48:54Z scholz $
#############################################################################

# include default settings ##################################################
include Makefile.in.defaults

# include Makefile.in.$HOSTNAME #############################################

# set hostname if undefined
ifeq ($(HOSTNAME),)
  HOSTNAME=$(shell hostname)
endif

# possibly override various options (above) with those
# from machine specific Makefiles.in.$HOSTNAME

# check if file exists
exist := $(wildcard Makefile.in.$(HOSTNAME))
ifneq ($(strip $(exist)),)
  # include if it does
  include Makefile.in.$(HOSTNAME)
else
  exist := $(wildcard addons/Makefile.in.$(HOSTNAME))
  ifneq ($(strip $(exist)),)
    # include if it does
    include addons/Makefile.in.$(HOSTNAME)
  endif
endif

# PETSC #####################################################################

ifeq ($(PETSC_VERSION),3.0.0)
  PETSC_ARCH  = PETSc-config-magpar
  PETSC_DIR   = $(PD)/petsc-3.0.0-p10
  TAO_DIR     = $(PD)/tao-1.10-p1

  # check if we compile for single processor only
  uni=$(shell grep "define  *PETSC_HAVE_MPIUNI  *1" $(PETSC_DIR)/$(PETSC_ARCH)/include/petscconf.h)
endif

ifeq ($(PETSC_VERSION),2.3.3)
  PETSC_ARCH  = PETSc-config-magpar
  PETSC_DIR   = $(PD)/petsc-2.3.3-p15
  TAO_DIR     = $(PD)/tao-1.9

  # check if we compile for single processor only
  uni=$(shell grep "define  *PETSC_HAVE_MPIUNI  *1" $(PETSC_DIR)/bmake/$(PETSC_ARCH)/petscconf.h)
endif

ifneq ($(TAO_DIR),FALSE)
  file := $(TAO_DIR)/bmake/tao_common
  exist := $(wildcard $(file))
  ifneq ($(strip $(exist)),)
    include $(file)
    CFLAGS    += -DTAO
  endif
else
  ifeq ($(PETSC_VERSION),3.0.0)
    file := $(PETSC_DIR)/conf/base
  else
    file := $(PETSC_DIR)/bmake/common/base
  endif
  exist := $(wildcard $(file))
  ifneq ($(strip $(exist)),)
    include $(file)
  endif
endif

# SUNDIALS ##################################################################

SUNDIALS_LIBS  = -L$(SUNDIALS_DIR)/lib -lsundials_cvode

ifeq ($(uni),)
  UNIPROC = FALSE
else
  UNIPROC = TRUE
  CFLAGS      += -DUNIPROC
endif

ifeq ($(UNIPROC),TRUE)
  SUNDIALS_LIBS  += -lsundials_nvecserial
else
  SUNDIALS_LIBS  += -lsundials_nvecparallel
endif

ifeq ($(SUNDIALS_VERSION),240)
  # SUNDIALS version 2.4.0
  SUNDIALS_DIR   = $(PD)/sundials-2.4.0
  CFLAGS         += -DSUNDIALS_VERSION=$(SUNDIALS_VERSION) -I$(SUNDIALS_DIR)/include
endif

ifeq ($(SUNDIALS_VERSION),230)
  # SUNDIALS version 2.3.0
  SUNDIALS_DIR   = $(PD)/sundials-2.3.0
  CFLAGS         += -DSUNDIALS_VERSION=$(SUNDIALS_VERSION) -I$(SUNDIALS_DIR)/include
endif

ifneq ($(SUNDIALS_VERSION),FALSE)
  EXTERNAL_LIB += $(SUNDIALS_LIBS)
endif

# other libraries ###########################################################

ifneq ($(METIS_DIR),FALSE)
  EXTERNAL_LIB += -L$(METIS_DIR) -lmetis
  CFLAGS       += -DMETIS -I$(METIS_DIR)/METISLib
endif

ifneq ($(PNG_DIR),FALSE)
  EXTERNAL_LIB += -L$(PNG_DIR) -L$(PNG_DIR)/lib -lpng
  CFLAGS       += -DPNG -I$(PNG_DIR)
endif

ifneq ($(ZLIB_DIR),FALSE)
  EXTERNAL_LIB += -L$(ZLIB_DIR) -lz
  CFLAGS       += -DZLIB -I$(ZLIB_DIR)
endif

ifneq ($(PYTHON),FALSE)
  EXTERNAL_LIB += -L$(PYTHON)/config/ -l$(PYTHON)
  CFLAGS       += -DPYTHON -I/usr/include/$(PYTHON)
endif


Makefile.in.defaults

#############################################################################
# $Id: Makefile.in.defaults 2891 2009-12-03 20:50:13Z scholz $
#############################################################################

# default settings ##########################################################

# magpar home directory
MAGPAR_HOME = $(HOME)/work/magpar

# directory where the manually compiled libraries are installed
PD = $(MAGPAR_HOME)/libs

# directory of magpar source code
MAGPAR_SRC = $(MAGPAR_HOME)/src

# set floating point precision (single/double)
PRECISION=double

# select your PETSc version (suitable TAO required!)
# check Makefile.in for valid values
PETSC_VERSION = 3.0.0

# set to FALSE to disable
#TAO_DIR =

# set dummy
PETSC_XTRALIBS=

# select your SUNDIALS version
#
# check Makefile.in for valid values
# and update the path to your SUNDIALS installation directory;
# set to FALSE to disable
SUNDIALS_VERSION = 230

# select BLAS/ATLAS version
# below in the hardware specific section!

# select LAPACK version
liblapack=lapack-3.2.1

# additional libraries ######################################################
#
# activate by setting correct path
# deactivate by setting to FALSE
# NB: libpng requires zlib!

# ParMetis is required!
METIS_DIR   = $(PD)/ParMetis-3.1.1
PNG_DIR     = $(PD)/libpng-1.2.40
ZLIB_DIR    = $(PD)/zlib-1.2.3

#DRL: added these, will be used by PETSc,
#rather than assuming they are under $(PD)
ATLAS_DIR   = $(PD)/atlas/lib
MPI_DIR     = $(PD)/mpi

##### use SUPERLU for A*u1=divM (experimental)
#CFLAGS      += -DSUPERLU
# XOR
##### BLOCKSOLVE for A*u1=divM (experimental)
#CFLAGS      += -DBLOCKSOLVE

# magpar specific flags #####################################################

##### calculate exchange energy separately?
#
# set define to have exchange field and energy calculated separately from
# anisotropy; then the exchange energy is also slightly more accurate and
# the exchange energy is stored in a separate column in the log file;
# calculation of the anisotropy energy for cubic anisotropy is done
# properly including K1 and K2 terms for both uniaxial and cubic anisotropy
# (important especially for large K2!)
#
# undefine (comment out) to have anisotropy and exchange field and energy
# combined (slightly faster: saves two matrix-vector multiplications)
# anisotropy energy might be very inaccurate (for large K2)
# K2 term of uniaxial anisotropy is ignored!
#
# disable
#EXCH = FALSE
# enable
EXCH = TRUE

ADDONS   = FALSE
SPINTORQ = FALSE
EBM      = FALSE
PYTHON   = FALSE

SVNSERVER = 300.300.300.300 # dummy

# compiler flags ############################################################
CFLAGS      += -Wunused

# Adjust the following variables according to your hardware #################

# set filename of requested ATLAS library (precompiled binary)
# for your hardware check ATLAS download page for available versions:
# http://sourceforge.net/project/showfiles.php?group_id=23725
#
libatlas = atlas3.6.0_Linux_PIIISSE1.tar.gz

# general optimization options
#
# used during PETSc compilation and then immutable
# use CFLAGS to change compile options later
#
OPTFLAGS += -O2
#OPTFLAGS += -O3

# CPU specific compiler options for GCC >= 3.0
#
#OPTFLAGS += -march=pentium4  -msse -msse2  -mfpmath=sse
#OPTFLAGS += -march=pentium-m -msse -msse2  -mfpmath=sse
#OPTFLAGS += -march=athlon    -m3dnow       -mfpmath=sse
#OPTFLAGS += -march=athlon-xp -m3dnow       -mfpmath=sse
#OPTFLAGS += -march=opteron   -msse -msse2  -mfpmath=sse -m64
#OPTFLAGS += -march=nocona    -msse2        -mfpmath=sse -m64


# for Mac OS X on an iBook G4 (cf. FAQ in documentation)
#
#OPTFLAGS += -mcpu=7450 -O2 -arch=G4 -faltivec

# more (possibly unsafe!) optimizations (for newer gcc versions)
# (inspired by Acovea: http://www.coyotegulch.com/products/acovea/ )
#
#OPTFLAGS += -ffast-math
# --fast-math implies:
# -fno-math-errno -funsafe-math-optimizations -ffinite-math-only -fno-trapping-math
#OPTFLAGS += -funroll-loops -ftree-loop-linear
#OPTFLAGS += -ftree-vectorize -ftracer -fvariable-expansion-in-unroller
#OPTFLAGS += -funsafe-loop-optimizations -Wunsafe-loop-optimizations

# compiler options for development/debugging
#
#OPTFLAGS += -pedantic -msg_enable noansi -msg_enable obsolescent
#OPTFLAGS += -msg_enable performance -msg_enable portable
#OPTFLAGS += -msg_enable overflow -msg_enable questcode
#OPTFLAGS += -msg_enable unused #-msg_enable returnchecks
#OPTFLAGS += -fbounds-check # currently only supported by gcj and gfortran

# set Fortran compiler
# default: gfortran
# use g77 on old Linux distributions
# g77 usually requires libg2c (uncomment PETSC_XTRALIBS below)
#
#FC = g77
#PETSC_XTRALIBS=/usr/lib/gcc-lib/i386-redhat-linux/2.96/libg2c.a

# link static magpar binary
#STATIC   = TRUE


Makefile.in.host_debian

# example Makefile.in.$HOST for a machine running Debian testing (lenny/sid)
#
# using Debian packages:
#   libatlas-$ATLAS_ARCH-dev (ATLAS_ARCH=base, 3dnow, sse, or sse2) - see below
#   libmpich1.0-dev
#   mpichbin
#   libparmetis-dev
#   libpng12-dev
#   zlib1g-dev
#
# Debian packages need to be installed first:
# apt-get install libmpich1.0-dev libparmetis-dev libpng12-dev zlib1g-dev

METIS_DIR     =
EXTERNAL_LIB  += -lmetis
CFLAGS        += -DMETIS -I/usr/include/metis

PNG_DIR     = /usr/lib
ZLIB_DIR    = /usr/lib
MPI_DIR     = /usr/lib/mpich

# ATLAS packages: includes full BLAS and LAPACK
#
# Debian has different ATLAS packages optimized for different optimized
# instruction sets.  Check the processor flags in /proc/cpuinfo to find out
# which extensions your processor supports, and install the appropriate
# package.
#
# apt-get install libatlas3-$ATLAS_ARCH-dev
#
# ATLAS_ARCH should be set to the highest-performing vectorized math implementation
# that your system is capable of, in decreasing order of preference:
#
# optimized packages:
#
# ATLAS_ARCH  comment
# -----------------------------------------------------------------
#   sse2      AMD/Intel processors with SSE2 extensions (32-bit mode)
#   sse       AMD/Intel processors with SSE extensions (32-bit mode)
#   3dnow     AMD processors with 3dnow extensions (32-bit mode)
#   altivec   PowerPC processors
#   ev6       Alpha processors
#   v9        Sparc processors
#
#ATLAS_ARCH    = sse2
#ATLAS_DIR     = /usr/lib/$ATLAS_ARCH/atlas
#EXTERNAL_LIB  += -L/usr/lib/$ATLAS_ARCH -latlas
#
# generic package:
#
# ATLAS_ARCH  comment
# -----------------------------------------------------------------
#   base      generic for i386 compatible processors and
#             for AMD/Intel 64-bit processors in 64-bit mode
#
ATLAS_ARCH    = generic
ATLAS_DIR     = /usr/lib/atlas
EXTERNAL_LIB  += -latlas

Makefile.in.host_oldlibs

# example Makefile.in.$HOST using older libraries

# override settings in Makefile.in.defaults
libatlas = atlas3.6.0_Linux_HAMMER64SSE2.tar.gz
liblapack=lapack-3.1

METIS_DIR    = $(PD)/ParMetis-3.1
PNG_DIR     = $(PD)/libpng-1.2.22
ZLIB_DIR    = $(PD)/zlib-1.2.3

# override settings in Makefile.in
PETSC_VERSION = 2.3.3-p4
PETSC_ARCH  = PETSc-config-magpar
PETSC_DIR   = $(PD)/petsc-$(PETSC_VERSION)
TAO_DIR     = $(PD)/tao-1.9

# set Fortran compiler
# use g77 on old RedHat
FC = g77
PETSC_XTRALIBS=/usr/lib/gcc-lib/i386-redhat-linux/2.96/libg2c.a

Makefile.files

############################################################################
# $Id: Makefile.files 2746 2009-08-26 21:49:39Z scholz $
#############################################################################

griddata  = griddata.h

magparobj = main.o
main.o: $(magpar_verh) $(magpar_revh)

initdir   = init
initobj   = $(initdir)/destroyinit.o \
            $(initdir)/distortmesh.o \
            $(initdir)/elevertvol.o \
            $(initdir)/facnb.o \
            $(initdir)/filterelements.o \
            $(initdir)/filternodes.o \
            $(initdir)/initinfo.o \
            $(initdir)/maginit.o \
            $(initdir)/magset.o \
            $(initdir)/modifyprop_par.o \
            $(initdir)/modifyprop_ser.o \
            $(initdir)/movedata.o \
            $(initdir)/parinit.o \
            $(initdir)/parteleser.o \
            $(initdir)/regrefine.o \
            $(initdir)/reorder.o \
            $(initdir)/serinit.o \
            $(initdir)/vertprop.o
magparobj += $(initobj)

$(initdir)/initinfo.o: $(magpar_verh)

fielddir  = field
fieldobj  = $(fielddir)/bele.o \
            $(fielddir)/hdemag.o \
            $(fielddir)/hexch_ani.o \
            $(fielddir)/hcubic.o \
            $(fielddir)/helastic.o \
            $(fielddir)/hexternal.o \
            $(fielddir)/hext_cu.o \
            $(fielddir)/hext_ho.o \
            $(fielddir)/hext_py.o \
            $(fielddir)/htot.o \
            $(fielddir)/hstep_file.o
magparobj += $(fieldobj)

$(fielddir)/hdemag.o: $(fielddir)/bmatrix.c

iodir     = io
ioobj     = $(iodir)/readinp.o \
            $(iodir)/readmesh.o \
            $(iodir)/readkrn.o \
            $(iodir)/readpatran.o \
            $(iodir)/writedata.o \
            $(iodir)/writedataavs.o \
            $(iodir)/writedatadat.o \
            $(iodir)/writefemavs.o \
            $(iodir)/writelog.o \
            $(iodir)/writelog_pid.o
magparobj += $(ioobj)

utildir   = util
utilobj   = $(utildir)/area.o \
            $(utildir)/ascat.o \
            $(utildir)/axesrot.o \
            $(utildir)/barycent.o \
            $(utildir)/bbox2.o \
            $(utildir)/calAfe2fe.o \
            $(utildir)/calAfe2sq.o \
            $(utildir)/calAsq2fe.o \
            $(utildir)/calcbbox.o \
            $(utildir)/cart2sphere.o \
            $(utildir)/distint.o \
            $(utildir)/distortvec.o \
            $(utildir)/distpointline.o \
            $(utildir)/ipol.o \
            $(utildir)/matviewstruct.o \
            $(utildir)/matcreateseqadj.o \
            $(utildir)/mesh2dual.o \
            $(utildir)/printmatinfo.o \
            $(utildir)/progressbar.o \
            $(utildir)/renormvec.o \
            $(utildir)/solidangle.o \
            $(utildir)/syncffprintf.o \
            $(utildir)/tettri.o \
            $(utildir)/vecsetvec.o
magparobj += $(utilobj)

llgdir    = llg
llgobj    = $(llgdir)/myllgjacobian.o \
            $(llgdir)/calc_dMdt.o

ifneq ($(SUNDIALS_VERSION),FALSE)
llgobj    +=$(llgdir)/checkiterationllg.o \
            $(llgdir)/mytscreatepvode.o \
            $(llgdir)/mytssteppvode.o \
            $(llgdir)/precond.o \
            $(llgdir)/rhsfunction.o \
            $(llgdir)/writelog_pvode.o
endif
magparobj += $(llgobj)

ifneq ($(TAO_DIR),FALSE)
eminidir  = emini
eminiobj  = $(eminidir)/checkiterationemini.o \
            $(eminidir)/eminisolve.o
magparobj += $(eminiobj)
endif

ifneq ($(PNG_DIR),FALSE)
pngdir    = png
pngobj    = $(pngdir)/writedatapng.o \
            $(pngdir)/writedatapng2.o \
            $(pngdir)/writepng.o
magparobj += $(pngobj)
endif

ifeq ($(EBM),TRUE)
ifneq ($(SUNDIALS_VERSION),FALSE)
  CFLAGS += -DEBM
  include ebm/Makefile.in
endif
endif

ifeq ($(ADDONS),TRUE)
  ENABLED_SECTIONS = addons
  CFLAGS += -DADDONS
  addonsdir = addons
  include $(addonsdir)/Makefile.in

  llg2dir   = llg2
  llg2obj   = $(llg2dir)/myts2.o \
              $(llg2dir)/checkiteration2.o
  magparobj += $(llg2obj)

  llgtsdir  = llgts
  llgtsobj  = $(llgtsdir)/mytscreate.o \
              $(llgtsdir)/checkiterationllgts.o
  magparobj += $(llgtsobj)

  browndir  = brown
  brownobj  = $(browndir)/brown.o
  magparobj += $(brownobj)
endif

ifeq ($(SPINTORQ),TRUE)
  CFLAGS += -DSPINTORQ
  spintorqdir = spintorq
  include $(spintorqdir)/Makefile.in
endif

# other settings ############################################################

ifeq ($(EXCH),TRUE)
  CFLAGS += -DEXCH
endif

# append default CFLAGS (maybe set to "CFLAGS += -I. -o $@")
CFLAGS += -I.

# configure for linking static executable if requested
ifeq ($(STATIC),TRUE)
  EXTERNAL_LIB   += -static
  SL_LINKER_LIBS := $(SL_LINKER_LIBS:-lgcc_s=)
  BLASLAPACK_LIB := $(BLASLAPACK_LIB:-lgcc_s=)
  PCC_LINKER_LIBS:= $(PCC_LINKER_LIBS:-lgcc_s=)
  FC_LINKER_LIBS := $(FC_LINKER_LIBS:-lgcc_s=)
endif


Makefile.libs

#############################################################################
# $Id: Makefile.libs 2908 2009-12-08 19:54:00Z scholz $
#############################################################################
#
# This file is part of magpar.
#
# Copyright (C) 2002-2009 Werner Scholz
#
# www:   http://www.magpar.net/
# email: magpar(at)magpar.net
#
# magpar 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 2 of the License, or
# (at your option) any later version.
#
# magpar 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 magpar; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#############################################################################

# set Fortran compiler
# GNU GCC >=4.0 Fortran 77/95: gfortran
FC=gfortran
TIMER=INT_ETIME
#
# GNU GCC < 4.0 Fortran 77: g77
#FC=g77
#TIMER=EXT_ETIME

# Modify Makefile.in, Makefile.in.$HOSTNAME:
# Update variables, paths to required libraries, compiler options, etc.

# get desired configuration
include Makefile.in

# Tell make to export all variables to child processes by default.
# http://www.cs.utah.edu/dept/old/texinfo/make/make.html#SEC62
export

all: atlas lapack mpi parmetis sundials petsc tao zlib libpng
others: atlas_compile gmp mpfr gcc mgridgen python numpy matplotlib scotch

############################
# GMP
############################

# http://gmplib.org/

gmplib=$(PD)/gmplib/

# latest version is: 4.3.1
gmp: $(gmplib)
$(gmplib):
	gmprel=4.2.2; \
	cd $(PD); \
	lib=gmp-$$gmprel; \
	if [ ! -e $$lib.tar.gz ]; then wget -N ftp://ftp.gnu.org/gnu/gmp/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/gmp_$$gmprel; \
	./configure --prefix=$$instdir 2>&1 | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) check 2>&1 | tee makecheck.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	ln -s $$instdir $(PD)/gmp

############################
# MPFR
############################

# http://www.mpfr.org/

mpfrlib=$(PD)/mpfrlib/

# latest version is: 2.4.2
mpfr: $(mpfrlib)
$(mpfrlib):
	mpfrrel=2.3.1; \
	cd $(PD); \
	lib=mpfr-$$mpfrrel; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://www.mpfr.org/mpfr-current/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/mpfr_$$mpfrrel; \
	./configure --with-gmp=$(PD)/gmp --prefix=$$instdir 2>&1 | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) check 2>&1 | tee makecheck.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	ln -s $$instdir $(PD)/mpfr

############################
# GCC
############################

# http://gcc.gnu.org/mirrors.html
# ftp://mirrors.laffeycomputer.com/pub/gcc.gnu.org/pub/gcc/releases/

gccbin=$(PD)/gcc/bin/gcc

# latest version is: 4.4.2
gcc: $(gccbin)
$(gccbin):
	gccrel=4.3.0; \
	cd $(PD); \
	srcdir=$(PD)/gccsrc-$$gccrel; \
	mkdir $$srcdir; \
	cd $$srcdir; \
	ftpserv=http://mirrors.usc.edu/pub/gnu/gcc/; \
	for i in core fortran g++ ; do \
	  lib=gcc-$$i-$$gccrel.tar.bz2; \
	  if [ ! -e $$lib ]; then wget -N $$ftpserv/gcc-$$gccrel/$$lib; fi; \
	  bunzip2 -c $$lib | tar xvf -; \
	done; \
	instdir=$(PD)/gcc-$$gccrel; \
	cd gcc-$$gccrel;\
	./configure --with-gmp=$(PD)/gmp --with-mpfr=$(PD)/mpfr --prefix=$$instdir 2>&1 | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	ln -s $$instdir $(PD)/gcc

############################
# ATLAS
############################

atlaslib = $(PD)/atlas/lib/libatlas.a
atlas: $(atlaslib)
$(atlaslib):
	cd $(PD); \
	if [ -n "$$libatlas" ]; then lib=$(libatlas); \
	else lib=atlas3.6.0_Linux_PIIISSE1.tar.gz; \
	fi; \
	if [ ! -e $$lib ]; then wget -N http://downloads.sourceforge.net/math-atlas/$$lib; fi; \
	arctype=`file $$lib | awk '{print $$2}'` ; \
	echo $$lib; \
	if [ ! -d $$lib ] ; then $$arctype -d -c $$lib | tar xvf - ; fi ; \
	atlasdir=`$$arctype -d -c $$lib | tar tf - |grep libatlas.a` ; \
	atlasdir=`dirname $$atlasdir`; atlasdir=`dirname $$atlasdir`; \
	rm -f atlas; ln -s -f $$atlasdir atlas; \
	mv $(lapacklib) $(lapacklib).atlas

atlas_compile:
	instdir=$(PD)/atlas; \
	cd $(PD); \
	mkdir -p $$instdir; \
	lib=atlas3.9.17.tar.bz2; \
	if [ ! -e $$lib ]; then wget -N http://downloads.sourceforge.net/math-atlas/$$lib; fi; \
	bunzip2 -c $$lib | tar xvf -; \
	cd $(PD)/atlas; \
	$(PD)/ATLAS/configure $(atlasgcc) 2>&1 | tee configure.log; \
	$(MAKE) -j 1 2>&1 | tee make.log; \
	$(MAKE) check 2>&1 | tee make_check.log; \
	$(MAKE) ptcheck 2>&1 | tee make_ptcheck.log; \
	$(MAKE) test 2>&1 | tee make_test.log; \
	$(MAKE) time 2>&1 | tee make_time.log; \
	ln -s -f Linux_* atlas; \
	mv $(lapacklib) $(lapacklib).atlas

############################
# LAPACK
############################

lapacklib2 = $(PD)/$(liblapack)/lapack_LINUX.a
$(lapacklib2): $(atlaslib)
	$(FC) --version
	cd $(PD); \
	lib=$(liblapack); \
	if [ ! -e $$lib.tgz ]; then wget -N http://www.netlib.org/lapack/$$lib.tgz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tgz|tar xv ; fi ; \
	cd $(liblapack); \
	mtmpl=INSTALL/make.inc.gfortran; \
	cp $$mtmpl make.inc; \
	$(MAKE) "FORTRAN=$(FC)" "LOADER=$(FC)" \
	  "TIMER=$(TIMER)" \
	  "BLASLIB=$(PD)/atlas/lib/libf77blas.a $(PD)/atlas/lib/libatlas.a" \
	  "OPTS=-funroll-all-loops $(OPTFLAGS)" \
	  "NOOPT=$(NOOPT)" \
	  lapacklib 2>&1 | tee make.log; \

lapacklib = $(PD)/atlas/lib/liblapack.a
lapack: $(lapacklib2) $(lapacklib)
$(lapacklib): $(atlaslib) FORCE
	cd $(PD)/atlas/lib; \
	cp $(lapacklib).atlas $(lapacklib); \
	mkdir tmp; cd tmp; \
	ar x $(PD)/$(liblapack)/lapack_LINUX.a; \
	ar r ../liblapack.a *.o; \
	cd ..; rm -rf tmp

############################
# MPI
############################

# select requested mpi library here (choose from targets below)
mpiimp=mpich2

mpilib=$($(mpiimp)lib)
mpi: $(mpiimp)

############################
# MPICH2
############################

mpich2lib = $(PD)/mpich2/lib/libmpich.a
mpich2: $(mpich2lib)
$(mpich2lib):
	cd $(PD); \
	lib=1.2.1; \
	if [ ! -e mpich2-$$lib.tar.gz ]; then wget -N --retr-symlinks http://www.mcs.anl.gov/research/projects/mpich2/downloads/tarballs/$$lib/mpich2-$$lib.tar.gz; fi; \
	if [ ! -e mpich2-$$lib.tar.gz ]; then \
	  lib=1.2.1; \
	  echo "Automatic fallback to older version mpich2-$$lib"; \
	  wget -N --retr-symlinks ftp://ftp.mcs.anl.gov/pub/mpi/mpich2-$$lib.tar.gz; \
	fi; \
	if [ ! -d mpich2-$$lib ] ; then gunzip -c mpich2-$$lib.tar.gz|tar xv ; fi ; \
	cd mpich2-$$lib; \
	instdir=$(PD)/$(mpiimp); \
	./configure --prefix=$$instdir --with-device=ch3:ssm 2>&1 | tee configure.log; \
	echo "Enforcing '-j 1' because of problems"; \
	echo "with simultaneous/parallel make jobs"; \
	$(MAKE) -j 1 2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	cd ..; ln -s $(mpiimp) mpi

############################
# MVAPICH2 1.0.X
############################

mvapich2olib = $(PD)/mvapich2o/lib/libmpich.a
mvapich2o: $(mvapich2olib)
$(mvapich2olib):
	cd $(PD); \
	lib=mvapich2-1.1;  ext=tar.gz; \
	pl= ; \
	if [ ! -e $$lib$$pl.tar.gz ]; then wget -N --retr-symlinks http://mvapich.cse.ohio-state.edu/download/mvapich2/$$lib$$pl.$$ext; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib$$pl.$$ext|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/$(mpiimp); \
	unset CFLAGS; export PREFIX=$$instdir; export OPEN_IB_HOME=/usr; export F77=$(FC); export F90=$(FC); \
	./make.mvapich2.ofa | tee configure.log; \
	cd ..; ln -s $(mpiimp) mpi

# ./configure --prefix=$$instdir --with-device=osu_ch3:mrail:ssm --with-rdma=gen2 --with-pm=mpd --disable-romio --without-mpe 2>&1 | tee configure.log; \
# $(MAKE) 2>&1 | tee make.log; \
# $(MAKE) install 2>&1 | tee makeinst.log

############################
# MVAPICH2 1.2 and later
############################

mvapich2lib = $(PD)/mvapich2/lib/libmpich.a
mvapich2: $(mvapich2lib)
$(mvapich2lib):
	cd $(PD); \
	lib=mvapich2-1.4; ext=tgz; \
	pl= ; \
	if [ ! -e $$lib$$pl.tar.gz ]; then wget -N --retr-symlinks http://mvapich.cse.ohio-state.edu/download/mvapich2/$$lib$$pl.$$ext; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib$$pl.$$ext|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/$(mpiimp); \
	./configure --prefix=$$instdir 2>&1 | tee configure.log; \
	$(MAKE)  2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	cd ..; ln -s $(mpiimp) mpi

############################
# MPICH1
############################

mpich1lib = $(PD)/mpich1/lib/libmpich.a
mpich1: $(mpich1lib)
$(mpich1lib):
	cd $(PD); \
	lib=mpich-1.2.7p1; \
	if [ ! -e $$lib.tar.gz ]; then wget -N --retr-symlinks ftp://ftp.mcs.anl.gov/pub/mpi/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/$(mpiimp); \
	./configure | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) testing 2>&1 | tee makeinst.log; \
	./bin/mpiinstall --prefix=$$instdir; \
	cd ..; ln -s $(mpiimp) mpi

############################
# OpenMPI
############################

openmpilib = $(PD)/openmpi/lib/libopenmpi.a
openmpi: $(openmpilib)
$(openmpilib):
	cd $(PD); \
	lib=openmpi-1.3.4; \
	if [ ! -e $$lib.tar.gz ]; then wget -N --retr-symlinks http://www.open-mpi.org/software/ompi/v1.2/downloads/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/$(mpiimp); \
	./configure --prefix=$$instdir | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	cd ..; ln -s $(mpiimp) mpi

############################
# ParMETIS
############################

parmetislib = $(PD)/ParMetis-3.1.1/libmetis.a
parmetis: $(parmetislib)
$(parmetislib):
	cd $(PD); \
	lib=ParMetis-3.1.1; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib/METISLib; \
	$(MAKE) "CC=$(MPI_DIR)/bin/mpicc" "LD=$(MPI_DIR)/bin/mpicc" 2>&1 | tee make.log

############################
# MGridGen
############################

mgridgenlib = $(PD)/ParMGridGen-1.0/libmgrid.a
mgridgen: $(mgridgenlib)
$(mgridgenlib):
	cd $(PD); \
	lib=ParMGridGen-1.0; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://www-users.cs.umn.edu/~moulitsa/download/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib/; \
	$(MAKE) "make=make" 2>&1 | tee make.log

############################
# SCOTCH
############################

scotchlib = $(PD)/scotch_5.0/libscotch.a
scotch: $(scotchlib)
$(scotchlib):
	cd $(PD); \
	lib=scotch_5.0; \
	if [ ! -e $$lib.6.tgz ]; then wget -N http://gforge.inria.fr/frs/download.php/5218/$$lib.6.tgz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib/src; \
	ln -s Make.inc/Makefile.inc.i686_pc_linux2 Makefile.inc ; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log

############################
# SUNDIALS/PVODE
############################

# set compiler options (modify for your setup!)
# add CPU specific options, e.g. -march=pentium4 -msse2 (cf. man gcc)

sundialslib = $(SUNDIALS_DIR)/lib/libsundials_cvode.a
sundials: $(sundialslib)
$(sundialslib):
	cd $(PD); \
	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
	echo "Please register on the SUNDIALS webpage:"; \
	echo "http://www.llnl.gov/CASC/sundials/download/download.html"; \
	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
	lib=`basename $(SUNDIALS_DIR)`; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://www.magpar.net/static/magpar/libs/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $(PD)/$$lib; \
	instdir=$(PD)/$$lib; \
	./configure --prefix=$$instdir --with-mpi-root=$(MPI_DIR) CFLAGS="$(OPTFLAGS)" --with-precision=$(PRECISION) 2>&1 | tee configure.log; \
	echo "forcing make install with -i to ignore errors when overwriting include files"; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) -i install 2>&1 | tee makeinst.log

############################
# Python
############################

pythonver=2.6.4
python: FORCE
	cd $(PD); \
	libver=$(pythonver); \
	lib=Python-$$libver; \
	if [ ! -e $$lib.tgz ]; then wget -N http://www.python.org/ftp/python/$$libver/$$lib.tgz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tgz|tar xv ; fi ; \
	cd $$lib; \
	export CPP=cpp CC=gcc CXX=g++; \
	./configure --prefix=$(PD)/python 2>&1 | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log

############################
# NumPy
############################

numpy: FORCE
	cd $(PD); \
	libver=1.3.0; \
	lib=numpy-$$libver; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://internap.dl.sourceforge.net/sourceforge/numpy/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	export CPP=cpp CC=gcc CXX=g++; unset CFLAGS; unset LDFLAGS; \
	rm -f site.cfg ; \
	echo "[atlas]"  >> site.cfg; \
	echo "libraries = f77blas, cblas, atlas"  >> site.cfg; \
	echo "library_dirs = $(PD)/atlas/lib"  >> site.cfg; \
	echo "include_dirs = $(PD)/atlas/include"  >> site.cfg; \
	$(PD)/python/bin/python setup.py install

############################
# matplotlib
############################

matplotlib: FORCE
	cd $(PD); \
	libver=0.99.1.2; \
	lib=matplotlib-$$libver; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://internap.dl.sourceforge.net/sourceforge/matplotlib/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	export CPP=cpp CC=gcc CXX=g++; unset CFLAGS; unset LDFLAGS; \
	$(PD)/python/bin/python setup.py build; \
	$(PD)/python/bin/python setup.py install

############################
# PETSc
############################

#petsclib = $(PETSC_DIR)/lib/PETSc-config-magpar/libpetsc.a
petsc: FORCE
	cd $(PD); \
	lib=`basename $(PETSC_DIR)`; \
	if [ ! -e $$lib.tar.gz ]; then wget ftp://ftp.mcs.anl.gov/pub/petsc/release-snapshots/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	cp $(MAGPAR_SRC)/PETSc-config-magpar.py $(PETSC_DIR)/config/; \
	OPTFLAGS="$(OPTFLAGS)"; export OPTFLAGS; \
	PRECISION="$(PRECISION)"; export PRECISION; \
	./config/PETSc-config-magpar.py 2>&1 | tee config.log; \
	$(MAKE) all 2>&1 | tee make.log

petsc_mingw: FORCE
	cd $(PD); \
	lib=`basename $(PETSC_DIR)`; \
	if [ ! -e $$lib.tar.gz ]; then Xwget ftp://ftp.mcs.anl.gov/pub/petsc/release-snapshots/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	cp $(MAGPAR_SRC)/PETSc-config-magpar.py $(PETSC_DIR)/config/; \
	OPTFLAGS="$(OPTFLAGS)"; export OPTFLAGS; \
	PRECISION="$(PRECISION)"; export PRECISION; \
	./config/PETSc-config-magpar.py 2>&1 | tee config.log; \
	hfile=PETSc-config-magpar/include/petscconf.h; \
	cp $$hfile $$hfile.bak; \
	cat $$hfile.bak | \
	sed "/PETSC_HAVE_GETPAGESIZE/,+2 d" | \
	sed "/PETSC_HAVE_IEEEFP_H/,+2 d" | \
	sed "/PETSC_HAVE_NETDB_H/,+2 d" | \
	sed "/PETSC_HAVE_PWD_H/,+2 d" | \
	sed "/PETSC_HAVE_SYS_PROCFS_H/,+2 d" | \
	sed "/PETSC_HAVE_SYS_RESOURCE_H/,+2 d" | \
	sed "/PETSC_HAVE_SYS_TIMES_H/,+2 d" | \
	sed "/PETSC_HAVE_SYS_UTSNAME_H/,+2 d" \
	> $$hfile; \
	$(MAKE) all 2>&1 | tee make.log

# Installation instructions for PETSc versions older than 2.3.0
# have been moved to the FAQ page.

############################
# TAO
############################

# magpar requires
# (PETSc version 3.0.0 and TAO 1.10) or
# (PETSc version 2.3.3 and TAO 1.9) or
# (PETSc version 2.3.2 and TAO 1.8.2) or
# (PETSc version 2.3.0 and TAO 1.8) or
# (PETSc version 2.2.1 and TAO 1.7) or
# (PETSc version 2.2.0 and TAO 1.6) or
# (PETSc version 2.1.6 and TAO 1.5)

taolib = $(TAO_DIR)/lib/PETSc-config-magpar/libtao.a
tao: $(taolib)
$(taolib):
	cd $(PD); \
	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
	echo "Please register on the TAO webpage:"; \
	echo "http://www.mcs.anl.gov/research/projects/tao/download/"; \
	echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
	lib=`basename $(TAO_DIR)`; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://www.mcs.anl.gov/research/projects/tao/download/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $(TAO_DIR); \
	echo "Enforcing '-j 1' because of problems"; \
	echo "with simultaneous/parallel make jobs"; \
	$(MAKE) -j 1 2>&1 | tee make.log

############################
# zlib
############################

zliblib = $(ZLIB_DIR)/libz.a
zlib: $(zliblib)
$(zliblib):
	cd $(PD); \
	lib=`basename $(ZLIB_DIR)`; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://www.zlib.net/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	ln -s $$lib zlib; \
	cd $$lib; \
	$(MAKE) CC=$(CC) CFLAGS="-O -fPIC" 2>&1 | tee make.log; \
	$(MAKE) test 2>&1 | tee maketest.log

############################
# libpng
############################

pnglib = $(PNG_DIR)/lib/libpng12.a
libpng: $(pnglib)
$(pnglib): $(zliblib)
	cd $(PD); \
	lib=`basename $(PNG_DIR)`; \
	if [ ! -e $$lib.tar.gz ]; then wget -N http://downloads.sourceforge.net/libpng/$$lib.tar.gz; fi; \
	if [ ! -d $$lib ] ; then gunzip -c $$lib.tar.gz|tar xv ; fi ; \
	cd $$lib; \
	instdir=$(PD)/$$lib; \
	true ./configure --prefix=$$instdir --enable-shared=no 2>&1 | tee configure.log; \
	true CFLAGS="-I$(ZLIB_DIR)"; export CFLAGS; \
	true LDFLAGS="-L$(ZLIB_DIR)"; export LDFLAGS; \
	./configure CFLAGS="-I$(ZLIB_DIR)" LDFLAGS="-L$(ZLIB_DIR)" --prefix=$$instdir --enable-shared=no 2>&1 | tee configure.log; \
	$(MAKE) 2>&1 | tee make.log; \
	$(MAKE) install 2>&1 | tee makeinst.log; \
	$(MAKE) check 2>&1 | tee makecheck.log

############################
# Gmsh
############################

gmsh: FORCE
	cd $(PD); \
	ver=2.4.2; \
	arc=gmsh-$$ver-Linux.tgz; \
	if [ ! -e $$arc ]; then wget -N http://geuz.org/gmsh/bin/Linux/$$arc; fi; \
	gunzip -c $$arc|tar xv

############################
# Netgen
############################

netgen: FORCE
	cd $(PD); \
	ver=4.9.11; \
	arc=netgen-$$ver.tar.gz; \
	if [ ! -e $$arc ]; then wget -N http://voxel.dl.sourceforge.net/sourceforge/netgen-mesher/$$arc; fi; \
	gunzip -c $$arc|tar xv

# dummy target to enforce rebuild of other targets
FORCE:

.PHONY: all atlas atlas_compile lapack mpi mpich2 mvapich2 mpich2 openmpi parmetis mgridgen sundials petsc tao zlib libpng


magpar - Parallel Finite Element Micromagnetics Package
Copyright (C) 2002-2009 Werner Scholz