mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-12-05 02:06:27 +00:00
12fc5329ce
unit tests run under linux and openbsd. last checkin before 0.1 branch git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@45 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
102 lines
2.5 KiB
Bash
Executable File
102 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
program=libkqueue
|
|
version=0.1
|
|
|
|
finalize() {
|
|
eval "if [ \"\$$1\" = \"\" ] ; then $1=\"$2\" ; fi"
|
|
|
|
# Add the variable to config.mk and config.h
|
|
uc_id=`echo $1 | tr 'a-z' 'A-Z'`;
|
|
eval "echo \"$uc_id=\"\$$1\"\" >> config.mk"
|
|
eval "echo \"#define $uc_id \\\"\$$1\\\"\" >> config.h"
|
|
}
|
|
|
|
process_argv() {
|
|
for arg in $*
|
|
do
|
|
id=`echo "$arg" | sed 's/=.*//; s/^--//;'`
|
|
val=`echo "$arg" | sed 's/^.*=//'`
|
|
if [ "$val" = "" ] ; then val=1 ; fi
|
|
eval "$id=$val"
|
|
done
|
|
}
|
|
|
|
check_header() {
|
|
sym=`echo "HAVE_$1" | tr a-z A-Z | sed 's,[./],_,g'`
|
|
path=$1
|
|
|
|
printf "checking for $path.. "
|
|
if [ -f "/usr/include/$path" ] ; then
|
|
echo "yes"
|
|
echo "#define $sym" >> config.h
|
|
return 0
|
|
else
|
|
echo "no"
|
|
echo "#undef $sym" >> config.h
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
#######################################################################
|
|
#
|
|
# MAIN()
|
|
#
|
|
#######################################################################
|
|
|
|
default_cflags="-fPIC -D_REENTRANT -I. -Wall -Werror"
|
|
|
|
# Initialize the output files
|
|
#
|
|
for output_file in config.mk $program.pc
|
|
do
|
|
rm -f $output_file
|
|
echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" > $output_file
|
|
done
|
|
rm -f config.h
|
|
echo "/* AUTOMATICALLY GENERATED -- DO NOT EDIT */" > config.h
|
|
|
|
process_argv $*
|
|
|
|
if [ "$debug" = "yes" ]
|
|
then
|
|
default_cflags="$default_cflags -DKQUEUE_DEBUG"
|
|
fi
|
|
|
|
finalize program $program
|
|
finalize version $version
|
|
finalize target `uname -s | tr A-Z a-z`
|
|
finalize prefix /usr/local
|
|
finalize libdir "${prefix}/lib"
|
|
finalize includedir "${prefix}/include"
|
|
finalize mandir "${prefix}/share/man"
|
|
finalize cflags "$default_cflags"
|
|
|
|
echo "Checking operating system type... $target"
|
|
rm -f socket.c vnode.c signal.c timer.c user.c
|
|
if [ $target = "linux" ] ; then
|
|
check_header sys/epoll.h && ln -s os/linux/socket.c \
|
|
|| ln -sf os/posix/socket.c
|
|
check_header sys/inotify.h && ln -s os/linux/vnode.c \
|
|
|| ln -sf os/posix/vnode.c
|
|
check_header sys/signalfd.h && ln -s os/linux/signal.c \
|
|
|| ln -sf os/posix/signal.c
|
|
check_header sys/timerfd.h && ln -s os/linux/timer.c \
|
|
|| ln -sf os/posix/timer.c
|
|
ln -sf os/posix/user.c
|
|
fi
|
|
echo "Creating config.h"
|
|
|
|
echo "Creating $program.pc"
|
|
sed -e "
|
|
s,@@PROGRAM@@,$program,g;
|
|
s,@@VERSION@@,$version,g;
|
|
s,@@PREFIX@@,$prefix,g;
|
|
s,@@LIBDIR@@,$libdir,g;
|
|
s,@@INCLUDEDIR@@,$includedir,g;
|
|
s,@@MANDIR@@,$mandir,g;
|
|
" < $program.pc.in >> $program.pc
|
|
chmod 400 $program.pc
|
|
|
|
echo "Creating config.mk"
|