feat: initial ANODE desktop environment adapted from Geminux
This commit is contained in:
commit
65bfe3c65a
137 files changed
+33788
No files matched your search
Executable
+307
@@ -0,0 +1,307 @@
|
||||
#!/bin/sh
|
||||
# Detect OS, compiler capabilities, and X11/toolkit flags for ANODE.
|
||||
# Strictly POSIX sh; writes an atomic shell-sourceable build configuration.
|
||||
set -eu
|
||||
|
||||
OUT_FILE="${1:-build/flags.sh}"
|
||||
CC_BIN="${CC:-cc}"
|
||||
CXX_BIN="${CXX:-c++}"
|
||||
PKG_CFG="${PKG_CONFIG:-pkg-config}"
|
||||
WITH_GTKTTK="${WITH_GTKTTK:-auto}"
|
||||
|
||||
OS_NAME="$(uname -s 2>/dev/null || printf 'Unknown')"
|
||||
|
||||
# Ensure common BSD/Linux/pkgsrc pkg-config directories are searched.
|
||||
for pcdir in \
|
||||
/usr/local/lib/pkgconfig \
|
||||
/usr/local/libdata/pkgconfig \
|
||||
/usr/X11R6/lib/pkgconfig \
|
||||
/usr/X11R7/lib/pkgconfig \
|
||||
/usr/pkg/lib/pkgconfig \
|
||||
/usr/lib/pkgconfig \
|
||||
/usr/share/pkgconfig
|
||||
do
|
||||
if [ -d "$pcdir" ]; then
|
||||
case ":${PKG_CONFIG_PATH:-}:" in
|
||||
*":$pcdir:"*) ;;
|
||||
*) PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}$pcdir" ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
if ! command -v "$PKG_CFG" >/dev/null 2>&1; then
|
||||
printf 'detect-env.sh: error: %s not found\n' "$PKG_CFG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p \
|
||||
build \
|
||||
build/common \
|
||||
build/dwm \
|
||||
build/dmenu \
|
||||
build/st \
|
||||
build/libgemui \
|
||||
build/apps \
|
||||
build/daemons \
|
||||
build/gtkTtk \
|
||||
build/tests
|
||||
|
||||
TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/anode-probe.XXXXXX")"
|
||||
cleanup() {
|
||||
rm -rf "$TMP_DIR"
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
require_pkgs() {
|
||||
for pkg in "$@"; do
|
||||
if ! "$PKG_CFG" --exists "$pkg" 2>/dev/null; then
|
||||
printf 'detect-env.sh: error: required pkg-config module "%s" not found\n' "$pkg" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
require_pkgs \
|
||||
x11 xext xft xinerama xrender xrandr xfixes xi xtst \
|
||||
fontconfig freetype2 pango pangoxft pangocairo cairo harfbuzz
|
||||
|
||||
# Probe openpty (libc vs -lutil)
|
||||
cat > "$TMP_DIR/pty.c" <<'EOF'
|
||||
#if defined(__linux__) || defined(__linux)
|
||||
#include <pty.h>
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <sys/types.h>
|
||||
#include <libutil.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
#include <util.h>
|
||||
#endif
|
||||
int main(void) {
|
||||
int m = 0, s = 0;
|
||||
return openpty(&m, &s, 0, 0, 0);
|
||||
}
|
||||
EOF
|
||||
PTY_LIBS=""
|
||||
if "$CC_BIN" "$TMP_DIR/pty.c" -o "$TMP_DIR/pty.out" >/dev/null 2>&1; then
|
||||
PTY_LIBS=""
|
||||
elif "$CC_BIN" "$TMP_DIR/pty.c" -lutil -o "$TMP_DIR/pty.out" >/dev/null 2>&1; then
|
||||
PTY_LIBS="-lutil"
|
||||
fi
|
||||
|
||||
# Probe clock_gettime (libc vs -lrt)
|
||||
cat > "$TMP_DIR/rt.c" <<'EOF'
|
||||
#include <time.h>
|
||||
int main(void) {
|
||||
struct timespec ts;
|
||||
return clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
}
|
||||
EOF
|
||||
RT_LIBS=""
|
||||
if "$CC_BIN" "$TMP_DIR/rt.c" -o "$TMP_DIR/rt.out" >/dev/null 2>&1; then
|
||||
RT_LIBS=""
|
||||
elif "$CC_BIN" "$TMP_DIR/rt.c" -lrt -o "$TMP_DIR/rt.out" >/dev/null 2>&1; then
|
||||
RT_LIBS="-lrt"
|
||||
fi
|
||||
|
||||
# Probe crypt() and shadow.h vs BSD getpwnam(), with or without <crypt.h>
|
||||
HAVE_CRYPT_H=0
|
||||
cat > "$TMP_DIR/crypt_h.c" <<'EOF'
|
||||
#include <crypt.h>
|
||||
int main(void) { return 0; }
|
||||
EOF
|
||||
if "$CC_BIN" "$TMP_DIR/crypt_h.c" -o "$TMP_DIR/chk.out" >/dev/null 2>&1; then
|
||||
HAVE_CRYPT_H=1
|
||||
fi
|
||||
|
||||
cat > "$TMP_DIR/shadow.c" <<EOF
|
||||
#define _XOPEN_SOURCE 700
|
||||
#include <shadow.h>
|
||||
#include <unistd.h>
|
||||
$( [ "$HAVE_CRYPT_H" = "1" ] && printf '#include <crypt.h>\n' )
|
||||
int main(void) {
|
||||
struct spwd *sp = getspnam("root");
|
||||
(void)sp;
|
||||
return crypt("a", "aa") ? 0 : 1;
|
||||
}
|
||||
EOF
|
||||
cat > "$TMP_DIR/bsd_pw.c" <<EOF
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
$( [ "$HAVE_CRYPT_H" = "1" ] && printf '#include <crypt.h>\n' )
|
||||
int main(void) {
|
||||
struct passwd *pw = getpwnam("root");
|
||||
(void)pw;
|
||||
return crypt("a", "aa") ? 0 : 1;
|
||||
}
|
||||
EOF
|
||||
|
||||
CHECKPW_DEFS="-DHAVE_BSD_PASSWD=1"
|
||||
[ "$HAVE_CRYPT_H" = "1" ] && CHECKPW_DEFS="$CHECKPW_DEFS -DHAVE_CRYPT_H=1"
|
||||
CHECKPW_LIBS=""
|
||||
if "$CC_BIN" "$TMP_DIR/shadow.c" -o "$TMP_DIR/chk.out" >/dev/null 2>&1; then
|
||||
CHECKPW_DEFS="-DHAVE_SHADOW_H=1"
|
||||
[ "$HAVE_CRYPT_H" = "1" ] && CHECKPW_DEFS="$CHECKPW_DEFS -DHAVE_CRYPT_H=1"
|
||||
CHECKPW_LIBS=""
|
||||
elif "$CC_BIN" "$TMP_DIR/shadow.c" -lcrypt -o "$TMP_DIR/chk.out" >/dev/null 2>&1; then
|
||||
CHECKPW_DEFS="-DHAVE_SHADOW_H=1"
|
||||
[ "$HAVE_CRYPT_H" = "1" ] && CHECKPW_DEFS="$CHECKPW_DEFS -DHAVE_CRYPT_H=1"
|
||||
CHECKPW_LIBS="-lcrypt"
|
||||
elif "$CC_BIN" "$TMP_DIR/bsd_pw.c" -o "$TMP_DIR/chk.out" >/dev/null 2>&1; then
|
||||
CHECKPW_DEFS="-DHAVE_BSD_PASSWD=1"
|
||||
[ "$HAVE_CRYPT_H" = "1" ] && CHECKPW_DEFS="$CHECKPW_DEFS -DHAVE_CRYPT_H=1"
|
||||
CHECKPW_LIBS=""
|
||||
elif "$CC_BIN" "$TMP_DIR/bsd_pw.c" -lcrypt -o "$TMP_DIR/chk.out" >/dev/null 2>&1; then
|
||||
CHECKPW_DEFS="-DHAVE_BSD_PASSWD=1"
|
||||
[ "$HAVE_CRYPT_H" = "1" ] && CHECKPW_DEFS="$CHECKPW_DEFS -DHAVE_CRYPT_H=1"
|
||||
CHECKPW_LIBS="-lcrypt"
|
||||
fi
|
||||
|
||||
# Probe XScrnSaver for idle time tracking in anode-powerd
|
||||
POWERD_PKGS="x11 xext"
|
||||
POWERD_DEFS=""
|
||||
if "$PKG_CFG" --exists xscrnsaver 2>/dev/null; then
|
||||
POWERD_PKGS="x11 xext xscrnsaver"
|
||||
POWERD_DEFS="-DHAVE_XSCRNSAVER=1"
|
||||
fi
|
||||
|
||||
DWM_CFLAGS="$("$PKG_CFG" --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama xrender)"
|
||||
DWM_LIBS="$("$PKG_CFG" --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama xrender)"
|
||||
|
||||
DMENU_CFLAGS="$("$PKG_CFG" --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xfixes xi xinerama)"
|
||||
DMENU_LIBS="$("$PKG_CFG" --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xfixes xi xinerama) -lm"
|
||||
|
||||
ST_CFLAGS="$("$PKG_CFG" --cflags fontconfig freetype2 harfbuzz xft x11 xfixes xi)"
|
||||
ST_LIBS="$("$PKG_CFG" --libs fontconfig freetype2 harfbuzz xft x11 xfixes xi) -lm $RT_LIBS $PTY_LIBS"
|
||||
|
||||
GEMUI_CFLAGS="$("$PKG_CFG" --cflags x11 xext xft xinerama xrandr cairo pangocairo pango harfbuzz fontconfig freetype2)"
|
||||
GEMUI_LIBS="$("$PKG_CFG" --libs x11 xext xft xinerama xrandr cairo pangocairo pango harfbuzz fontconfig freetype2) -lm"
|
||||
|
||||
APP_CFLAGS="$("$PKG_CFG" --cflags x11 xext xft xinerama xrandr xtst cairo pangocairo pango harfbuzz fontconfig freetype2)"
|
||||
APP_LIBS="$("$PKG_CFG" --libs x11 xext xft xinerama xrandr xtst cairo pangocairo pango harfbuzz fontconfig freetype2) -lm"
|
||||
|
||||
TOUCHD_CFLAGS="$("$PKG_CFG" --cflags x11 xi xtst)"
|
||||
TOUCHD_LIBS="$("$PKG_CFG" --libs x11 xi xtst) -lm"
|
||||
|
||||
STATUSD_CFLAGS="$("$PKG_CFG" --cflags x11)"
|
||||
STATUSD_LIBS="$("$PKG_CFG" --libs x11)"
|
||||
|
||||
POWERD_CFLAGS="$POWERD_DEFS $("$PKG_CFG" --cflags $POWERD_PKGS)"
|
||||
POWERD_LIBS="$("$PKG_CFG" --libs $POWERD_PKGS)"
|
||||
|
||||
# Probe gtkTtk dependencies (gtk+-2.0, x11, tcl, tk, ttkTheme.h)
|
||||
GTKTTK_AVAILABLE="0"
|
||||
GTKTTK_REASON="disabled via WITH_GTKTTK=0"
|
||||
GTKTTK_CXXFLAGS=""
|
||||
GTKTTK_LDFLAGS=""
|
||||
|
||||
if [ "$WITH_GTKTTK" != "0" ]; then
|
||||
GTKTTK_REASON=""
|
||||
if ! "$PKG_CFG" --exists gtk+-2.0 x11 2>/dev/null; then
|
||||
GTKTTK_REASON="gtk+-2.0 development headers not found"
|
||||
else
|
||||
GTK2_C="$("$PKG_CFG" --cflags gtk+-2.0 x11)"
|
||||
GTK2_L="$("$PKG_CFG" --libs gtk+-2.0 x11)"
|
||||
TCL_C=""
|
||||
TCL_L=""
|
||||
|
||||
for tclmod in tcl tcl8.6 tcl86; do
|
||||
if "$PKG_CFG" --exists "$tclmod" 2>/dev/null; then
|
||||
TCL_C="$("$PKG_CFG" --cflags "$tclmod")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
for tkmod in tk tk8.6 tk86; do
|
||||
if "$PKG_CFG" --exists "$tkmod" 2>/dev/null; then
|
||||
TCL_C="$TCL_C $("$PKG_CFG" --cflags "$tkmod")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for incdir in \
|
||||
/usr/include \
|
||||
/usr/include/tcl8.6 \
|
||||
/usr/include/tk8.6 \
|
||||
/usr/include/tk8.6/tk-private/generic/ttk \
|
||||
/usr/include/tk/tk-private/generic/ttk \
|
||||
/usr/local/include \
|
||||
/usr/local/include/tcl8.6 \
|
||||
/usr/local/include/tk8.6 \
|
||||
/usr/local/include/tk8.6/generic/ttk \
|
||||
/usr/pkg/include \
|
||||
/usr/pkg/include/tcl \
|
||||
/usr/pkg/include/tk
|
||||
do
|
||||
if [ -d "$incdir" ]; then
|
||||
if [ -f "$incdir/tcl.h" ] || [ -f "$incdir/tk.h" ] || [ -f "$incdir/ttkTheme.h" ]; then
|
||||
TCL_C="$TCL_C -I$incdir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for stubver in 8.6 86 8.7 ""; do
|
||||
for libdir in /usr/lib /usr/lib64 /usr/local/lib /usr/pkg/lib; do
|
||||
if [ -d "$libdir" ]; then
|
||||
:
|
||||
fi
|
||||
done
|
||||
if [ -n "$stubver" ]; then
|
||||
CAND_L="-ltclstub${stubver} -ltkstub${stubver}"
|
||||
else
|
||||
CAND_L="-ltclstub -ltkstub"
|
||||
fi
|
||||
cat > "$TMP_DIR/gtkttk_probe.cpp" <<'EOF'
|
||||
#include <tk.h>
|
||||
#include "ttkTheme.h"
|
||||
#include <gtk/gtk.h>
|
||||
int probe_fn(void) { return 0; }
|
||||
EOF
|
||||
if "$CXX_BIN" -shared -fPIC -DUSE_TCL_STUBS -DUSE_TK_STUBS -DUSE_TTK_STUBS \
|
||||
$GTK2_C $TCL_C "$TMP_DIR/gtkttk_probe.cpp" \
|
||||
$CAND_L $GTK2_L -o "$TMP_DIR/gtkttk_probe.so" >/dev/null 2>&1; then
|
||||
GTKTTK_AVAILABLE="1"
|
||||
GTKTTK_CXXFLAGS="$GTK2_C $TCL_C"
|
||||
GTKTTK_LDFLAGS="$CAND_L $GTK2_L"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$GTKTTK_AVAILABLE" != "1" ]; then
|
||||
GTKTTK_REASON="Tcl/Tk stub libraries or ttkTheme.h not found"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
escape_sh() {
|
||||
printf '%s' "$1" | sed "s/'/'\\\\''/g"
|
||||
}
|
||||
|
||||
TMP_OUT="${OUT_FILE}.tmp.$$"
|
||||
{
|
||||
printf '# Auto-generated by scripts/detect-env.sh (%s)\n' "$OS_NAME"
|
||||
printf "OS_NAME='%s'\n" "$(escape_sh "$OS_NAME")"
|
||||
printf "DWM_CFLAGS='%s'\n" "$(escape_sh "$DWM_CFLAGS")"
|
||||
printf "DWM_LIBS='%s'\n" "$(escape_sh "$DWM_LIBS")"
|
||||
printf "DMENU_CFLAGS='%s'\n" "$(escape_sh "$DMENU_CFLAGS")"
|
||||
printf "DMENU_LIBS='%s'\n" "$(escape_sh "$DMENU_LIBS")"
|
||||
printf "ST_CFLAGS='%s'\n" "$(escape_sh "$ST_CFLAGS")"
|
||||
printf "ST_LIBS='%s'\n" "$(escape_sh "$ST_LIBS")"
|
||||
printf "GEMUI_CFLAGS='%s'\n" "$(escape_sh "$GEMUI_CFLAGS")"
|
||||
printf "GEMUI_LIBS='%s'\n" "$(escape_sh "$GEMUI_LIBS")"
|
||||
printf "APP_CFLAGS='%s'\n" "$(escape_sh "$APP_CFLAGS")"
|
||||
printf "APP_LIBS='%s'\n" "$(escape_sh "$APP_LIBS")"
|
||||
printf "TOUCHD_CFLAGS='%s'\n" "$(escape_sh "$TOUCHD_CFLAGS")"
|
||||
printf "TOUCHD_LIBS='%s'\n" "$(escape_sh "$TOUCHD_LIBS")"
|
||||
printf "STATUSD_CFLAGS='%s'\n" "$(escape_sh "$STATUSD_CFLAGS")"
|
||||
printf "STATUSD_LIBS='%s'\n" "$(escape_sh "$STATUSD_LIBS")"
|
||||
printf "POWERD_CFLAGS='%s'\n" "$(escape_sh "$POWERD_CFLAGS")"
|
||||
printf "POWERD_LIBS='%s'\n" "$(escape_sh "$POWERD_LIBS")"
|
||||
printf "CHECKPW_DEFS='%s'\n" "$(escape_sh "$CHECKPW_DEFS")"
|
||||
printf "CHECKPW_LIBS='%s'\n" "$(escape_sh "$CHECKPW_LIBS")"
|
||||
printf "GTKTTK_AVAILABLE='%s'\n" "$(escape_sh "$GTKTTK_AVAILABLE")"
|
||||
printf "GTKTTK_REASON='%s'\n" "$(escape_sh "$GTKTTK_REASON")"
|
||||
printf "GTKTTK_CXXFLAGS='%s'\n" "$(escape_sh "$GTKTTK_CXXFLAGS")"
|
||||
printf "GTKTTK_LDFLAGS='%s'\n" "$(escape_sh "$GTKTTK_LDFLAGS")"
|
||||
} > "$TMP_OUT"
|
||||
mv -f "$TMP_OUT" "$OUT_FILE"
|
||||
Reference in new issue
Block a user