#!/bin/sh -e ##################################################### # this configure-script searches for the needed includes # and libraries. # # it is MUCH faster, smaller and does what I want. :-) # # If you have openssl installed in # an unusual directory like /home/me/install/ssl # just give it as argument to ./configure # it then searches for headers in /home/me/install/ssl/include # and librarys in /home/me/install/ssl/lib # # if you have a very unusual setup or you are cross-compiling # you can edit "Local.mak" to fit your needs and to reflect your setup # # The Makefiles should support parallel builds. # ####################################################### DIRS="" HOST=linux cygcheck.exe -V >/dev/null 2>&1 && HOST=w32 for dir in $@; do DIRS="$DIRS `cd $dir; pwd`" done DIRS="$QTDIR $DIRS" if test "$HOST" = "linux"; then DIRS="$DIRS /usr /usr/X11R6 /usr/local" STDINC="-I/usr/include" STDLIB="-L/usr/lib" prefix=${prefix:=/usr/local} CFLAGS=${CFLAGS:=-Wall -ggdb -O2} fi if test "$HOST" = "w32"; then LIBS="-lQtCore4 -lstdc++ -lqtmain -lws2_32 -lwsock32 -lgdi32" SUFFIX=.exe CFLAGS="-Wall -g -ggdb -mthreads -mno-cygwin" LDFLAGS="-Wl,-enable-stdcall-fixup -Wl,-enable-auto-import \ -Wl,-enable-runtime-pseudo-reloc" fi CC=${CC:=gcc} CF="-I. -I.. -I\$(TOPDIR)/ui" LDIRS= MOC=moc UIC=uic LRELEASE=lrelease err() { echo echo ERROR: $1 echo err_occ=Y } #adds an includedir to $CF add_include() { for _dir in $STDINC ${CF}; do if test "-I$1" = "${_dir}"; then return 0 fi done CF="${CF} -I$1" } add_lib() { if test "$3" = "a"; then SLIBS="$SLIBS -l$2" else LIBS="$LIBS -l$2" fi for _libs in -L/usr/lib ${LDIRS}; do if test "-L$1" = "${_libs}"; then return 0 fi done LDIRS="${LDIRS} -L$1" } # check for includes search_includes() { for dir in ${DIRS}; do for dbn in "" ${subdirs}; do for include in outinc include; do if test -r "${dir}/${include}${dbn}/$1"; then add_include ${dir}/${include}${dbn} test -z "${dbn}" || add_include ${dir}/${include} echo "Found: $1 at ${dir}/${include}${dbn}" return 0 fi done done done return 1 } # check for libs search_lib() { for dir in ${DIRS}; do for dbn in $@; do for suffix in so dylib obj a; do for lib in lib out; do if test -r "${dir}/${lib}/lib${dbn}.${suffix}"; then add_lib "${dir}/${lib}" "${dbn}" "${suffix}" echo "Found: lib${dbn}.${suffix} at ${dir}/${lib}" return 0 fi done done done done return 1 } echo -e "\n\nConfiguring XCA `cat VERSION`\n----------------------------" ######################### QT subdirs="/qt /qt4" search_includes Qt/qobject.h || err "The QT Library headerfiles were not found. Set QTDIR appropriately." subdirs="/qt/Qt /qt4/Qt" search_includes qobject.h || err "The QT Library headerfiles were not found. Set QTDIR appropriately." search_lib QtGui4 QtGui || err "The QT library was not found." search_lib c_r || true ###################### OpenSSL subdirs="" search_includes openssl/opensslv.h || err "The OpenSSL library headerfiles were not found." search_lib crypto || err "The OpenSSL library was not found." export LD_LIBRARY_PATH ##### Try to compile them all together and show the versions. cat >conftest.c < #include #include int main(){ printf("\nThe Versions of the used libraries are:\n\t%s\n\tQT: %s\n", OPENSSL_VERSION_TEXT, QT_VERSION_STR ); if (QT_VERSION < 0x040001) { printf("You need Qt 4 or higher\n"); return 1; } return 0; } EOF echo "${CC} $LIBS $LDIRS $CF $CFLAGS conftest.c -o conftest${SUFFIX}" >conftest.log if ${CC} $LIBS $LDIRS $CF $CFLAGS conftest.c -o conftest${SUFFIX} >> conftest.log 2>&1; then ./conftest${SUFFIX} || err "Unable to execute a freshly compiled application, maybe you have to adjust your LD_LIBRARY_PATH or /etc/ld.so.conf" && rm -f conftest.c conftest conftest.log else err "Unable to compile a minimal application look at 'conftest.log' for errors" fi findapp() { for app in `which $@ 2>/dev/null`; do if test -x "$app"; then echo "$app" break fi done } if test "$HOST" = "w32"; then LIBS="-lQtGui4 -lQtCore4 -lqtmain -lstdc++ -lws2_32 -lcrypto -lwsock32 -lgdi32" SLIBS="" fi MOC=`findapp $QTDIR/bin/moc moc4 moc-qt4 moc` UIC=`findapp $QTDIR/bin/uic uic4 uic-qt4 uic` RCC=`findapp $QTDIR/bin/rcc rcc4 rcc-qt4 rcc` LRELEASE=`findapp $QTDIR/bin/lrelease lrelease4 lrelease-qt4 lrelease` cat >Local.mak <local.h </dev/null | grep GNU; then mak="${dirs}/${make}" return fi done done } find_make echo if test ! -z "${mak}"; then echo "A usable 'make' executable was found in ${mak}" else echo "No usable 'make' executable found." fi echo if test "x${err_occ}" = "xY"; then echo echo "An error occured. Please edit 'Local.mak' manually if compiling fails." fi