summaryrefslogtreecommitdiff
path: root/m4/stp_cups.m4
blob: f1b5b7fee5120199b9151d2cc252fc5a45112f7c (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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# This file is part of Gutenprint.                     -*- Autoconf -*-
# CUPS support.
# Copyright 2000-2002 Roger Leigh
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.


## ------------ ##
## CUPS support ##
## ------------ ##


# STP_CUPS_LIBS
# -------------
# Check for CUPS libraries.
AC_DEFUN([STP_CUPS_LIBS],
[dnl CUPS library checks
dnl check for libm, and also add to CUPS LIBS
AC_CHECK_LIB(m,pow,
  CUPS_LIBS="${CUPS_LIBS} -lm")
dnl CUPS library checks
if test x${BUILD_CUPS} = xyes ; then
  AC_CHECK_LIB(z,gzgets,
    HAVE_LIBZ=true, HAVE_LIBZ=false)
  if test x${HAVE_LIBZ} = xtrue ; then
    GENPPD_LIBS="-lz"
    AC_DEFINE(HAVE_LIBZ,, [Define if libz is present.])
  fi
  AC_PATH_PROG(CUPS_CONFIG, cups-config)
  if test "x$CUPS_CONFIG" != x; then
    dnl Use values from CUPS config...
    CUPS_LIBS="`$CUPS_CONFIG --ldflags` `$CUPS_CONFIG --image --libs`"
    CUPS_CFLAGS="`$CUPS_CONFIG --cflags`"
  else
    dnl Save current library list...
    SAVELIBS="$LIBS"
    LIBS="$LIBS ${CUPS_LIBS}"
    AC_CHECK_LIB(socket,socket,
      if test x${OSTYPE} != xirix ; then
      CUPS_LIBS="${CUPS_LIBS} -lsocket"
      LIBS="$LIBS -lsocket"
    fi)
    AC_CHECK_LIB(nsl,gethostbyaddr,
      if test x${OSTYPE} != xirix ; then
      CUPS_LIBS="${CUPS_LIBS} -lnsl"
      LIBS="$LIBS -lnsl"
    fi)

    dnl Some OS's need to link against crypto stuff too if CUPS is compiled
    dnl with crypto support... :(
    AC_CHECK_HEADER(openssl/ssl.h,
      dnl Some ELF systems can't resolve all the symbols in libcrypto
      dnl if libcrypto was linked against RSAREF, and fail to link the
      dnl test program correctly, even though a correct installation
      dnl of OpenSSL exists.  So we test the linking three times in
      dnl case the RSAREF libraries are needed.

      SSL="no"

      for libcrypto in \
	  "-lcrypto" \
	  "-lcrypto -lrsaref" \
	  "-lcrypto -lRSAglue -lrsaref"
      do
	  AC_CHECK_LIB(ssl,SSL_new,
	      [CUPS_LIBS="${CUPS_LIBS} -lssl $libcrypto"
	       SSL="yes"],,
	      $libcrypto)

	  if test x$SSL = xyes; then
	      break
	  fi
      done)

    dnl Require CUPS 1.1...
    AC_CHECK_LIB(cups,cupsPrintFiles,
      CUPS_LIBS="${CUPS_LIBS} -lcups",
      LIBS="$LIBS -lcups"
      AC_MSG_ERROR([Cannot find CUPS libraries (libcups)]))
    AC_CHECK_LIB(cupsimage,cupsRasterOpen,
      CUPS_LIBS="${CUPS_LIBS} -lcupsimage",
      AC_MSG_ERROR([Cannot find CUPS libraries (libcupsimage)]),
      -lcups)
    dnl Restore old library list...
    LIBS="$SAVELIBS"

    dnl Add CUPS include directory as needed...
    if test "x${cups_prefix}" != "x/usr" -a "x${cups_prefix}" != x; then
      CUPS_CFLAGS="-I${cups_prefix}/include"
    else
      CUPS_CFLAGS=""
    fi
  fi
fi
])


# STP_CUPS_PROGS
# --------------
# Check for programs needed by CUPS
AC_DEFUN([STP_CUPS_PROGS],
[dnl
if test x${BUILD_CUPS} = xyes; then
  AC_PATH_PROG(DIALOG, dialog)
fi
])


# STP_CUPS_PATH
# -------------
# Set CUPS install paths
AC_DEFUN([STP_CUPS_PATH],
[# CUPS path setup
# Fix "prefix" variable if it hasn't been specified...
if test x${cups_prefix} = xNONE ; then
  cups_prefix="/usr"
fi
# Fix "exec_prefix" variable if it hasn't been specified...
if test x${exec_prefix} = xNONE ; then
  if test "${cups_prefix}" = "/" ; then
    cups_exec_prefix="/usr"
  else
    cups_exec_prefix="${cups_prefix}"
  fi
fi
# Fix "bindir" variable if it hasn't been specified...
if test "${bindir}" = "\${prefix}/bin" -a "${cups_prefix}" = "/" ; then
  cups_bindir="/usr/bin"
else
  cups_bindir="${cups_prefix}/bin"
fi
# Fix "sbindir" variable if it hasn't been specified...
if test "${sbindir}" = "\${prefix}/sbin" -a "${cups_prefix}" = "/" ; then
  cups_sbindir="/usr/sbin"
else
  cups_sbindir="${cups_prefix}/sbin"
fi

# Get explicit CUPS directories if possible
if test "x$CUPS_CONFIG" != x; then
  cups_conf_datadir="`$CUPS_CONFIG --datadir`"
  cups_conf_serverbin="`$CUPS_CONFIG --serverbin`"
  cups_conf_serverroot="`$CUPS_CONFIG --serverroot`"
else
# Some logical guessing
  if test "${datadir}" = "\${prefix}/share" -a "${cups_prefix}" = "/" ; then
    cups_conf_datadir="/usr/share/cups"
  else
    cups_conf_datadir="${cups_prefix}/share/cups"
  fi
  if test "${libdir}" = "\${prefix}/lib" -a "${cups_prefix}" = "/" ; then
    cups_conf_serverbin="/usr/lib/cups"
  else
    cups_conf_serverbin="${cups_prefix}/lib/cups"
  fi
  if test "${sysconfdir}" = "\${prefix}/etc"; then
    if test "${cups_prefix}" = "/usr" ; then
      cups_conf_serverroot="/etc/cups"
    else
      cups_conf_serverroot="${cups_prefix}/etc/cups"
    fi
  fi
fi
])