Modernize configure.ac

This commit is contained in:
Andrea Mazzoleni 2026-08-12 00:33:14 +02:00
parent c66ea18715
commit e44fb81da2
4 changed files with 46 additions and 64 deletions

View file

@ -125,7 +125,6 @@ noinst_HEADERS = \
os/os.h \ os/os.h \
os/mingw.h \ os/mingw.h \
os/unix.h \ os/unix.h \
os/os.h \
os/portable.h os/portable.h
mktest_SOURCES = \ mktest_SOURCES = \
@ -173,7 +172,7 @@ LIST_TXT = doc/snapraid.txt doc/snapraid_log.txt $(patsubst %, doc/snapraid-%.tx
LIST_XML = doc/snapraid.xml doc/snapraid_log.xml $(patsubst %, doc/snapraid-%.xml, $(LANG_CODES)) LIST_XML = doc/snapraid.xml doc/snapraid_log.xml $(patsubst %, doc/snapraid-%.xml, $(LANG_CODES))
EXTRA_DIST = \ EXTRA_DIST = \
autogen.sh autover.sh \ autogen.sh autover.sh valgrind.supp \
README AUTHORS HISTORY INSTALL BLUEBOX TODO CHECK INSTALL.windows \ README AUTHORS HISTORY INSTALL BLUEBOX TODO CHECK INSTALL.windows \
COPYING LICENSES/GPL-2.0 LICENSES/GPL-3.0 LICENSES/BSD-2-Clause \ COPYING LICENSES/GPL-2.0 LICENSES/GPL-3.0 LICENSES/BSD-2-Clause \
$(LIST_D) \ $(LIST_D) \
@ -1289,16 +1288,16 @@ lcov_html:
# Rules for documentation # Rules for documentation
if HAVE_ADVD2 if HAVE_ADVD2
%.1 : %.d %.1 : %.d
advd2 man < $(srcdir)/$< > $@ advd2 man < $< > $@
%.txt : %.d %.txt : %.d
advd2 txt < $(srcdir)/$< | todos > $@ advd2 txt < $< | todos > $@
%.html : %.d %.html : %.d
advd2 html < $(srcdir)/$< > $@ advd2 html < $< > $@
%.xml : %.d %.xml : %.d
advd2 xml < $(srcdir)/$< > $@ advd2 xml < $< > $@
endif endif
# Web distribution # Web distribution
@ -1319,13 +1318,13 @@ distwindows-x86: $(DISTWIN)
rm -f $(PACKAGE)-$(VERSION)-windows-x86.zip rm -f $(PACKAGE)-$(VERSION)-windows-x86.zip
mkdir tmp mkdir tmp
cp $(DISTWIN) tmp cp $(DISTWIN) tmp
cp support/smartctl.exe tmp/smartctl.exe cp $(srcdir)/support/smartctl.exe tmp/smartctl.exe
todos < snapraid.conf.example.windows > tmp/snapraid.conf.example todos < $(srcdir)/snapraid.conf.example.windows > tmp/snapraid.conf.example
todos < README > tmp/readme.txt todos < $(srcdir)/README > tmp/readme.txt
todos < AUTHORS > tmp/authors.txt todos < $(srcdir)/AUTHORS > tmp/authors.txt
todos < HISTORY > tmp/history.txt todos < $(srcdir)/HISTORY > tmp/history.txt
todos < BLUEBOX > tmp/bluebox.txt todos < $(srcdir)/BLUEBOX > tmp/bluebox.txt
todos < LICENSES/GPL-3.0 > tmp/copying.txt todos < $(srcdir)/LICENSES/GPL-3.0 > tmp/copying.txt
cd tmp && zip -r ../$(PACKAGE)-$(VERSION)-windows-x86.zip * cd tmp && zip -r ../$(PACKAGE)-$(VERSION)-windows-x86.zip *
rm -r tmp rm -r tmp
@ -1333,12 +1332,12 @@ distwindows-x64: $(DISTWIN)
rm -f $(PACKAGE)-$(VERSION)-windows-x64.zip rm -f $(PACKAGE)-$(VERSION)-windows-x64.zip
mkdir tmp mkdir tmp
cp $(DISTWIN) tmp cp $(DISTWIN) tmp
cp support/smartctl.exe tmp/smartctl.exe cp $(srcdir)/support/smartctl.exe tmp/smartctl.exe
todos < snapraid.conf.example.windows > tmp/snapraid.conf.example todos < $(srcdir)/snapraid.conf.example.windows > tmp/snapraid.conf.example
todos < README > tmp/readme.txt todos < $(srcdir)/README > tmp/readme.txt
todos < AUTHORS > tmp/authors.txt todos < $(srcdir)/AUTHORS > tmp/authors.txt
todos < HISTORY > tmp/history.txt todos < $(srcdir)/HISTORY > tmp/history.txt
todos < BLUEBOX > tmp/bluebox.txt todos < $(srcdir)/BLUEBOX > tmp/bluebox.txt
todos < LICENSES/GPL-3.0 > tmp/copying.txt todos < $(srcdir)/LICENSES/GPL-3.0 > tmp/copying.txt
cd tmp && zip -r ../$(PACKAGE)-$(VERSION)-windows-x64.zip * cd tmp && zip -r ../$(PACKAGE)-$(VERSION)-windows-x64.zip *
rm -r tmp rm -r tmp

View file

@ -1,19 +1,21 @@
#!/bin/sh #!/bin/sh
# #
if [ -f .version ]; then SRCDIR="${srcdir:-$(dirname "$0")}"
if [ -f "$SRCDIR/.version" ]; then
# Get version from the .version file # Get version from the .version file
VERSION=$(cat .version) VERSION=$(cat "$SRCDIR/.version")
fi fi
if [ -z "$VERSION" ] && [ -d .git ]; then if [ -z "$VERSION" ] && [ -e "$SRCDIR/.git" ]; then
# Get version from git tags, removing the 'v' prefix # Get version from git tags, removing the 'v' prefix
VERSION=$(git describe --match 'v*' 2>/dev/null | sed 's/^v//') VERSION=$(git -C "$SRCDIR" describe --match 'v*' 2>/dev/null | sed 's/^v//')
fi fi
if [ -z "$VERSION" ] && [ -d .git ]; then if [ -z "$VERSION" ] && [ -e "$SRCDIR/.git" ]; then
# Fall back to short commit hash # Fall back to short commit hash
VERSION=0-$(git rev-parse --short HEAD 2>/dev/null) VERSION=0-$(git -C "$SRCDIR" rev-parse --short HEAD 2>/dev/null)
fi fi
if [ -z "$VERSION" ]; then if [ -z "$VERSION" ]; then

View file

@ -1,8 +1,8 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65]) AC_PREREQ([2.70])
dnl Get version number from git dnl Get version number from git
m4_define([git_revision], m4_esyscmd_s([./autover.sh])) m4_define([git_revision], m4_esyscmd_s([./autover.sh]))
AC_INIT([SnapRAID CLI], [git_revision], [], [snapraid], [https://www.snapraid.it]) AC_INIT([SnapRAID CLI],[git_revision],[],[snapraid],[https://www.snapraid.it])
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_CANONICAL_BUILD AC_CANONICAL_BUILD
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
@ -57,7 +57,7 @@ AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer], CFLAGS="$CFLAGS -fno-omit-frame
# AX_CHECK_COMPILE_FLAG([-fno-inline-small-functions], CFLAGS="$CFLAGS -fno-inline-small-functions", []) # AX_CHECK_COMPILE_FLAG([-fno-inline-small-functions], CFLAGS="$CFLAGS -fno-inline-small-functions", [])
# AX_CHECK_COMPILE_FLAG([-fno-optimize-sibling-calls], CFLAGS="$CFLAGS -fno-optimize-sibling-calls", []) # AX_CHECK_COMPILE_FLAG([-fno-optimize-sibling-calls], CFLAGS="$CFLAGS -fno-optimize-sibling-calls", [])
AX_CHECK_COMPILE_FLAG([-rdynamic], CFLAGS="$CFLAGS -rdynamic", []) AX_CHECK_COMPILE_FLAG([-rdynamic], CFLAGS="$CFLAGS -rdynamic", [])
# This the new default for gcc 10 # This is the new default for gcc 10
AX_CHECK_COMPILE_FLAG([-fno-common], CFLAGS="$CFLAGS -fno-common", []) AX_CHECK_COMPILE_FLAG([-fno-common], CFLAGS="$CFLAGS -fno-common", [])
dnl Checks for system. dnl Checks for system.
@ -68,9 +68,8 @@ AC_C_BIGENDIAN
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_ASSERT AC_HEADER_ASSERT
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([stdint.h inttypes.h unistd.h math.h execinfo.h strings.h getopt.h syslog.h grp.h pwd.h io.h alloca.h]) AC_CHECK_HEADERS([dirent.h stdint.h inttypes.h unistd.h math.h execinfo.h strings.h getopt.h syslog.h grp.h pwd.h io.h alloca.h])
AC_CHECK_HEADERS([sys/file.h sys/sysctl.h sys/ioctl.h sys/time.h sys/types.h sys/mkdev.h sys/sysmacros.h sys/stat.h sys/prctl.h sys/sysinfo.h sys/utsname.h]) AC_CHECK_HEADERS([sys/file.h sys/sysctl.h sys/ioctl.h sys/time.h sys/types.h sys/mkdev.h sys/sysmacros.h sys/stat.h sys/prctl.h sys/sysinfo.h sys/utsname.h])
AC_CHECK_HEADERS([linux/fs.h linux/btrfs.h linux/fiemap.h mach/mach_time.h]) AC_CHECK_HEADERS([linux/fs.h linux/btrfs.h linux/fiemap.h mach/mach_time.h])
@ -95,13 +94,11 @@ AC_COMPILE_IFELSE([
]) ])
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE AC_C_INLINE
AC_C_RESTRICT AC_C_RESTRICT
AC_C_VOLATILE AC_C_VOLATILE
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_TYPE_OFF_T AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T AC_TYPE_SSIZE_T
AC_TYPE_UINT32_T AC_TYPE_UINT32_T
AC_TYPE_UINT64_T AC_TYPE_UINT64_T
@ -183,7 +180,6 @@ AC_CHECK_MEMBERS([struct statfs.f_fstypename], [], [], [[
]]) ]])
dnl Checks for libraries dnl Checks for libraries
have_pthreads=no
AS_IF([test "x$is_windows" = "xyes"], [ AS_IF([test "x$is_windows" = "xyes"], [
AC_MSG_NOTICE([Windows native threads support enabled]) AC_MSG_NOTICE([Windows native threads support enabled])
], [ ], [
@ -198,18 +194,16 @@ AS_IF([test "x$is_windows" = "xyes"], [
AC_MSG_WARN([Single-threaded version]) AC_MSG_WARN([Single-threaded version])
]) ])
]) ])
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$have_pthreads" = "xyes"])
dnl Checks for compiler dnl Checks for compiler
AC_CHECK_CC_OPT([-Wall], CFLAGS="$CFLAGS -Wall", []) AX_CHECK_COMPILE_FLAG([-Wall], CFLAGS="$CFLAGS -Wall", [])
AC_CHECK_CC_OPT([-Wextra], CFLAGS="$CFLAGS -Wextra", []) AX_CHECK_COMPILE_FLAG([-Wextra], CFLAGS="$CFLAGS -Wextra", [])
AC_CHECK_CC_OPT([-Wuninitialized], CFLAGS="$CFLAGS -Wuninitialized", []) AX_CHECK_COMPILE_FLAG([-Wuninitialized], CFLAGS="$CFLAGS -Wuninitialized", [])
AC_CHECK_CC_OPT([-Wshadow], CFLAGS="$CFLAGS -Wshadow", []) AX_CHECK_COMPILE_FLAG([-Wshadow], CFLAGS="$CFLAGS -Wshadow", [])
AC_CHECK_CC_OPT([-Wshorten-64-to-32], CFLAGS="$CFLAGS -Wshorten-64-to-32", []) AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], CFLAGS="$CFLAGS -Wshorten-64-to-32", [])
dnl Disable warning about zero-length-bounds raised by gcc 10 on linux kernel header on the fm_extents field dnl Disable warning about zero-length-bounds raised by gcc 10 on linux kernel header on the fm_extents field
AC_CHECK_CC_OPT([-Wno-zero-length-bounds], CFLAGS="$CFLAGS -Wno-zero-length-bounds", []) AX_CHECK_COMPILE_FLAG([-Wno-zero-length-bounds], CFLAGS="$CFLAGS -Wno-zero-length-bounds", [])
dnl Checks for asm dnl Checks for asm
AC_ARG_ENABLE([asm], AC_ARG_ENABLE([asm],
@ -345,29 +339,29 @@ AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[enable debugging])], [AS_HELP_STRING([--enable-debug],[enable debugging])],
[ [
CFLAGS="-Og -g -pthread -Wall -Wextra" CFLAGS="-Og -g -pthread -Wall -Wextra"
AC_CHECK_CC_OPT([-rdynamic], CFLAGS="$CFLAGS -rdynamic", []) AX_CHECK_COMPILE_FLAG([-rdynamic], CFLAGS="$CFLAGS -rdynamic", [])
], ],
[]) [])
AC_ARG_ENABLE([warning-as-error], AC_ARG_ENABLE([warning-as-error],
[AS_HELP_STRING([--enable-warning-as-error],[stop build on warnings])], [AS_HELP_STRING([--enable-warning-as-error],[stop build on warnings])],
[ [
AC_CHECK_CC_OPT([-Werror], CFLAGS="$CFLAGS -Werror", []) AX_CHECK_COMPILE_FLAG([-Werror], CFLAGS="$CFLAGS -Werror", [])
dnl This avoid the Darwin error: clang: error: argument unused during compilation: '-pthread' dnl This avoid the Darwin error: clang: error: argument unused during compilation: '-pthread'
dnl See: https://llvm.org/bugs/show_bug.cgi?id=7798 dnl See: https://llvm.org/bugs/show_bug.cgi?id=7798
AC_CHECK_CC_OPT([-Wno-error=unused-command-line-argument], CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument", []) AX_CHECK_COMPILE_FLAG([-Wno-error=unused-command-line-argument], CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument", [])
], ],
[]) [])
AC_ARG_ENABLE([warning], AC_ARG_ENABLE([warning],
[AS_HELP_STRING([--enable-warning],[enable extra warning])], [AS_HELP_STRING([--enable-warning],[enable extra warning])],
[ [
AC_CHECK_CC_OPT([-Wpointer-arith], CFLAGS="$CFLAGS -Wpointer-arith", []) AX_CHECK_COMPILE_FLAG([-Wpointer-arith], CFLAGS="$CFLAGS -Wpointer-arith", [])
AC_CHECK_CC_OPT([-Wcast-qual], CFLAGS="$CFLAGS -Wcast-qual", []) AX_CHECK_COMPILE_FLAG([-Wcast-qual], CFLAGS="$CFLAGS -Wcast-qual", [])
AC_CHECK_CC_OPT([-Wunused], CFLAGS="$CFLAGS -Wunused", []) AX_CHECK_COMPILE_FLAG([-Wunused], CFLAGS="$CFLAGS -Wunused", [])
AC_CHECK_CC_OPT([-Wunreachable-code], CFLAGS="$CFLAGS -Wunreachable-code", []) AX_CHECK_COMPILE_FLAG([-Wunreachable-code], CFLAGS="$CFLAGS -Wunreachable-code", [])
AC_CHECK_CC_OPT([-Wpadded], CFLAGS="$CFLAGS -Wpadded", []) AX_CHECK_COMPILE_FLAG([-Wpadded], CFLAGS="$CFLAGS -Wpadded", [])
AC_CHECK_CC_OPT([-Weverything], CFLAGS="$CFLAGS -Weverything", []) AX_CHECK_COMPILE_FLAG([-Weverything], CFLAGS="$CFLAGS -Weverything", [])
], ],
[]) [])

View file

@ -180,19 +180,6 @@
#if HAVE_DIRENT_H #if HAVE_DIRENT_H
#include <dirent.h> #include <dirent.h>
#define NAMLEN(dirent) strlen((dirent)->d_name)
#else
#define dirent direct
#define NAMLEN(dirent) (dirent)->d_namlen
#if HAVE_SYS_NDIR_H
#include <sys/ndir.h>
#endif
#if HAVE_SYS_DIR_H
#include <sys/dir.h>
#endif
#if HAVE_NDIR_H
#include <ndir.h>
#endif
#endif #endif
#if HAVE_SYS_TYPES_H #if HAVE_SYS_TYPES_H