|
root / base / xf86-input-mouse / build.sh
build.sh Bash 73 lines 3.2 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
# Build script for xf86-input-mouse (autotools, Template A).
#
# Phase 2 Task 4 (M3). Ships a pre-generated `configure` - straight Template A,
# same shape as xf86-input-keyboard.
#
# Patches (patches/, applied below):
#   01-6892799-mouse-fd-persist.patch - reorder DEVICE_ON/DEVICE_OFF/
#     DEVICE_CLOSE in src/mouse.c so the /dev/mouse fd (+ Xisb buffer) is
#     opened once and closed only at DEVICE_CLOSE, surviving console mode
#     switches (VT enter/leave otherwise churns close()/open() on the VUID
#     stream on every switch). Equivalent of OI's 01-6892799.patch.
#
# Module install dir: same reasoning as xf86-input-keyboard - configure.ac
# computes inputdir=${moduledir}/input, so pass --with-xorg-module-dir
# pointing at .../xlibre-25/drivers so the result lands at
# .../xlibre-25/drivers/input, matching xorg-server.pc's input_drivers_dir.
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# --- Hammerhead/illumos portability patches ---
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"
# sun_mouse.c's CheckRelToAbs() calls libdevinfo's di_init()/di_walk_node()
# under HAVE_ABSOLUTE_MOUSE_SCALING (on by default), but neither
# configure.ac nor src/Makefile.am declares the libdevinfo dependency
# anywhere - a genuine upstream build-system gap for the Solaris/illumos
# path, not something a source patch fixes. automake's generated link line
# includes $(LIBS), so just set it before configure so it gets baked into
# mouse_drv.la's link command. Found at Xorg startup (ld.so.1 relocation
# error: symbol di_init not found), not at compile time - configure/gmake
# both succeed without this; only actually loading the .so into Xorg fails.
export LIBS="${LIBS} -ldevinfo"

# MANDATORY libtool fix (Template A) - piggyback hammerhead onto the
# kopensolaris arm in configure's dynamic-linker case block.
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# OS-detection fix: the generated configure picks the source file to build
# via `case $host_os in ... solaris*) OS_MOUSE_NAME=sun ;; ... esac`, then
# src/Makefile.am uses @OS_MOUSE_NAME@_mouse.c. Our host_os is "hammerhead",
# not "solaris*", so OS_MOUSE_NAME is left empty and the build tries to
# compile a literal "_mouse.c" (missing file). Piggyback hammerhead* onto
# the solaris* arm so OS_MOUSE_NAME=sun selects sun_mouse.c (the VUID
# /dev/mouse backend this task is porting).
if [ -f configure ]; then
    sed -i -E 's/^  solaris\*\)$/  solaris* | hammerhead*)/' configure
fi

./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --with-xorg-module-dir="$PREFIX/lib/xorg/modules/xlibre-25/drivers"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"