]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Add support for transparent compilation
authorGuillem Jover <guillem@hadrons.org>
Wed, 23 Feb 2011 13:04:57 +0000 (14:04 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sat, 14 May 2011 11:43:49 +0000 (13:43 +0200)
This means that software being ported should not need to be modified in
the usual case, as the libbsd headers will take over the standard
namespace and fill the missing gaps, and include the system headers.

To use this the new libbsd-transparent.pc file can be used through
pkg-config, which should end up doing the right thing.

14 files changed:
Makefile
include/bsd/err.h
include/bsd/getopt.h
include/bsd/stdio.h
include/bsd/stdlib.h
include/bsd/string.h
include/bsd/sys/cdefs.h
include/bsd/unistd.h
libbsd-transparent.pc.in [new file with mode: 0644]
src/bsd_getopt.c
src/err.c
src/flopen.c
src/progname.c
src/readpassphrase.c

index b333ef7c55983470dac5ea72eecdab88246d54ee..553b4641cd043a54425cf12585b7dde56681e60b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ LIB_VERSION_MICRO := 0
 LIB_VERSION := $(LIB_VERSION_MAJOR).$(LIB_VERSION_MINOR).$(LIB_VERSION_MICRO)
 
 LIB_PKGCONFIG := $(LIB_NAME).pc
+LIB_PKGCONFIG_TRANS := $(LIB_NAME)-transparent.pc
 LIB_STATIC := $(LIB_NAME).a
 LIB_SHARED_SO := $(LIB_NAME).so
 LIB_SONAME := $(LIB_SHARED_SO).$(LIB_VERSION_MAJOR)
@@ -121,7 +122,7 @@ CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
 LDFLAGS ?=
 
 # Internal makefile variables
-MK_CPPFLAGS := -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
+MK_CPPFLAGS := -Iinclude/bsd/ -Iinclude/ -DLIBBSD_TRANSPARENT -D_GNU_SOURCE -D__REENTRANT
 MK_CFLAGS :=
 MK_LDFLAGS :=
 
@@ -137,7 +138,7 @@ pkgconfigdir        = ${usrlibdir}/pkgconfig
 mandir         = ${prefix}/share/man
 
 .PHONY: libs
-libs: $(LIB_STATIC) $(LIB_SHARED_SO) $(LIB_PKGCONFIG)
+libs: $(LIB_STATIC) $(LIB_SHARED_SO) $(LIB_PKGCONFIG) $(LIB_PKGCONFIG_TRANS)
 
 .PHONY: man
 man: $(LIB_MANS)
@@ -207,6 +208,7 @@ install: libs man
        done
        install -m644 $(LIB_MANS) $(DESTDIR)$(mandir)/man3
        install -m644 $(LIB_PKGCONFIG) $(DESTDIR)$(pkgconfigdir)
+       install -m644 $(LIB_PKGCONFIG_TRANS) $(DESTDIR)$(pkgconfigdir)
 ifeq ($(libdir),$(usrlibdir))
        # If both dirs are the same, do a relative symlink.
        ln -sf $(LIB_SHARED) $(DESTDIR)$(usrlibdir)/$(LIB_SHARED_SO)
@@ -219,6 +221,7 @@ endif
 .PHONY: clean
 clean:
        rm -f $(LIB_PKGCONFIG)
+       rm -f $(LIB_PKGCONFIG_TRANS)
        rm -f $(LIB_SRCS_GEN) $(LIB_MANS_GEN)
        rm -f $(LIB_STATIC_OBJS)
        rm -f $(LIB_STATIC)
index 489138bd5f5bf689fc869f1c63b78b7349fbb707..b6226555d7908df3d28db076ac6455ac401db899 100644 (file)
 #define LIBBSD_ERR_H
 
 #include <sys/cdefs.h>
-#include <err.h>
+
 #include <stdarg.h>
 
+#ifdef LIBBSD_TRANSPARENT
+#include_next <err.h>
+#else
+#include <err.h>
+#endif
+
 __BEGIN_DECLS
 extern void warnc (int code, const char *format, ...);
 extern void vwarnc (int code, const char *format, va_list ap);
index 699a00e37a0c8dc5c408f3ce878af7630d16b774..b0057cf8ae21f6b63ad247f499ebc4ea9b92a034 100644 (file)
 #define LIBBSD_GETOPT_H
 
 #include <sys/cdefs.h>
+
+#ifdef LIBBSD_TRANSPARENT
+#include_next <getopt.h>
+#else
 #include <getopt.h>
+#endif
 
 __BEGIN_DECLS
 extern int optreset;
index 882f3741029110f884323e4a9719318a88ece1d7..dfde0c3385afb1c4fa09955347adb4fe62503c5d 100644 (file)
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
+
+#ifdef LIBBSD_TRANSPARENT
+#include_next <stdio.h>
+#else
 #include <stdio.h>
+#endif
 
 __BEGIN_DECLS
 const char *fmtcheck(const char *, const char *);
index bf30f36aaccef6d421006b102ce353e0b9fa4c3c..6736ed112ea5fbb209844a00a2d6c3253da1b13e 100644 (file)
 #include <sys/cdefs.h>
 #include <sys/stat.h>
 #include <stdint.h>
+
+#ifdef LIBBSD_TRANSPARENT
+#include_next <stdlib.h>
+#else
 #include <stdlib.h>
+#endif
 
 /* For compatibility with NetBSD, which defines humanize_number here. */
+#ifdef LIBBSD_TRANSPARENT
 #include <libutil.h>
+#else
+#include <bsd/libutil.h>
+#endif
 
 /* FIXME: Temporary inclusions to avoid API breakage, will be removed soon. */
 #include <bsd/stdio.h>
index cf72cc0d7581d6cb3af9a023f6ad3efe7715eebe..edc16fc18b19fb7d47293019686253f943ef3ea8 100644 (file)
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
+#ifdef LIBBSD_TRANSPARENT
+#include_next <string.h>
+#else
+#include <string.h>
+#endif
+
 /* FIXME: Temporary inclusion to avoid API breakage, will be removed soon. */
 #include <bsd/stdio.h>
 
index 4d9aa4918011ac94b24d88e6a2f82b13bc78bc08..87d8a4815828c065fdd33b95d65ffcf6014c4733 100644 (file)
 #ifndef LIBBSD_CDEFS_H
 #define LIBBSD_CDEFS_H
 
+#ifdef LIBBSD_TRANSPARENT
+#include_next <sys/cdefs.h>
+#else
 #include <sys/cdefs.h>
+#endif
 
 #ifndef __dead2
 # define __dead2
index 2a22fbc20e77fa15338f73bee08198489561f589..ac56787e8b3827428b21c4da4b3308b30d573e1f 100644 (file)
 #include <sys/cdefs.h>
 #include <sys/stat.h>
 
+#ifdef LIBBSD_TRANSPARENT
+#include_next <unistd.h>
+#else
+#include <unistd.h>
+#endif
+
 #ifndef S_ISTXT
 #define S_ISTXT S_ISVTX
 #endif
diff --git a/libbsd-transparent.pc.in b/libbsd-transparent.pc.in
new file mode 100644 (file)
index 0000000..2549e1c
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libbsd
+Description: Utility functions from BSD systems (transparent)
+Version: @VERSION@
+URL: http://libbsd.freedesktop.org/
+Libs: -L${libdir} -lbsd
+Cflags: -isystem ${includedir}/bsd -DLIBBSD_TRANSPARENT
index a213d9b9e8d8dcb6eca7de08d1b3f2ad252c9c76..f5fb304523c1da6ef2a1be670476ac950588b9ff 100644 (file)
@@ -24,7 +24,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <bsd/getopt.h>
+#include <getopt.h>
 
 int optreset = 0;
 
index d33f08e74a725cf5a880738ec3e2815d69b9939c..e5c604d85ae9122268827306816d1b6a8bec3d21 100644 (file)
--- a/src/err.c
+++ b/src/err.c
@@ -24,7 +24,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <bsd/err.h>
+#include <err.h>
 #include <errno.h>
 #include <stdarg.h>
 
index 754c9c037fa2d58fbd9477acc1452208c6338d03..f5f733816132312bc938d07665c7fd143ab65d8a 100644 (file)
@@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
 #include <errno.h>
 #include <stdarg.h>
 #include <unistd.h>
-
 #include <libutil.h>
 
 int
index 107942911a4769c4f5fa12add19ee19715f394eb..f24071ae7c47d4706c24d430279d14e79f72bd4d 100644 (file)
@@ -31,8 +31,7 @@
 
 #include <errno.h>
 #include <string.h>
-
-#include <bsd/stdlib.h>
+#include <stdlib.h>
 
 static const char *__progname = NULL;
 
index 601da49a996b9db6fd629a03b0ecd19cde862bab..1f4fe0eb0f54c3d3654fb5e250a26dae4cc65552 100644 (file)
@@ -29,7 +29,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
-#include <bsd/readpassphrase.h>
+#include <readpassphrase.h>
 
 #ifndef TCSASOFT
 #define TCSASOFT 0