diff --git a/.gitignore b/.gitignore index b46a1ca2..ad990c37 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,8 @@ install-sh missing stamp-h1 .dirstamp +linux/ +windows/ # objects snapraid diff --git a/AGENTS.md b/AGENTS.md index 6e03126a..fa018762 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -80,12 +80,16 @@ SnapRAID is designed to recover from an interruption, including `SIGKILL`, at an - `Makefile.am`: Source file lists, dependencies, install hooks (including rules for generating documentation) - `uncrustify.cfg`: Code formatting rules for main application source files - `linux.cfg`: Code formatting rules for `raid/` directory and its subdirectories -- Run `make doc` to regenerate all manual pages (`*.1`) and text manuals (`*.txt`) +- Run `(cd linux && make doc)` to regenerate all manual pages (`*.1`) and text manuals (`*.txt`) - Always use parallel compilation with `make -j$(nproc)` instead of plain `make` - Create temporary files and directories under `/tmp/snapraid/`. -- To cross-compile for Windows x64: build out-of-tree in `/tmp/snapraid/` so the Linux configuration is preserved: - `mkdir -p /tmp/snapraid/windows && (cd /tmp/snapraid/windows && /path/to/configure.windows-x64 && make -j$(nproc))` - Subsequent Windows rebuilds only require: `(cd /tmp/snapraid/windows && make -j$(nproc))` +- Both Linux and Windows builds are out-of-tree in dedicated subdirectories (`linux/` and `windows/`) in the project directory, keeping the root directory clean: + - Linux build: + `mkdir -p linux && (cd linux && ../configure && make -j$(nproc))` + Subsequent Linux rebuilds: `(cd linux && make -j$(nproc))` + - Windows x64 cross-compilation: + `mkdir -p windows && (cd windows && ../configure.windows-x64 && make -j$(nproc))` + Subsequent Windows rebuilds: `(cd windows && make -j$(nproc))` - The Windows build needs to be tested only when modifying Windows-specific code (e.g., `os/mingw.*`, `cmdline/mingwapp.c`, or Windows-specific `#ifdef` paths) ## Code Style Guidelines @@ -137,8 +141,8 @@ SnapRAID is designed to recover from an interruption, including `SIGKILL`, at an #### Testing Changes - Never run `make check` because it's too expansive -- Run `./snapraid test` for the regression test -- The `test` and `selftest` suites (in `cmdline/selftest.c` and `./snapraid test`) must be strictly memory-only without creating files or performing filesystem I/O -- If running the speed benchmark (`./snapraid -T`), always use `--speed-test-period 100` (e.g. `./snapraid -T --speed-test-period 100`) to run it faster +- Run `./linux/snapraid test` for the regression test +- The `test` and `selftest` suites (in `cmdline/selftest.c` and `./linux/snapraid test`) must be strictly memory-only without creating files or performing filesystem I/O +- If running the speed benchmark (`./linux/snapraid -T`), always use `--speed-test-period 100` (e.g. `./linux/snapraid -T --speed-test-period 100`) to run it faster - The Windows build needs to be tested only when modifying Windows-specific code - Verify error paths and recovery scenarios (the test suite covers aborted sync, UUID changes, disk failures) diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 00000000..e84f6b87 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,18 @@ +# If Makefile exists (generated by ./configure in this directory), delegate +# directly to it so that in-tree builds work normally as if this file were absent. +# Otherwise, redirect all targets to linux/Makefile for out-of-tree builds. +# Named GNUmakefile so it takes precedence in GNU Make without conflicting with +# Makefile on case-insensitive filesystems (Windows/macOS). +ifeq ($(wildcard Makefile),Makefile) +include Makefile +else ifeq ($(wildcard linux/Makefile),linux/Makefile) +all doc: + $(MAKE) -C linux $@ + +.DEFAULT: + $(MAKE) -C linux $@ + +.PHONY: all doc +else +$(error SnapRAID is not configured. Run './configure') +endif diff --git a/configure.analyzer b/configure.analyzer index 68cb0dc5..97f53575 100755 --- a/configure.analyzer +++ b/configure.analyzer @@ -1 +1,3 @@ -./configure CC=/usr/libexec/ccc-analyzer +DIR=$(dirname "$0") +"$DIR/configure" CC=/usr/libexec/ccc-analyzer + diff --git a/configure.windows-x64 b/configure.windows-x64 index 3e413824..ba330db5 100755 --- a/configure.windows-x64 +++ b/configure.windows-x64 @@ -1,35 +1,2 @@ -#!/bin/bash - -# Identify the original source directory DIR=$(dirname "$0") -# Resolve the absolute path of the source directory to prevent path ambiguity -SRC_DIR=$(cd "$DIR" && pwd) - -# List of critical Autotools files to hide temporarily -FILES_TO_HIDE=("config.status" "Makefile" "config.log") -HIDDEN_FILES=() - -# Function to restore original files when the script finishes or exits -restore_files() { - for file in "${HIDDEN_FILES[@]}"; do - if [ -f "$SRC_DIR/${file}.bak" ]; then - mv "$SRC_DIR/${file}.bak" "$SRC_DIR/$file" - fi - done -} - -# Ensure files are restored under any exit condition (success, error, or interruption like Ctrl+C) -trap restore_files EXIT INT TERM - -# 1. Mask the files in the original source directory -for file in "${FILES_TO_HIDE[@]}"; do - if [ -f "$SRC_DIR/$file" ]; then - mv "$SRC_DIR/$file" "$SRC_DIR/${file}.bak" - HIDDEN_FILES+=("$file") # Keep track of files that were actually renamed - fi -done - -# 2. Run the original configure command -"$SRC_DIR/configure" --host=x86_64-w64-mingw32.static --build=$("$SRC_DIR/config.guess") "$@" - -# Note: The 'restore_files' function will automatically trigger here via the trap hook. +"$DIR/configure" --host=x86_64-w64-mingw32.static --build=$("$DIR/config.guess") "$@" diff --git a/makedist.sh b/makedist.sh index e54d7c2d..b10f9a2e 100755 --- a/makedist.sh +++ b/makedist.sh @@ -47,3 +47,6 @@ sudo sh makeslackware.sh sudo sh makearch.sh sudo sh makedeb.sh sudo sh makerpm.sh + +make distclean +