From 8f945e1138ef06560f09c275a1cdb6cc509fa874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 11 Jun 2021 17:26:31 +0200 Subject: [PATCH] WIP: rework build system Thas was made necessary because the coexistence of two MEXs in the same build directory, one with OpenMP, and the other without, is not easy to handle with automake + Fortran modules. --- mex/build/A_times_B_kronecker_C.am | 16 +++++++++++++++ mex/build/kronecker.am | 20 ------------------- .../matlab/A_times_B_kronecker_C/Makefile.am | 2 ++ mex/build/matlab/Makefile.am | 2 +- mex/build/matlab/configure.ac | 3 ++- mex/build/matlab/kronecker/Makefile.am | 2 -- .../Makefile.am | 2 ++ .../octave/A_times_B_kronecker_C/Makefile.am | 3 +++ mex/build/octave/Makefile.am | 2 +- mex/build/octave/configure.ac | 3 ++- mex/build/octave/kronecker/Makefile.am | 3 --- .../Makefile.am | 3 +++ .../sparse_hessian_times_B_kronecker_C.am | 19 ++++++++++++++++++ 13 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 mex/build/A_times_B_kronecker_C.am delete mode 100644 mex/build/kronecker.am create mode 100644 mex/build/matlab/A_times_B_kronecker_C/Makefile.am delete mode 100644 mex/build/matlab/kronecker/Makefile.am create mode 100644 mex/build/matlab/sparse_hessian_times_B_kronecker_C/Makefile.am create mode 100644 mex/build/octave/A_times_B_kronecker_C/Makefile.am delete mode 100644 mex/build/octave/kronecker/Makefile.am create mode 100644 mex/build/octave/sparse_hessian_times_B_kronecker_C/Makefile.am create mode 100644 mex/build/sparse_hessian_times_B_kronecker_C.am diff --git a/mex/build/A_times_B_kronecker_C.am b/mex/build/A_times_B_kronecker_C.am new file mode 100644 index 000000000..ef160ad41 --- /dev/null +++ b/mex/build/A_times_B_kronecker_C.am @@ -0,0 +1,16 @@ +# NB: build directories are separated for the two kronecker MEX, because one requires +# OpenMP while the other doesn’t. Building both in the same directory does not play well +# with automake (which will in particular be confused around Fortran modules, because of object +# renaming that takes place when setting per-object compilation flags). + +mex_PROGRAMS = A_times_B_kronecker_C + +nodist_A_times_B_kronecker_C_SOURCES = A_times_B_kronecker_C.f08 matlab_mex.F08 blas_lapack.F08 + +BUILT_SOURCES = $(nodist_A_times_B_kronecker_C_SOURCES) +CLEANFILES = $(nodist_A_times_B_kronecker_C_SOURCES) + +A_times_B_kronecker_C.o : matlab_mex.mod lapack.mod + +%.f08: $(top_srcdir)/../../sources/kronecker/%.f08 + $(LN_S) -f $< $@ diff --git a/mex/build/kronecker.am b/mex/build/kronecker.am deleted file mode 100644 index 236d18625..000000000 --- a/mex/build/kronecker.am +++ /dev/null @@ -1,20 +0,0 @@ -mex_PROGRAMS = sparse_hessian_times_B_kronecker_C A_times_B_kronecker_C - -nodist_sparse_hessian_times_B_kronecker_C_SOURCES = sparse_hessian_times_B_kronecker_C.f08 matlab_mex.F08 -nodist_A_times_B_kronecker_C_SOURCES = A_times_B_kronecker_C.f08 matlab_mex.F08 blas_lapack.F08 - -# Technically, only the sparse version needs OpenMP compilation flags. -# However, using per-object compilation flags triggers object renaming in Automake, -# with many problems (notably with Fortran modules, whose .o will be renamed, but -# not their .mod). -AM_FCFLAGS += -fopenmp -AM_LDFLAGS += $(OPENMP_LDFLAGS) - -BUILT_SOURCES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) $(nodist_A_times_B_kronecker_C_SOURCES) -CLEANFILES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) $(nodist_A_times_B_kronecker_C_SOURCES) - -sparse_hessian_times_B_kronecker_C.o : matlab_mex.mod -A_times_B_kronecker_C.o : matlab_mex.mod lapack.mod - -%.f08: $(top_srcdir)/../../sources/kronecker/%.f08 - $(LN_S) -f $< $@ diff --git a/mex/build/matlab/A_times_B_kronecker_C/Makefile.am b/mex/build/matlab/A_times_B_kronecker_C/Makefile.am new file mode 100644 index 000000000..fa5673270 --- /dev/null +++ b/mex/build/matlab/A_times_B_kronecker_C/Makefile.am @@ -0,0 +1,2 @@ +include ../mex.am +include ../../A_times_B_kronecker_C.am diff --git a/mex/build/matlab/Makefile.am b/mex/build/matlab/Makefile.am index e84baee6e..a80713a15 100644 --- a/mex/build/matlab/Makefile.am +++ b/mex/build/matlab/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I ../../../m4 -SUBDIRS = mjdgges kronecker bytecode block_kalman_filter sobol perfect_foresight_problem num_procs block_trust_region disclyap_fast +SUBDIRS = mjdgges sparse_hessian_times_B_kronecker_C A_times_B_kronecker_C bytecode block_kalman_filter sobol perfect_foresight_problem num_procs block_trust_region disclyap_fast # libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ if ENABLE_MEX_DYNAREPLUSPLUS diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index b6ab2178e..7a0504f65 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -149,7 +149,8 @@ Binaries (with "make"): AC_CONFIG_FILES([Makefile mjdgges/Makefile - kronecker/Makefile + sparse_hessian_times_B_kronecker_C/Makefile + A_times_B_kronecker_C/Makefile bytecode/Makefile libdynare++/Makefile gensylv/Makefile diff --git a/mex/build/matlab/kronecker/Makefile.am b/mex/build/matlab/kronecker/Makefile.am deleted file mode 100644 index 41a9064ab..000000000 --- a/mex/build/matlab/kronecker/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -include ../mex.am -include ../../kronecker.am diff --git a/mex/build/matlab/sparse_hessian_times_B_kronecker_C/Makefile.am b/mex/build/matlab/sparse_hessian_times_B_kronecker_C/Makefile.am new file mode 100644 index 000000000..fc2af45c7 --- /dev/null +++ b/mex/build/matlab/sparse_hessian_times_B_kronecker_C/Makefile.am @@ -0,0 +1,2 @@ +include ../mex.am +include ../../sparse_hessian_times_B_kronecker_C.am diff --git a/mex/build/octave/A_times_B_kronecker_C/Makefile.am b/mex/build/octave/A_times_B_kronecker_C/Makefile.am new file mode 100644 index 000000000..9de2509b4 --- /dev/null +++ b/mex/build/octave/A_times_B_kronecker_C/Makefile.am @@ -0,0 +1,3 @@ +EXEEXT = .mex +include ../mex.am +include ../../A_times_B_kronecker_C.am diff --git a/mex/build/octave/Makefile.am b/mex/build/octave/Makefile.am index 6726be71e..3b591a45c 100644 --- a/mex/build/octave/Makefile.am +++ b/mex/build/octave/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I ../../../m4 -SUBDIRS = mjdgges kronecker bytecode block_kalman_filter sobol perfect_foresight_problem num_procs block_trust_region disclyap_fast +SUBDIRS = mjdgges sparse_hessian_times_B_kronecker_C A_times_B_kronecker_C bytecode block_kalman_filter sobol perfect_foresight_problem num_procs block_trust_region disclyap_fast # libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ if ENABLE_MEX_DYNAREPLUSPLUS diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac index 7df4785c3..62a4061d2 100644 --- a/mex/build/octave/configure.ac +++ b/mex/build/octave/configure.ac @@ -131,7 +131,8 @@ Binaries (with "make"): AC_CONFIG_FILES([Makefile mjdgges/Makefile - kronecker/Makefile + sparse_hessian_times_B_kronecker_C/Makefile + A_times_B_kronecker_C/Makefile bytecode/Makefile libdynare++/Makefile gensylv/Makefile diff --git a/mex/build/octave/kronecker/Makefile.am b/mex/build/octave/kronecker/Makefile.am deleted file mode 100644 index 26b50e81c..000000000 --- a/mex/build/octave/kronecker/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -EXEEXT = .mex -include ../mex.am -include ../../kronecker.am diff --git a/mex/build/octave/sparse_hessian_times_B_kronecker_C/Makefile.am b/mex/build/octave/sparse_hessian_times_B_kronecker_C/Makefile.am new file mode 100644 index 000000000..ff85cd6b1 --- /dev/null +++ b/mex/build/octave/sparse_hessian_times_B_kronecker_C/Makefile.am @@ -0,0 +1,3 @@ +EXEEXT = .mex +include ../mex.am +include ../../sparse_hessian_times_B_kronecker_C.am diff --git a/mex/build/sparse_hessian_times_B_kronecker_C.am b/mex/build/sparse_hessian_times_B_kronecker_C.am new file mode 100644 index 000000000..ab8537b61 --- /dev/null +++ b/mex/build/sparse_hessian_times_B_kronecker_C.am @@ -0,0 +1,19 @@ +# NB: build directories are separated for the two kronecker MEX, because one requires +# OpenMP while the other doesn’t. Building both in the same directory does not play well +# with automake (which will in particular be confused around Fortran modules, because of object +# renaming that takes place when setting per-object compilation flags). + +mex_PROGRAMS = sparse_hessian_times_B_kronecker_C + +nodist_sparse_hessian_times_B_kronecker_C_SOURCES = sparse_hessian_times_B_kronecker_C.f08 matlab_mex.F08 + +AM_FCFLAGS += -fopenmp +AM_LDFLAGS += $(OPENMP_LDFLAGS) + +BUILT_SOURCES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) +CLEANFILES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) + +sparse_hessian_times_B_kronecker_C.o : matlab_mex.mod + +%.f08: $(top_srcdir)/../../sources/kronecker/%.f08 + $(LN_S) -f $< $@ -- GitLab