commit: 196ad8682a5e698046749921ac5ec284027911dd
parent ff45ded2c2f737f9d7873f5a92cd154b0758d65c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 9 Jan 2026 06:51:29 +0100
Makefile: add xcd-rgb and install-rgb targets
Diffstat:
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,4 +1,5 @@
-# SPDX-FileCopyrightText: 2025 Haelwenn (lanodan) Monnier <contact+cmd-xcd@hacktivis.me>
+# SPDX-FileCopyrightText: 2025 Haelwenn (lanodan) Monnier <contact+xcd-rgb@hacktivis.me>
# SPDX-License-Identifier: MPL-2.0
-/xcd
-\ No newline at end of file
+/xcd
+/xcd-rgb
diff --git a/Makefile b/Makefile
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2025 Haelwenn (lanodan) Monnier <contact+cmd-xcd@hacktivis.me>
+# SPDX-FileCopyrightText: 2025 Haelwenn (lanodan) Monnier <contact+xcd-rgb@hacktivis.me>
# SPDX-License-Identifier: MPL-2.0
PREFIX ?= /usr/local
@@ -11,8 +11,11 @@ CFLAGS ?= -O2 -g -Wall -Wextra
xcd: xcd.c
${CC} -std=c99 ${CFLAGS} -o xcd xcd.c ${LDFLAGS} ${LDSTATIC}
+xcd-rgb: xcd.c
+ ${CC} -std=c99 ${CFLAGS} -DARG0_XCD_RGB -o xcd-rgb xcd.c ${LDFLAGS} ${LDSTATIC}
+
clean:
- rm -f xcd
+ rm -f xcd-rgb xcd
.PHONY: format
format:
@@ -24,3 +27,10 @@ install: xcd
cp -p ./xcd ${DESTDIR}${BINDIR}/xcd
mkdir -p ${DESTDIR}${MAN1DIR}/
cp -p ./xcd.1 ${DESTDIR}${MAN1DIR}/xcd.1
+
+.PHONY: install-rgb
+install-rgb: xcd-rgb
+ mkdir -p ${DESTDIR}${BINDIR}/
+ cp -p ./xcd-rgb ${DESTDIR}${BINDIR}/rgb-xcd
+ mkdir -p ${DESTDIR}${MAN1DIR}/
+ sed -e 's,Nm xcd,Nm xcd-rgb,' -e 's,Dt XCD,Dt XCD-RGB,' > ${DESTDIR}${MAN1DIR}/rgb-xcd.1
diff --git a/xcd.c b/xcd.c
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+cmd-xcd@hacktivis.me>
+// SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+xcd-rgb@hacktivis.me>
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
@@ -14,6 +14,12 @@
#define 3.14159265358979323846
#endif
+#ifndef ARG0_XCD_RGB
+const char *argv0 = "xcd-rgb";
+#else
+const char *argv0 = "xcd";
+#endif
+
struct rgb
{
int r, g, b;
@@ -134,7 +140,7 @@ concat(FILE *stream)
return 0;
werr:
- fprintf(stderr, "\n\033[0mxcd: error: Failed writing to stdout: %s\n", strerror(errno));
+ fprintf(stderr, "\n\033[0m%s: error: Failed writing to stdout: %s\n", argv0, strerror(errno));
return 1;
}
@@ -168,7 +174,8 @@ main(int argc, char *argv[])
if(!file)
{
fprintf(stderr,
- "\n\033[0mxcd: error: Failed opening file ‘%s’: %s\n",
+ "\n\033[0m%s: error: Failed opening file ‘%s’: %s\n",
+ argv0,
argv[argi],
strerror(errno));
err = 1;
@@ -180,7 +187,8 @@ main(int argc, char *argv[])
if(fclose(file) != 0)
{
fprintf(stderr,
- "\n\033[0mxcd: error: Failed closing file ‘%s’: %s\n",
+ "\n\033[0m%s: error: Failed closing file ‘%s’: %s\n",
+ argv0,
argv[argi],
strerror(errno));
err = 1;