Skip to content

Commit caf2c52

Browse files
committed
Create separate library for Fortran bindings
1 parent d219821 commit caf2c52

10 files changed

+55
-23
lines changed

Makefile.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ ACLOCAL_AMFLAGS = -I m4
33

44
pkgconfigdir = $(libdir)/pkgconfig
55
pkgconfig_DATA = easyRNG.pc
6+
if ENABLE_FORTRAN
7+
pkgconfig_DATA += easyRNGf03.pc
8+
endif
69

7-
EXTRA_DIST = easyRNG.pc.in easyRNG.spec.in meson.build meson_options.txt install_fortran_mod.py
10+
EXTRA_DIST = easyRNG.pc.in easyRNG.spec.in meson.build meson_options.txt install_fortran_mod.py easyRNGf03.pc.in

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
178178
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([docs/Doxyfile])])
179179

180180

181-
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile easyRNG.pc docs/Makefile easyRNG.spec])
181+
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile easyRNG.pc easyRNGf03.pc docs/Makefile easyRNG.spec])
182182
AC_CONFIG_HEADERS([config.h])
183183

184184
AC_OUTPUT

docs/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ doxygen_cdata.set('builddir', meson.current_build_dir())
77

88
doxyfile = configure_file(input: 'Doxyfile.in',
99
output: 'Doxyfile',
10-
configuration: doxygen_cdata,
11-
install: false)
10+
configuration: doxygen_cdata)
1211

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

easyRNG.pc.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ prefix=@prefix@
22
exec_prefix=@exec_prefix@
33
libdir=@libdir@
44
includedir=@includedir@
5-
with_fortran=@with_fortran@
65

76
Name: easyRNG
8-
Description: wrapper around C++11's random number generators for use in C and Fortran
7+
Description: wrapper around C++11's random number generators for use in C
98
Version: @VERSION@
109
Requires:
1110
Conflicts:

easyRNGf03.pc.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@prefix@
2+
exec_prefix=@exec_prefix@
3+
libdir=@libdir@
4+
includedir=@includedir@
5+
6+
Name: easyRNGf03
7+
Description: wrapper around C++11's random number generators for use in Fortran
8+
Version: @VERSION@
9+
Requires: easyRNG
10+
Conflicts:
11+
Libs: -L${libdir} -leasyRNGf03
12+
Cflags: -I${includedir}/easyRNGf03

meson.build

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project('easyRNG', ['c', 'cpp'], version:'1.2', license: 'BSD', default_options: ['cpp_std=c++11'])
1+
project('easyRNG', ['c', 'cpp'], version:'1.2', license: 'BSD', default_options: ['cpp_std=c++11'], meson_version: '>= 0.46.0')
22

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

7272
# generate pkg-config file
7373
pkgconfig.generate(
74+
easyRNG_lib,
7475
filebase: 'easyRNG',
7576
name: 'easyRNG',
76-
description: 'wrapper around C++11\'s random number generators for use in C and Fortran',
77+
description: 'wrapper around C++11\'s random number generators for use in C',
7778
version: meson.project_version(),
7879
libraries: easyRNG_lib,
7980
subdirs: 'easyRNG',
80-
variables: ['with_fortran=' + (get_option('with-fortran') ? 'yes' : 'no')],
8181
)
8282

83+
if get_option('with-fortran')
84+
pkgconfig.generate(
85+
easyRNGf03_lib,
86+
filebase: 'easyRNGf03',
87+
name: 'easyRNGf03',
88+
description: 'wrapper around C++11\'s random number generators for use in Fortran',
89+
version: meson.project_version(),
90+
libraries: [easyRNGf03_lib, easyRNG_lib],
91+
subdirs: 'easyRNG',
92+
)
93+
94+
endif
95+
8396
# generate RPM SPEC file
8497
rpm_config = configuration_data()
8598
rpm_config.set('VERSION', meson.project_version())
86-
configure_file(input: 'easyRNG.spec.in', output: 'easyRNG.spec', configuration: rpm_config, install: false)
99+
configure_file(input: 'easyRNG.spec.in', output: 'easyRNG.spec', configuration: rpm_config)
87100

88101
subdir('tests')
89102

src/Makefile.am

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ libeasyRNG_la_CXXFLAGS = $(HIDDEN_VISIBILITY_CXXFLAGS)
1010

1111

1212
if ENABLE_FORTRAN
13-
libeasyRNG_la_SOURCES += easy_rng_f.F90
13+
lib_LTLIBRARIES += libeasyRNGf03.la
14+
libeasyRNGf03_la_SOURCES = easy_rng_f.F90
1415
nodist_easyRNGinclude_HEADERS = easyrng.mod
1516
BUILT_SOURCES = easyrng.mod
16-
libeasyRNG_la_LIBADD = $(FCLIBS)
17-
easyrng.mod: libeasyRNG.la
17+
libeasyRNGf03_la_LIBADD = $(FCLIBS) libeasyRNG.la
18+
libeasyRNGf03_la_LDFLAGS = -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@ $(LDFLAGS_EXTRA)
19+
easyrng.mod: libeasyRNGf03.la
1820
endif
1921

2022
clean-local:

src/meson.build

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ private_headers = files('easy_rng_private.h')
44

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

7-
if get_option('with-fortran')
8-
sources += files('easy_rng_f.F90')
9-
endif
10-
117
install_headers(headers, subdir: 'easyRNG')
128

139
easyRNG_sources = headers + private_headers + sources
1410

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

1713
easyRNG_lib_dep = declare_dependency(link_with: easyRNG_lib, include_directories: include_directories('.'))
14+
15+
if get_option('with-fortran')
16+
easyRNGf03_sources = files('easy_rng_f.F90')
17+
18+
easyRNGf03_lib = library('easyRNGf03', easyRNGf03_sources, version: version, darwin_versions: darwin_versions, install: true, dependencies: easyRNG_lib_dep)
19+
20+
easyRNGf03_lib_dep = declare_dependency(link_with: easyRNGf03_lib, dependencies: easyRNG_lib_dep, include_directories: include_directories('.'))
21+
endif

tests/Makefile.am

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ if ENABLE_FORTRAN
2121
check_PROGRAMS += test4
2222
test4_SOURCES = test4.F90
2323
test4_FCFLAGS = -I$(top_builddir)/src
24-
test4_LDADD = ../src/libeasyRNG.la
24+
test4_LDADD = ../src/libeasyRNGf03.la
2525

2626
if ENABLE_FGSL_TEST
2727
check_PROGRAMS += test5
2828
test5_SOURCES = test5.F90
2929
test5_FCFLAGS = -I$(top_builddir)/src $(fgsl_CFLAGS)
30-
test5_LDADD = ../src/libeasyRNG.la $(fgsl_LIBS) -lm
30+
test5_LDADD = ../src/libeasyRNGf03.la ../src/libeasyRNG.la $(fgsl_LIBS) -lm
3131
endif
3232

3333
check_PROGRAMS += test6
3434
test6_SOURCES = test6.F90
3535
test6_FCFLAGS = -I$(top_builddir)/src
36-
test6_LDADD = ../src/libeasyRNG.la -lm
36+
test6_LDADD = ../src/libeasyRNGf03.la ../src/libeasyRNG.la -lm
3737
endif
3838

3939
TESTS = $(check_PROGRAMS)

tests/meson.build

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ test3 = executable('test3', 'test3.c', dependencies: easyRNG_lib_dep, install: f
1010
test('test3', test3, timeout: 300)
1111

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

1616
if fgsl_dep.found()
17-
test5 = executable('test5', 'test5.F90', dependencies: [easyRNG_lib_dep, fgsl_dep], install: false)
17+
test5 = executable('test5', 'test5.F90', dependencies: [easyRNGf03_lib_dep, fgsl_dep], install: false)
1818
test('test5', test5)
1919
endif
2020

21-
test6 = executable('test6', 'test6.F90', dependencies: easyRNG_lib_dep, install: false)
21+
test6 = executable('test6', 'test6.F90', dependencies: easyRNGf03_lib_dep, install: false)
2222
test('test6', test6, timeout: 300)
2323
endif

0 commit comments

Comments
 (0)