diff --git a/Makefile b/Makefile index 3c96d38..5d97dd2 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ RAY_OBJ := $(patsubst %,$(OBJDIR)/raylib/%.o,$(RAY_MODULES)) DEPS := $(APP_OBJ:.o=.d) $(RAY_OBJ:.o=.d) # ---- top-level targets -------------------------------------------------- -.PHONY: all run test bench clean help +.PHONY: all run test bench check-deps clean help .DEFAULT_GOAL := all all: $(TARGET) @@ -102,8 +102,34 @@ clean: rm -rf $(OBJDIR) $(TARGET) $(RAYLIB) $(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 \n#include \n'\ +'#include \n#include \n'\ +'#include \n#include \n#include \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: - @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 "Vars: CC, AR, ARCH (e.g. ARCH=-march=native)" diff --git a/README.md b/README.md index a9ef0e5..dfdfc87 100644 --- a/README.md +++ b/README.md @@ -61,37 +61,67 @@ format. ## Building -The build is driven by a checked-in Makefile. `premake5` is **not** required to -build — only to regenerate the makefiles. +You need only **`make` and a C compiler** (`gcc` or `clang`) plus the X11/OpenGL +**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 -make -f rspektrum.make config=debug_x64 # -> bin/Debug/rspektrum -make -f rspektrum.make config=release_x64 # -> bin/Release/rspektrum +make # release -> bin/Release/rspektrum (-O3 -ffast-math, AVX2/FMA) +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 -./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) ```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, or pressing **O** for the file browser. Try the bundled sample: ```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 diff --git a/build_web.sh b/build_web.sh index a7271db..5867c15 100755 --- a/build_web.sh +++ b/build_web.sh @@ -50,12 +50,21 @@ fi # Compile the application modules (web version — no subprocess support). # 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 ===" 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" if [ "$BUILD_TYPE" = "debug" ]; then