summaryrefslogtreecommitdiff
path: root/acinclude.m4
blob: aefa8f192e6755af79a10134a1539968af83dbe1 (plain)
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
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
dnl example
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
dnl will set SYSCONFDIR to /usr/local/etc

dnl written by thomas vander stichele

AC_DEFUN(AS_AC_EXPAND,
[
  EXP_VAR=[$1]
  FROM_VAR=[$2]

  dnl first expand prefix and exec_prefix if necessary
  prefix_save=$prefix
  if test "x$prefix" = "xNONE"; then
    prefix=/usr/local
  fi
  exec_prefix_save=$exec_prefix
  if test "x$exec_prefix" = "xNONE"; then
    if test "x$prefix_save" = "xNONE"; then
      exec_prefix=/usr/local
    else
      exec_prefix=$prefix
    fi
  fi

  full_var="$FROM_VAR"
  dnl loop until it doesn't change anymore
  while true; do
    new_full_var="`eval echo $full_var`"
    if test "x$new_full_var"="x$full_var"; then break; fi
    full_var=$new_full_var
  done

  dnl clean up
  full_var=$new_full_var
  [$1]=$full_var
  prefix=$prefix_save
  exec_prefix=$exec_prefix_save
])

#
# fltk.m4
#
# You have permission to use this file under GNU's General Public License,
# version 2 or later
#
# Copyright (C) 2002 Robert Ham (node@users.sourceforge.net)
#

AC_DEFUN([AC_LIB_FLTK],[
  AC_LANG_PUSH([C++])
  AC_ARG_ENABLE(
    [fltktest],
    AC_HELP_STRING([--disable-fltktest],
                   [assume fltk is installed and skip the test]),
    [
      case "$enableval" in
        "yes")
          FLTK_TEST="yes"
          ;;
        "no")
          FLTK_TEST="no"
          ;;
        *)
          AC_MSG_ERROR([must use --enable-fltktest(=yes/no) or --disable-fltktest])
          ;;
      esac
    ],
    [ FLTK_TEST="yes"
    ])
                
  if test "$FLTK_TEST" = "no"; then
    AC_MSG_WARN([fltk test disabled: assuming FLTK_LDFLAGS="-lfltk" and FLTK_CXXFLAGS=""])
    FLTK_LDFLAGS="-lfltk"
    FLTK_CXXFLAGS=""
    FLTK_FOUND="yes"
  else
    AC_CACHE_VAL(
      [fltk_cv_prog_fltkconfig],
      [
        AC_ARG_WITH(
          [fltk-config],
          AC_HELP_STRING([--with-fltk-config=DIR],
                         [the directory containing the fltk-config program]),
          [
            case "$withval" in
              "yes")
                if test -d yes; then
                  FLTK_CONFIG_PATH="yes"
                else
                  AC_MSG_ERROR([you must use --with-fltk-config=DIR with DIR as a directory name])
                fi
                ;;
              "no")
                AC_MSG_ERROR([you must use --with-fltk-config=DIR with DIR as a directory name])
                ;;
              *)
                FLTK_CONFIG_PATH="$withval"
                ;;
            esac
          ])

        if test "$FLTK_CONFIG_PATH" = ""; then
          AC_PATH_PROG([FLTK_CONFIG], [fltk-config], [no])
        else
          AC_PATH_PROG([FLTK_CONFIG], [fltk-config], [no], "${FLTK_CONFIG_PATH}:${PATH}")
        fi

        if test "$FLTK_CONFIG" = "no"; then
          AC_MSG_WARN([could not find the fltk-config program - try using --with-fltk-config=DIR])
          FLTK_FOUND="no";
        fi

        fltk_cv_prog_fltkconfig="$FLTK_CONFIG"
      ])
    FLTK_CXXFLAGS="$( "$fltk_cv_prog_fltkconfig" --cxxflags )"
    FLTK_LDFLAGS="$( "$fltk_cv_prog_fltkconfig" --ldflags )"
    FLTK_FOUND="yes"
  fi
  AC_LANG_POP([C++])

  AC_SUBST(FLTK_CXXFLAGS)
  AC_SUBST(FLTK_LDFLAGS)
])