untested finished nlsop* binaries - configure script needs to get adjusted.
[physik/nlsop.git] / configure
index 3c5f599..303dde0 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,11 +1,13 @@
 #!/bin/sh
 
 #!/bin/sh
 
-name="nlsop"
+name="nlsop_server nlsop_client nlsop_gui"
+main="nlsop"
 
 #defaults
 prefix=/usr
 dfblib=""
 dfbinc=""
 
 #defaults
 prefix=/usr
 dfblib=""
 dfbinc=""
+apidir=""
 nodfb=0
 
 echo $run_cmd
 nodfb=0
 
 echo $run_cmd
@@ -16,6 +18,7 @@ usage()       {
        echo "--prefix=PREFIX   specify install prefix"
        echo "--with-dfblib=DIR specify directfb lib dir"
        echo "--with-dfbinc=DIR specify directfb include dir"
        echo "--prefix=PREFIX   specify install prefix"
        echo "--with-dfblib=DIR specify directfb lib dir"
        echo "--with-dfbinc=DIR specify directfb include dir"
+        echo "--with-api=DIR   specify api dir"
        echo
        }
 
        echo
        }
 
@@ -26,9 +29,30 @@ while [ "$1" ]; do
                --with-dfblib)  dfblib=`echo $1 | awk -F= '{ print $2 }'`; shift;;
                --with-dfbinc)  dfbinc=`echo $1 | awk -F= '{ print $2 }'`; shift;;
                --without-dfb)  nodfb=1; shift ;;
                --with-dfblib)  dfblib=`echo $1 | awk -F= '{ print $2 }'`; shift;;
                --with-dfbinc)  dfbinc=`echo $1 | awk -F= '{ print $2 }'`; shift;;
                --without-dfb)  nodfb=1; shift ;;
+               --with-api)     apidir=`echo $1 | awk -F= '{ print $2 }'`; shift;;
        esac
 done
 
        esac
 done
 
+echo "checking for api stuff ..."
+api_dir="0"
+if [ -z "$apidir" ]; then
+       for i in ../api ../../api; do
+               if [ -f $i/CHANGELOG ]; then
+                       api_dir=$i
+               fi
+       done
+else
+       if [ -f $apidir/CHANGELOG ]; then
+               api_dir=$apidir
+       fi
+fi
+if [ "$api_dir" = "0" ]; then
+       echo "api files not found ..."
+       echo "WARNING: your build will fail."
+       echo "please get the api files first (see README file)."
+       api_dir="./"
+fi
+
 echo "checking for dfb stuff ..."
 dfb_inc_dir="0"
 if [ -z "$dfbinc" ]; then
 echo "checking for dfb stuff ..."
 dfb_inc_dir="0"
 if [ -z "$dfbinc" ]; then
@@ -65,10 +89,13 @@ fi
 
 [ "$nodfb" = "0" ] && echo "directfb installation looks good :)"
 
 
 [ "$nodfb" = "0" ] && echo "directfb installation looks good :)"
 
+GENLIBS="-lm -lncurses"
+GENAPI="network.o event.o list.o display.o input.o"
+
 echo "creating Makefile"
 
 cat > Makefile << EOF
 echo "creating Makefile"
 
 cat > Makefile << EOF
-# $name Makefile, created `date`
+# $main Makefile, created `date`
 
 INCLUDEDIR = /usr/include
 EOF
 
 INCLUDEDIR = /usr/include
 EOF
@@ -77,18 +104,18 @@ if [ "$nodfb" = "0" ]; then
 
 cat >> Makefile << EOF
 CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$name/decker.ttf\" -O3 -Wall -I$dfb_inc_dir
 
 cat >> Makefile << EOF
 CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$name/decker.ttf\" -O3 -Wall -I$dfb_inc_dir
-LIBS = -L$dfb_lib_dir -ldirectfb
+LIBS = -L$dfb_lib_dir -ldirectfb $GENLIBS
 
 
-OBJS = random.o dfbapi.o
+OBJS = random.o dfbapi.o $GENAPI
 EOF
 
 else
 
 cat >> Makefile << EOF
 CFLAGS = -DDEBUG -DNODFB -O3 -Wall
 EOF
 
 else
 
 cat >> Makefile << EOF
 CFLAGS = -DDEBUG -DNODFB -O3 -Wall
-LIBS = -lm
+LIBS = -lm -lncurses
 
 
-OBJS = random.o
+OBJS = random.o $GENAPI
 EOF
 
 fi
 EOF
 
 fi
@@ -96,23 +123,45 @@ fi
 cat >> Makefile << EOF
 OBJS2 = $name
 
 cat >> Makefile << EOF
 OBJS2 = $name
 
-$name: \$(OBJS)
-       \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) ${name}.c
+links:
+EOF
+
+for i in $GENAPI; do
+       foo="`echo $i | sed 's/\.o//g'`"
+       cat >> Makefile << EOF
+       ln -sf $api_dir/$foo/${foo}.{c,h} .
+EOF
+done
 
 
-all: $name
+for i in $name; do
+cat >> Makefile << EOF
+
+$i: links \$(OBJS)
+       \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) ${i}.c
+
+EOF
+done
+
+cat >> Makefile << EOF
+nlsop: links $name
+       \$(CC) \$(CFLAGS) -o \$@ \$(OBJS) \$(LIBS) nlsop.c
+
+EOF
+
+cat >> Makefile << EOF
+all: $main
 
 clean:
 
 clean:
-       rm \$(OBJS) \$(OBJS2)
+       rm -f \$(OBJS) \$(OBJS2)
 
 remake: clean all
 
 install:
        mkdir -p $prefix/bin
        cp $name $prefix/bin
 
 remake: clean all
 
 install:
        mkdir -p $prefix/bin
        cp $name $prefix/bin
-       chmod 755 $prefix/bin/$name
-       mkdir -p $prefix/share/$name
-       cp decker.ttf $prefix/share/$name
-       chmod 644 $prefix/share/$name/decker.ttf
+       mkdir -p $prefix/share/$main
+       cp decker.ttf $prefix/share/$main
+       chmod 644 $prefix/share/$main/decker.ttf
 EOF
 
 echo "done"
 EOF
 
 echo "done"