summaryrefslogtreecommitdiff
path: root/pkgtools/posix_headers
diff options
context:
space:
mode:
authortnn <tnn@pkgsrc.org>2007-08-01 21:33:40 +0000
committertnn <tnn@pkgsrc.org>2007-08-01 21:33:40 +0000
commitc075ccd194d7a9699bdce12d62c668d838b4b54f (patch)
tree4e88e9e51b5ad5599d83f11b5d4e481ae9f43e26 /pkgtools/posix_headers
parentc84e5b58b3fc66269624e305d941bbe410ba9cb2 (diff)
downloadpkgsrc-c075ccd194d7a9699bdce12d62c668d838b4b54f.tar.gz
Near full rewrite of posix_headers:
- Implement a simple framework for automated header testing and generation using the c preprocessor. - Make it installable on all platforms. On most platforms it will not install any files however. - Bump revision to 0.5. The changes should make it easier to add Interix support to this package. Note that the package is still far from complete; for example the replacement stdint.h does not yet provide fallback definitions for int_*t and friends but relies on inttypes.h to provide them, which turns out to work for HPUX.
Diffstat (limited to 'pkgtools/posix_headers')
-rw-r--r--pkgtools/posix_headers/Makefile35
-rw-r--r--pkgtools/posix_headers/buildlink3.mk6
-rwxr-xr-xpkgtools/posix_headers/files/make.sh17
-rw-r--r--pkgtools/posix_headers/files/math.h18
-rw-r--r--pkgtools/posix_headers/files/math.h.in30
-rw-r--r--pkgtools/posix_headers/files/math.h.tests10
-rw-r--r--pkgtools/posix_headers/files/resolv.h.in (renamed from pkgtools/posix_headers/files/resolv.h)10
-rw-r--r--pkgtools/posix_headers/files/resolv.h.tests1
-rw-r--r--pkgtools/posix_headers/files/stdint.h12
-rw-r--r--pkgtools/posix_headers/files/stdint.h.in8
-rw-r--r--pkgtools/posix_headers/files/stdint.h.tests2
-rw-r--r--pkgtools/posix_headers/files/stdlib.h32
-rw-r--r--pkgtools/posix_headers/files/stdlib.h.in5
-rw-r--r--pkgtools/posix_headers/files/stdlib.h.tests1
-rwxr-xr-xpkgtools/posix_headers/files/subr.sh111
-rw-r--r--pkgtools/posix_headers/files/sys/select.h9
-rw-r--r--pkgtools/posix_headers/files/sys/select.h.in3
-rw-r--r--pkgtools/posix_headers/files/sys/select.h.tests1
18 files changed, 203 insertions, 108 deletions
diff --git a/pkgtools/posix_headers/Makefile b/pkgtools/posix_headers/Makefile
index 853d07309d4..ff20b882d6b 100644
--- a/pkgtools/posix_headers/Makefile
+++ b/pkgtools/posix_headers/Makefile
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.5 2007/04/28 21:03:56 tnn Exp $
+# $NetBSD: Makefile,v 1.6 2007/08/01 21:33:40 tnn Exp $
-DISTNAME= posix_headers-0.4
-PKGREVISION= 5
+DISTNAME= posix_headers-0.5
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -14,37 +13,21 @@ NO_PKGTOOLS_REQD_CHECK= yes
NO_CHECKSUM= yes
NO_MTREE= yes
NO_CONFIGURE= yes
-ONLY_FOR_PLATFORM= HPUX-11.11-* # add more as needed
PLIST_SRC= ${WRKDIR}/PLIST_SRC
-
-POSIX_HEADERS.HPUX= sys/select.h stdint.h math.h resolv.h stdlib.h
-SUBST_HEADERS.HPUX= math.h resolv.h stdlib.h
-
+REPLACE_SH+= make.sh
BUILDING_POSIX_HEADERS= yes
-# Command that uses the C preprocessing feature to find out the real absolute
-# path of a header included using #include <someheader.h>
-REAL_HEADER_CMD= ${ECHO} "\#include <@REAL_HEADER@>" | ${CC} -E - | \
- ${AWK} -F'"' '/\# 1 .*@REAL_HEADER@"/ {print $$2}'
-
do-extract:
- ${MKDIR} ${WRKSRC}
- cd ${FILESDIR} && ${PAX} -rw * ${WRKSRC}
+ cp -R ${FILESDIR} ${WRKSRC}
do-build:
-.for header in ${SUBST_HEADERS.${OPSYS}}
- realheader=`${REAL_HEADER_CMD:S/@REAL_HEADER@/${header}/}` ;\
- ${ECHO} "header: ${header} -> $$realheader" ;\
- ${SED} "s|@REAL_HEADER@|$$realheader|" \
- < ${WRKSRC}/${header} > ${WRKSRC}/${header}.tmp
- ${MV} ${WRKSRC}/${header}.tmp ${WRKSRC}/${header}
-.endfor
+ cd ${WRKSRC} && ./make.sh
+ find ${WRKSRC} -name "*.h" | sed s,${WRKSRC}/,, > ${WRKSRC}/hfiles
+ cat ${WRKSRC}/hfiles | sed s,^,include/, > ${PLIST_SRC}
do-install:
-.for header in ${POSIX_HEADERS.${OPSYS}}
- ${INSTALL_DATA} ${WRKSRC}/${header} ${PREFIX}/include/${header}
- ${ECHO} include/${header} >> ${PLIST_SRC}
-.endfor
+ for f in `cat ${WRKSRC}/hfiles`; do \
+ ${INSTALL_DATA} ${WRKSRC}/$$f ${DESTDIR}${PREFIX}/include/$$f; done
.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/posix_headers/buildlink3.mk b/pkgtools/posix_headers/buildlink3.mk
index 695669ee9ee..680440fa304 100644
--- a/pkgtools/posix_headers/buildlink3.mk
+++ b/pkgtools/posix_headers/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.4 2007/04/29 19:52:44 tnn Exp $
+# $NetBSD: buildlink3.mk,v 1.5 2007/08/01 21:33:40 tnn Exp $
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
POSIX_HEADERS_BUILDLINK3_MK:= ${POSIX_HEADERS_BUILDLINK3_MK}+
@@ -12,8 +12,8 @@ BUILDLINK_PACKAGES+= posix_headers
BUILDLINK_ORDER:= ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}posix_headers
.if !empty(POSIX_HEADERS_BUILDLINK3_MK:M+)
-BUILDLINK_API_DEPENDS.posix_headers+= posix_headers>=0.4nb5
-BUILDLINK_ABI_DEPENDS.posix_headers+= posix_headers>=0.4nb5
+BUILDLINK_API_DEPENDS.posix_headers+= posix_headers>=0.5
+BUILDLINK_ABI_DEPENDS.posix_headers+= posix_headers>=0.5
BUILDLINK_PKGSRCDIR.posix_headers?= ../../pkgtools/posix_headers
BUILDLINK_DEPMETHOD.posix_headers?= build
.endif # POSIX_HEADERS_BUILDLINK3_MK
diff --git a/pkgtools/posix_headers/files/make.sh b/pkgtools/posix_headers/files/make.sh
new file mode 100755
index 00000000000..cf5eafe4638
--- /dev/null
+++ b/pkgtools/posix_headers/files/make.sh
@@ -0,0 +1,17 @@
+#! /bin/sh
+#
+# $NetBSD: make.sh,v 1.1 2007/08/01 21:33:40 tnn Exp $
+#
+# Please read subr.sh for a brief explanation of how this works.
+
+[ -z "$CC" ] && CC=gcc
+[ -z "$CPP" ] && CPP="$CC -E"
+
+HEADERS="math.h resolv.h stdlib.h stdint.h sys/select.h"
+
+. ./subr.sh
+
+for hdr in $HEADERS
+do
+ make_header $hdr
+done
diff --git a/pkgtools/posix_headers/files/math.h b/pkgtools/posix_headers/files/math.h
deleted file mode 100644
index d1967d51903..00000000000
--- a/pkgtools/posix_headers/files/math.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* $NetBSD: math.h,v 1.2 2007/04/24 23:12:44 tnn Exp $ */
-#ifndef _PKGSRC_MATH_H_
-#define _PKGSRC_MATH_H_
-#include "@REAL_HEADER@"
-#ifdef __hpux
-/* Floatified math functions are not available. */
-#define floorf(x) ((float)floor (x))
-#define ceilf(x) ((float)ceil (x))
-#define sinf(x) ((float)sin (x))
-#define cosf(x) ((float)cos (x))
-#define tanf(x) ((float)tan (x))
-#define asinf(x) ((float)asin (x))
-#define acosf(x) ((float)acos (x))
-#define atanf(x) ((float)atan (x))
-#define atan2f(x,y) ((float)atan2 (x, y))
-#define sqrtf(x) ((float)sqrt (y))
-#endif /* __hpux */
-#endif /* _PKGSRC_MATH_H_ */
diff --git a/pkgtools/posix_headers/files/math.h.in b/pkgtools/posix_headers/files/math.h.in
new file mode 100644
index 00000000000..3d05518567d
--- /dev/null
+++ b/pkgtools/posix_headers/files/math.h.in
@@ -0,0 +1,30 @@
+#ifndef @floorf@
+@define floorf(x) ((float)floor (x))
+#endif
+#ifndef @ceilf@
+@define ceilf(x) ((float)ceil (x))
+#endif
+#ifndef @sinf@
+@define sinf(x) ((float)sin (x))
+#endif
+#ifndef @cosf@
+@define cosf(x) ((float)cos (x))
+#endif
+#ifndef @tanf@
+@define tanf(x) ((float)tan (x))
+#endif
+#ifndef @asinf@
+@define asinf(x) ((float)asin (x))
+#endif
+#ifndef @acosf@
+@define acosf(x) ((float)acos (x))
+#endif
+#ifndef @atanf@
+@define atanf(x) ((float)atan (x))
+#endif
+#ifndef @atan2f@
+@define atan2f(x,y) ((float)atan2 (x, y))
+#endif
+#ifndef @sqrtf@
+@define sqrtf(x) ((float)sqrt (y))
+#endif
diff --git a/pkgtools/posix_headers/files/math.h.tests b/pkgtools/posix_headers/files/math.h.tests
new file mode 100644
index 00000000000..cb87667d1de
--- /dev/null
+++ b/pkgtools/posix_headers/files/math.h.tests
@@ -0,0 +1,10 @@
+scan_preproc|floorf| floorf(
+scan_preproc|ceilf| ceilf(
+scan_preproc|sinf| sinf(
+scan_preproc|cosf| cosf(
+scan_preproc|tanf| tanf(
+scan_preproc|asinf| asinf(
+scan_preproc|acosf| acosf(
+scan_preproc|atanf| atanf(
+scan_preproc|atan2f| atan2f(
+scan_preproc|sqrtf| sqrtf(
diff --git a/pkgtools/posix_headers/files/resolv.h b/pkgtools/posix_headers/files/resolv.h.in
index 7fdf864aee5..37b0b49e504 100644
--- a/pkgtools/posix_headers/files/resolv.h
+++ b/pkgtools/posix_headers/files/resolv.h.in
@@ -1,9 +1,4 @@
-/* $NetBSD: resolv.h,v 1.2 2007/04/28 21:03:56 tnn Exp $ */
-#ifndef _PKGSRC_RESOLV_H_
-#define _PKGSRC_RESOLV_H_
-#include "@REAL_HEADER@"
-#ifdef __hpux
-/* Missing prototypes. We have them in libc though. */
+#if !defined(@have_res_proto@) && defined(__hpux)
ssize_t res_query(char*, int, int, u_char*, int);
ssize_t res_search(char*, int, int, u_char*, int);
ssize_t res_mkquery(int, const char*, int, int, const char*, int,\
@@ -12,5 +7,4 @@ ssize_t res_send(const char*, ssize_t, char*, int);
int res_init();
ssize_t dn_comp(const char*, u_char*, ssize_t, u_char**, u_char**);
ssize_t dn_expand(const u_char*, const u_char*, const u_char*, u_char*, int);
-#endif /* __hpux */
-#endif /* _PKGSRC_RESOLV_H_ */
+#endif
diff --git a/pkgtools/posix_headers/files/resolv.h.tests b/pkgtools/posix_headers/files/resolv.h.tests
new file mode 100644
index 00000000000..4d4a93a36ee
--- /dev/null
+++ b/pkgtools/posix_headers/files/resolv.h.tests
@@ -0,0 +1 @@
+scan_preproc|have_res_proto|dn_expand
diff --git a/pkgtools/posix_headers/files/stdint.h b/pkgtools/posix_headers/files/stdint.h
deleted file mode 100644
index e8f893ee2f8..00000000000
--- a/pkgtools/posix_headers/files/stdint.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* $NetBSD: stdint.h,v 1.1.1.1 2007/04/24 19:35:46 tnn Exp $ */
-#ifndef _PKGSRC_STDINT_H_
-#define _PKGSRC_STDINT_H_
-#ifdef __hpux
-#include <inttypes.h>
-#ifndef UINT_FAST32_MAX
-#define UINT_FAST32_MAX 0xffffffffU
-#endif /* UINT_FAST32_MAX */
-#else
-#error No support for this platform.
-#endif /* __hpux */
-#endif /* _PKGSRC_STDINT_H_ */
diff --git a/pkgtools/posix_headers/files/stdint.h.in b/pkgtools/posix_headers/files/stdint.h.in
new file mode 100644
index 00000000000..ab9d10c8b57
--- /dev/null
+++ b/pkgtools/posix_headers/files/stdint.h.in
@@ -0,0 +1,8 @@
+#ifndef @have_stdint@
+#ifdef @have_inttypes@
+@include <inttypes.h>
+#endif
+@ifndef UINT_FAST32_MAX
+@define UINT_FAST32_MAX 0xffffffffU
+@endif
+#endif
diff --git a/pkgtools/posix_headers/files/stdint.h.tests b/pkgtools/posix_headers/files/stdint.h.tests
new file mode 100644
index 00000000000..101de91fdc5
--- /dev/null
+++ b/pkgtools/posix_headers/files/stdint.h.tests
@@ -0,0 +1,2 @@
+have_header|have_stdint|stdint.h
+have_header|have_inttypes|inttypes.h
diff --git a/pkgtools/posix_headers/files/stdlib.h b/pkgtools/posix_headers/files/stdlib.h
deleted file mode 100644
index bdec28cec45..00000000000
--- a/pkgtools/posix_headers/files/stdlib.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* $NetBSD: stdlib.h,v 1.3 2007/04/28 23:33:36 tnn Exp $ */
-#ifndef _PKGSRC_STDLIB_H_
-#define _PKGSRC_STDLIB_H_
-#include "@REAL_HEADER@"
-#ifdef __hpux
-/* What were they thinking? */
-#include <inttypes.h>
-#define strtoll __strtoll
-#define strtoull __strtoull
-/* provide a setenv(3) implementation */
-#if 0
-/*
- * XXX: disabled because some GNU configure scripts don't pick this up,
- * they look for the symbol in the c library. A better solution is needed.
- */
-#include <string.h>
-#include <stdio.h>
-static __inline int setenv(const char *name, const char *value, int overwrite);
-static __inline int setenv(const char *name, const char *value, int overwrite) {
- char *c;
- int ret;
- if (!overwrite && getenv(name)) return(-1);
- c = (char*)malloc(strlen(name)+strlen(value)+2);
- if(!c) return(-1);
- sprintf(c, "%s=%s", name, value);
- ret = putenv(c);
- free(c);
- return(ret);
-}
-#endif /* 0 */
-#endif /* __hpux */
-#endif /* _PKGSRC_STDLIB_H_ */
diff --git a/pkgtools/posix_headers/files/stdlib.h.in b/pkgtools/posix_headers/files/stdlib.h.in
new file mode 100644
index 00000000000..61c32ef8f71
--- /dev/null
+++ b/pkgtools/posix_headers/files/stdlib.h.in
@@ -0,0 +1,5 @@
+#if !defined(@strtoll@) || defined(__hpux)
+@include <inttypes.h>
+@define strtoll __strtoll
+@define strtoull __strtoull
+#endif
diff --git a/pkgtools/posix_headers/files/stdlib.h.tests b/pkgtools/posix_headers/files/stdlib.h.tests
new file mode 100644
index 00000000000..ff9ca56633d
--- /dev/null
+++ b/pkgtools/posix_headers/files/stdlib.h.tests
@@ -0,0 +1 @@
+scan_preproc|strtoll| strtoll
diff --git a/pkgtools/posix_headers/files/subr.sh b/pkgtools/posix_headers/files/subr.sh
new file mode 100755
index 00000000000..8a3a9fead1b
--- /dev/null
+++ b/pkgtools/posix_headers/files/subr.sh
@@ -0,0 +1,111 @@
+#
+# $NetBSD: subr.sh,v 1.1 2007/08/01 21:33:46 tnn Exp $
+#
+
+DIFS="$IFS"
+newline="
+"
+
+# The order in which files are generated by this script:
+#
+# someheader.h.tests ---> test_header()
+# \
+# someheader.h.in ---> +---> someheader.h.out ---+
+# |
+# someheader.h <--- someheader.h.pre <--- c preprocessor <---+
+#
+# someheader.h.tests: Definitions of tests we want to perform on the system
+# supplied header. Each successfull test will cause a
+# @macro@ to be defined during the preprocessing stage.
+# someheader.h.out: The result of the tests concatenated with the .in file.
+# someheader.h.pre: The preprocessed output. In this file any compatiblity
+# definitions that weren't needed have been removed.
+# someheader.h: The final header to be installed.
+#
+# The syntax used in test definitions is:
+#
+# test_function|test_name|argument
+#
+# Example:
+#
+# scan_preproc|have_printf|printf
+#
+# If the above line would be used in the file stdio.h.tests, it would test
+# if the preprocessed output of <stdio.h> contains the string printf. If it
+# does, the macro @have_printf@ will be defined when parsing stdio.h.in.
+
+
+# Test if a given regexp can be found in the preprocessed output of the hdr.
+test_scan_preproc() {
+ IFS="$DIFS"
+ echo "#include <$hdr>" | $CPP - 2>/dev/null | grep "$1" > /dev/null
+ return $?
+}
+
+# Test if the specified header can be included.
+test_have_header() {
+ IFS="$DIFS"
+ echo "#include <$1>" | $CPP - > /dev/null 2>&1
+ return $?
+}
+
+# Prints the full absolute pathname to the file that is included by doing
+# #include <file.h>.
+real_header() {
+ echo "#include <$hdr>" | $CPP - 2> /dev/null |\
+ awk -F\" '/^\# 1 "\// {if(!done){print $2;done=1;}}'
+}
+
+# Prints the uppercase of $1 with some characters converted to underscore.
+toupper() {
+ echo "$@" | tr a-z A-Z | tr . _ | tr / _
+}
+
+# Run a single header test and print the result.
+do_test() {
+ testtype=$1
+ testname=$2
+ shift 2
+ testarg="$@"
+ IFS=""
+ if test_${testtype} $testarg
+ then
+ echo "#define PH_TEST_`toupper $hdr`_$testname 1"
+ fi
+}
+
+# Run all header tests for a header and print the result.
+test_header() {
+ IFS="$newline"
+ for line in `cat $hdr.tests`
+ do
+ IFS="|"
+ do_test $line
+ IFS="$newline"
+ done
+}
+
+# Test, preprocess and generate a header.
+make_header() {
+ hdr="$1"
+ HDR="`toupper $hdr`"
+ rm -f $hdr
+ test_header > $hdr.out
+ IFS="$DIFS"
+ cat $hdr.in | sed 's/@\(.*\)@/PH_TEST_'$HDR'_\1/g' >> $hdr.out
+ $CPP - < $hdr.out | awk '/^[^#]/ {sub("^@", "#");print $0;}' > $hdr.pre
+ if [ -s "$hdr.pre" ]
+ then
+ echo "/* --- This header file was automatically generated by pkgsrc. */" > $hdr
+ echo "#ifndef _PKGSRC_${HDR}_" >> $hdr
+ echo "#define _PKGSRC_${HDR}_" >> $hdr
+ real_hdr="`real_header $hdr`"
+ if [ "$real_hdr" != "" ]
+ then
+ echo "/* --- real header: */" >> $hdr
+ echo "#include \"$real_hdr\"" >> $hdr
+ fi
+ cat $hdr.pre >> $hdr
+ echo "#endif /* _PKGSRC_${HDR}_ */" >> $hdr
+ fi
+}
diff --git a/pkgtools/posix_headers/files/sys/select.h b/pkgtools/posix_headers/files/sys/select.h
deleted file mode 100644
index b978f381abd..00000000000
--- a/pkgtools/posix_headers/files/sys/select.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* $NetBSD: select.h,v 1.1.1.1 2007/04/24 19:35:46 tnn Exp $ */
-#ifndef _PKGSRC_SYS_SELECT_H_
-#define _PKGSRC_SYS_SELECT_H_
-#ifdef __hpux
-#include <sys/time.h>
-#else
-#error This header file only applies to HP-UX.
-#endif /* __hpux */
-#endif /* _PKGSRC_SYS_SELECT_H_ */
diff --git a/pkgtools/posix_headers/files/sys/select.h.in b/pkgtools/posix_headers/files/sys/select.h.in
new file mode 100644
index 00000000000..a3c2734a8fd
--- /dev/null
+++ b/pkgtools/posix_headers/files/sys/select.h.in
@@ -0,0 +1,3 @@
+#if !defined(@select@) && defined(__hpux)
+@include <sys/time.h>
+#endif
diff --git a/pkgtools/posix_headers/files/sys/select.h.tests b/pkgtools/posix_headers/files/sys/select.h.tests
new file mode 100644
index 00000000000..2f2b0488c46
--- /dev/null
+++ b/pkgtools/posix_headers/files/sys/select.h.tests
@@ -0,0 +1 @@
+scan_preproc|select|select