From ac16a358b26faacfd3966641d93562ad698ae813 Mon Sep 17 00:00:00 2001 From: Fabian Druschke Date: Sun, 8 Feb 2026 21:45:14 +0100 Subject: [PATCH] Add Meson build system --- Makefile.am | 9 ---- README.md | 70 ++++++++++---------------- autogen.sh | 8 --- configure.ac | 92 ---------------------------------- man/Makefile.am | 1 - meson.build | 130 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 10 ---- 7 files changed, 157 insertions(+), 163 deletions(-) delete mode 100644 Makefile.am delete mode 100755 autogen.sh delete mode 100644 configure.ac delete mode 100644 man/Makefile.am create mode 100644 meson.build delete mode 100644 src/Makefile.am diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 0df77f551..000000000 --- a/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -SUBDIRS = src man - -# The set of files to be formatted. -FORMATSOURCES = src/*.c src/*.h -format: - clang-format -i -style=file $(FORMATSOURCES) - -check-format: - clang-format -i -style=file $(FORMATSOURCES) && git diff --exit-code diff --git a/README.md b/README.md index a307461ae..e98d76484 100644 --- a/README.md +++ b/README.md @@ -231,9 +231,9 @@ If you are compiling `nwipe` from source on Debian/Ubuntu: sudo apt install \ build-essential \ pkg-config \ - automake \ libncurses5-dev \ - autotools-dev \ + meson \ + ninja-build \ libparted-dev \ libconfig-dev \ libconfig++-dev \ @@ -250,6 +250,8 @@ sudo bash sudo dnf update -y sudo dnf groupinstall -y "Development Tools" "C Development Tools and Libraries" sudo dnf install -y \ + meson \ + ninja-build \ ncurses-devel \ parted-devel \ libconfig-devel \ @@ -265,6 +267,8 @@ sudo dnf install -y \ ```bash sudo pacman -Syu --needed \ base-devel \ + meson \ + ninja \ ncurses \ parted \ libconfig \ @@ -279,10 +283,9 @@ sudo pacman -Syu --needed \ sudo zypper refresh sudo zypper install -y \ gcc \ - make \ - automake \ - autoconf \ - libtool \ + meson \ + ninja \ + pkg-config \ ncurses-devel \ libparted-devel \ libconfig-devel \ @@ -297,30 +300,16 @@ Note: `dmidecode`, `readlink` (from `coreutils`) and `smartmontools` are technic ### Compilation -Generate the autoconf files: - -```bash -./autogen.sh -``` - -Then configure, build and install: +Configure, build and install with Meson: ```bash -./configure -make format # only required if you intend to submit pull requests -make -sudo make install +meson setup build +meson compile -C build +meson install -C build ``` Run nwipe: -```bash -cd src -sudo ./nwipe -``` - -or simply: - ```bash sudo nwipe ``` @@ -334,10 +323,9 @@ If you intend to submit patches or pull requests, we recommend enabling full war For a debug–friendly build: ```bash -./configure --prefix=/usr CFLAGS='-O0 -g -Wall -Wextra' -make format # necessary if submitting pull requests -make -sudo make install +meson setup build --prefix=/usr -Dc_args='-O0 -g -Wall -Wextra' +meson compile -C build +meson install -C build ``` * `-O0 -g` @@ -349,7 +337,7 @@ sudo make install The code style is defined via `.clang-format`. Before submitting: ```bash -make format +meson compile -C build format ``` You will need `clang-format` installed for this step. @@ -357,9 +345,9 @@ You will need `clang-format` installed for this step. To rebuild a "release-like" binary with normal optimisations after development: ```bash -./configure --prefix=/usr -make -sudo make install +meson setup --wipe build --prefix=/usr +meson compile -C build +meson install -C build ``` --- @@ -388,9 +376,9 @@ cd "$nwipe_directory" sudo apt install -y \ build-essential \ pkg-config \ - automake \ libncurses5-dev \ - autotools-dev \ + meson \ + ninja-build \ libparted-dev \ libconfig-dev \ libconfig++-dev \ @@ -403,24 +391,22 @@ sudo apt install -y \ rm -rf nwipe git clone https://github.com/martijnvanbrummelen/nwipe.git cd nwipe -./autogen.sh -./configure -make +meson setup build +meson compile -C build -cd src -sudo ./nwipe +sudo ./build/nwipe ``` To run the latest master later on: ```bash -sudo ~/nwipe_master/nwipe/src/nwipe +sudo ~/nwipe_master/nwipe/build/nwipe ``` If you already have nwipe from your distro’s repo installed, remember: * `nwipe` → runs the packaged version in your `$PATH` -* `./nwipe` in `~/nwipe_master/nwipe/src` → runs the freshly built master +* `./nwipe` in `~/nwipe_master/nwipe/build` → runs the freshly built master --- @@ -486,5 +472,3 @@ Please include: nwipe is licensed under the **GNU General Public License v2.0**. See the `LICENSE` file for details. - - diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index da9a805c3..000000000 --- a/autogen.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Script to create all the required autoconf files - -aclocal -autoheader -automake --add-missing -autoconf diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 9d2271201..000000000 --- a/configure.ac +++ /dev/null @@ -1,92 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.63]) -AC_INIT([nwipe],[0.40],[git@brumit.nl]) -AM_INIT_AUTOMAKE(foreign subdir-objects) -AC_CONFIG_FILES([Makefile src/Makefile man/Makefile]) -AC_OUTPUT -AC_CONFIG_SRCDIR([src/nwipe.c]) -AC_CONFIG_HEADERS([config.h]) - -# Checks for programs. -AC_PROG_CC -AC_PROG_CXX -PKG_PROG_PKG_CONFIG - -# Checks for libraries. - -PKG_CHECK_MODULES( - [PANEL], - [panel], - [ - CFLAGS="${CFLAGS} ${PANEL_CFLAGS}" - LIBS="${LIBS} ${PANEL_LIBS}" - ], - [AC_CHECK_LIB([panel], [main], [ - LIBS="-lpanel $LIBS" - AC_CHECK_HEADERS(panel.h,, [ - AC_CHECK_HEADERS(ncurses/panel.h, [ - AC_DEFINE([PANEL_IN_SUBDIR], [ncurses/], [Look for ncurses headers in subdir]) - ], [AC_MSG_ERROR([ncurses panel headers not found])]) - ]) - ], [AC_MSG_ERROR([ncurses panel library not found])])] -) - -PKG_CHECK_MODULES( - [NCURSES], - [ncurses], - [ - CFLAGS="${CFLAGS} ${NCURSES_CFLAGS}" - LIBS="${LIBS} ${NCURSES_LIBS}" - ], - [AC_CHECK_LIB([ncurses], [delscreen], [ - LIBS="-lncurses $LIBS" - AC_CHECK_HEADERS(ncurses.h,, [ - AC_CHECK_HEADERS(ncurses/ncurses.h, [ - AC_DEFINE([NCURSES_IN_SUBDIR], [ncurses/], [Look for ncurses headers in subdir]) - ], [AC_MSG_ERROR([ncurses headers not found])]) - ]) - ], [AC_MSG_ERROR([ncurses development library not found])] - )] -) - -PKG_CHECK_MODULES( - [LIBCONFIG], - [libconfig], - [ - CFLAGS="${CFLAGS} ${LIBCONFIG_CFLAGS}" - LIBS="${LIBS} ${LIBCONFIG_LIBS}" - ], - [AC_CHECK_LIB([libconfig], [main], [ - LIBS="-llibconfig $LIBS" - AC_CHECK_HEADERS(libconfig.h,, [ - AC_CHECK_HEADERS(libconfig.h, [ - AC_DEFINE([LIBCONFIG_IN_SUBDIR], [libconfig/], [Look for libconfig headers in subdir]) - ], [AC_MSG_ERROR([libconfig headers not found])]) - ]) - ], [AC_MSG_ERROR([libconfig library not found])])] -) - -# Libraries needed for static linking with parted -if echo "$LDFLAGS" | grep -q "static"; then - AC_CHECK_LIB([uuid], [uuid_generate], [LIBS="-luuid $LIBS"], [AC_MSG_ERROR([libuuid is required for static linking but not found])]) - AC_CHECK_LIB([devmapper], [dm_task_create], [LIBS="-ldevmapper $LIBS"], [AC_MSG_ERROR([libdevmapper is required for static linking but not found])]) - AC_CHECK_LIB([blkid], [blkid_new_probe], [LIBS="-lblkid $LIBS"], [AC_MSG_ERROR([libblkid is required for static linking but not found])]) -fi - -PKG_CHECK_MODULES([PARTED], [libparted]) -AC_CHECK_LIB([pthread], [main], ,[AC_MSG_ERROR([pthread development library not found])]) - -# Checks for header files. -AC_CHECK_HEADERS([libconfig.h fcntl.h inttypes.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/ioctl.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_SIZE_T -AC_CHECK_MEMBERS([struct stat.st_blksize]) - -# Checks for library functions. -AC_FUNC_MALLOC -AC_CHECK_FUNCS([fdatasync memset regcomp strdup strerror]) - -AC_OUTPUT diff --git a/man/Makefile.am b/man/Makefile.am deleted file mode 100644 index 99a6ba0eb..000000000 --- a/man/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -dist_man_MANS = nwipe.8 diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..a3a40e5b0 --- /dev/null +++ b/meson.build @@ -0,0 +1,130 @@ +project('nwipe', 'c', 'cpp', version: '0.40') + +cc = meson.get_compiler('c') + +ncurses_dep = dependency('ncurses', required: true) +panel_dep = dependency('panel', required: true) +libconfig_dep = dependency('libconfig', required: true) +parted_dep = dependency('libparted', required: true) +threads_dep = dependency('threads', required: true) + +config_data = configuration_data() + +if cc.has_header('ncurses.h') + # default include path +elif cc.has_header('ncurses/ncurses.h') + config_data.set('NCURSES_IN_SUBDIR', 1) +else + error('ncurses headers not found') +endif + +if cc.has_header('panel.h') + # default include path +elif cc.has_header('ncurses/panel.h') + config_data.set('PANEL_IN_SUBDIR', 1) +else + error('panel headers not found') +endif + +configure_file( + output: 'config.h', + configuration: config_data, +) + +add_project_arguments('-DHAVE_CONFIG_H', language: ['c', 'cpp']) + +include_dirs = include_directories( + 'src', + meson.current_build_dir(), +) + +nwipe_sources = files( + 'src/aes/aes_ctr_prng.cpp', + 'src/aes/aes_ctr_prng.h', + 'src/alfg/add_lagg_fibonacci_prng.c', + 'src/alfg/add_lagg_fibonacci_prng.h', + 'src/conf.c', + 'src/conf.h', + 'src/context.h', + 'src/cpu_features.c', + 'src/cpu_features.h', + 'src/create_pdf.c', + 'src/create_pdf.h', + 'src/customers.c', + 'src/customers.h', + 'src/device.c', + 'src/device.h', + 'src/embedded_images/nwipe_exclamation.jpg.c', + 'src/embedded_images/nwipe_exclamation.jpg.h', + 'src/embedded_images/redcross.c', + 'src/embedded_images/redcross.h', + 'src/embedded_images/shred_db.jpg.c', + 'src/embedded_images/shred_db.jpg.h', + 'src/embedded_images/tick_erased.jpg.c', + 'src/embedded_images/tick_erased.jpg.h', + 'src/gui.c', + 'src/gui.h', + 'src/hddtemp_scsi/get_scsi_temp.c', + 'src/hddtemp_scsi/hddtemp.h', + 'src/hddtemp_scsi/scsi.c', + 'src/hddtemp_scsi/scsi.h', + 'src/hddtemp_scsi/scsicmds.c', + 'src/hddtemp_scsi/scsicmds.h', + 'src/hpa_dco.c', + 'src/hpa_dco.h', + 'src/isaac_rand/isaac64.c', + 'src/isaac_rand/isaac64.h', + 'src/isaac_rand/isaac_rand.c', + 'src/isaac_rand/isaac_rand.h', + 'src/isaac_rand/isaac_standard.h', + 'src/logging.c', + 'src/logging.h', + 'src/method.c', + 'src/method.h', + 'src/miscellaneous.c', + 'src/miscellaneous.h', + 'src/mt19937ar-cok/mt19937ar-cok.c', + 'src/mt19937ar-cok/mt19937ar-cok.h', + 'src/nwipe.c', + 'src/nwipe.h', + 'src/options.c', + 'src/options.h', + 'src/pass.c', + 'src/pass.h', + 'src/PDFGen/pdfgen.c', + 'src/PDFGen/pdfgen.h', + 'src/prng.c', + 'src/prng.h', + 'src/temperature.c', + 'src/temperature.h', + 'src/version.c', + 'src/version.h', + 'src/xor/xoroshiro256_prng.c', + 'src/xor/xoroshiro256_prng.h', +) + +nwipe_exe = executable( + 'nwipe', + nwipe_sources, + include_directories: include_dirs, + dependencies: [ + ncurses_dep, + panel_dep, + libconfig_dep, + parted_dep, + threads_dep, + ], + install: true, +) + +install_man('man/nwipe.8') + +run_target( + 'format', + command: ['clang-format', '-i', '-style=file', 'src/*.c', 'src/*.h'], +) + +run_target( + 'check-format', + command: ['sh', '-c', 'clang-format -i -style=file src/*.c src/*.h && git diff --exit-code'], +) diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 83d60e750..000000000 --- a/src/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -# what flags you want to pass to the C compiler & linker -#CFLAGS = -lncurses -lparted -AM_CFLAGS = -AM_LDFLAGS = - -# this lists the binaries to produce, the (non-PHONY, binary) targets in -# the previous manual Makefile -bin_PROGRAMS = nwipe -nwipe_SOURCES = context.h logging.h options.h prng.h version.h temperature.h nwipe.c gui.c method.h pass.c device.c gui.h isaac_rand/isaac_standard.h isaac_rand/isaac_rand.h isaac_rand/isaac_rand.c isaac_rand/isaac64.h isaac_rand/isaac64.c mt19937ar-cok/mt19937ar-cok.c nwipe.h mt19937ar-cok/mt19937ar-cok.h alfg/add_lagg_fibonacci_prng.h alfg/add_lagg_fibonacci_prng.c xor/xoroshiro256_prng.h xor/xoroshiro256_prng.c aes/aes_ctr_prng.h aes/aes_ctr_prng.cpp pass.h device.h logging.c method.c options.c prng.c version.c temperature.c PDFGen/pdfgen.h PDFGen/pdfgen.c create_pdf.c create_pdf.h embedded_images/shred_db.jpg.c embedded_images/shred_db.jpg.h embedded_images/tick_erased.jpg.c embedded_images/tick_erased.jpg.h embedded_images/redcross.c embedded_images/redcross.h hpa_dco.h hpa_dco.c miscellaneous.h miscellaneous.c embedded_images/nwipe_exclamation.jpg.h embedded_images/nwipe_exclamation.jpg.c conf.h conf.c customers.h customers.c hddtemp_scsi/hddtemp.h hddtemp_scsi/scsi.h hddtemp_scsi/scsicmds.h hddtemp_scsi/get_scsi_temp.c hddtemp_scsi/scsi.c hddtemp_scsi/scsicmds.c cpu_features.h cpu_features.c -nwipe_LDADD = $(PARTED_LIBS) $(LIBCONFIG)