чување 94c2f1ddf39f9ea593602eed8842b4308f408b18
родитељ ce35210ab75eb55605a1d478b71733efac64fb08
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Thu, 26 Feb 2026 14:44:14 +0100
Propagate build system changes from other projects; update copyright year
Diffstat:
измењених датотека: 15, додавања: 175(+), брисања: 59(-)
diff --git a/INSTALL b/INSTALL
@@ -1,7 +1,7 @@
Prerequisites
=============
-* C compiler - defaults in config.mk
+* C compiler - defaults in config.mk (HaikuOS needs Clang/LLVM)
Install
@@ -9,6 +9,7 @@ Install
$ git clone https://git.sr.ht/~strahinja/dtree
$ cd dtree
+ $ cp config.$(uname -s) config.mk
$ su
# make install
@@ -17,6 +18,7 @@ With got[1]:
$ got clone https://git.sr.ht/~strahinja/dtree
$ got checkout dtree.git
$ cd dtree
+ $ cp config.$(uname -s) config.mk
$ su
# make install
@@ -25,24 +27,10 @@ Persistent build configuration file
-----------------------------------
The file config.mk will be sourced when building targets which also accept
-configuration through environment variables. For example, CC and PREFIX
+configuration through environment variables. For example, CPPFLAGS and PREFIX
are specified in config.mk.
+Initially, there will be no config.mk, you will need to copy one of the
+customized config.* files or write your own:
-OpenBSD
--------
-
-Before running make(1), comment the CPPFLAGS definition in config.mk above the
-line with the "OpenBSD" comment and uncomment the one below it:
-
- #CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
- # -D_XOPEN_SOURCE=700
- # OpenBSD
- CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
- -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
-
-Also, do the same for MANPREFIX:
-
- #MANPREFIX = $(DESTDIR)$(PREFIX)/share/man
- # OpenBSD
- MANPREFIX = $(DESTDIR)$(PREFIX)/man
+ $ cp config.$(uname -s) config.mk || echo Write config.mk from scratch
diff --git a/README b/README
@@ -26,7 +26,7 @@ License
-------
dtree - Command line program to draw trees
-Copyright (C) 2023-2025 Страхиња Радић
+Copyright (C) 2023-2026 Страхиња Радић
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
diff --git a/config.Haiku b/config.Haiku
@@ -0,0 +1,18 @@
+CC = clang
+CFLAGS = -I. -Os -Wextra -Wall -pedantic -std=c99
+CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=700 -DNDEBUG
+DESTDIR = /boot/home/config/non-packaged
+INSTALL = install
+LIBS =
+SRC = dtree.c utf8.c
+HEADERS = utf8.h version.h
+OBJS = dtree.o utf8.o
+PREFIX = /usr/local
+PROG = dtree
+
+# Derived macros
+BINDIR = $(DESTDIR)$(PREFIX)/bin
+DOCDIR = $(DESTDIR)$(PREFIX)/documentation/$(PROG)
+MANPREFIX = $(DESTDIR)$(PREFIX)/documentation/man
+MANPAGE = $(PROG).1
diff --git a/config.Linux b/config.Linux
@@ -0,0 +1,16 @@
+CFLAGS = -Os -Wextra -Wall -pedantic -std=c99
+CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DNDEBUG
+INSTALL = install
+LIBS =
+SRC = dtree.c utf8.c
+HEADERS = utf8.h version.h
+OBJS = dtree.o utf8.o
+PREFIX = /usr/local
+PROG = dtree
+
+# Derived macros
+BINDIR = $(DESTDIR)$(PREFIX)/bin
+DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/$(PROG)
+MANPREFIX = $(DESTDIR)$(PREFIX)/share/man
+MANPAGE = $(PROG).1
diff --git a/config.OpenBSD b/config.OpenBSD
@@ -0,0 +1,16 @@
+CFLAGS = -Os -Wextra -Wall -pedantic -std=c99
+CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=700 -DNDEBUG
+INSTALL = install
+LIBS =
+SRC = dtree.c utf8.c
+HEADERS = utf8.h version.h
+OBJS = dtree.o utf8.o
+PREFIX = /usr/local
+PROG = dtree
+
+# Derived macros
+BINDIR = $(DESTDIR)$(PREFIX)/bin
+DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/$(PROG)
+MANPREFIX = $(DESTDIR)$(PREFIX)/man
+MANPAGE = $(PROG).1
diff --git a/config.mk b/config.mk
@@ -1,22 +0,0 @@
-#CC = cc
-CFLAGS = -Os -Wextra -Wall -pedantic -std=c99
-CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
- -D_XOPEN_SOURCE=700
-# OpenBSD
-#CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
-# -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
-INSTALL = install
-LIBS =
-SRC = dtree.c utf8.c
-HEADERS = utf8.h version.h
-OBJS = dtree.o utf8.o
-PREFIX = /usr/local
-PROG = dtree
-
-# Derived macros
-BINDIR = $(DESTDIR)$(PREFIX)/bin
-DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/$(PROG)
-MANPREFIX = $(DESTDIR)$(PREFIX)/share/man
-# OpenBSD
-#MANPREFIX = $(DESTDIR)$(PREFIX)/man
-MANPAGE = $(PROG).1
diff --git a/dtree.1.in b/dtree.1.in
@@ -1,5 +1,5 @@
.\" This program is licensed under the terms of GNU GPL v3 or (at your option)
-.\" any later version. Copyright (C) 2023-2025 Страхиња Радић.
+.\" any later version. Copyright (C) 2023-2026 Страхиња Радић.
.\" See the file LICENSE for exact copyright and license details.
.Dd %DATE%
.Dt DTREE 1
@@ -124,4 +124,4 @@ with
.Xr tree 1
.Sh AUTHORS
.An "Strahinya Radich" Aq sr@strahinja.org ,
-2023\-2025
+2023\-2026
diff --git a/dtree.c b/dtree.c
@@ -1,10 +1,7 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2023-2025 Страхиња Радић.
+ * any later version. Copyright (C) 2023-2026 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
-/* Comment out to turn on assert(3) */
-#define NDEBUG
-
#include <assert.h>
#include <errno.h>
#include <limits.h>
@@ -23,7 +20,7 @@
#define COPYRIGHT \
(" This program is licensed under the terms of GNU GPL v3" \
" or (at your option)\n" \
- " any later version. Copyright (C) 2023-2025 Strahinya Radich.\n" \
+ " any later version. Copyright (C) 2023-2026 Strahinya Radich.\n" \
" See the file LICENSE for exact copyright and license " \
"details.")
diff --git a/lib/makedate b/lib/makedate
@@ -4,6 +4,24 @@ FALLBACKDATE=${FALLBACKDATE:-unknown}
LC_ALL=C
export LC_ALL
+getent()
+{
+ geresult=''
+ if geresult=$(command getent "$@" 2>/dev/null); then
+ return
+ fi
+ case "$1" in
+ passwd|group)
+ if [ -z "$2" ]; then
+ geresult=$(cat /etc/"$1")
+ else
+ geresult=$(awk -F: -vu="$2" '{ if ($3 == u) print }' /etc/"$1")
+ fi
+ ;;
+ *) ;;
+ esac
+}
+
if [ -d .got ] && command -v got >/dev/null 2>&1; then
got log |
awk '
@@ -26,8 +44,13 @@ if [ -d .got ] && command -v got >/dev/null 2>&1; then
exit
}' >date.new
elif [ -d .git ] && command -v git >/dev/null 2>&1; then
- user=$(unalias ls >/dev/null 2>&1 || true; \
- command ls -ld . | awk '{print $3}')
+ getent passwd "$(unalias ls >/dev/null 2>&1 || true; \
+ command ls -nd . | awk '{print $3}')"
+ user=$(printf "%s\n" "$geresult" | awk -F: '{print $1}')
+ if [ -z "$user" ]; then
+ printf "$0: error: Cannot determine owner of %s" "$(pwd)" >&2
+ exit 1
+ fi
e_user=$(id -un)
if [ "$e_user" = "$user" ]; then
git log --format=format:%cd \
diff --git a/lib/makeversion b/lib/makeversion
@@ -2,6 +2,24 @@
# vim: set ft=bash:
FALLBACKVER=${FALLBACKVER:-unknown}
+getent()
+{
+ geresult=''
+ if geresult=$(command getent "$@" 2>/dev/null); then
+ return
+ fi
+ case "$1" in
+ passwd|group)
+ if [ -z "$2" ]; then
+ geresult=$(cat /etc/"$1")
+ else
+ geresult=$(awk -F: -vu="$2" '{ if ($3 == u) print }' /etc/"$1")
+ fi
+ ;;
+ *) ;;
+ esac
+}
+
if [ -d .got ] && command -v got >/dev/null 2>&1; then
lastcommit=$(got log |
awk '/^commit/ {print substr($2,1,7); exit}')
@@ -33,13 +51,18 @@ if [ -d .got ] && command -v got >/dev/null 2>&1; then
elif [ -d .git ] && command -v git >/dev/null 2>&1; then
LC_ALL=C
export LC_ALL
- user=$(unalias ls >/dev/null 2>&1 || true; \
- command ls -ld . | awk '{print $3}')
+ getent passwd "$(unalias ls >/dev/null 2>&1 || true; \
+ command ls -nd . | awk '{print $3}')"
+ user=$(printf "%s\n" "$geresult" | awk -F: '{print $1}')
+ if [ -z "$user" ]; then
+ printf "$0: error: Cannot determine owner of %s" "$(pwd)" >&2
+ exit 1
+ fi
e_user=$(id -un)
if [ "$e_user" = "$user" ]; then
git describe 2>/dev/null | sed 's/^v//' >version.new
else
- su "${user}" -c 'git describe' 2>/dev/null |
+ su "$user" -c 'git describe' 2>/dev/null |
sed 's/^v//' >version.new
fi
else
diff --git a/lib/mkpack b/lib/mkpack
@@ -4,7 +4,7 @@ DISTDIR=$(grep '^PROG[[:space:]]\{1,\}=' config.mk |
sed -E 's,.*=[[:space:]]+([[:alpha:]]+),\1,')-$(cat version)
mkdir "$DISTDIR"
if [ -d .got ] && command -v got >/dev/null 2>&1; then
- files=$(got tree | sed -e 's,[@/*$]$,,g')
+ files=$(got tree -R | sed -e 's,[@/*$]$,,g')
elif [ -d .git ] && command -v git >/dev/null 2>&1; then
files=$(git ls-files)
else
@@ -14,7 +14,7 @@ fi
for f in $files; do
d="$DISTDIR"/"$(dirname "$f")"
mkdir -p "$d"
- cp "$f" "$d"/
+ [ -f "$f" ] && cp "$f" "$d"/
done
tar -cf - "$DISTDIR" | xz -9v - > "$DISTDIR".tar.xz
rm -fr "$DISTDIR"
diff --git a/lib/runtests b/lib/runtests
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+# This program is licensed under the terms of GNU GPL v3 or (at your option)
+# any later version. Copyright (C) 2022-2026 Страхиња Радић.
+# See the file LICENSE for exact copyright and license details.
+
+
+use 5.010;
+use File::Find;
+
+my $errors = 0;
+my @files;
+my $maxlen = 60;
+my $testdir = 'tests';
+
+system("sh -c 'command -v expect' >/dev/null") == 0 ||
+ die "Test suite requires expect";
+
+find(sub {
+ push @files, $File::Find::name if (/\.test$/);
+}, $testdir . "/");
+
+for (@files)
+{
+ system $_;
+ $results{$_} = $?>>8;
+}
+
+# Clear the screen
+print "\033[0m\033[2J\033[2K\033[1;1H";
+
+print <<"!";
+TEST RESULTS
+============================================================
+!
+
+for (@files)
+{
+ printf "%s:%*s%s\t%s\n", $_, $maxlen-5-length($_), " ",
+ $results{$_} == 0 ? " OK" : "FAIL";
+ if ($results{$_})
+ {
+ $errors = 1;
+ }
+}
+
+if ($errors == 1)
+{
+ printf "Some tests were unsuccessful - please report\n";
+}
+else
+{
+ printf "All tests passed\n";
+}
+
+print <<"!";
+============================================================
+!
diff --git a/utf8.c b/utf8.c
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2023-2025 Страхиња Радић.
+ * any later version. Copyright (C) 2023-2026 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#include "utf8.h"
diff --git a/utf8.h b/utf8.h
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2023-2025 Страхиња Радић.
+ * any later version. Copyright (C) 2023-2026 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#include <stdint.h>
diff --git a/version.h.in b/version.h.in
@@ -1,5 +1,5 @@
/* This program is licensed under the terms of GNU GPL v3 or (at your option)
- * any later version. Copyright (C) 2023-2025 Страхиња Радић.
+ * any later version. Copyright (C) 2023-2026 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
#define PROGRAMNAME "dtree"