Skip to content

Commit

Permalink
Create separate library for Fortran bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoonj committed Jun 28, 2019
1 parent d219821 commit cffb34e
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 23 deletions.
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ ACLOCAL_AMFLAGS = -I m4

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = easyRNG.pc
if ENABLE_FORTRAN
pkgconfig_DATA += easyRNGf03.pc
endif

EXTRA_DIST = easyRNG.pc.in easyRNG.spec.in meson.build meson_options.txt install_fortran_mod.py
EXTRA_DIST = easyRNG.pc.in easyRNG.spec.in meson.build meson_options.txt install_fortran_mod.py easyRNGf03.pc.in
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([docs/Doxyfile])])


AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile easyRNG.pc docs/Makefile easyRNG.spec])
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile easyRNG.pc easyRNGf03.pc docs/Makefile easyRNG.spec])
AC_CONFIG_HEADERS([config.h])

AC_OUTPUT
3 changes: 1 addition & 2 deletions docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ doxygen_cdata.set('builddir', meson.current_build_dir())

doxyfile = configure_file(input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: doxygen_cdata,
install: false)
configuration: doxygen_cdata)

datadir = join_paths(get_option('datadir'), 'doc', 'easyRNG')

Expand Down
3 changes: 1 addition & 2 deletions easyRNG.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
with_fortran=@with_fortran@

Name: easyRNG
Description: wrapper around C++11's random number generators for use in C and Fortran
Description: wrapper around C++11's random number generators for use in C
Version: @VERSION@
Requires:
Conflicts:
Expand Down
12 changes: 12 additions & 0 deletions easyRNGf03.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: easyRNGf03
Description: wrapper around C++11's random number generators for use in Fortran
Version: @VERSION@
Requires: easyRNG
Conflicts:
Libs: -L${libdir} -leasyRNGf03
Cflags: -I${includedir}/easyRNGf03
21 changes: 17 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('easyRNG', ['c', 'cpp'], version:'1.2', license: 'BSD', default_options: ['cpp_std=c++11'])
project('easyRNG', ['c', 'cpp'], version:'1.2', license: 'BSD', default_options: ['cpp_std=c++11'], meson_version: '>= 0.46.0')

# versioning stuff -> maintain compatibility with libtool!
# # a) If binary compatibility has been broken (eg removed or changed interfaces)
Expand Down Expand Up @@ -71,19 +71,32 @@ subdir('src')

# generate pkg-config file
pkgconfig.generate(
easyRNG_lib,
filebase: 'easyRNG',
name: 'easyRNG',
description: 'wrapper around C++11\'s random number generators for use in C and Fortran',
description: 'wrapper around C++11\'s random number generators for use in C',
version: meson.project_version(),
libraries: easyRNG_lib,
subdirs: 'easyRNG',
variables: ['with_fortran=' + (get_option('with-fortran') ? 'yes' : 'no')],
)

if get_option('with-fortran')
pkgconfig.generate(
easyRNGf03_lib,
filebase: 'easyRNGf03',
name: 'easyRNGf03',
description: 'wrapper around C++11\'s random number generators for use in Fortran',
version: meson.project_version(),
libraries: [easyRNGf03_lib, easyRNG_lib],
subdirs: 'easyRNG',
)

endif

# generate RPM SPEC file
rpm_config = configuration_data()
rpm_config.set('VERSION', meson.project_version())
configure_file(input: 'easyRNG.spec.in', output: 'easyRNG.spec', configuration: rpm_config, install: false)
configure_file(input: 'easyRNG.spec.in', output: 'easyRNG.spec', configuration: rpm_config)

subdir('tests')

Expand Down
8 changes: 5 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ libeasyRNG_la_CXXFLAGS = $(HIDDEN_VISIBILITY_CXXFLAGS)


if ENABLE_FORTRAN
libeasyRNG_la_SOURCES += easy_rng_f.F90
lib_LTLIBRARIES += libeasyRNGf03.la
libeasyRNGf03_la_SOURCES = easy_rng_f.F90
nodist_easyRNGinclude_HEADERS = easyrng.mod
BUILT_SOURCES = easyrng.mod
libeasyRNG_la_LIBADD = $(FCLIBS)
easyrng.mod: libeasyRNG.la
libeasyRNGf03_la_LIBADD = $(FCLIBS) libeasyRNG.la
libeasyRNGf03_la_LDFLAGS = -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@ $(LDFLAGS_EXTRA)
easyrng.mod: libeasyRNGf03.la
endif

clean-local:
Expand Down
12 changes: 8 additions & 4 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ private_headers = files('easy_rng_private.h')

sources = files('easy_rng.cpp', 'easy_randist.cpp')

if get_option('with-fortran')
sources += files('easy_rng_f.F90')
endif

install_headers(headers, subdir: 'easyRNG')

easyRNG_sources = headers + private_headers + sources

easyRNG_lib = library('easyRNG', easyRNG_sources, version: version, darwin_versions: darwin_versions, install: true, include_directories: rootdir)

easyRNG_lib_dep = declare_dependency(link_with: easyRNG_lib, include_directories: include_directories('.'))

if get_option('with-fortran')
easyRNGf03_sources = files('easy_rng_f.F90')

easyRNGf03_lib = library('easyRNGf03', easyRNGf03_sources, version: version, darwin_versions: darwin_versions, install: true, dependencies: easyRNG_lib_dep)

easyRNGf03_lib_dep = declare_dependency(link_with: easyRNGf03_lib, dependencies: easyRNG_lib_dep, include_directories: include_directories('.'))
endif
6 changes: 3 additions & 3 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ if ENABLE_FORTRAN
check_PROGRAMS += test4
test4_SOURCES = test4.F90
test4_FCFLAGS = -I$(top_builddir)/src
test4_LDADD = ../src/libeasyRNG.la
test4_LDADD = ../src/libeasyRNGf03.la

if ENABLE_FGSL_TEST
check_PROGRAMS += test5
test5_SOURCES = test5.F90
test5_FCFLAGS = -I$(top_builddir)/src $(fgsl_CFLAGS)
test5_LDADD = ../src/libeasyRNG.la $(fgsl_LIBS) -lm
test5_LDADD = ../src/libeasyRNGf03.la ../src/libeasyRNG.la $(fgsl_LIBS) -lm
endif

check_PROGRAMS += test6
test6_SOURCES = test6.F90
test6_FCFLAGS = -I$(top_builddir)/src
test6_LDADD = ../src/libeasyRNG.la -lm
test6_LDADD = ../src/libeasyRNGf03.la -lm
endif

TESTS = $(check_PROGRAMS)
Expand Down
6 changes: 3 additions & 3 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ test3 = executable('test3', 'test3.c', dependencies: easyRNG_lib_dep, install: f
test('test3', test3, timeout: 300)

if get_option('with-fortran')
test4 = executable('test4', 'test4.F90', dependencies: easyRNG_lib_dep, install: false)
test4 = executable('test4', 'test4.F90', dependencies: easyRNGf03_lib_dep, install: false)
test('test4', test4)

if fgsl_dep.found()
test5 = executable('test5', 'test5.F90', dependencies: [easyRNG_lib_dep, fgsl_dep], install: false)
test5 = executable('test5', 'test5.F90', dependencies: [easyRNGf03_lib_dep, fgsl_dep], install: false)
test('test5', test5)
endif

test6 = executable('test6', 'test6.F90', dependencies: easyRNG_lib_dep, install: false)
test6 = executable('test6', 'test6.F90', dependencies: easyRNGf03_lib_dep, install: false)
test('test6', test6, timeout: 300)
endif

0 comments on commit cffb34e

Please sign in to comment.