1dnl Process this file with autoconf to produce a configure script.
2dnl The macros which aren't shipped with the autotools are stored in the
3dnl Tools/config directory in .m4 files.
4
5AC_INIT([VisualNaCro],[0.1],[http://libvncserver.sourceforge.net])
6AC_PREREQ(2.54)
7AC_CANONICAL_HOST
8AM_INIT_AUTOMAKE
9
10dnl Checks for programs.
11AC_CHECK_PROG(SWIG,swig,swig)
12AC_CHECK_PROG(LIBVNCSERVERCONFIG,libvncserver-config,yes,no)
13if test "$LIBVNCSERVERCONFIG" != "yes"; then
14	AC_MSG_ERROR([Need to have libvncserver-config in PATH])
15	exit 1
16fi
17AC_PROG_CC
18AC_PROG_RANLIB
19AC_EXEEXT
20AC_OBJEXT
21
22LIBVNCSERVERCFLAGS=`libvncserver-config --cflags`
23LIBVNCSERVERLIBS=`libvncserver-config --libs`
24AC_SUBST(LIBVNCSERVERCFLAGS)
25AC_SUBST(LIBVNCSERVERLIBS)
26
27dnl Checks for header files.
28AC_HEADER_STDC
29
30dnl How to specify include directories that may be system directories.
31# -I should not be used on system directories (GCC)
32if test "$GCC" = yes; then
33    ISYSTEM="-isystem "
34else
35    ISYSTEM="-I"
36fi
37
38
39# Set info about shared libraries.
40AC_SUBST(SO)
41AC_SUBST(LDSHARED)
42AC_SUBST(CCSHARED)
43AC_SUBST(LINKFORSHARED)
44
45# SO is the extension of shared libraries `(including the dot!)
46AC_MSG_CHECKING(SO)
47if test -z "$SO"
48then
49	case $host in
50	*-*-hp*) SO=.sl;;
51	*-*-darwin*) SO=.bundle;;
52	*-*-cygwin* | *-*-mingw*) SO=.dll;;
53	*) SO=.so;;
54	esac
55fi
56AC_MSG_RESULT($SO)
57
58# LDSHARED is the ld *command* used to create shared library
59# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
60# (Shared libraries in this instance are shared modules to be loaded into
61# Python, as opposed to building Python itself as a shared library.)
62AC_MSG_CHECKING(LDSHARED)
63if test -z "$LDSHARED"
64then
65	case $host in
66	*-*-aix*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
67	*-*-cygwin* | *-*-mingw*)
68            if test "$GCC" = yes; then
69                LDSHARED="dllwrap --driver-name gcc --dlltool dlltool --export-all-symbols --as as --dllname \$(LIBPREFIX)\$(TARGET)\$(SO)"
70            else
71                if test "cl" = $CC ;  then
72                    # Microsoft Visual C++ (MSVC)
73                    LDSHARED="$CC -nologo -LD"
74                else
75                    # Unknown compiler try gcc approach
76                    LDSHARED="$CC -shared"
77                fi
78            fi ;;
79	*-*-irix5*) LDSHARED="ld -shared";;
80	*-*-irix6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
81	*-*-sunos4*) LDSHARED="ld";;
82	*-*-solaris*) LDSHARED="ld -G";;
83	*-*-hp*) LDSHARED="ld -b";;
84	*-*-osf*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
85	*-sequent-sysv4) LDSHARED="ld -G";;
86	*-*-next*)
87		if test "$ns_dyld"
88		then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
89		else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
90		fi
91                if test "$with_next_framework" ; then
92		    LDSHARED="$LDSHARED \$(LDLIBRARY)"
93		fi ;;
94	*-*-linux*) LDSHARED="gcc -shared";;
95	*-*-dgux*) LDSHARED="ld -G";;
96	*-*-freebsd3*) LDSHARED="gcc -shared";;
97	*-*-freebsd* | *-*-openbsd*) LDSHARED="ld -Bshareable";;
98	*-*-netbsd*)
99		if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
100		then
101			LDSHARED="cc -shared"
102		else
103			LDSHARED="ld -Bshareable"
104		fi;;
105	*-sco-sysv*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
106	*-*-darwin*) LDSHARED="cc -bundle -undefined suppress -flat_namespace";;
107	*)	LDSHARED="ld";;
108	esac
109fi
110AC_MSG_RESULT($LDSHARED)
111# CCSHARED are the C *flags* used to create objects to go into a shared
112# library (module) -- this is only needed for a few systems
113AC_MSG_CHECKING(CCSHARED)
114if test -z "$CCSHARED"
115then
116	case $host in
117	*-*-hp*) if test "$GCC" = yes;
118		 then CCSHARED="-fpic";
119		 else CCSHARED="+z";
120		 fi;;
121	*-*-linux*) CCSHARED="-fpic";;
122	*-*-freebsd* | *-*-openbsd*) CCSHARED="-fpic";;
123	*-*-netbsd*) CCSHARED="-fPIC";;
124	*-sco-sysv*) CCSHARED="-KPIC -dy -Bdynamic";;
125	*-*-irix6*)  case $CC in
126		   *gcc*) CCSHARED="-shared";;
127		   *) CCSHARED="";;
128		   esac;;
129	esac
130fi
131AC_MSG_RESULT($CCSHARED)
132
133# RPATH is the path used to look for shared library files.
134AC_MSG_CHECKING(RPATH)
135if test -z "$RPATH"
136then
137	case $host in
138	*-*-solaris*) RPATH='-R. -R$(exec_prefix)/lib';;
139        *-*-irix*) RPATH='-rpath .:$(exec_prefix)/lib';;
140	*-*-linux*) RPATH='-Xlinker -rpath $(exec_prefix)/lib -Xlinker -rpath .';;
141	*)	RPATH='';;
142	esac
143fi
144AC_MSG_RESULT($RPATH)
145AC_SUBST(RPATH)
146
147# LINKFORSHARED are the flags passed to the $(CC) command that links
148# the a few executables -- this is only needed for a few systems
149
150AC_MSG_CHECKING(LINKFORSHARED)
151if test -z "$LINKFORSHARED"
152then
153	case $host in
154	*-*-aix*)	LINKFORSHARED='-Wl,-bE:$(srcdir)/python.exp -lld';;
155	*-*-hp*)
156	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
157	*-*-linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
158	*-*-next*) LINKFORSHARED="-u libsys_s";;
159	*-sco-sysv*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
160	*-*-irix6*) LINKFORSHARED="-all";;
161	esac
162fi
163AC_MSG_RESULT($LINKFORSHARED)
164
165# This variation is needed on OS-X because there is no (apparent) consistency in shared libary naming.
166# Sometimes .bundle works, but sometimes .so is needed.  It depends on the target language
167
168# Optional CFLAGS used to silence compiler warnings on some platforms.
169
170AC_SUBST(PLATFLAGS)
171case $host in
172   *-*-darwin*) PLATFLAGS="-Wno-long-double";;
173   *) PLATFLAGS="";;
174esac
175
176#----------------------------------------------------------------
177# Look for Perl5
178#----------------------------------------------------------------
179
180PERLBIN=
181
182AC_ARG_WITH(perl5,[  --with-perl5=path       Set location of Perl5 executable],[ PERLBIN="$withval"], [PERLBIN=])
183
184# First figure out what the name of Perl5 is
185
186if test -z "$PERLBIN"; then
187AC_CHECK_PROGS(PERL, perl perl5.8.1 perl5.6.1 perl5.6.0 perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl)
188else
189PERL="$PERLBIN"
190fi
191
192
193AC_MSG_CHECKING(for Perl5 header files)
194if test -n "$PERL"; then
195	PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null`
196	if test "$PERL5DIR" != ""; then
197		dirs="$PERL5DIR $PERL5DIR/CORE"
198		PERL5EXT=none
199		for i in $dirs; do
200			if test -r $i/perl.h; then
201				AC_MSG_RESULT($i)
202				PERL5EXT="$i"
203				break;
204			fi
205		done
206		if test "$PERL5EXT" = none; then
207			PERL5EXT="$PERL5DIR/CORE"
208			AC_MSG_RESULT(could not locate perl.h...using $PERL5EXT)
209		fi
210
211		AC_MSG_CHECKING(for Perl5 library)
212		PERL5LIB=`($PERL -e 'use Config; $_=$Config{libperl}; s/^lib//; s/$Config{_a}$//; print $_, "\n"') 2>/dev/null`
213		if test "$PERL5LIB" = "" ; then
214			AC_MSG_RESULT(not found)
215		else
216			AC_MSG_RESULT($PERL5LIB)
217		fi
218    AC_MSG_CHECKING(for Perl5 compiler options)
219 		PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-I/$ISYSTEM/") 2>/dev/null`
220 		if test "$PERL5CCFLAGS" = "" ; then
221 			AC_MSG_RESULT(not found)
222 		else
223 			AC_MSG_RESULT($PERL5CCFLAGS)
224 		fi
225	else
226		AC_MSG_RESULT(unable to determine perl5 configuration)
227		PERL5EXT=$PERL5DIR
228	fi
229else
230       	AC_MSG_RESULT(could not figure out how to run perl5)
231fi
232
233# Cygwin (Windows) needs the library for dynamic linking
234case $host in
235*-*-cygwin* | *-*-mingw*) PERL5DYNAMICLINKING="-L$PERL5EXT -l$PERL5LIB";;
236*)PERL5DYNAMICLINKING="";;
237esac
238
239AC_SUBST(PERL)
240AC_SUBST(PERL5EXT)
241AC_SUBST(PERL5DYNAMICLINKING)
242AC_SUBST(PERL5LIB)
243AC_SUBST(PERL5CCFLAGS)
244
245#----------------------------------------------------------------
246# Miscellaneous
247#----------------------------------------------------------------
248
249AC_CONFIG_FILES([Makefile])
250AC_OUTPUT
251
252dnl configure.in ends here
253