New build system for standalone dynare++

Note that dynare++ will only be built if configure finds ctangle, blas, lapack and pthreads


git-svn-id: https://www.dynare.org/svn/dynare/trunk@2922 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2009-09-11 17:34:15 +00:00
parent 0798669d20
commit 345a3e587a
34 changed files with 1087 additions and 893 deletions

View File

@ -1,3 +1,13 @@
SUBDIRS = preprocessor doc tests
if HAVE_CTANGLE
if HAVE_BLAS
if HAVE_LAPACK
if HAVE_PTHREAD
SUBDIRS += dynare++
endif
endif
endif
endif
ACLOCAL_AMFLAGS = -I m4

View File

@ -58,6 +58,9 @@ AC_CHECK_HEADERS([boost/graph/adjacency_list.hpp], [], [AC_MSG_ERROR([Can't find
# Don't use deprecated hash structures
AC_DEFINE([BOOST_NO_HASH])
AC_CHECK_PROG([PDFTEX], [pdftex], [pdftex])
AM_CONDITIONAL([HAVE_PDFTEX], [test "x$PDFTEX" != "x"])
AC_CHECK_PROG([PDFLATEX], [pdflatex], [pdflatex])
AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$PDFLATEX" != "x"])
@ -76,6 +79,21 @@ AM_CONDITIONAL([HAVE_XSLT], [test "x$DOCBOOK_XSLT_CURRENT_VERSION" != "xno"])
AC_CHECK_PROG([OCTAVE], [octave], [octave])
AM_CONDITIONAL([HAVE_OCTAVE], [test "x$OCTAVE" != "x"])
AC_CHECK_PROG([CTANGLE], [ctangle], [ctangle])
AM_CONDITIONAL([HAVE_CTANGLE], [test "x$CTANGLE" != "x"])
AC_CHECK_PROG([CWEAVE], [cweave], [cweave])
AM_CONDITIONAL([HAVE_CWEAVE], [test "x$CWEAVE" != "x"])
AX_BLAS
AM_CONDITIONAL([HAVE_BLAS], [test x"$ax_blas_ok" = "xyes"])
AX_LAPACK
AM_CONDITIONAL([HAVE_LAPACK], [test x"$ax_lapack_ok" = "xyes"])
AX_PTHREAD
AM_CONDITIONAL([HAVE_PTHREAD], [test x"$ax_pthread_ok" = "xyes"])
AX_MATLAB
if test "$ax_enable_matlab" = "yes"
@ -95,6 +113,22 @@ AC_CONFIG_FILES([Makefile
tests/Makefile
matlab/dynare_version.m
windows/dynare-version.nsi
dynare++/Makefile
dynare++/parser/cc/Makefile
dynare++/sylv/Makefile
dynare++/sylv/cc/Makefile
dynare++/sylv/testing/Makefile
dynare++/tl/Makefile
dynare++/tl/cc/Makefile
dynare++/tl/testing/Makefile
dynare++/doc/Makefile
dynare++/utils/cc/Makefile
dynare++/integ/Makefile
dynare++/integ/cc/Makefile
dynare++/integ/src/Makefile
dynare++/integ/testing/Makefile
dynare++/kord/Makefile
dynare++/src/Makefile
])
AC_OUTPUT

2
dynare++/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
SUBDIRS = sylv parser/cc tl doc utils/cc integ kord src

View File

@ -1,27 +0,0 @@
# $Id: Makefile 843 2006-07-28 08:54:19Z tamas $
# Copyright 2008, Ondra Kamenik
CC = g++
#LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c
LD_LIBS := -L /opt//intel/Compiler/11.0/074/mkl/lib/em64t -lmkl_intel_thread -lmkl_lapack -lmkl -lmkl_em64t -L /opt//intel/Compiler/11.0/074/lib/intel64 -lguide -lstdc++
CC_FLAGS := -Wall
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DPOSIX_THREADS -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O2 -DPOSIX_THREADS
endif
ifeq ($(OS),Windows_NT)
CC_FLAGS := -mno-cygwin -mthreads $(CC_FLAGS)
LD_LIBS := -mno-cygwin -mthreads $(LD_LIBS) -lpthreadGC1
else
CC_FLAGS := -fPIC $(CC_FLAGS)
LD_LIBS := $(LD_LIBS) -lpthread
endif

14
dynare++/doc/Makefile.am Normal file
View File

@ -0,0 +1,14 @@
EXTRA_DIST = dynare++-ramsey.tex dynare++-tutorial.tex
if HAVE_PDFLATEX
pdf-local: dynare++-ramsey.pdf dynare++-tutorial.pdf
endif
%.pdf: %.tex
$(PDFLATEX) $<
$(PDFLATEX) $<
$(PDFLATEX) $<
CLEANFILES = *.pdf *.log *.aux *.out *.toc

View File

@ -1,23 +0,0 @@
It is suggested that you compile Dynare++ with gcc version 3.4. If you have
other versions of gcc installed on your system, you need to select version
3.4, for example,
$ make "CC=gcc-3.4"
For linking, you need to compile the required linear algebra libraries
(blas, atlas, etc). Alternatively, you can install precompiled versions of
these -- make sure that you select the version that matches your CPU.
For example, if you have an SSE2 capable CPU, then on Debian GNU/Linux
(etch) you need to install the following packages to get the precompiled
linear algebra libraries:
lapack3-dev
atlas3-sse2-dev
Then set the environment variable LD_LIBRARY_PATH, eg
$ export LD_LIBRARY_PATH /usr/lib/sse2
before calling make. This will include the shared libraries in the search
path for ld.

View File

@ -0,0 +1 @@
SUBDIRS = cc src testing

View File

@ -1,67 +0,0 @@
# $Id: Makefile 2344 2009-02-09 20:36:08Z michel $
# Copyright 2005, Ondra Kamenik
include ../../Makefile.include
CC_FLAGS := -I../../sylv/cc -I../../tl/cc
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O2 -DPOSIX_THREADS
endif
ifeq ($(OS),Windows_NT)
CC_FLAGS := -mno-cygwin -mthreads $(CC_FLAGS)
LD_LIBS := -mno-cygwin -mthreads $(LD_LIBS) -lpthreadGC1
else
LD_LIBS := $(LD_LIBS) -lpthread
endif
matrix_interface := GeneralMatrix Vector SylvException
matobjs := $(patsubst %, ../../sylv/cc/%.o, $(matrix_interface))
cwebsource := $(wildcard *.cweb)
cppsource := $(patsubst %.cweb,%.cpp,$(cwebsource))
objects := $(patsubst %.cweb,%.o,$(cwebsource))
hwebsource := $(wildcard *.hweb)
hsource := $(patsubst %.hweb,%.h,$(hwebsource))
tlcwebsource := $(wildcard ../../tl/cc/*.cweb)
tlcppsource := $(patsubst %.cweb,%.cpp,$(tlcwebsource))
tlhwebsource := $(wildcard ../../tl/cc/*.hweb)
tlhsource := $(patsubst %.hweb,%.h,$(tlhwebsource))
dummy.ch:
touch dummy.ch
../../tl/cc/dummy.ch:
make -C ../../tl/cc dummy.ch
../../tl/cc/%.h: ../../tl/cc/%.hweb ../../tl/cc/dummy.ch
make -C ../../tl/cc $*.h
%.cpp: %.cweb dummy.ch
ctangle -bhp $*.cweb dummy.ch $*.cpp
%.h: %.hweb dummy.ch
ctangle -bhp $*.hweb dummy.ch $*.h
%.o : %.cpp $(hsource) $(tlhsource)
$(CC) $(CC_FLAGS) $(EXTERN_DEFS) -c $*.cpp
doc: main.web $(hwebsource) $(cwebsource)
cweave -bhp main.web
pdftex main
mv main.pdf integ.pdf
all: $(objects) $(cppsource) $(hsource)
clear:
rm -f $(cppsource)
rm -f $(hsource)
rm -f *.o
rm -f dummy.ch
rm -f *~

View File

@ -0,0 +1,53 @@
CWEBSRC = \
product.cweb \
quadrature.cweb \
quasi_mcarlo.cweb \
smolyak.cweb \
vector_function.cweb \
product.hweb \
quadrature.hweb \
quasi_mcarlo.hweb \
smolyak.hweb \
vector_function.hweb
GENERATED_FILES = \
product.cpp \
quadrature.cpp \
quasi_mcarlo.cpp \
smolyak.cpp \
vector_function.cpp \
product.h \
quadrature.h \
quasi_mcarlo.h \
smolyak.h \
vector_function.h
noinst_LIBRARIES = libinteg.a
libinteg_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) precalc_quadrature.dat
libinteg_a_CPPFLAGS = -I../../sylv/cc -I../../tl/cc -DPOSIX_THREADS
libinteg_a_CXXFLAGS = $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = main.web
dummy.ch:
touch dummy.ch
%.cpp: %.cweb dummy.ch
$(CTANGLE) -bhp $< dummy.ch $@
%.h: %.hweb dummy.ch
$(CTANGLE) -bhp $< dummy.ch $@
if HAVE_CWEAVE
if HAVE_PDFTEX
pdf: main.web $(CWEBSRC)
$(CWEAVE) -bhp main.web
$(PDFTEX) main
mv main.pdf integ.pdf
endif
endif
CLEANFILES = dummy.ch integ.pdf main.idx main.log main.scn main.tex main.toc

View File

@ -1,103 +0,0 @@
CC_FLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc $(CC_FLAGS)
#LDFLAGS = -llapack -lcblas -lf77blas -latlas -lg2c -lstdc++
ifeq ($(CC),)
CC := gcc
endif
ifneq ($(LD_LIBRARY_PATH),) # use LD_LIBRARY_PATH from environment
LDFLAGS := -Wl,--library-path $(LD_LIBRARY_PATH) $(LDFLAGS)
endif
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O3 -DPOSIX_THREADS
endif
ifeq ($(OS),Windows_NT)
CC_FLAGS := -mno-cygwin -mthreads $(CC_FLAGS)
LDFLAGS := -mno-cygwin -mthreads $(LDFLAGS) -lpthreadGC2
ARCH := w32
else
LDFLAGS := $(LDFLAGS) -lpthread
ARCH := linux
endif
sylvcppsource := $(wildcard ../../sylv/cc/*.cpp)
sylvhsource := $(wildcard ../../sylv/cc/*.h)
sylvobjects := $(patsubst %.cpp, %.o, $(sylvcppsource))
tlcwebsource := $(wildcard ../../tl/cc/*.cweb)
tlcppsource := $(patsubst %.cweb,%.cpp,$(tlcwebsource))
tlhwebsource := $(wildcard ../../tl/cc/*.hweb)
tlhsource := $(patsubst %.hweb,%.h,$(tlhwebsource))
tlobjects := $(patsubst %.cweb,%.o,$(tlcwebsource))
integcwebsource := $(wildcard ../../integ/cc/*.cweb)
integcppsource := $(patsubst %.cweb,%.cpp,$(integcwebsource))
integhwebsource := $(wildcard ../../integ/cc/*.hweb)
integhsource := $(patsubst %.hweb,%.h,$(integhwebsource))
integobjects := $(patsubst %.cweb,%.o,$(integcwebsource))
parserhsource := $(wildcard ../../parser/cc/*.h)
parsercppsource := $(wildcard ../../parser/cc/*.cpp)
utilshsource := $(wildcard ../../utils/cc/*.h)
utilscppsource := $(wildcard ../../utils/cc/*.cpp)
utilsobjects := $(patsubst %.cpp,%.o,$(utilscppsource))
../../tl/cc/dummy.ch:
make -C ../../tl/cc dummy.ch
../../tl/cc/%.cpp: ../../tl/cc/%.cweb ../../tl/cc/dummy.ch
make -C ../../tl/cc $*.cpp
../../tl/cc/%.h: ../../tl/cc/%.hweb ../../tl/cc/dummy.ch
make -C ../../tl/cc $*.h
../../tl/cc/%.o: ../../tl/cc/%.cpp $(tlhsource)
make -C ../../tl/cc $*.o
../../integ/cc/dummy.ch:
make -C ../../integ/cc dummy.ch
../../integ/cc/%.cpp: ../../integ/cc/%.cweb ../../integ/cc/dummy.ch
make -C ../../integ/cc $*.cpp
../../integ/cc/%.h: ../../integ/cc/%.hweb ../../integ/cc/dummy.ch
make -C ../../integ/cc $*.h
../../integ/cc/%.o: ../../integ/cc/%.cpp $(integhsource) $(tlhsource)
make -C ../../integ/cc $*.o
../../sylv/cc/%.o: ../../sylv/cc/%.cpp $(sylvhsource)
make -C ../../sylv/cc $*.o
../../utils/cc/%.o: ../../utils/cc/%.cpp $(utilshsource)
make -C ../../utils/cc $*.o
../../parser/cc/%.o: ../../parser/cc/%.cpp $(parserhsource)
make -C ../../parser/cc $*.o
../../parser/cc/matrix_tab.o:
make -C ../../parser/cc matrix_tab.o
../../parser/cc/matrix_ll.o:
make -C ../../parser/cc matrix_ll.o
quadrature-points: quadrature-points.cpp $(sylvhsource) $(sylvobjects) $(integhsource) $(integobjects) $(parserhsource) $(utilshsource) $(tlhsource) $(tlobjects) $(utilsobjects)
$(CC) $(CC_FLAGS) quadrature-points.cpp -o quadrature-points ../../integ/cc/quadrature.o ../../integ/cc/smolyak.o ../../integ/cc/product.o ../../integ/cc/vector_function.o ../../tl/cc/sthread.o ../../tl/cc/symmetry.o ../../tl/cc/equivalence.o ../../tl/cc/int_sequence.o ../../tl/cc/tl_static.o ../../tl/cc/permutation.o ../../parser/cc/matrix_parser.o ../../parser/cc/matrix_tab.o ../../parser/cc/matrix_ll.o ../../parser/cc/parser_exception.o ../../sylv/cc/GeneralMatrix.o ../../sylv/cc/Vector.o ../../sylv/cc/SymSchurDecomp.o ../../sylv/cc/SylvException.o ../../utils/cc/memory_file.o $(LDFLAGS)
clear:
make -C ../../tl/cc/ clear
make -C ../../integ/cc clear
make -C ../../parser/cc clear
make -C ../../utils/cc clear
make -C ../../sylv/cc clear
rm -rf quadrature-points

View File

@ -0,0 +1,6 @@
noinst_PROGRAMS = quadrature-points
quadrature_points_SOURCES = quadrature-points.cpp
quadrature_points_CPPFLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc -DPOSIX_THREADS
quadrature_points_CXXFLAGS = $(PTHREAD_CFLAGS)
quadrature_points_LDADD = ../cc/libinteg.a ../../tl/cc/libtl.a ../../parser/cc/libparser.a ../../sylv/cc/libsylv.a ../../utils/cc/libutils.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)

View File

@ -1,62 +0,0 @@
# $Id: Makefile 843 2006-07-28 08:54:19Z tamas $
# Copyright 2005, Ondra Kamenik
LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c -lpthread
CC_FLAGS := -Wall -I../cc -I ../../tl/cc -I../../sylv/cc
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O2 -DPOSIX_THREADS
endif
matrix_interface := GeneralMatrix Vector SylvException
matobjs := $(patsubst %, ../../sylv/cc/%.o, $(matrix_interface))
cwebsource := $(wildcard ../cc/*.cweb)
cppsource := $(patsubst %.cweb,%.cpp,$(cwebsource))
objects := $(patsubst %.cweb,%.o,$(cwebsource))
hwebsource := $(wildcard ../cc/*.hweb)
hsource := $(patsubst %.hweb,%.h,$(hwebsource))
tlcwebsource := $(wildcard ../../tl/cc/*.cweb)
tlcppsource := $(patsubst %.cweb,%.cpp,$(tlcwebsource))
tlobjects := $(patsubst %.cweb,%.o,$(tlcwebsource))
tlhwebsource := $(wildcard ../../tl/cc/*.hweb)
tlhsource := $(patsubst %.hweb,%.h,$(tlhwebsource))
../cc/dummy.ch:
make -C ../cc dummy.ch
../cc/%.cpp: ../cc/%.cweb ../cc/dummy.ch
make -C ../cc $*.cpp
../cc/%.h: ../cc/%.hweb ../cc/dummy.ch
make -C ../cc $*.h
../cc/%.o: ../cc/%.cpp $(hsource)
make -C ../cc $*.o
../../tl/cc/dummy.ch:
make -C ../../tl/cc dummy.ch
../../tl/cc/%.cpp: ../../tl/cc/%.cweb ../../tl/cc/dummy.ch
make -C ../../tl/cc $*.cpp
../../tl/cc/%.h: ../../tl/cc/%.hweb ../../tl/cc/dummy.ch
make -C ../../tl/cc $*.h
../../tl/cc/%.o: ../../tl/cc/%.cpp $(tlhsource)
make -C ../../tl/cc $*.o
%.o: %.cpp $(hwebsource) $(hsource) $(tlhwebsource) $(tlhsource)
$(CC) $(CC_FLAGS) -c $*.cpp
tests: $(hwebsource) $(cwebsoure) $(hsource) $(cppsource) \
$(tlhwebsource) $(tlcwebsoure) $(tlhsource) $(tlcppsource) \
tests.o $(objects) $(tlobjects)
$(CC) $(CC_FLAGS) $(objects) $(tlobjects) $(matobjs) tests.o -o tests $(LD_LIBS)
clear:
rm -f *.o
rm -f tests
make -C ../cc clear
make -C ../../tl/cc clear

View File

@ -0,0 +1,9 @@
check_PROGRAMS = tests
tests_SOURCES = tests.cpp
tests_CPPFLAGS = -I../cc -I../../tl/cc -I../../sylv/cc -DPOSIX_THREADS
tests_CXXFLAGS = $(PTHREAD_CFLAGS)
tests_LDADD = ../../tl/cc/libtl.a ../../sylv/cc/libsylv.a ../cc/libinteg.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
check-local:
./tests

View File

@ -1,78 +0,0 @@
# $Id: Makefile 2344 2009-02-09 20:36:08Z michel $
# Copyright 2004, Ondra Kamenik
include ../Makefile.include
CC_FLAGS := -I../tl/cc -I../sylv/cc -I../integ/cc $(CC_FLAGS)
xbsylvcppsource := $(wildcard ../sylv/cc/*.cpp)
sylvhsource := $(wildcard ../sylv/cc/*.h)
sylvobjects := $(patsubst %.cpp, %.o, $(sylvcppsource))
tlcwebsource := $(wildcard ../tl/cc/*.cweb)
tlcppsource := $(patsubst %.cweb,%.cpp,$(tlcwebsource))
tlhwebsource := $(wildcard ../tl/cc/*.hweb)
tlhsource := $(patsubst %.hweb,%.h,$(tlhwebsource))
tlobjects := $(patsubst %.cweb,%.o,$(tlcwebsource))
integhwebsource := $(wildcard ../integ/cc/*.hweb)
integhsource := $(patsubst %.hweb,%.h,$(integhwebsource))
cwebsource := $(wildcard *.cweb)
cppsource := $(patsubst %.cweb,%.cpp,$(cwebsource))
objects := $(patsubst %.cweb,%.o,$(cwebsource))
hwebsource := $(wildcard *.hweb)
hsource := $(patsubst %.hweb,%.h,$(hwebsource))
../integ/cc/dummy.ch:
make -C ../integ/cc dummy.ch
../tl/cc/dummy.ch:
make -C ../tl/cc dummy.ch
../tl/cc/%.cpp: ../tl/cc/%.cweb ../tl/cc/dummy.ch
make -C ../tl/cc $*.cpp
../tl/cc/%.h: ../tl/cc/%.hweb ../tl/cc/dummy.ch
make -C ../tl/cc $*.h
../integ/cc/%.h: ../integ/cc/%.hweb ../integ/cc/dummy.ch
make -C ../integ/cc $*.h
../tl/cc/%.o: ../tl/cc/%.cpp $(tlhsource)
make -C ../tl/cc $*.o
../sylv/cc/%.o: ../sylv/cc/%.cpp $(sylvhsource)
make -C ../sylv/cc $*.o
dummy.ch:
touch dummy.ch
%.cpp: %.cweb dummy.ch
ctangle -bhp $*.cweb dummy.ch $*.cpp
%.h: %.hweb dummy.ch
ctangle -bhp $*.hweb dummy.ch $*.h
%.o: %.cpp $(hwebsource) $(hsource) $(tlhwebsource) $(tlhsource) \
$(integhwebsource) $(integhsource)
$(CC) $(CC_FLAGS) -c $*.cpp
tests: $(hwebsource) $(cwebsoure) $(hsource) $(cppsource) \
$(tlhwebsource) $(tlcwebsoure) $(tlhsource) $(tlcppsource) \
$(sylvhsource) $(sylvcppsource) \
tests.o $(objects) $(tlobjects) $(sylvobjects)
$(CC) $(CC_FLAGS) $(objects) $(tlobjects) $(sylvobjects) tests.o -o tests $(LD_LIBS)
kord.pdf: doc
doc: main.web $(hwebsource) $(cwebsource)
cweave -bhp main.web
pdftex main
mv main.pdf kord.pdf
clear:
rm -f $(hsource)
rm -f $(cppsource)
rm -f *.o
rm -f tests
make -C ../tl/cc clear
make -C ../sylv/cc clear
rm -f main.{idx,dvi,pdf,scn,log,tex,toc}

91
dynare++/kord/Makefile.am Normal file
View File

@ -0,0 +1,91 @@
CWEBSRC = \
faa_di_bruno.cweb \
korder_stoch.cweb \
journal.cweb \
decision_rule.cweb \
dynamic_model.cweb \
random.cweb \
first_order.cweb \
normal_conjugate.cweb \
approximation.cweb \
global_check.cweb \
korder.cweb \
kord_exception.hweb \
random.hweb \
journal.hweb \
approximation.hweb \
korder_stoch.hweb \
dynamic_model.hweb \
decision_rule.hweb \
korder.hweb \
normal_conjugate.hweb \
first_order.hweb \
mersenne_twister.hweb \
global_check.hweb \
faa_di_bruno.hweb
GENERATED_FILES = \
faa_di_bruno.cpp \
korder_stoch.cpp \
journal.cpp \
decision_rule.cpp \
dynamic_model.cpp \
random.cpp \
first_order.cpp \
normal_conjugate.cpp \
approximation.cpp \
global_check.cpp \
korder.cpp \
kord_exception.h \
random.h \
journal.h \
approximation.h \
korder_stoch.h \
dynamic_model.h \
decision_rule.h \
korder.h \
normal_conjugate.h \
first_order.h \
mersenne_twister.h \
global_check.h \
faa_di_bruno.h
noinst_LIBRARIES = libkord.a
libkord_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES)
libkord_a_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -DPOSIX_THREADS
libkord_a_CXXFLAGS = $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = main.web
check_PROGRAMS = tests
tests_SOURCES = tests.cpp
tests_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc
tests_CXXFLAGS = $(PTHREAD_CFLAGS)
tests_LDADD = libkord.a ../tl/cc/libtl.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
check-local:
./tests
dummy.ch:
touch dummy.ch
%.cpp: %.cweb dummy.ch
$(CTANGLE) -bhp $< dummy.ch $@
%.h: %.hweb dummy.ch
$(CTANGLE) -bhp $< dummy.ch $@
if HAVE_CWEAVE
if HAVE_PDFTEX
pdf: main.web $(CWEBSRC)
$(CWEAVE) -bhp main.web
$(PDFTEX) main
mv main.pdf kord.pdf
endif
endif
CLEANFILES = dummy.ch kord.pdf main.idx main.log main.scn main.tex main.toc out.txt

View File

@ -1,113 +0,0 @@
# Copyright (C) 2005, Ondra Kamenik
# $Id: Makefile 1211 2007-03-19 21:43:42Z kamenik $
CC_FLAGS := -Wall -I../..
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g
else
CC_FLAGS := $(CC_FLAGS) -O3
endif
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
headers := $(wildcard *.h)
source := $(wildcard *.cpp)
objects := $(objects) formula_tab.o formula_ll.o matrix_tab.o matrix_ll.o \
assign_tab.o assign_ll.o namelist_tab.o namelist_ll.o \
csv_tab.o csv_ll.o
headers := $(headers) formula_tab.hh matrix_tab.hh assign_tab.hh namelist_tab.hh csv_tab.hh
source := $(source) formula_tab.cc formula_ll.cc formula.y formula.lex \
matrix_tab.cc matrix_ll.cc matrix.y matrix.lex \
assign_tab.cc assign_ll.cc assign.y assign.lex \
namelist_tab.cc namelist_ll.cc namelist.y namelist.lex \
csv_tab.cc csv_ll.cc csv.y csv.lex
formula_tab.cc: formula.y tree.h formula_parser.h
bison -d -t --verbose -oformula_tab.cc formula.y
formula_tab.hh: formula.y tree.h formula_parser.h
bison -d -t --verbose -oformula_tab.cc formula.y
formula_ll.cc: formula.lex formula_tab.hh
flex -i -oformula_ll.cc formula.lex
formula_ll.o: formula_ll.cc $(headers)
$(CC) -O3 -c formula_ll.cc
formula_tab.o: formula_tab.cc $(headers)
$(CC) -O3 -c formula_tab.cc
matrix_tab.cc: matrix.y tree.h matrix_parser.h
bison -d -t --verbose -omatrix_tab.cc matrix.y
matrix_tab.hh: matrix.y tree.h matrix_parser.h
bison -d -t --verbose -omatrix_tab.cc matrix.y
matrix_ll.cc: matrix.lex matrix_tab.hh
flex -i -omatrix_ll.cc matrix.lex
matrix_ll.o: matrix_ll.cc $(headers)
$(CC) -O3 -c matrix_ll.cc
matrix_tab.o: matrix_tab.cc $(headers)
$(CC) -O3 -c matrix_tab.cc
assign_tab.cc: assign.y static_atoms.h atom_assignings.h
bison -d -t --verbose -oassign_tab.cc assign.y
assign_tab.hh: assign.y static_atoms.h atom_assignings.h
bison -d -t --verbose -oassign_tab.cc assign.y
assign_ll.cc: assign.lex assign_tab.hh
flex -i -oassign_ll.cc assign.lex
assign_ll.o: assign_ll.cc $(headers)
$(CC) -O3 -c assign_ll.cc
assign_tab.o: assign_tab.cc $(hsource)
$(CC) -O3 -c assign_tab.cc
namelist_tab.cc: namelist.y namelist.h
bison -d -t --verbose -onamelist_tab.cc namelist.y
namelist_tab.hh: namelist.y namelist.h
bison -d -t --verbose -onamelist_tab.cc namelist.y
namelist_ll.cc: namelist.lex namelist_tab.hh
flex -i -onamelist_ll.cc namelist.lex
namelist_ll.o: namelist_ll.cc $(headers)
$(CC) -O3 -c namelist_ll.cc
namelist_tab.o: namelist_tab.cc $(hsource)
$(CC) -O3 -c namelist_tab.cc
csv_tab.cc: csv.y csv_parser.h
bison -d -t --verbose -ocsv_tab.cc csv.y
csv_tab.hh: csv.y csv_parser.h
bison -d -t --verbose -ocsv_tab.cc csv.y
csv_ll.cc: csv.lex csv_tab.hh
flex -i -ocsv_ll.cc csv.lex
csv_ll.o: csv_ll.cc $(headers)
$(CC) -O3 -c csv_ll.cc
csv_tab.o: csv_tab.cc $(hsource)
$(CC) -O3 -c csv_tab.cc
%.o: %.cpp $(headers)
$(CC) $(CC_FLAGS) -c $*.cpp
parser.a: $(objects) $(source) $(headers)
ar cr parser.a $(objects)
clear:
rm -f *~
rm -f *.o
rm -f *.cc *.hh
rm -f parser.a
rm -rf html/
rm -rf latex/

View File

@ -0,0 +1,42 @@
noinst_LIBRARIES = libparser.a
GENERATED_FILES = assign_tab.cc csv_tab.cc formula_tab.cc matrix_tab.cc namelist_tab.cc assign_tab.hh csv_tab.hh formula_tab.hh matrix_tab.hh namelist_tab.hh assign_ll.cc csv_ll.cc formula_ll.cc matrix_ll.cc namelist_ll.cc
libparser_a_SOURCES = \
location.h \
namelist.h \
atom_assignings.cpp \
atom_assignings.h \
atom_substitutions.cpp \
atom_substitutions.h \
csv_parser.cpp \
csv_parser.h \
dynamic_atoms.cpp \
dynamic_atoms.h \
fine_atoms.cpp \
fine_atoms.h \
formula_parser.cpp \
formula_parser.h \
matrix_parser.cpp \
matrix_parser.h \
parser_exception.cpp \
parser_exception.h \
static_atoms.cpp \
static_atoms.h \
static_fine_atoms.cpp \
static_fine_atoms.h \
tree.cpp \
tree.h \
$(GENERATED_FILES)
libparser_a_CPPFLAGS = -I../..
BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = assign.y csv.y formula.y matrix.y namelist.y assign.lex csv.lex formula.lex matrix.lex namelist.lex
%_tab.cc %_tab.hh: %.y
$(YACC) -d -o$*_tab.cc $<
%_ll.cc: %.lex
$(LEX) -i -o$@ $<

View File

@ -1,220 +0,0 @@
ifeq ($(USE_ATLAS),yes)
LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c -lstdc++
else ifeq ($(USE_MKL),yes)
LD_LIBS := -L /opt//intel/Compiler/11.0/074/mkl/lib/em64t -lmkl_intel_thread -lmkl_lapack -lmkl -lmkl_em64t -L /opt//intel/Compiler/11.0/074/lib/intel64 -lguide -lstdc++
else
LD_LIBS := -llapack -lblas -lg2c -lstdc++
endif
CC_FLAGS = -Wall -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I..
DYNVERSION = 1.3.7
tmpdir = /tmp/aaabbb123321
pthreadGC2 = `which pthreadGC2.dll`
mingwm10 = `which mingwm10.dll`
ifeq ($(CC),)
CC := gcc
endif
ifneq ($(LD_LIBRARY_PATH),) # use LD_LIBRARY_PATH from environment
LDFLAGS := -Wl,--library-path $(LD_LIBRARY_PATH) $(LDFLAGS)
endif
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O3 -DPOSIX_THREADS
endif
ifeq ($(OS),Windows_NT)
CC_FLAGS := -mno-cygwin -mthreads $(CC_FLAGS)
LDFLAGS := -mno-cygwin -mthreads $(LDFLAGS) $(LD_LIBS) -lpthreadGC2
ARCH := w32
MEX_SUFFIX = dll
else
LDFLAGS := $(LDFLAGS) $(LD_LIBS) -lpthread
ARCH := linux
MEX_SUFFIX = mexglx
endif
sylvcppsource := $(wildcard ../sylv/cc/*.cpp)
sylvhsource := $(wildcard ../sylv/cc/*.h)
sylvobjects := $(patsubst %.cpp, %.o, $(sylvcppsource))
tlcwebsource := $(wildcard ../tl/cc/*.cweb)
tlcppsource := $(patsubst %.cweb,%.cpp,$(tlcwebsource))
tlhwebsource := $(wildcard ../tl/cc/*.hweb)
tlhsource := $(patsubst %.hweb,%.h,$(tlhwebsource))
tlobjects := $(patsubst %.cweb,%.o,$(tlcwebsource))
kordcwebsource := $(wildcard ../kord/*.cweb)
kordcppsource := $(patsubst %.cweb,%.cpp,$(kordcwebsource))
kordhwebsource := $(wildcard ../kord/*.hweb)
kordhsource := $(patsubst %.hweb,%.h,$(kordhwebsource))
kordobjects := $(patsubst %.cweb,%.o,$(kordcwebsource))
integcwebsource := $(wildcard ../integ/cc/*.cweb)
integcppsource := $(patsubst %.cweb,%.cpp,$(integcwebsource))
integhwebsource := $(wildcard ../integ/cc/*.hweb)
integhsource := $(patsubst %.hweb,%.h,$(integhwebsource))
integobjects := $(patsubst %.cweb,%.o,$(integcwebsource))
parserhsource := $(wildcard ../parser/cc/*.h)
parsercppsource := $(wildcard ../parser/cc/*.cpp)
utilshsource := $(wildcard ../utils/cc/*.h)
utilscppsource := $(wildcard ../utils/cc/*.cpp)
cppsource := $(wildcard *.cpp) $(patsubst %.y,%_ll.cc,$(wildcard *.y)) $(patsubst %.lex,%_tab.cc,$(wildcard *.lex))
hsource := $(wildcard *.h) $(patsubst %.lex,%_tab.hh,$(wildcard *.lex))
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp)) $(patsubst %.y,%_ll.o,$(wildcard *.y)) $(patsubst %.lex,%_tab.o,$(wildcard *.lex))
all: dynare++
../tl/cc/dummy.ch:
make -C ../tl/cc dummy.ch
../tl/cc/%.cpp: ../tl/cc/%.cweb ../tl/cc/dummy.ch
make -C ../tl/cc $*.cpp
../tl/cc/%.h: ../tl/cc/%.hweb ../tl/cc/dummy.ch
make -C ../tl/cc $*.h
../tl/cc/%.o: ../tl/cc/%.cpp $(tlhsource)
make -C ../tl/cc $*.o
../integ/cc/dummy.ch:
make -C ../integ/cc dummy.ch
../integ/cc/%.cpp: ../integ/cc/%.cweb ../integ/cc/dummy.ch
make -C ../integ/cc $*.cpp
../integ/cc/%.h: ../integ/cc/%.hweb ../integ/cc/dummy.ch
make -C ../integ/cc $*.h
../integ/cc/%.o: ../integ/cc/%.cpp $(integhsource) $(tlhsource)
make -C ../integ/cc $*.o
../sylv/cc/%.o: ../sylv/cc/%.cpp $(sylvhsource)
make -C ../sylv/cc $*.o
../kord/dummy.ch:
make -C ../kord dummy.ch
../kord/%.cpp: ../kord/%.cweb ../kord/dummy.ch
make -C ../kord $*.cpp
../kord/%.h: ../kord/%.hweb ../kord/dummy.ch
make -C ../kord $*.h
../kord/%.o: ../kord/%.cpp $(tlhsource) $(kordhsource) $(integhsource)
make -C ../kord $*.o
# for some reason, the pattern rules didn't work here, so the rules
# are expanded:
dynglob_tab.cc: dynglob.y dynare_atoms.h dynare_model.h
bison -d -t --verbose -odynglob_tab.cc dynglob.y
dynglob_tab.hh: dynglob.y dynare_atoms.h dynare_model.h
bison -d -t --verbose -odynglob_tab.cc dynglob.y
dynglob_ll.cc: dynglob.lex dynglob_tab.hh
flex -i -odynglob_ll.cc dynglob.lex
dynglob_ll.o: dynglob_ll.cc $(hsource)
$(CC) -I.. -I../sylv/cc -I../tl/cc -O3 -c dynglob_ll.cc
dynglob_tab.o: dynglob_tab.cc $(hsource)
$(CC) -I.. -I../sylv/cc -I../tl/cc -O3 -c dynglob_tab.cc
%.o: %.cpp $(hsource) $(kordhsource) $(tlhsource) $(sylvhsource) $(parserhsource)
$(CC) $(CC_FLAGS) -DDYNVERSION=\"$(DYNVERSION)\" -o $*.o -c $*.cpp
../parser/cc/parser.a: $(parserhsource) $(parsercppsource)
make -C ../parser/cc parser.a
../utils/cc/utils.a: $(utilshsource) $(utilscppsource)
make -C ../utils/cc utils.a
dynare++: $(tlhwebsource) $(tlcwebsoure) $(tlhsource) $(tlcppsource) \
$(integhwebsource) $(integcwebsoure) $(integhsource) $(integcppsource) \
$(kordhwebsource) $(kordcwebsoure) $(kordhsource) $(kordcppsource) \
$(sylvhsource) $(sylvcppsource) \
$(kordobjects) $(tlobjects) $(integobjects) $(sylvobjects) $(objects) \
../parser/cc/parser.a ../utils/cc/utils.a
$(CC) -g -o dynare++ $(objects) $(kordobjects) $(integobjects) $(tlobjects) ../parser/cc/parser.a ../utils/cc/utils.a $(sylvobjects) $(LDFLAGS)
../extern/matlab/dynare_simul_.$(MEX_SUFFIX):
make -C ../extern/matlab all
srcball:
rm -rf $(tmpdir)
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/tests
cp ../tests/*.mod ../tests/*.dyn $(tmpdir)/dynare++-$(DYNVERSION)/tests
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/src
cp *.h *.cpp *.y *.lex Makefile $(tmpdir)/dynare++-$(DYNVERSION)/src
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/tl/cc
cp ../tl/cc/*web ../tl/cc/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/tl/cc
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/tl/testing
cp ../tl/testing/*.cpp ../tl/testing/*.h ../tl/testing/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/tl/testing
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/integ/cc
cp ../integ/cc/*web ../integ/cc/Makefile ../integ/cc/*.dat $(tmpdir)/dynare++-$(DYNVERSION)/integ/cc
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/integ/testing
cp ../integ/testing/*.cpp ../integ/testing/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/integ/testing
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/sylv/cc
cp ../sylv/cc/*.cpp ../sylv/cc/*.h ../sylv/cc/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/sylv/cc
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/sylv/testing
cp ../sylv/testing/*.cpp ../sylv/testing/*.h ../sylv/testing/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/sylv/testing
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/kord
cp ../kord/*web ../kord/Makefile ../kord/tests.cpp $(tmpdir)/dynare++-$(DYNVERSION)/kord
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/parser/cc
cp ../parser/cc/*.cpp ../parser/cc/*.h ../parser/cc/*.lex ../parser/cc/*.y ../parser/cc/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/parser/cc
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/utils/cc
cp ../utils/cc/*.cpp ../utils/cc/*.h ../utils/cc/Makefile $(tmpdir)/dynare++-$(DYNVERSION)/utils/cc
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/extern/matlab
cp ../extern/matlab/*.cpp ../extern/matlab/*.m ../extern/matlab/Makefile ../extern/matlab/*.bat $(tmpdir)/dynare++-$(DYNVERSION)/extern/matlab
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/doc
cp ../doc/*.tex $(tmpdir)/dynare++-$(DYNVERSION)/doc
cp ../change_log.html $(tmpdir)/dynare++-$(DYNVERSION)/
cd $(tmpdir); tar czf dynare++-$(DYNVERSION).src.tgz dynare++-$(DYNVERSION)/*
mv $(tmpdir)/dynare++-$(DYNVERSION).src.tgz ..
rm -rf $(tmpdir)
binball: dynare++ ../extern/matlab/dynare_simul_.$(MEX_SUFFIX)
rm -rf $(tmpdir)
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/tests
cp ../tests/*.mod ../tests/*.dyn $(tmpdir)/dynare++-$(DYNVERSION)/tests
mkdir -p $(tmpdir)/dynare++-$(DYNVERSION)/doc
cp ../doc/*.pdf $(tmpdir)/dynare++-$(DYNVERSION)/doc
cp dynare++* $(tmpdir)/dynare++-$(DYNVERSION)
cp ../extern/matlab/*.m $(tmpdir)/dynare++-$(DYNVERSION)
cp ../extern/matlab/dynare_simul_.$(MEX_SUFFIX) $(tmpdir)/dynare++-$(DYNVERSION)
cp ../change_log.html $(tmpdir)/dynare++-$(DYNVERSION)
ifeq ($(OS),Windows_NT)
cp $(pthreadGC2) $(tmpdir)/dynare++-$(DYNVERSION)
cp $(mingwm10) $(tmpdir)/dynare++-$(DYNVERSION)
cd $(tmpdir); zip -r dynare++-$(DYNVERSION)-$(ARCH).ix86.zip dynare++-$(DYNVERSION)/*
mv $(tmpdir)/dynare++-$(DYNVERSION)-$(ARCH).ix86.zip ..
else
cd $(tmpdir); tar czf dynare++-$(DYNVERSION)-$(ARCH).ix86.tgz dynare++-$(DYNVERSION)/*
mv $(tmpdir)/dynare++-$(DYNVERSION)-$(ARCH).ix86.tgz ..
endif
rm -rf $(tmpdir)
clear:
rm -f *.o
rm -f dynare++*
rm -f *_ll.cc *_tab.hh *_tab.cc *.output
make -C ../tl/testing clear
make -C ../tl/cc clear
make -C ../integ/testing clear
make -C ../integ/cc clear
make -C ../sylv/testing clear
make -C ../sylv/cc clear
make -C ../kord clear
make -C ../parser/cc clear
make -C ../utils/cc clear

35
dynare++/src/Makefile.am Normal file
View File

@ -0,0 +1,35 @@
bin_PROGRAMS = dynare++
GENERATED_FILES = dynglob_ll.cc dynglob_tab.cc dynglob_tab.hh
dynare___SOURCES = \
main.cpp \
dynare3.cpp \
dynare_atoms.h \
dynare_model.h \
forw_subst_builder.h \
planner_builder.cpp \
dynare3.h \
dynare_exception.h \
dynare_params.cpp \
nlsolve.cpp \
planner_builder.h \
dynare_atoms.cpp \
dynare_model.cpp \
dynare_params.h \
forw_subst_builder.cpp \
nlsolve.h \
$(GENERATED_FILES)
dynare___CPPFLAGS = -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I.. -DDYNVERSION=\"$(PACKAGE_VERSION)\" -DPOSIX_THREADS
dynare___LDADD = ../kord/libkord.a ../integ/cc/libinteg.a ../tl/cc/libtl.a ../parser/cc/libparser.a ../utils/cc/libutils.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
dynare___CXXFLAGS = $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = dynglob.lex dynglob.y
dynglob_tab.cc dynglob_tab.hh: dynglob.y
$(YACC) -d -odynglob_tab.cc dynglob.y
dynglob_ll.cc: dynglob.lex
$(LEX) -i -odynglob_ll.cc dynglob.lex

View File

@ -0,0 +1 @@
SUBDIRS = cc testing

View File

@ -1,35 +0,0 @@
# $Header: /var/lib/cvs/dynare_cpp/sylv/cc/Makefile,v 1.4 2005/01/18 21:28:26 kamenik Exp $
# Tag $Name: $
include ../../Makefile.include
CC_FLAGS := -I../testing -I../cc $(CC_FLAGS)
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g
else
CC_FLAGS := $(CC_FLAGS) -O2
endif
ifeq ($(OS),Windows_NT)
CC_FLAGS := -mno-cygwin -mthreads $(CC_FLAGS)
endif
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
headers := $(wildcard *.h)
all: $(objects)
sylvester.a: $(objects)
ar cr sylvester.a $(objects)
ranlib sylvester.a
clear:
rm -f *.o
rm -f sylvester.a
%.o : %.cpp $(headers)
$(CC) $(CC_FLAGS) $(EXTERN_DEFS) -c $*.cpp

View File

@ -0,0 +1,42 @@
noinst_LIBRARIES = libsylv.a
libsylv_a_SOURCES = \
IterativeSylvester.cpp \
cpplapack.h \
SylvMatrix.h \
QuasiTriangular.cpp \
QuasiTriangularZero.cpp \
TriangularSylvester.h \
GeneralMatrix.cpp \
SylvMemory.h \
SylvException.h \
GeneralSylvester.cpp \
GeneralMatrix.h \
Vector.h \
SchurDecompEig.h \
QuasiTriangularZero.h \
SimilarityDecomp.cpp \
BlockDiagonal.h \
SylvesterSolver.h \
SylvException.cpp \
cppblas.h \
SimilarityDecomp.h \
IterativeSylvester.h \
SchurDecompEig.cpp \
KronUtils.h \
Vector.cpp \
TriangularSylvester.cpp \
GeneralSylvester.h \
SylvParams.cpp \
SchurDecomp.h \
SymSchurDecomp.h \
BlockDiagonal.cpp \
SylvParams.h \
KronVector.cpp \
SylvMemory.cpp \
SymSchurDecomp.cpp \
SylvMatrix.cpp \
QuasiTriangular.h \
SchurDecomp.cpp \
KronVector.h \
KronUtils.cpp

View File

@ -1,36 +0,0 @@
# $Header: /var/lib/cvs/dynare_cpp/sylv/testing/Makefile,v 1.2 2004/09/28 16:16:43 kamenik Exp $
# Tag $Name: $
LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c
CC_FLAGS := -Wall -I../cc
CC_DEFS := #-DUSE_MEMORY_POOL
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g
CC_DEFS := $(CC_DEFS) -DDEBUG
else
CC_FLAGS := $(CC_FLAGS) -O2
endif
objects := $(patsubst %.cpp,%.o,$(wildcard ../cc/*.cpp))
headers := $(wildcard ../cc/*.h)
clear:
make -C ../cc clear
rm -f tests.exe
rm -f tests
rm -f *.o
../cc/%.o : ../cc/%.cpp $(headers)
make EXTERN_DEFS="$(CC_DEFS)" -C ../cc $*.o
%.o : %.cpp $(headers)
$(CC) $(CC_FLAGS) $(CC_DEFS) -c $*.cpp
# untar testing data
tdata.done : tdata.tgz
tar -xzf tdata.tgz
touch tdata.done
test: $(objects) tests.o MMMatrix.o tdata.done
$(CC) $(CC_FLAGS) -o test $(objects) tests.o MMMatrix.o $(LD_LIBS)

View File

@ -0,0 +1,13 @@
check_PROGRAMS = tests
tests_SOURCES = MMMatrix.cpp MMMatrix.h tests.cpp
tests_LDADD = ../cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS)
tests_CPPFLAGS = -I../cc
EXTRA_DIST = tdata.tgz
check-local: tdata.tgz
tar xzf tdata.tgz
./tests
CLEANFILES = *.mm

1
dynare++/tl/Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = cc testing

View File

@ -1,60 +0,0 @@
# $Id: Makefile 2344 2009-02-09 20:36:08Z michel $
# Copyright 2004, Ondra Kamenik
include ../../Makefile.include
#LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c
CC_FLAGS := -I../../sylv/cc $(CC_FLAGS)
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O2 -DPOSIX_THREADS
endif
ifeq ($(OS),Windows_NT)
CC_FLAGS := -mno-cygwin -mthreads $(CC_FLAGS)
LD_LIBS := -mno-cygwin -mthreads $(LD_LIBS) -lpthreadGC1
else
LD_LIBS := $(LD_LIBS) -lpthread
endif
matrix_interface := GeneralMatrix Vector SylvException
matobjs := $(patsubst %, ../../sylv/cc/%.o, $(matrix_interface))
cwebsource := $(wildcard *.cweb)
cppsource := $(patsubst %.cweb,%.cpp,$(cwebsource))
objects := $(patsubst %.cweb,%.o,$(cwebsource))
hwebsource := $(wildcard *.hweb)
hsource := $(patsubst %.hweb,%.h,$(hwebsource))
dummy.ch:
touch dummy.ch
%.cpp: %.cweb dummy.ch
ctangle -bhp $*.cweb dummy.ch $*.cpp
%.h: %.hweb dummy.ch
ctangle -bhp $*.hweb dummy.ch $*.h
%.o : %.cpp $(hsource)
$(CC) $(CC_FLAGS) $(EXTERN_DEFS) -c $*.cpp
all: $(objects) $(cppsource) $(hsource)
tl.pdf: doc
doc: main.web $(hwebsource) $(cwebsource)
cweave -bhp main.web
pdftex main
mv main.pdf tl.pdf
clear:
rm -f $(cppsource)
rm -f $(hsource)
rm -f *.o
rm -f main.{dvi,idx,log,pdf,scn,tex,toc}
rm -f dummy.ch
rm -f *~

119
dynare++/tl/cc/Makefile.am Normal file
View File

@ -0,0 +1,119 @@
CWEBSRC = \
normal_moments.cweb \
int_sequence.cweb \
tensor.cweb \
ps_tensor.cweb \
pyramid_prod2.cweb \
equivalence.cweb \
fine_container.cweb \
kron_prod.cweb \
ps_tensor.hweb \
t_polynomial.cweb \
symmetry.cweb \
stack_container.cweb \
sthread.hweb \
twod_matrix.hweb \
twod_matrix.cweb \
symmetry.hweb \
sparse_tensor.cweb \
fine_container.hweb \
sthread.cweb \
int_sequence.hweb \
tl_exception.hweb \
pyramid_prod2.hweb \
t_container.hweb \
permutation.hweb \
tensor.hweb \
gs_tensor.cweb \
rfs_tensor.hweb \
pyramid_prod.hweb \
t_polynomial.hweb \
pyramid_prod.cweb \
fs_tensor.cweb \
sparse_tensor.hweb \
permutation.cweb \
equivalence.hweb \
gs_tensor.hweb \
normal_moments.hweb \
tl_static.hweb \
kron_prod.hweb \
fs_tensor.hweb \
stack_container.hweb \
rfs_tensor.cweb \
t_container.cweb \
tl_static.cweb
GENERATED_FILES = \
normal_moments.cpp \
int_sequence.cpp \
tensor.cpp \
ps_tensor.cpp \
pyramid_prod2.cpp \
equivalence.cpp \
fine_container.cpp \
kron_prod.cpp \
ps_tensor.h \
t_polynomial.cpp \
symmetry.cpp \
stack_container.cpp \
sthread.h \
twod_matrix.h \
twod_matrix.cpp \
symmetry.h \
sparse_tensor.cpp \
fine_container.h \
sthread.cpp \
int_sequence.h \
tl_exception.h \
pyramid_prod2.h \
t_container.h \
permutation.h \
tensor.h \
gs_tensor.cpp \
rfs_tensor.h \
pyramid_prod.h \
t_polynomial.h \
pyramid_prod.cpp \
fs_tensor.cpp \
sparse_tensor.h \
permutation.cpp \
equivalence.h \
gs_tensor.h \
normal_moments.h \
tl_static.h \
kron_prod.h \
fs_tensor.h \
stack_container.h \
rfs_tensor.cpp \
t_container.cpp \
tl_static.cpp
noinst_LIBRARIES = libtl.a
libtl_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES)
libtl_a_CPPFLAGS = -I../../sylv/cc -DPOSIX_THREADS
libtl_a_CXXFLAGS = $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = main.web
dummy.ch:
touch dummy.ch
%.cpp: %.cweb dummy.ch
$(CTANGLE) -bhp $< dummy.ch $@
%.h: %.hweb dummy.ch
$(CTANGLE) -bhp $< dummy.ch $@
if HAVE_CWEAVE
if HAVE_PDFTEX
pdf: main.web $(CWEBSRC)
$(CWEAVE) -bhp main.web
$(PDFTEX) main
mv main.pdf tl.pdf
endif
endif
CLEANFILES = dummy.ch tl.pdf main.idx main.log main.scn main.tex main.toc

View File

@ -1,43 +0,0 @@
# $Id: Makefile 843 2006-07-28 08:54:19Z tamas $
# Copyright 2004, Ondra Kamenik
LD_LIBS := -llapack -lcblas -lf77blas -latlas -lg2c -lpthread
CC_FLAGS := -Wall -I../cc -I../../sylv/cc
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g -DTL_DEBUG=2
else
CC_FLAGS := $(CC_FLAGS) -O2 -DPOSIX_THREADS
endif
matrix_interface := GeneralMatrix Vector SylvException
matobjs := $(patsubst %, ../../sylv/cc/%.o, $(matrix_interface))
cwebsource := $(wildcard ../cc/*.cweb)
cppsource := $(patsubst %.cweb,%.cpp,$(cwebsource))
objects := $(patsubst %.cweb,%.o,$(cwebsource))
hwebsource := $(wildcard ../cc/*.hweb)
hsource := $(patsubst %.hweb,%.h,$(hwebsource))
../cc/dummy.ch:
make -C ../cc dummy.ch
../cc/%.cpp: ../cc/%.cweb ../cc/dummy.ch
make -C ../cc $*.cpp
../cc/%.h: ../cc/%.hweb ../cc/dummy.ch
make -C ../cc $*.h
../cc/%.o: ../cc/%.cpp $(hsource)
make -C ../cc $*.o
%.o: %.cpp factory.h monoms.h $(hwebsource) $(hsource)
$(CC) $(CC_FLAGS) -c $*.cpp
tests: $(hwebsource) $(cwebsoure) $(hsource) $(cppsource) \
tests.o factory.o monoms.o $(objects)
$(CC) $(CC_FLAGS) $(objects) $(matobjs) tests.o factory.o monoms.o -o tests $(LD_LIBS)
clear:
rm -f *.o
rm -f tests
make -C ../cc clear

View File

@ -0,0 +1,10 @@
check_PROGRAMS = tests
tests_SOURCES = factory.cpp factory.h monoms.cpp monoms.h tests.cpp
tests_CPPFLAGS = -I../cc -I../../sylv/cc -DPOSIX_THREADS
tests_CXXFLAGS = $(PTHREAD_CFLAGS)
tests_LDADD = ../cc/libtl.a ../../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
check-local:
./tests

View File

@ -1,26 +0,0 @@
# Copyright (C) 2005, Ondra Kamenik
# $Id: Makefile 843 2006-07-28 08:54:19Z tamas $
CC_FLAGS := -Wall -I../../
ifeq ($(DEBUG),yes)
CC_FLAGS := $(CC_FLAGS) -g
else
CC_FLAGS := $(CC_FLAGS) -O3
endif
objects := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
headers := $(wildcard *.h)
source := $(wildcard *.cpp)
%.o: %.cpp $(headers)
$(CC) $(CC_FLAGS) -c $*.cpp
utils.a: $(objects) $(headers) $(source)
ar cr utils.a $(objects)
clear:
rm -f *~
rm -f *.o
rm -f utils.a

View File

@ -0,0 +1,8 @@
noinst_LIBRARIES = libutils.a
libutils_a_SOURCES = \
exception.h \
memory_file.cpp \
memory_file.h \
pascal_triangle.cpp \
pascal_triangle.h

195
m4/ax_blas.m4 Normal file
View File

@ -0,0 +1,195 @@
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_blas.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro looks for a library that implements the BLAS linear-algebra
# interface (see http://www.netlib.org/blas/). On success, it sets the
# BLAS_LIBS output variable to hold the requisite library linkages.
#
# To link with BLAS, you should link with:
#
# $BLAS_LIBS $LIBS $FLIBS
#
# in that order. FLIBS is the output variable of the
# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is
# sometimes necessary in order to link with F77 libraries. Users will also
# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
# reason.
#
# Many libraries are searched for, from ATLAS to CXML to ESSL. The user
# may also use --with-blas=<lib> in order to use some specific BLAS
# library <lib>. In order to link successfully, however, be aware that you
# will probably need to use the same Fortran compiler (which can be set
# via the F77 env. var.) as was used to compile the BLAS library.
#
# ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is
# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
# not found. If ACTION-IF-FOUND is not specified, the default action will
# define HAVE_BLAS.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
#
# 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/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
AU_ALIAS([ACX_BLAS], [AX_BLAS])
AC_DEFUN([AX_BLAS], [
AC_PREREQ(2.50)
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
ax_blas_ok=no
AC_ARG_WITH(blas,
[AC_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])])
case $with_blas in
yes | "") ;;
no) ax_blas_ok=disable ;;
-* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;;
*) BLAS_LIBS="-l$with_blas" ;;
esac
# Get fortran linker names of BLAS functions to check for.
AC_F77_FUNC(sgemm)
AC_F77_FUNC(dgemm)
ax_blas_save_LIBS="$LIBS"
LIBS="$LIBS $FLIBS"
# First, check BLAS_LIBS environment variable
if test $ax_blas_ok = no; then
if test "x$BLAS_LIBS" != x; then
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes], [BLAS_LIBS=""])
AC_MSG_RESULT($ax_blas_ok)
LIBS="$save_LIBS"
fi
fi
# BLAS linked to by default? (happens on some supercomputers)
if test $ax_blas_ok = no; then
save_LIBS="$LIBS"; LIBS="$LIBS"
AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes])
LIBS="$save_LIBS"
fi
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(atlas, ATL_xerbla,
[AC_CHECK_LIB(f77blas, $sgemm,
[AC_CHECK_LIB(cblas, cblas_dgemm,
[ax_blas_ok=yes
BLAS_LIBS="-lcblas -lf77blas -latlas"],
[], [-lf77blas -latlas])],
[], [-latlas])])
fi
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(blas, $sgemm,
[AC_CHECK_LIB(dgemm, $dgemm,
[AC_CHECK_LIB(sgemm, $sgemm,
[ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
[], [-lblas])],
[], [-lblas])])
fi
# BLAS in Intel MKL library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl"])
fi
# BLAS in Apple vecLib library?
if test $ax_blas_ok = no; then
save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS"
AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"])
LIBS="$save_LIBS"
fi
# BLAS in Alpha CXML library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"])
fi
# BLAS in Alpha DXML library? (now called CXML, see above)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"])
fi
# BLAS in Sun Performance library?
if test $ax_blas_ok = no; then
if test "x$GCC" != xyes; then # only works with Sun CC
AC_CHECK_LIB(sunmath, acosp,
[AC_CHECK_LIB(sunperf, $sgemm,
[BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
ax_blas_ok=yes],[],[-lsunmath])])
fi
fi
# BLAS in SCSL library? (SGI/Cray Scientific Library)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"])
fi
# BLAS in SGIMATH library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(complib.sgimath, $sgemm,
[ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
fi
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
if test $ax_blas_ok = no; then
AC_CHECK_LIB(blas, $sgemm,
[AC_CHECK_LIB(essl, $sgemm,
[ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
[], [-lblas $FLIBS])])
fi
# Generic BLAS library?
if test $ax_blas_ok = no; then
AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"])
fi
AC_SUBST(BLAS_LIBS)
LIBS="$ax_blas_save_LIBS"
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_blas_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])
:
else
ax_blas_ok=no
$2
fi
])dnl AX_BLAS

129
m4/ax_lapack.m4 Normal file
View File

@ -0,0 +1,129 @@
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_lapack.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LAPACK([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro looks for a library that implements the LAPACK linear-algebra
# interface (see http://www.netlib.org/lapack/). On success, it sets the
# LAPACK_LIBS output variable to hold the requisite library linkages.
#
# To link with LAPACK, you should link with:
#
# $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS
#
# in that order. BLAS_LIBS is the output variable of the AX_BLAS macro,
# called automatically. FLIBS is the output variable of the
# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is
# sometimes necessary in order to link with F77 libraries. Users will also
# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same
# reason.
#
# The user may also use --with-lapack=<lib> in order to use some specific
# LAPACK library <lib>. In order to link successfully, however, be aware
# that you will probably need to use the same Fortran compiler (which can
# be set via the F77 env. var.) as was used to compile the LAPACK and BLAS
# libraries.
#
# ACTION-IF-FOUND is a list of shell commands to run if a LAPACK library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_LAPACK.
#
# LICENSE
#
# Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
#
# 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/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
AU_ALIAS([ACX_LAPACK], [AX_LAPACK])
AC_DEFUN([AX_LAPACK], [
AC_REQUIRE([AX_BLAS])
ax_lapack_ok=no
AC_ARG_WITH(lapack,
[AC_HELP_STRING([--with-lapack=<lib>], [use LAPACK library <lib>])])
case $with_lapack in
yes | "") ;;
no) ax_lapack_ok=disable ;;
-* | */* | *.a | *.so | *.so.* | *.o) LAPACK_LIBS="$with_lapack" ;;
*) LAPACK_LIBS="-l$with_lapack" ;;
esac
# Get fortran linker name of LAPACK function to check for.
AC_F77_FUNC(cheev)
# We cannot use LAPACK if BLAS is not found
if test "x$ax_blas_ok" != xyes; then
ax_lapack_ok=noblas
LAPACK_LIBS=""
fi
# First, check LAPACK_LIBS environment variable
if test "x$LAPACK_LIBS" != x; then
save_LIBS="$LIBS"; LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
AC_MSG_CHECKING([for $cheev in $LAPACK_LIBS])
AC_TRY_LINK_FUNC($cheev, [ax_lapack_ok=yes], [LAPACK_LIBS=""])
AC_MSG_RESULT($ax_lapack_ok)
LIBS="$save_LIBS"
if test $ax_lapack_ok = no; then
LAPACK_LIBS=""
fi
fi
# LAPACK linked to by default? (is sometimes included in BLAS lib)
if test $ax_lapack_ok = no; then
save_LIBS="$LIBS"; LIBS="$LIBS $BLAS_LIBS $FLIBS"
AC_CHECK_FUNC($cheev, [ax_lapack_ok=yes])
LIBS="$save_LIBS"
fi
# Generic LAPACK library?
for lapack in lapack lapack_rs6k; do
if test $ax_lapack_ok = no; then
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
AC_CHECK_LIB($lapack, $cheev,
[ax_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS])
LIBS="$save_LIBS"
fi
done
AC_SUBST(LAPACK_LIBS)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_lapack_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_LAPACK,1,[Define if you have LAPACK library.]),[$1])
:
else
ax_lapack_ok=no
$2
fi
])dnl AX_LAPACK

272
m4/ax_pthread.m4 Normal file
View File

@ -0,0 +1,272 @@
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well. e.g. you should link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threads programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
#
# 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/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_SAVE
AC_LANG_C
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
AC_MSG_RESULT($ax_pthread_ok)
if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case "${host_cpu}-${host_os}" in
*solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
esac
if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
if test x"$ax_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_TRY_LINK([#include <pthread.h>],
[pthread_t th; pthread_join(th, 0);
pthread_attr_init(0); pthread_cleanup_push(0, 0);
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
[ax_pthread_ok=yes])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($ax_pthread_ok)
if test "x$ax_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute])
attr_name=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
[attr_name=$attr; break])
done
AC_MSG_RESULT($attr_name)
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case "${host_cpu}-${host_os}" in
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: must compile with xlc_r or cc_r
if test x"$GCC" != xyes; then
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
else
PTHREAD_CC=$CC
fi
else
PTHREAD_CC="$CC"
fi
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_RESTORE
])dnl AX_PTHREAD