Skip to content
Snippets Groups Projects
Commit 1924ac90 authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

fix meson.build for libiberty header file location issues (Fedora vs Debian)

parent 5b44cd0f
No related branches found
No related tags found
No related merge requests found
......@@ -462,6 +462,33 @@ if get_option('generic') == false
endforeach
endif
############################################################
# make a list of include directories
# We do this so that $HOME/include is searched (e.g. for
# libgsl)
#
my_incdirs = []
found = false
_include_search_paths = [
homedir + '/include',
'/usr/include',
'/usr/local/include',
]
foreach idir : _include_search_paths
if run_command('sh','-c','meson/directory_exists.sh',idir).returncode() == 0
inc_arg = idir
_Inc_arg = '-I' + idir
if not found and compiler.has_header('gsl/gsl_blas.h',
args: _Inc_arg)
my_incdirs += [inc_arg]
found = true
endif
endif
endforeach
incdirs += [ my_incdirs ]
############################################################
# features which are converted into preprocessor flags (-D)
#
......@@ -469,7 +496,10 @@ endif
###########
# drand48 #
#
if compiler.has_header('stdlib.h') and \
if compiler.has_header('stdlib.h',
args: cflags,
include_directories: include_directories(incdirs)\
) and \
compiler.sizeof('drand48_r',
prefix : '#include <stdlib.h>') > 0
cflags += '-D__HAVE_DRAND48__'
......@@ -478,18 +508,23 @@ endif
############
# malloc.h #
#
if compiler.has_header('malloc.h')
if compiler.has_header('malloc.h',
args: cflags,
include_directories: include_directories(incdirs))
cflags += '-D__HAVE_MALLOC_H__'
endif
############
# setitimer
#
if compiler.has_header('sys/time.h') and \
if compiler.has_header('sys/time.h',
args: cflags,
include_directories: include_directories(incdirs)) and \
compiler.has_function('setitimer')
cflags += '-D__HAVE_SETITIMER__'
endif
#################################
# pkg-config (external command) #
#
......@@ -500,7 +535,9 @@ endif
###########################
# valgrind (header files) #
#
if compiler.has_header('valgrind/valgrind.h')
if compiler.has_header('valgrind/valgrind.h',
args: cflags,
include_directories: include_directories(incdirs))
cflags += '-D__HAVE_VALGRIND__'
endif
......@@ -525,31 +562,22 @@ if compiler.get_id() != 'gcc' and compiler.get_id() != 'clang'
cflags += '-UBACKTRACE'
endif
############################################################
# make a list of include directories
# We do this so that $HOME/include is searched (e.g. for
# libgsl)
#
my_incdirs = []
found = false
_include_search_paths = [
homedir + '/include',
'/usr/include',
'/usr/local/include',
]
foreach idir : _include_search_paths
if run_command('sh','-c','meson/directory_exists.sh',idir).returncode() == 0
inc_arg = idir
_Inc_arg = '-I' + idir
if not found and compiler.has_header('gsl/gsl_blas.h',
args: _Inc_arg)
my_incdirs += [inc_arg]
found = true
endif
endif
endforeach
incdirs += [ my_incdirs ]
##########################
# location of libiberty.h
#
if compiler.has_header('libiberty.h',
args: cflags,
include_directories: include_directories(incdirs))
# Fedora
cflags += '-D__HAVE_LIBIBERTYH__'
elif compiler.has_header('libiberty/libiberty.h',
args: cflags,
include_directories: include_directories(incdirs))
# Debian and derivatives e.g. Ubuntu
cflags += '-D__HAVE_LIBIBERTY_LIBIBERTYH__'
else
error('cannot find libiberty.h at either <libiberty.h> or <libiberty/libiberty.h>')
endif
############################################################
# data objects
......
......@@ -33,9 +33,19 @@
*/
#define _GNU_SOURCE
/*
* Test if we have libiberty, and find where it its
* header file should be (meson checks). We need to know
* because Debian and Fedora use different locations.
*/
#ifdef __HAVE_LIBIBERTY__
#ifdef __HAVE_LIBIBERTYH__
#include <libiberty.h>
#endif // __HAVE_LIBIBERTYH__
#ifdef __HAVE_LIBIBERTY_LIBIBERTYH__
#include <libiberty/libiberty.h>
#endif
#endif // __HAVE_LIBIBERTY_LIBIBERTYH__
#endif // __HAVE_LIBIBERTY__
#include <string.h>
#include <malloc.h>
#include <stdio.h>
......
......@@ -38,7 +38,6 @@ int main (int argc,
* options, make a stardata, then call binary_c main
* with the stardata.
*/
printf("ok\n");
#if !defined SEGFAULTS
char * altstack = setup_segfaults();
#endif
......
......@@ -961,6 +961,8 @@ void version(struct stardata_t * RESTRICT const stardata)
Macrotest(__HAVE_LIBBFD__);
Macrotest(__HAVE_LIBBSD__);
Macrotest(__HAVE_LIBIBERTY__);
Macrotest(__HAVE_LIBIBERTYH__);
Macrotest(__HAVE_LIBIBERTY_LIBIBERTYH__);
Macrotest(__HAVE_LIBBACKTRACE__);
Macrotest(__HAVE_MALLOC_H__);
Macrotest(__HAVE_DRAND48__);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment