aboutsummaryrefslogtreecommitdiff
path: root/nxcompext/configure.in
blob: 5b9ccc4dafb87698130ea983f92c18a1aa122dce (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
dnl Process this file with autoconf to produce a configure script.

dnl Prolog

AC_INIT(NXlib.h)
AC_PREREQ(2.13)

pkgconfigdir=${libdir}/pkgconfig
AC_SUBST(pkgconfigdir)

dnl Reset default compilation flags.

CXXFLAGS="$CXXFLAGS -O3"
CFLAGS="$CFLAGS -O3"

dnl Reset default linking directives.

LIBSTATIC=""
LIBSHARED=""

dnl Prefer headers and libraries from nx-X11, if present.

if test -d "../nx-X11/include" ; then
    CXXFLAGS="$CXXFLAGS -I../nx-X11/exports/include -I../nx-X11/lib/X11 \
                        -I../nx-X11/include -I../nx-X11/programs/Xserver/include"
    CFLAGS="$CFLAGS -I../nx-X11/exports/include -I../nx-X11/lib/X11 \
                    -I../nx-X11/include -I../nx-X11/programs/Xserver/include"
    LDFLAGS="$LDFLAGS -L../nx-X11/exports/lib"
fi

X_CFLAGS=`pkg-config --cflags-only-I pixman-1`

dnl Check for programs.

AC_PROG_CXX
AC_PROG_CC
AC_LANG_CPLUSPLUS

dnl Check for BSD compatible install.

AC_PROG_INSTALL

dnl Check for extra header files.

AC_PATH_XTRA

dnl Custom addition.
ac_help="$ac_help
  --with-symbols          add the -g flag to produce the debug symbols
  --with-info             enable basic log output to trace the program
  --with-valgrind         clean up allocated buffers to avoid valgrind warnings
  --with-version          use this version for produced libraries

  --with-static-png       enable static linking of PNG library
  --with-static-jpeg      enable static linking of JPEG library"

dnl Check to see if we're running under Cygwin32.

AC_DEFUN(nxproxy_CYGWIN32,
[AC_CACHE_CHECK(for Cygwin32 environment, nxproxy_cv_cygwin32,
[AC_TRY_COMPILE(,[return __CYGWIN32__;],
nxproxy_cv_cygwin32=yes, nxproxy_cv_cygwin32=no)
rm -f conftest*])
CYGWIN32=
test "$nxproxy_cv_cygwin32" = yes && CYGWIN32=yes])

dnl CygWin32 requires the stdc++ library explicitly linked.

nxproxy_CYGWIN32
if test "$CYGWIN32" = yes; then
    LIBS="$LIBS -mwindows -lstdc++"
fi

dnl Check whether we're building on a AMD64.

AC_DEFUN(nxconf_AMD64,
[AC_CACHE_CHECK(for Amd64 environment, nxconf_cv_amd64,
[AC_TRY_COMPILE(,[return (__amd64__ || __x86_64__);],
nxconf_cv_amd64=yes, nxconf_cv_amd64=no)
rm -f conftest*])
AMD64=
test "$nxconf_cv_amd64" = yes && AMD64=yes])
nxconf_AMD64

dnl Check to see if we're running under Solaris.

AC_DEFUN(nxconf_SUN,
[AC_CACHE_CHECK(for SunOS environment, nxconf_cv_sun,
[AC_TRY_COMPILE(,[return __sun;],
nxconf_cv_sun=yes, nxconf_cv_sun=no)
rm -f conftest*])
SUN=
test "$nxconf_cv_sun" = yes && SUN=yes])
nxconf_SUN

if test "$SUN" = yes; then
  CFLAGS="$CFLAGS -I/usr/sfw/include"
fi

if test "$SUN" = yes; then
  LDFLAGS="$LDFLAGS -G -h \$(LIBLOAD) -L/usr/sfw/lib" 
else
  LDFLAGS="$LDFLAGS -shared -Wl,-soname,\$(LIBLOAD)"
fi

dnl Check to see if we're running under FreeBSD.

AC_DEFUN(nxconf_FreeBSD,
[AC_CACHE_CHECK(for FreeBSD environment, nxconf_cv_freebsd,
[AC_TRY_COMPILE(,[return __FreeBSD__;],
nxconf_cv_freebsd=yes, nxconf_cv_freebsd=no)
rm -f conftest*])
FreeBSD=
test "$nxconf_cv_freebsd" = yes && FreeBSD=yes])
nxconf_FreeBSD

dnl Build PIC libraries.

if test "$CYGWIN32" != yes -a "$DARWIN" != yes; then
  CXXFLAGS="$CXXFLAGS -fPIC"
  CFLAGS="$CFLAGS -fPIC"
fi

dnl On FreeBSD search libraries and includes under /usr/local.

if test "$FreeBSD" = yes; then
  LIBS="$LIBS  -L/usr/local/lib"
  CXXFLAGS="$CXXFLAGS -I/usr/local/include"
  CFLAGS="$CFLAGS -I/usr/local/include"
fi

dnl Check whether --with-static-png  was
dnl given and add -lpng or libpng.a to linking.

if test "${with_static_png}" = yes; then
  echo -e "enabling static linking of PNG library"
  if test "$CYGWIN32" = yes; then
    LIBS="$LIBSTATIC -static -lpng"
  else
    if test -f "/usr/lib/libpng.a" ; then
      LIBS="/usr/lib/libpng.a $LIBS"
    else
      if test -f "/usr/local/lib/libpng.a" ; then
        echo -e "assuming libpng.a in /usr/local/lib"
        LIBS="/usr/local/lib/libpng.a $LIBS"
      else
        echo -e "assuming libpng.a in default linker path"
        LIBS="libpng.a $LIBS"
      fi
    fi
  fi
else
  echo -e "enabling dynamic linking of PNG library"
  LIBS="-lpng $LIBS"
fi

dnl Check whether --with-static-jpeg  was
dnl given and add -ljpeg or libjpeg.a to linking.
if test "${with_static_jpeg}" = yes; then
  echo -e "enabling static linking of JPEG library"
  if test "$CYGWIN32" = yes; then
    LIBSTATIC="$LIBS -static -ljpeg"
  else
    if test -f "/usr/lib/libjpeg.a" ; then
      LIBS="/usr/lib/libjpeg.a $LIBS"
    else
      if test -f "/usr/local/lib/libjpeg.a" ; then
        echo -e "assuming libjpeg.a in /usr/local/lib"
        LIBS="/usr/local/lib/libjpeg.a $LIBS"
      else
        echo -e "assuming libjpeg.a in default linker path"
        LIBS="libjpeg.a $LIBS"
      fi
    fi
  fi
else
  echo -e "enabling dynamic linking of JPEG library"
  LIBS="-ljpeg $LIBS"
fi

dnl Check whether --with-symbols or --without-symbols was
dnl given and set the required optimization level.
if test "${with_symbols}" = yes; then
  echo -e "enabling production of debug symbols"
  CXXFLAGS="-g $CXXFLAGS"
  CFLAGS="-g $CFLAGS"
else
  echo -e "disabling production of debug symbols"
fi

dnl Check whether --with-info or --without-info was given.
if test "${with_info}" = yes; then
  echo -e "enabling info output in the log file"
  CXXFLAGS="$CXXFLAGS -DINFO"
  CFLAGS="$CFLAGS -DINFO"
else
  echo -e "disabling info output in the log file"
fi

dnl Check whether --with-valgrind or --without-valgrind was given.
if test "${with_valgrind}" = yes; then
  echo -e "enabling valgrind memory checker workarounds"
  CXXFLAGS="$CXXFLAGS -DVALGRIND"
  CFLAGS="$CFLAGS -DVALGRIND"
else
  echo -e "disabling valgrind memory checker workarounds"
fi

dnl Check whether --with-version was given.
AC_SUBST(LIBVERSION)
AC_SUBST(VERSION)
if test "${with_version}" = yes; then
  VERSION=${ac_option}
else
  VERSION=`cat VERSION`
fi
echo -e "compiling version ${VERSION}"

LIBVERSION=`echo ${VERSION} | cut -d '.' -f 1`

CXXFLAGS="$CXXFLAGS -DVERSION=\\\"${VERSION}\\\""
CFLAGS="$CFLAGS -DVERSION=\\\"${VERSION}\\\""

dnl Find makedepend somewhere.

AC_SUBST(MAKEDEPEND)
MAKEDEPEND="$(which makedepend)"

# Try to desperately find makedepend.
# Set MAKEDEPEND to the shipped makedepend binary. This will not
# exist in nx-libs-lite, though, in which case MAKEDEPEND
# will stay empty.
if test -z "${MAKEDEPEND}"; then
  if test -x "../nx-X11/config/makedepend/makedepend"; then
    MAKEDEPEND="../nx-X11/config/makedepend/makedepend"
  fi
fi

dnl Determine what to build based on the platform.
dnl Override the LIBS settings on Cygwin32 so that
dnl we always link with the exact set of libraries.

AC_SUBST(ALL)

if test "$CYGWIN32" = yes; then
    ALL="\$(LIBCYGARCHIVE) \$(LIBCYGSHARED) \$(LIBARCHIVE)"
else
    ALL="\$(LIBFULL) \$(LIBLOAD) \$(LIBSHARED) \$(LIBARCHIVE)"
fi

AC_OUTPUT(Makefile nxcompext.pc)