migrate to meson

pull/62/head
Alberto Fanjul 2022-02-08 22:15:21 +01:00
rodzic eb0287f6e8
commit e35da6179d
8 zmienionych plików z 84 dodań i 269 usunięć

Wyświetl plik

@ -1,42 +0,0 @@
src = $(sort $(wildcard src/*.c))
hdr = $(wildcard src/*.h)
obj = $(src:.c=.o)
dep = $(obj:.o=.d)
bin = spacenavd
ctl = spnavd_ctl
CC ?= gcc
CFLAGS = -pedantic -Wall $(dbg) $(opt) -fno-strict-aliasing -fcommon \
-I$(srcdir)/src -I/usr/local/include -MMD $(add_cflags)
LDFLAGS = -L/usr/local/lib $(xlib) $(add_ldflags)
$(bin): $(obj)
$(CC) -o $@ $(obj) $(LDFLAGS)
-include $(dep)
tags: $(src) $(hdr)
ctags $(src) $(hdr)
%.o: $(srcdir)/%.c
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
rm -f $(obj) $(bin)
.PHONY: cleandep
cleandep:
rm -f $(dep)
.PHONY: install
install: $(bin)
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $(bin) $(DESTDIR)$(PREFIX)/bin/$(bin)
cp $(srcdir)/$(ctl) $(DESTDIR)$(PREFIX)/bin/$(ctl)
cd $(srcdir) && ./setup_init --no-install
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(bin)
rm -f $(DESTDIR)$(PREFIX)/bin/$(ctl)

223
configure vendored
Wyświetl plik

@ -1,223 +0,0 @@
#!/bin/sh
test_kver() {
req_major=`echo $1 | awk -F . '{ print $1 }'`
req_minor=`echo $1 | awk -F . '{ print $2 }'`
req_rev=`echo $1 | awk -F . '{ print $3 }'`
linux_rev=`uname -r | sed 's/-.*//'`
kver_major=`echo $linux_rev | awk -F . '{ print $1 }'`
kver_minor=`echo $linux_rev | awk -F . '{ print $2 }'`
kver_rev=`echo $linux_rev | awk -F . '{ print $3 }'`
if [ "$kver_major" -lt "$req_major" ]; then
return 1
fi
if [ "$kver_major" = "$req_major" ]; then
if [ "$kver_minor" -lt "$req_minor" ]; then
return 1
fi
if [ "$kver_minor" = "$req_minor" -a "$kver_rev" -lt "$req_rev" ]; then
return 1
fi
fi
return 0
}
check_header() {
printf "Looking for header: $1 ... " >&2
echo "#include <$1>" >.chkhdr.c
if cpp -I/usr/local/include .chkhdr.c >/dev/null 2>&1; then
echo found >&2
echo "#define HAVE_`basename $1 | tr '[:lower:]' '[:upper:]' | sed 's/\./_/g'`"
else
echo not found >&2
fi
rm -f .chkhdr.c
}
PREFIX=/usr/local
OPT=yes
DBG=yes
X11=yes
HOTPLUG=yes
XINPUT=yes
VER=`git describe --tags 2>/dev/null`
CFGDIR=/etc
if [ -z "$VER" ]; then
VER=`git rev-parse --short HEAD`
if [ -z "$VER" ]; then
VER=v`pwd | grep 'spacenavd-[0-9]\+\.' | sed 's/.*spacenavd-\(\([0-9]\+\.\)\+[0-9]\+\).*$/\1/'`
if [ $VER = v ]; then
VER='<unknown version>'
fi
fi
fi
echo "configuring spacenavd - $VER"
sys=`uname -s`
if [ "$sys" = Linux ]; then
# NETLINK_KOBJECT_UEVENT used for hotplug detection requires 2.6.10
if test_kver 2.6.10; then
HOTPLUG=yes
else
HOTPLUG=no
fi
elif [ "$sys" = Darwin ]; then
LDFLAGS='-framework CoreFoundation -framework IOKit'
else
# TODO implement hotplug for other systems then switch this on
HOTPLUG=no
fi
srcdir="`dirname "$0"`"
# process arguments
for arg; do
case "$arg" in
--prefix=*)
value=`echo $arg | sed 's/--prefix=//'`
PREFIX=${value:-$prefix}
;;
--cfgdir=*)
value=`echo $arg | sed 's/--cfgdir=//'`
CFGDIR=${value:-$cfgdir}
;;
--enable-opt)
OPT=yes;;
--disable-opt)
OPT=no;;
--enable-debug)
DBG=yes;;
--disable-debug)
DBG=no;;
--enable-x11)
X11=yes;;
--disable-x11)
X11=no;;
--enable-hotplug)
HOTPLUG=yes;;
--disable-hotplug)
HOTPLUG=no;;
--help)
echo 'usage: ./configure [options]'
echo 'options:'
echo ' --prefix=<path>: installation path (default: /usr/local)'
echo ' --enable-x11: enable X11 communication mode (default)'
echo ' --disable-x11: disable X11 communication mode'
echo ' --enable-hotplug: enable hotplug using NETLINK_KOBJECT_UEVENT (default)'
echo ' --disable-hotplug: disable hotplug, fallback to polling for the device'
echo ' --enable-opt: enable speed optimizations (default)'
echo ' --disable-opt: disable speed optimizations'
echo ' --enable-debug: include debugging symbols (default)'
echo ' --disable-debug: do not include debugging symbols'
echo 'all invalid options are silently ignored'
exit 0
;;
esac
done
echo " prefix: $PREFIX"
echo " config dir: $CFGDIR"
echo " optimize for speed: $OPT"
echo " include debugging symbols: $DBG"
echo " x11 communication method: $X11"
echo " use hotplug: $HOTPLUG"
echo ""
HAVE_ALLOCA_H=`check_header alloca.h`
HAVE_MALLOC_H=`check_header malloc.h`
if [ "$X11" = "no" ]; then
echo "WARNING: you have disabled the X11 interface, the resulting daemon \
won't be compatible with applications written for the proprietary 3Dconnexion \
daemon (3dxserv)!"
echo
else
HAVE_XINPUT2_H=`check_header X11/extensions/XInput2.h`
HAVE_XTEST_H=`check_header X11/extensions/XTest.h`
if [ -z "$HAVE_XTEST_H" ]; then
echo "WARNING: building without XTEST support, makes keyboard emulation \
less reliable (fallback to XSendEvent)."
fi
fi
# create Makefile
echo 'creating Makefile ...'
echo "PREFIX = $PREFIX" >Makefile
echo "srcdir = $srcdir" >>Makefile
echo "ver = $VER" >>Makefile
if [ "$DBG" = 'yes' ]; then
echo 'dbg = -g' >>Makefile
fi
if [ "$OPT" = 'yes' ]; then
echo 'opt = -O2' >>Makefile
fi
if [ "$X11" = 'yes' ]; then
echo 'xlib = -L/usr/X11/lib -lX11' >>Makefile
if [ -n "$HAVE_XINPUT2_H" ]; then
echo 'xlib += -lXi' >>Makefile
fi
if [ -n "$HAVE_XTEST_H" ]; then
echo xlib += -lXtst >>Makefile
fi
fi
if [ -n "$CFLAGS" ]; then
echo "add_cflags = $CFLAGS" >>Makefile
fi
if [ -n "$LDFLAGS" ]; then
echo "add_ldflags = $LDFLAGS" >>Makefile
fi
cat "$srcdir/Makefile.in" >>Makefile
# create config.h
cfgheader=$srcdir/src/config.h
echo 'creating config.h'
echo '#ifndef CONFIG_H_' >$cfgheader
echo '#define CONFIG_H_' >>$cfgheader
echo >>$cfgheader
if [ "$X11" = yes ]; then
echo '#define USE_X11' >>$cfgheader
echo >>$cfgheader
fi
if [ "$HOTPLUG" = yes ]; then
echo '#define USE_NETLINK' >>$cfgheader
echo >>$cfgheader
fi
echo '#define VERSION "'$VER'"' >>$cfgheader
echo >>$cfgheader
# check for alloca.h
[ -n "$HAVE_ALLOCA_H" ] && echo $HAVE_ALLOCA_H >>$cfgheader
[ -n "$HAVE_MALLOC_H" ] && echo $HAVE_MALLOC_H >>$cfgheader
[ -n "$HAVE_XINPUT2_H" ] && echo $HAVE_XINPUT2_H >>$cfgheader
[ -n "$HAVE_XTEST_H" ] && echo $HAVE_XTEST_H >>$cfgheader
echo >>$cfgheader
echo "#define CFGDIR \"$CFGDIR\"" >>$cfgheader
echo >>$cfgheader
echo '#endif /* CONFIG_H_ */' >>$cfgheader
echo ''
echo 'Done. You can now type make (or gmake) to compile spacenavd.'
echo ''

5
meson.build 100644
Wyświetl plik

@ -0,0 +1,5 @@
project('src', 'c',
version : run_command(['git', 'describe', '--tags'], capture : true, check : true).stdout().strip(),
default_options : ['warning_level=3'])
subdir('src')

Wyświetl plik

@ -0,0 +1,3 @@
option('x11', type: 'boolean', value: true, description: 'Use x11')
option('hotplug', type: 'boolean', value: true, description: 'Use hotplug')

17
src/config.h.in 100644
Wyświetl plik

@ -0,0 +1,17 @@
#ifndef CONFIG_H_'
#define CONFIG_H_'
#mesondefine X11
#mesondefine USE_NETLINK
#mesondefine VERSION
/*
[ -n "$HAVE_ALLOCA_H" ] && echo $HAVE_ALLOCA_H >>$cfgheader
[ -n "$HAVE_MALLOC_H" ] && echo $HAVE_MALLOC_H >>$cfgheader
[ -n "$HAVE_XINPUT2_H" ] && echo $HAVE_XINPUT2_H >>$cfgheader
[ -n "$HAVE_XTEST_H" ] && echo $HAVE_XTEST_H >>$cfgheader
*/
#mesondefine CFGDIR
#endif /* CONFIG_H_ */

54
src/meson.build 100644
Wyświetl plik

@ -0,0 +1,54 @@
cc = meson.get_compiler('c')
conf_data = configuration_data()
has_x11 = get_option('x11')
has_hotplug = get_option('hotplug')
conf_data.set('USE_X11', has_x11)
conf_data.set('USE_NETLINK', has_hotplug)
conf_data.set_quoted('VERSION', meson.project_version())
conf_data.set_quoted('CFGDIR', '/etc')
conf_data.set('HAVE_ALLOCA_H', cc.has_header('alloca.h'))
conf_data.set('HAVE_MALLOC_H', cc.has_header('malloc.h'))
if (not has_x11)
message('WARNING: you have disabled the X11 interface, the resulting daemon won\'t be compatible with applications written for the proprietary 3Dconnexion daemon (3dxserv)!')
else
conf_data.set('HAVE_XINPUT2_H', cc.has_header('X11/extensions/XInput2.h'))
has_xtest = cc.has_header('X11/extensions/XTest.h')
conf_data.set('HAVE_XTEST_H', has_xtest)
if (not has_xtest)
message('WARNING: building without XTEST support, makes keyboard emulation less reliable (fallback to XSendEvent).')
endif
endif
configure_file(output : 'config.h',
configuration : conf_data)
executable('spacenavd',
'proto_x11.c',
'kbemu.c',
'proto_unix.c',
'hotplug_freebsd.c',
'dev_usb.c',
'xdetect_freebsd.c',
'dev_usb_freebsd.c',
'dev_usb_linux.c',
'dev.c',
'client.c',
'dev_usb_darwin.c',
'hotplug_darwin.c',
'dummy_usb.c',
'xdetect_linux.c',
'spnavd.c',
'cfgfile.c',
'logger.c',
'event.c',
'hotplug_linux.c',
'spnavd_win32.c',
'dev_serial.c',
dependencies: [
dependency('x11'),
dependency('xi'),
dependency('xtst')
],
install : true)

Wyświetl plik

@ -50,6 +50,9 @@ static char *fix_path(char *str);
static char *cfgfile = DEF_CFGFILE;
static char *logfile = DEF_LOGFILE;
struct cfg cfg;
int verbose;
int main(int argc, char **argv)
{
int i, pid, ret, become_daemon = 1;

Wyświetl plik

@ -47,9 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
struct cfg cfg;
int verbose;
extern struct cfg cfg;
extern int verbose;
#endif /* SPNAVD_H_ */