#!/bin/sh
-name="nlsop"
+name="nlsop_server nlsop_client nlsop_gui nlsop_make_cryst"
+main="nlsop"
#defaults
prefix=/usr
dfblib=""
dfbinc=""
+apidir=""
+nodfb=0
echo $run_cmd
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
}
--help) usage; shift 1;;
--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
+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
fi
fi
if [ "$dfb_inc_dir" = "0" ]; then
- echo "dfb includes missing ..."
- exit 1
+ echo "dfb includes not found ..."
+ nodfb=1
fi
dfb_lib_dir="0"
if [ -z "$dfblib" ]; then
fi
fi
if [ "$dfb_lib_dir" = "0" ]; then
- echo "dfb libs missing ..."
- exit 1
+ echo "dfb libs not found ..."
+ nodfb=1
fi
-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
-# $name Makefile, created `date`
+# $main Makefile, created `date`
INCLUDEDIR = /usr/include
-CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$name/decker.ttf\" -O3 -Wall -I$dfb_inc_dir
-LIBS = -L$dfb_lib_dir -ldirectfb
+EOF
+
+if [ "$nodfb" = "0" ]; then
+
+cat >> Makefile << EOF
+CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$main/decker.ttf\" -O3 -Wall -I$dfb_inc_dir
+LIBS = -L$dfb_lib_dir -ldirectfb $GENLIBS
+
+OBJS = random.o dfbapi.o $GENAPI
+EOF
+
+else
-OBJS = random.o dfbapi.o
+cat >> Makefile << EOF
+CFLAGS = -DDEBUG -DNODFB -O3 -Wall
+LIBS = -lm -lncurses
+
+OBJS = random.o $GENAPI
+EOF
+
+fi
+
+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
+
+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
-all: $name
+cat >> Makefile << EOF
+all: $main
clean:
- rm \$(OBJS) \$(OBJS2)
+ rm -f \$(OBJS) \$(OBJS2)
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"