Subject: [PATCH 3/5] gnu: Add cppp.

From: Maxim Cournoyer <[email-masked]>
Date: Sat, 12 Oct 2024 13:28:12 +0900

* gnu/packages/c.scm (cppp): New variable.
* gnu/packages/patches/cppp-build-fixes.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: I7dc2215f4e57aec6356afa82d5740f78a64d3bab
---
 gnu/local.mk                                |  1 +
 gnu/packages/c.scm                          | 36 ++++++++++++++++++++-
 gnu/packages/patches/cppp-build-fixes.patch | 17 ++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/cppp-build-fixes.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 05a8716063..e08ecc744c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1105,6 +1105,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/coreutils-gnulib-tests.patch		\
   %D%/packages/patches/cppcheck-disable-char-signedness-test.patch	\
   %D%/packages/patches/cppdap-add-CPPDAP_USE_EXTERNAL_GTEST_PACKAGE.patch\
+  %D%/packages/patches/cppp-build-fixes.patch			\
   %D%/packages/patches/cpulimit-with-glib-2.32.patch		\
   %D%/packages/patches/crawl-upgrade-saves.patch		\
   %D%/packages/patches/crc32c-unbundle-googletest.patch		\
diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index 7c93676f0c..01bfb7eec5 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -9,7 +9,7 @@
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <[email-masked]>
 ;;; Copyright © 2020, 2021 Marius Bakke <[email-masked]>
 ;;; Copyright © 2020 Katherine Cox-Buday <[email-masked]>
-;;; Copyright © 2020, 2022, 2023 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2020, 2022, 2023, 2024 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2020, 2021 Greg Hogan <[email-masked]>
 ;;; Copyright © 2021 David Dashyan <[email-masked]>
 ;;; Copyright © 2021 Foo Chuan Wei <[email-masked]>
@@ -140,6 +140,40 @@ (define-public c-rrb
 slicing.")
      (license license:boost1.0))))
 
+(define-public cppp
+  ;; No release; use the latest commit.
+  (let ((commit "49ccb2162329c6619ab876c6d5765d9d0ac24f61")
+        (revision "0"))
+    (package
+      (name "cppp")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://git.sr.ht/~breadbox/cppp")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0r3vin9p1ql4ddbszwsvx493h6n0knlgxzpkahdb4a4df1xpqr1s"))
+                (patches (search-patches "cppp-build-fixes.patch"))))
+      (arguments
+       (list
+        #:make-flags #~(list (string-append "prefix=" #$output)
+                             #$(string-append "CC=" (cc-for-target)))
+        #:phases #~(modify-phases %standard-phases
+                     (delete 'configure)))) ;no configure script
+      (build-system gnu-build-system)
+      (home-page "https://www.muppetlabs.com/~breadbox/software/cppp.html")
+      (synopsis "Partial preprocessor for C")
+      (description "@command{cppp} is a partial preprocessor for C/C++ code.
+It implements enough of the C preprocessor to identify the preprocessor
+statements @code{#if}, @code{#ifdef}, et al., and applies their effects for
+the identifiers that are specified on the command-line.  Preprocessor
+statements using identifiers not specified by the user are passed through
+without modification; no other part of the input is altered.")
+      (license license:gpl2+))))
+
 (define-public cproc
   (let ((commit "70fe9ef1810cc6c05bde9eb0970363c35fa7e802")
         (revision "1"))
diff --git a/gnu/packages/patches/cppp-build-fixes.patch b/gnu/packages/patches/cppp-build-fixes.patch
new file mode 100644
index 0000000000..c46be950d8
--- /dev/null
+++ b/gnu/packages/patches/cppp-build-fixes.patch
@@ -0,0 +1,17 @@
+Upstream-status: Submitted to the author via email.
+
+diff --git a/Makefile b/Makefile
+index b4f404d..cbf7cae 100644
+--- a/Makefile
++++ b/Makefile
+@@ -28,8 +28,8 @@ ppproc.o  : ppproc.c ppproc.h gen.h types.h error.h symset.h mstr.h \
+ cppp.o    : cppp.c gen.h types.h unixisms.h error.h symset.h ppproc.h
+ 
+ install:
+-	cp ./cppp $(prefix)/bin/.
+-	cp ./cppp.1 $(prefix)/share/man/man1/.
++	install -D ./cppp $(prefix)/bin/cppp
++	install -D ./cppp.1 $(prefix)/share/man/man1/cppp.1
+ 
+ test: cppp
+ 	./tests/testall
-- 
2.46.0