aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: b56e90f970acbc9ad0c681de04c8146cb7afc516 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# This file is part of GNUnet.
# Copyright (C) 2022 GNUnet e.V.
#
# GNUnet is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# GNUnet is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: AGPL3.0-or-later
#
# Process this file with autoconf to produce a configure script.
#
#
AC_INIT([libgnunetchat],[m4_esyscmd_s(sh contrib/get_version.sh)],[bug-gnunet@gnu.org])

AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIRS([m4])

AC_CONFIG_HEADERS([
  include/gnunet/gnunet_chat_config.h
])

AC_CANONICAL_TARGET
AC_CANONICAL_HOST

AM_INIT_AUTOMAKE([tar-ustar])
AM_SILENT_RULES

# maybe use AC_USE_SYSTEM_EXTENSIONS?
AH_TOP([#define _GNU_SOURCE 1])

AC_PROG_AWK
AC_PROG_CC
AC_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
PKG_PROG_PKG_CONFIG([0.29.2])

LT_INIT([disable-static dlopen])

AS_IF([test "x$enable_shared" = "xno"],
  [AC_MSG_ERROR([GNUnet works only with shared libraries, sorry])])

# test for GNUnet core
gnunet=0
gnunet_conversation=0
lookin=${prefix}
GNUNET_CFLAGS=""
GNUNET_CPPFLAGS=""
GNUNET_LIBS=""
AC_MSG_CHECKING(for GNUnet core)
AC_ARG_WITH(gnunet,
   [  --with-gnunet=PFX       Base of GNUnet installation],
   [AC_MSG_RESULT([$with_gnunet])
    AS_CASE([$with_gnunet],
      [no],[lookin=""],
      [yes],[lookin="${prefix}"],
      [lookin="$with_gnunet"])
   ],
   [
     AC_MSG_RESULT([--with-gnunet not specified])
     PKG_CHECK_MODULES([GNUNET], [gnunetutil >= 0.18.0], gnunet=1)
     AC_CHECK_HEADERS([gnunet/gnunet_messenger_service.h],
     AC_CHECK_LIB([gnunetmessenger], [GNUNET_MESSENGER_connect],
      [
        EXT_LIB_PATH="-L${lookin}/lib $EXT_LIB_PATH"
        if test -d "${lookin}/lib64"; then
          EXT_LIB_PATH="-L${lookin}/lib64 $EXT_LIB_PATH"
        fi
      ]
      ),,[#include <gnunet/platform.h>]
     )
   ]
)

AS_IF([test "x$gnunet" = "x0" -a ! "x$lookin" = "x"],
[
  AC_MSG_CHECKING(for GNUnet util library in $lookin)
  backup_LIBS="$LIBS"
  backup_CFLAGS="$CFLAGS"
  backup_CPPFLAGS="$CPPFLAGS"
  GNUNET_LIBS="-L${lookin}/lib"
  if test -d "${lookin}/lib64"; then
    GNUNET_LIBS="-L${lookin}/lib64 $GNUNET_LIBS"
  fi
  GNUNET_CFLAGS="-I${lookin}/include"
  GNUNET_CPPFLAGS="-I${lookin}/include"
  LIBS="$GNUNET_LIBS $backup_LIBS"
  CFLAGS="$GNUNET_CFLAGS $backup_CFLAGS"
  CPPFLAGS="$GNUNET_CPPFLAGS $backup_CPPFLAGS"
  AC_CHECK_HEADERS([gnunet/gnunet_util_lib.h],
    AC_CHECK_LIB([gnunetutil], [GNUNET_xfree_],
      [
        gnunet=1
        EXT_LIB_PATH="-L${lookin}/lib $EXT_LIB_PATH"
        if test -d "${lookin}/lib64"; then
          EXT_LIB_PATH="-L${lookin}/lib64 $EXT_LIB_PATH"
        fi

      ]
    ),,[#include <gnunet/platform.h>]
  )
  AC_CHECK_HEADERS([gnunet/gnunet_messenger_service.h],
    AC_CHECK_LIB([gnunetmessenger], [GNUNET_MESSENGER_connect],
      [
        gnunet_messenger=1
      ]
    ),,[#include <gnunet/platform.h>]
  )
  LIBS="$backup_LIBS"
  CFLAGS="$backup_CFLAGS"
  CPPFLAGS="$backup_CPPFLAGS"
])

AS_IF([test "x$gnunet" = "x0" || test "x$gnunet_messenger" = "x0" ],
 [AC_MSG_ERROR([libgnunetchat requires GNUnet])])



AC_SUBST(GNUNET_CFLAGS)
AC_SUBST(GNUNET_LIBS)
CFLAGS="$GNUNET_CFLAGS $CFLAGS"
LIBS="$GNUNET_LIBS $LIBS"

AC_ARG_ENABLE([debug],
[  --enable-debug          turn on debugging],
[case "${enableval}" in
  yes) debug=true ;;
  no)  debug=false ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])

AC_CONFIG_FILES([
  Makefile
  include/Makefile
  src/Makefile
  tests/Makefile
])

AC_OUTPUT