xref: /openbsd/gnu/usr.bin/binutils/bfd/acinclude.m4 (revision 7b36286a)
1sinclude(../config/accross.m4)
2
3dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
4AC_DEFUN([BFD_BINARY_FOPEN],
5[AC_REQUIRE([AC_CANONICAL_SYSTEM])
6case "${host}" in
7changequote(,)dnl
8*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
9changequote([,])dnl
10  AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
11esac])dnl
12
13dnl Get a default for CC_FOR_BUILD to put into Makefile.
14AC_DEFUN([BFD_CC_FOR_BUILD],
15[# Put a plausible default for CC_FOR_BUILD in Makefile.
16if test -z "$CC_FOR_BUILD"; then
17  if test "x$cross_compiling" = "xno"; then
18    CC_FOR_BUILD='$(CC)'
19  else
20    CC_FOR_BUILD=gcc
21  fi
22fi
23AC_SUBST(CC_FOR_BUILD)
24# Also set EXEEXT_FOR_BUILD.
25if test "x$cross_compiling" = "xno"; then
26  EXEEXT_FOR_BUILD='$(EXEEXT)'
27else
28  AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
29    [rm -f conftest*
30     echo 'int main () { return 0; }' > conftest.c
31     bfd_cv_build_exeext=
32     ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
33     for file in conftest.*; do
34       case $file in
35       *.c | *.o | *.obj | *.ilk | *.pdb) ;;
36       *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
37       esac
38     done
39     rm -f conftest*
40     test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
41  EXEEXT_FOR_BUILD=""
42  test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
43fi
44AC_SUBST(EXEEXT_FOR_BUILD)])dnl
45
46dnl See whether we need a declaration for a function.
47AC_DEFUN([BFD_NEED_DECLARATION],
48[AC_MSG_CHECKING([whether $1 must be declared])
49AC_CACHE_VAL(bfd_cv_decl_needed_$1,
50[AC_TRY_COMPILE([
51#include <stdio.h>
52#ifdef HAVE_STRING_H
53#include <string.h>
54#else
55#ifdef HAVE_STRINGS_H
56#include <strings.h>
57#endif
58#endif
59#ifdef HAVE_STDLIB_H
60#include <stdlib.h>
61#endif
62#ifdef HAVE_UNISTD_H
63#include <unistd.h>
64#endif],
65[char *(*pfn) = (char *(*)) $1],
66bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
67AC_MSG_RESULT($bfd_cv_decl_needed_$1)
68if test $bfd_cv_decl_needed_$1 = yes; then
69  AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
70	    [Define if $1 is not declared in system header files.])
71fi
72])dnl
73
74dnl Check for existence of a type $1 in sys/procfs.h
75
76AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE],
77[AC_MSG_CHECKING([for $1 in sys/procfs.h])
78 AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
79   [AC_TRY_COMPILE([
80#define _SYSCALL32
81#include <sys/procfs.h>],
82      [$1 avar],
83      bfd_cv_have_sys_procfs_type_$1=yes,
84      bfd_cv_have_sys_procfs_type_$1=no
85   )])
86 if test $bfd_cv_have_sys_procfs_type_$1 = yes; then
87   AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1,
88	     [Define if <sys/procfs.h> has $1.])
89 fi
90 AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_$1)
91])
92
93
94dnl Check for existence of member $2 in type $1 in sys/procfs.h
95
96AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE_MEMBER],
97[AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
98 AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
99   [AC_TRY_COMPILE([
100#define _SYSCALL32
101#include <sys/procfs.h>],
102      [$1 avar; void* aref = (void*) &avar.$2],
103      bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
104      bfd_cv_have_sys_procfs_type_member_$1_$2=no
105   )])
106 if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then
107   AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1,
108	     [Define if <sys/procfs.h> has $1.$2.])
109 fi
110 AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2)
111])
112
113sinclude(../libtool.m4)
114dnl The lines below arrange for aclocal not to bring libtool.m4
115dnl AM_PROG_LIBTOOL into aclocal.m4, while still arranging for automake
116dnl to add a definition of LIBTOOL to Makefile.in.
117ifelse(yes,no,[
118AC_DEFUN([AM_PROG_LIBTOOL],)
119AC_DEFUN([AM_DISABLE_SHARED],)
120AC_SUBST(LIBTOOL)
121])
122
123sinclude(../gettext.m4)
124ifelse(yes,no,[
125AC_DEFUN([CY_WITH_NLS],)
126AC_SUBST(INTLLIBS)
127])
128
129AC_DEFUN([AM_INSTALL_LIBBFD],
130[AC_MSG_CHECKING([whether to install libbfd])
131  AC_ARG_ENABLE(install-libbfd,
132[  --enable-install-libbfd controls installation of libbfd and related headers],
133      install_libbfd_p=$enableval,
134      if test "${host}" = "${target}" || test "$enable_shared" = "yes"; then
135        install_libbfd_p=yes
136      else
137        install_libbfd_p=no
138      fi)
139  AC_MSG_RESULT($install_libbfd_p)
140  AM_CONDITIONAL(INSTALL_LIBBFD, test $install_libbfd_p = yes)
141  # libbfd.a is a host library containing target dependent code
142  bfdlibdir='$(libdir)'
143  bfdincludedir='$(includedir)'
144  if test "${host}" != "${target}"; then
145    bfdlibdir='$(exec_prefix)/$(host_alias)/$(target_alias)/lib'
146    bfdincludedir='$(exec_prefix)/$(host_alias)/$(target_alias)/include'
147  fi
148  AC_SUBST(bfdlibdir)
149  AC_SUBST(bfdincludedir)
150]
151)
152