build: document system deps, add check-deps, auto-glob web modules
- README: rewrite Build section for the hand-written Makefile (make / make DEBUG=1 / run / test / bench). Add a "System dependencies" table with the X11+GL dev packages per distro (apt/dnf/pacman/zypper/apk), since a clone won't build without them and the error is otherwise cryptic. Fix stale ./bin/Debug paths to ./bin/Release. - Makefile: add `make check-deps` — probes for the required X11/GL dev headers and prints the install command for the detected distro on failure (via /etc/os-release). - build_web.sh: auto-discover app modules from src/*.c (drop the hardcoded APP_MODULES list that had to be hand-synced), matching the desktop Makefile. Excludes the desktop platform backends. Remove the stale rspektrum.make reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,7 @@ RAY_OBJ := $(patsubst %,$(OBJDIR)/raylib/%.o,$(RAY_MODULES))
|
|||||||
DEPS := $(APP_OBJ:.o=.d) $(RAY_OBJ:.o=.d)
|
DEPS := $(APP_OBJ:.o=.d) $(RAY_OBJ:.o=.d)
|
||||||
|
|
||||||
# ---- top-level targets --------------------------------------------------
|
# ---- top-level targets --------------------------------------------------
|
||||||
.PHONY: all run test bench clean help
|
.PHONY: all run test bench check-deps clean help
|
||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
@@ -102,8 +102,34 @@ clean:
|
|||||||
rm -rf $(OBJDIR) $(TARGET) $(RAYLIB)
|
rm -rf $(OBJDIR) $(TARGET) $(RAYLIB)
|
||||||
$(MAKE) -C bench clean
|
$(MAKE) -C bench clean
|
||||||
|
|
||||||
|
# Preflight: probe for the X11/GL dev headers the build needs and, if any are
|
||||||
|
# missing, print the install command for the detected distribution. Headers are
|
||||||
|
# required even though the X11 extension libs are dlopen'd at runtime.
|
||||||
|
check-deps:
|
||||||
|
@printf '#include <X11/Xlib.h>\n#include <X11/extensions/Xrandr.h>\n'\
|
||||||
|
'#include <X11/extensions/Xinerama.h>\n#include <X11/Xcursor/Xcursor.h>\n'\
|
||||||
|
'#include <X11/extensions/XInput2.h>\n#include <GL/gl.h>\n#include <GL/glx.h>\n'\
|
||||||
|
'int main(void){return 0;}\n' > .depcheck.c
|
||||||
|
@if $(CC) -fsyntax-only .depcheck.c >/dev/null 2>&1; then \
|
||||||
|
echo "check-deps: all required X11/GL dev headers found."; \
|
||||||
|
rm -f .depcheck.c; \
|
||||||
|
else \
|
||||||
|
rm -f .depcheck.c; \
|
||||||
|
echo "check-deps: MISSING X11/GL development headers. Install them:"; \
|
||||||
|
. /etc/os-release 2>/dev/null; \
|
||||||
|
case "$$ID $$ID_LIKE" in \
|
||||||
|
*debian*|*ubuntu*) echo " sudo apt install build-essential xorg-dev libgl1-mesa-dev" ;; \
|
||||||
|
*fedora*|*rhel*|*centos*) echo " sudo dnf install gcc make libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel mesa-libGL-devel" ;; \
|
||||||
|
*arch*|*manjaro*) echo " sudo pacman -S base-devel libx11 libxrandr libxinerama libxcursor libxi mesa" ;; \
|
||||||
|
*suse*) echo " sudo zypper install gcc make libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel Mesa-libGL-devel" ;; \
|
||||||
|
*alpine*) echo " sudo apk add build-base libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-dev" ;; \
|
||||||
|
*) echo " Install X11 + OpenGL dev headers for your distro (Xlib, Xrandr, Xinerama, Xcursor, Xi, GL/GLX). See README."; \
|
||||||
|
esac; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Targets: all (default), run, test, bench, clean"
|
@echo "Targets: all (default), run, test, bench, check-deps, clean"
|
||||||
@echo "Configs: release (default), or 'make DEBUG=1'"
|
@echo "Configs: release (default), or 'make DEBUG=1'"
|
||||||
@echo "Vars: CC, AR, ARCH (e.g. ARCH=-march=native)"
|
@echo "Vars: CC, AR, ARCH (e.g. ARCH=-march=native)"
|
||||||
|
|
||||||
|
|||||||
@@ -61,37 +61,67 @@ format.
|
|||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
The build is driven by a checked-in Makefile. `premake5` is **not** required to
|
You need only **`make` and a C compiler** (`gcc` or `clang`) plus the X11/OpenGL
|
||||||
build — only to regenerate the makefiles.
|
**development** headers (see below). raylib is vendored in this repo and compiled
|
||||||
|
from source — there is no separate raylib install step, no `premake`, no network
|
||||||
|
access required. A plain clone builds:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make -f rspektrum.make config=debug_x64 # -> bin/Debug/rspektrum
|
make # release -> bin/Release/rspektrum (-O3 -ffast-math, AVX2/FMA)
|
||||||
make -f rspektrum.make config=release_x64 # -> bin/Release/rspektrum
|
make DEBUG=1 # debug -> bin/Debug/rspektrum (-g, no optimization)
|
||||||
|
make run # build + launch
|
||||||
|
make test # build + run the DSP correctness tests
|
||||||
|
make bench # FFT benchmark over mlnl_samples.wav
|
||||||
|
make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
Web (WebAssembly) build:
|
Useful overrides: `make CC=clang`, or `make ARCH=-march=native` to tune for your
|
||||||
|
own CPU (the default `-march=x86-64-v3` targets any ~2013+ x86-64 chip; drop it
|
||||||
|
with `make ARCH=` for an older CPU).
|
||||||
|
|
||||||
|
### System dependencies
|
||||||
|
|
||||||
|
The compiler needs the X11 and OpenGL **dev** headers (the runtime libs are
|
||||||
|
already present on any desktop; only the `-dev`/`-devel` packages are usually
|
||||||
|
missing). The X11 extension libraries (Xrandr, Xinerama, Xcursor, Xi) are opened
|
||||||
|
at runtime via `dlopen`, but their **headers** are still required to compile.
|
||||||
|
|
||||||
|
If `make` stops with an error like `fatal error: X11/Xlib.h: No such file` or
|
||||||
|
`GL/gl.h: No such file`, install the dev packages for your distribution:
|
||||||
|
|
||||||
|
| Distro | Command |
|
||||||
|
|--------|---------|
|
||||||
|
| **Debian / Ubuntu / Mint** | `sudo apt install build-essential libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev` |
|
||||||
|
| **Fedora / RHEL / Rocky** | `sudo dnf install gcc make libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel mesa-libGL-devel` |
|
||||||
|
| **Arch / Manjaro** | `sudo pacman -S base-devel libx11 libxrandr libxinerama libxcursor libxi mesa` |
|
||||||
|
| **openSUSE** | `sudo zypper install gcc make libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel Mesa-libGL-devel` |
|
||||||
|
| **Alpine** | `sudo apk add build-base libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-dev` |
|
||||||
|
|
||||||
|
On Debian/Ubuntu the single metapackage `xorg-dev` pulls in all of the X11 `-dev`
|
||||||
|
packages above, if you'd rather not list them.
|
||||||
|
|
||||||
|
Run `make check-deps` to probe for the required headers before building — it
|
||||||
|
prints the install hint for your platform if anything is missing.
|
||||||
|
|
||||||
|
### Web (WebAssembly) build
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./build_web.sh # emscripten; emits the WebAssembly bundle
|
./build_web.sh # emscripten; emits the WebAssembly bundle to bin/web/
|
||||||
```
|
```
|
||||||
|
|
||||||
> The release build enables `-O2`, which turns on extra warnings
|
|
||||||
> (`-Wformat-truncation`) that the debug build doesn't. Build release before
|
|
||||||
> declaring a change clean.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Usage (desktop GUI)
|
## Usage (desktop GUI)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/Debug/rspektrum [input.wav]
|
./bin/Release/rspektrum [input.wav]
|
||||||
```
|
```
|
||||||
|
|
||||||
Load a file by passing it on the command line, dragging a `.wav` onto the window,
|
Load a file by passing it on the command line, dragging a `.wav` onto the window,
|
||||||
or pressing **O** for the file browser. Try the bundled sample:
|
or pressing **O** for the file browser. Try the bundled sample:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/Debug/rspektrum mlnl_samples.wav # in-repo WAV with an embedded mLnL chunk
|
./bin/Release/rspektrum mlnl_samples.wav # in-repo WAV with an embedded mLnL chunk
|
||||||
```
|
```
|
||||||
|
|
||||||
### Controls
|
### Controls
|
||||||
|
|||||||
+12
-3
@@ -50,12 +50,21 @@ fi
|
|||||||
|
|
||||||
# Compile the application modules (web version — no subprocess support).
|
# Compile the application modules (web version — no subprocess support).
|
||||||
# platform_web.c provides stub implementations for spawn/error functions.
|
# platform_web.c provides stub implementations for spawn/error functions.
|
||||||
# Keep this list in sync with rspektrum.make (use platform_web instead of
|
#
|
||||||
# platform_linux for the web target).
|
# Auto-discovered from src/*.c (same as the desktop Makefile) so adding a module
|
||||||
|
# needs no edit here. The web target keeps platform_web.c and drops the desktop
|
||||||
|
# backends (platform_linux.c / platform_win32.c).
|
||||||
echo "=== Step 2: Compiling spectrogram modules for web ==="
|
echo "=== Step 2: Compiling spectrogram modules for web ==="
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
APP_MODULES="spectrogram fft stft audio render ui utils primitives mlnl platform_web"
|
APP_MODULES=""
|
||||||
|
for f in "$SRC_DIR"/*.c; do
|
||||||
|
m=$(basename "$f" .c)
|
||||||
|
case "$m" in
|
||||||
|
platform_linux|platform_win32) continue ;; # desktop-only backends
|
||||||
|
esac
|
||||||
|
APP_MODULES="$APP_MODULES $m"
|
||||||
|
done
|
||||||
|
|
||||||
APP_OPT="-Os"
|
APP_OPT="-Os"
|
||||||
if [ "$BUILD_TYPE" = "debug" ]; then
|
if [ "$BUILD_TYPE" = "debug" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user