Remove the config.h kludge and override vasprintf detection via HAVE_VASPRINTF.

This commit is contained in:
Juan RP 2014-01-20 18:50:33 +01:00
parent 16fc064aef
commit 5eea259c13
18 changed files with 36 additions and 58 deletions

View File

@ -12,7 +12,7 @@ endif
.PHONY: all
all:
@if test ! -e config.h; then \
@if test ! -e config.mk; then \
echo "You didn't run ./configure ... exiting."; \
exit 1; \
fi
@ -45,4 +45,4 @@ clean:
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean || exit 1; \
done
-rm -f config.h config.mk _ccflag.{,c,err}
-rm -f config.mk _ccflag.{,c,err}

View File

@ -42,7 +42,6 @@
#include <xbps.h>
#include "defs.h"
#include "config.h"
static void
get_time(struct timeval *tvp)

View File

@ -27,9 +27,7 @@
# define _GNU_SOURCE /* for strcasestr(3) */
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#include <stdio.h>
#include <stdbool.h>

26
configure vendored
View File

@ -111,7 +111,6 @@ _which()
return 1
}
CONFIG_H=config.h
CONFIG_MK=config.mk
if [ -z "$BUILD" ]; then
@ -138,9 +137,8 @@ if [ -z "$OS" ]; then
fi
echo "Configuring xbps for ... $OS"
rm -f $CONFIG_H $CONFIG_MK
rm -f $CONFIG_MK
echo "# Common vars used by XBPS on $OS." >$CONFIG_MK
echo "/* $OS */" >$CONFIG_H
echo "VERSION = $VERSION" >>$CONFIG_MK
echo "TOPDIR ?= $TOPDIR" >>$CONFIG_MK
@ -186,7 +184,6 @@ echo "CFLAGS = -O2 -pthread" >>$CONFIG_MK
echo "LDFLAGS = -L\$(TOPDIR)/lib" >>$CONFIG_MK
echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS += -DHAVE_CONFIG_H" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -D_unused=\"__attribute__((__unused__))\"" >>$CONFIG_MK
@ -346,22 +343,31 @@ echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
#
func=vasprintf
printf "Checking for $func() ... "
if test -n "$HAVE_VASPRINTF"; then
echo "yes (cached)."
else
cat <<EOF >_$func.c
#define _GNU_SOURCE
#include <stdio.h>
int main(void) {
vasprintf(NULL, NULL, NULL);
return 0;
}
EOF
if $XCC -D_GNU_SOURCE _$func.c -o _$func 2>/dev/null; then
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
HAVE_VASPRINTF=1
else
echo no.
echo "COMPAT_SRCS+= compat/vasprintf.o" >>$CONFIG_MK
echo "#include \"compat.h\"" >>$CONFIG_H
fi
rm -f _$func.c _$func
fi
if test -n "$HAVE_VASPRINTF"; then
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
else
echo "COMPAT_SRCS+= compat/vasprintf.o" >>$CONFIG_MK
fi
#
# Check for strcasestr().
@ -384,7 +390,6 @@ if $XCC _$func.c -o _$func 2>/dev/null; then
else
echo no.
echo "COMPAT_SRCS += compat/strcasestr.o" >>$CONFIG_MK
echo "#include \"compat.h\"" >>$CONFIG_H
fi
rm -f _$func _$func.c
@ -408,7 +413,6 @@ if $XCC _$func.c -o _$func 2>/dev/null; then
else
echo no.
echo "COMPAT_SRCS += compat/strlcpy.o" >>$CONFIG_MK
echo "#include \"compat.h\"" >>$CONFIG_H
fi
rm -f _$func.c _$func
@ -431,7 +435,6 @@ if $XCC _$func.c -o _$func 2>/dev/null; then
else
echo no.
echo "COMPAT_SRCS += compat/strlcat.o" >>$CONFIG_MK
echo "#include \"compat.h\"" >>$CONFIG_H
fi
rm -f _$func.c _$func
@ -454,7 +457,6 @@ if $XCC -lutil _$func.c -o _$func 2>/dev/null; then
else
echo no.
echo "COMPAT_SRCS+= compat/humanize_number.o" >>$CONFIG_MK
echo "#include \"compat.h\"" >>$CONFIG_H
fi
rm -f _$func.c _$func

View File

@ -22,7 +22,7 @@ size_t HIDDEN strlcpy(char *, const char *, size_t);
char HIDDEN *strcasestr(const char *, const char *);
#endif
#if !defined(HAVE_VASPRINTF) && !defined(_GNU_SOURCE)
#ifndef HAVE_VASPRINTF
int HIDDEN vasprintf(char **, const char *, va_list);
#endif

View File

@ -30,7 +30,7 @@
#include <assert.h>
#include <confuse.h>
#define LIBXBPS_PRIVATE
#include <xbps.h>
#include "xbps.h"
/*
* By default all public functions have default visibility, unless

View File

@ -34,10 +34,6 @@
#include <stdarg.h>
#include <errno.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xbps_api_impl.h"
#ifdef __clang__

View File

@ -37,9 +37,6 @@
#include <ctype.h>
#include "xbps_api_impl.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define PKG_PATTERN_MAX 1024

View File

@ -29,13 +29,15 @@
#define _BSD_SOURCE /* for vfork and chroot */
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#undef _BSD_SOURCE
#include "xbps_api_impl.h"
static int

View File

@ -30,9 +30,8 @@
* $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#ifndef NETBSD
#include <nbcompat.h>
#endif

View File

@ -30,9 +30,8 @@
* $FreeBSD: fetch.c,v 1.41 2007/12/19 00:26:36 des Exp $
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#ifndef NETBSD
#include <nbcompat.h>
#endif

View File

@ -30,9 +30,8 @@
* $FreeBSD: file.c,v 1.18 2007/12/14 10:26:58 des Exp $
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#ifndef NETBSD
#include <nbcompat.h>
#endif

View File

@ -57,9 +57,8 @@
*
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#ifndef NETBSD
#include <nbcompat.h>
#endif

View File

@ -63,9 +63,8 @@
* SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#ifndef NETBSD
#include <nbcompat.h>
#endif

View File

@ -29,7 +29,6 @@
#include <errno.h>
#include "xbps_api_impl.h"
/**
* @file lib/package_configure.c
* @brief Package configuration routines

View File

@ -23,10 +23,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/stat.h>
#include <stdio.h>
#include <stdbool.h>

View File

@ -29,9 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#include <prop/prop_object.h>
#include "prop_object_impl.h"

View File

@ -27,10 +27,6 @@
# define _GNU_SOURCE /* for vasprintf(3) */
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>