Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
50 changes: 46 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CANONICAL_HOST

LIB_CURRENT=0
LIB_REVISION=1
LIB_CURRENT=1
LIB_REVISION=0
LIB_AGE=0
AC_SUBST(LIB_CURRENT)
AC_SUBST(LIB_REVISION)
Expand All @@ -21,7 +21,7 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
#libtool
LT_PREREQ([2.0.0])

LT_INIT()
LT_INIT([win32-dll disable-static])
AC_PROG_LIBTOOL

AC_PROG_CC
Expand All @@ -48,13 +48,55 @@ AC_PROG_CXX_C_O
AX_CXX_COMPILE_STDCXX_11(noext, mandatory)

LDFLAGS_EXTRA=""
OS_WINDOWS=0
case "$host" in
*mingw*)
LDFLAGS_EXTRA+="-no-undefined"
OS_WINDOWS=1
;;
esac
AC_SUBST(LDFLAGS_EXTRA)

if test $OS_WINDOWS = 1 ; then
if test x$enable_static = xyes -a x$enable_shared = xyes; then
AC_MSG_ERROR([Can not build both shared and static at the same time on Windows.])
fi
fi

# Symbol visibility handling.
#
# Taken from gtksourceview and modified where necessary
HIDDEN_VISIBILITY_CXXFLAGS=""
case "$host" in
*-*-mingw*)
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
AC_DEFINE([EASYRNG_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
[defines how to decorate public symbols while building])
HIDDEN_VISIBILITY_CXXFLAGS="-fvisibility=hidden"
;;
*)
dnl on other compilers, check if we can do -fvisibility=hidden
SAVED_CXXFLAGS="${CXXFLAGS}"
CXXFLAGS="-fvisibility=hidden"
AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([], [return 0],
AC_MSG_RESULT(yes)
enable_fvisibility_hidden=yes,
AC_MSG_RESULT(no)
enable_fvisibility_hidden=no)
AC_LANG_POP(C++)
CXXFLAGS="${SAVED_CXXFLAGS}"

AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
AC_DEFINE([EASYRNG_EXTERN], [__attribute__((visibility("default"))) extern],
[defines how to decorate public symbols while building])
HIDDEN_VISIBILITY_CXXFLAGS="-fvisibility=hidden"
])
;;
esac

AC_SUBST(HIDDEN_VISIBILITY_CXXFLAGS)

#check for Fortran support
BUILD_FORTRAN=no
Expand Down Expand Up @@ -136,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
8 changes: 4 additions & 4 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ EXCLUDE_PATTERNS =
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories use the pattern */test/*

EXCLUDE_SYMBOLS =
EXCLUDE_SYMBOLS =

# The EXAMPLE_PATH tag can be used to specify one or more files or directories
# that contain example code fragments that are included (see the \include
Expand Down Expand Up @@ -1988,15 +1988,15 @@ ENABLE_PREPROCESSING = YES
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

MACRO_EXPANSION = NO
MACRO_EXPANSION = YES

# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and
# EXPAND_AS_DEFINED tags.
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

EXPAND_ONLY_PREDEF = NO
EXPAND_ONLY_PREDEF = YES

# If the SEARCH_INCLUDES tag is set to YES, the include files in the
# INCLUDE_PATH will be searched if a #include is found.
Expand Down Expand Up @@ -2028,7 +2028,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS EASYRNG_EXTERN

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
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
47 changes: 41 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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)
# # change to C+1:0:0.
# # b) If interfaces have been changed or added, but binary compatibility has
# # been preserved, change to C+1:0:A+1
# # c) If the interface is the same as the previous version, change to C:R+1:A
lib_current = 0
lib_revision = 1
lib_current = 1
lib_revision = 0
lib_age = 0

version = '@0@.@1@.@2@'.format((lib_current - lib_age), lib_age, lib_revision)
Expand Down Expand Up @@ -45,23 +45,58 @@ ENDSUBROUTINE
meson.add_install_script('install_fortran_mod.py')
endif

config_h = configuration_data()

# Detect and set symbol visibility
# Taken from gtksourceview
if get_option('default_library') != 'static'
cpp = meson.get_compiler('cpp')
if host_machine.system() == 'windows'
config_h.set('DLL_EXPORT', true)
if cpp.get_id() == 'msvc'
config_h.set('EASYRNG_EXTERN', '__declspec(dllexport) extern')
elif cpp.has_argument('-fvisibility=hidden')
config_h.set('EASYRNG_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
endif
elif cpp.has_argument('-fvisibility=hidden')
config_h.set('EASYRNG_EXTERN', '__attribute__((visibility("default"))) extern')
endif
endif

configure_file(output: 'config.h', configuration: config_h)

rootdir = include_directories('.')

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
9 changes: 6 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ easyRNGinclude_HEADERS = easy_rng.h easy_randist.h

libeasyRNG_la_SOURCES = $(easyRNGinclude_HEADERS) easy_rng.cpp easy_rng_private.h easy_randist.cpp
libeasyRNG_la_LDFLAGS = -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@ $(LDFLAGS_EXTRA)
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
1 change: 1 addition & 0 deletions src/easy_randist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "easy_randist.h"
#include "easy_rng_private.h"
#include <random>
Expand Down
Loading