[hackers] [sbase] [PATCH] ls, tar: Include sys/sysmacros.h by default

From: Michael Forney <mforney_AT_mforney.org>
Date: Sun, 30 Jun 2019 13:41:13 -0700

Current glibc and the upcoming musl no longer provide the device macros
through sys/types.h. So, include sys/sysmacros.h if HAVE_SYS_SYSMACROS_H
is defined, and define it by default.
---
Not really sure what to do here. This is my best idea apart from adding
a configure script.
 README    | 4 ++++
 config.mk | 3 ++-
 ls.c      | 2 +-
 tar.c     | 2 +-
 4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/README b/README
index 8653552..8b6b408 100644
--- a/README
+++ b/README
_AT_@ -30,6 +30,10 @@ including Linux, *BSD, OSX, Haiku, Solaris, SCO OpenServer and others.
 Various combinations of operating systems and architectures have also
 been built.
 
+If your system does not have the sys/sysmacros.h header, you will need
+to modify config.mk appropriately. This is necessary since there is no
+common header for the major, minor, and makedev macros.
+
 You can build sbase with gcc, clang, tcc, nwcc and pcc.
 
 Status
diff --git a/config.mk b/config.mk
index 9fb18da..5733fa7 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -10,7 +10,8 @@ AR = ar
 RANLIB = ranlib
 
 # for NetBSD add -D_NETBSD_SOURCE
+# remove -DHAVE_SYS_SYSMACROS_H if your system doesn't have sys/sysmacros.h
 # -lrt might be needed on some systems
-CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_FILE_OFFSET_BITS=64
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_FILE_OFFSET_BITS=64 -DHAVE_SYS_SYSMACROS_H
 CFLAGS   = -std=c99 -Wall -pedantic
 LDFLAGS  = -s
diff --git a/ls.c b/ls.c
index 7de15ac..8fda438 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -1,7 +1,7 @@
 /* See LICENSE file for copyright and license details. */
 #include <sys/stat.h>
 #include <sys/types.h>
-#ifdef __GLIBC__
+#ifdef HAVE_SYS_SYSMACROS_H
 #include <sys/sysmacros.h>
 #endif
 
diff --git a/tar.c b/tar.c
index fb0df45..6d7a380 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -2,7 +2,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#ifdef __GLIBC__
+#ifdef HAVE_SYS_SYSMACROS_H
 #include <sys/sysmacros.h>
 #endif
 
-- 
2.20.1
Received on Sun Jun 30 2019 - 22:41:13 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 01 2019 - 01:36:22 CEST