Source: libre
Version: 0.5.9-1
Tags: patch upstream
Control: block 798955 by -1

libre checks for header existence by searching them in a few filesystem
locations. Debian's /usr/include/<triplet> is not always among those
locations and that makes libre fail to build when built against a
non-glibc or a glibc with multiarch headers (#798955). The attached
multiarch-libc.patch replaces those file existence tests with compile
tests. The compiler knows much better whether headers exists.

Once doing this, you notice that the SYSROOT variable is unused and you
can as well remove it (remove-sysroot.patch). Once removing SYSROOT, you
notice that MACHINE is mostly unused: The only use is setting up
CROSS_COMPILE and OS, but these are supposed to be set by a user for
cross compilation. Removing this code makes win32 behave just like any
other arch and MACHINE can go in the bucket as well
(remove-machine.patch). This simplification is entirely optional of
course.

Please consider applying at least multiarch-libc.patch and close this
bug when doing so.

Helmut
--- libre-0.5.9.orig/mk/re.mk
+++ libre-0.5.9/mk/re.mk
@@ -449,22 +449,19 @@
 # External libraries section
 #
 
-USE_OPENSSL := $(shell [ -f $(SYSROOT)/include/openssl/ssl.h ] || \
-	[ -f $(SYSROOT)/local/include/openssl/ssl.h ] || \
-	[ -f $(SYSROOT_ALT)/include/openssl/ssl.h ] && echo "yes")
+USE_OPENSSL := $(shell echo '\#include <openssl/ssl.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "yes")
 
 ifneq ($(USE_OPENSSL),)
 CFLAGS  += -DUSE_OPENSSL -DUSE_TLS
 LIBS    += -lssl -lcrypto
 USE_TLS := yes
 
-USE_OPENSSL_DTLS := $(shell [ -f $(SYSROOT)/include/openssl/dtls1.h ] || \
-	[ -f $(SYSROOT)/local/include/openssl/dtls1.h ] || \
-	[ -f $(SYSROOT_ALT)/include/openssl/dtls1.h ] && echo "yes")
+USE_OPENSSL_DTLS := $(shell echo '\#include <openssl/dtls1.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "yes")
 
-USE_OPENSSL_SRTP := $(shell [ -f $(SYSROOT)/include/openssl/srtp.h ] || \
-	[ -f $(SYSROOT)/local/include/openssl/srtp.h ] || \
-	[ -f $(SYSROOT_ALT)/include/openssl/srtp.h ] && echo "yes")
+USE_OPENSSL_SRTP := $(shell echo '\#include <openssl/srtp.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "yes")
 
 ifneq ($(USE_OPENSSL_DTLS),)
 CFLAGS  += -DUSE_OPENSSL_DTLS -DUSE_DTLS
@@ -482,9 +479,8 @@
 endif
 
 
-USE_ZLIB    := $(shell [ -f $(SYSROOT)/include/zlib.h ] || \
-	[ -f $(SYSROOT)/local/include/zlib.h ] || \
-	[ -f $(SYSROOT_ALT)/include/zlib.h ] && echo "yes")
+USE_ZLIB    := $(shell echo '\#include <zlib.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "yes")
 
 ifneq ($(USE_ZLIB),)
 CFLAGS  += -DUSE_ZLIB
@@ -494,7 +490,8 @@
 
 ifneq ($(OS),win32)
 
-HAVE_PTHREAD    := $(shell [ -f $(SYSROOT)/include/pthread.h ] && echo "1")
+HAVE_PTHREAD    := $(shell echo '\#include <pthread.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(HAVE_PTHREAD),)
 HAVE_PTHREAD_RWLOCK := 1
 CFLAGS  += -DHAVE_PTHREAD
@@ -505,7 +502,8 @@
 endif
 
 ifneq ($(ARCH),mipsel)
-HAVE_GETIFADDRS := $(shell [ -f $(SYSROOT)/include/ifaddrs.h ] && echo "1")
+HAVE_GETIFADDRS := $(shell echo '\#include <ifaddrs.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(HAVE_GETIFADDRS),)
 CFLAGS  += -DHAVE_GETIFADDRS
 endif
@@ -518,22 +516,24 @@
 
 endif
 
-HAVE_GETOPT     := $(shell [ -f $(SYSROOT)/include/getopt.h ] && echo "1")
+HAVE_GETOPT     := $(shell echo '\#include <getopt.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(HAVE_GETOPT),)
 CFLAGS  += -DHAVE_GETOPT
 endif
-HAVE_INTTYPES_H := $(shell [ -f $(SYSROOT)/include/inttypes.h ] && echo "1")
+HAVE_INTTYPES_H := $(shell echo '\#include <inttypes.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(HAVE_INTTYPES_H),)
 CFLAGS  += -DHAVE_INTTYPES_H
 endif
-HAVE_NET_ROUTE_H := $(shell [ -f $(SYSROOT)/include/net/route.h ] && echo "1")
+HAVE_NET_ROUTE_H := $(shell echo '\#include <net/route.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(HAVE_NET_ROUTE_H),)
 CFLAGS  += -DHAVE_NET_ROUTE_H
 endif
 HAVE_SYS_SYSCTL_H := \
-	$(shell [ -f $(SYSROOT)/include/sys/sysctl.h ] || \
-		[ -f $(SYSROOT)/include/$(MACHINE)/sys/sysctl.h ] \
-		&& echo "1")
+	$(shell echo '\#include <sys/sysctl.h>' | \
+		$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(HAVE_SYS_SYSCTL_H),)
 CFLAGS  += -DHAVE_SYS_SYSCTL_H
 endif
@@ -549,15 +549,17 @@
 CFLAGS  += -DHAVE_SELECT
 CFLAGS  += -DHAVE_IO_H
 else
-HAVE_SYSLOG  := $(shell [ -f $(SYSROOT)/include/syslog.h ] && echo "1")
-HAVE_DLFCN_H := $(shell [ -f $(SYSROOT)/include/dlfcn.h ] && echo "1")
+HAVE_SYSLOG  := $(shell echo '\#include <syslog.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
+HAVE_DLFCN_H := $(shell echo '\#include <dlfcn.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 ifneq ($(OS),darwin)
-HAVE_EPOLL   := $(shell [ -f $(SYSROOT)/include/sys/epoll.h ] || \
-			[ -f $(SYSROOT)/include/$(MACHINE)/sys/epoll.h ] \
-			&& echo "1")
+HAVE_EPOLL   := $(shell echo '\#include <sys/epoll.h>' | \
+			$(CC) -E - >/dev/null 2>&1 && echo "1")
 endif
 
-HAVE_RESOLV := $(shell [ -f $(SYSROOT)/include/resolv.h ] && echo "1")
+HAVE_RESOLV := $(shell echo '\#include <resolv.h>' | \
+	$(CC) -E - >/dev/null 2>&1 && echo "1")
 
 ifneq ($(HAVE_RESOLV),)
 CFLAGS  += -DHAVE_RESOLV
--- libre-0.5.9.orig/mk/re.mk
+++ libre-0.5.9/mk/re.mk
@@ -16,7 +16,6 @@
 #   OPT_SPEED      If non-empty, optimize for speed
 #   PROJECT        Project name
 #   RELEASE        Release build
-#   SYSROOT        System root of library and include files
 #   SYSROOT_ALT    Alternative system root of library and include files
 #   USE_OPENSSL    If non-empty, link to libssl library
 #   USE_ZLIB       If non-empty, link to libz library
@@ -47,11 +46,6 @@
 endif
 
 
-# Default system root
-ifeq ($(SYSROOT),)
-SYSROOT := /usr
-endif
-
 # Alternative Systemroot
 ifeq ($(SYSROOT_ALT),)
 SYSROOT_ALT := $(shell [ -d /sw/include ] && echo "/sw")
@@ -337,7 +331,6 @@
 	LIB_SUFFIX	:= .dll
 	MOD_SUFFIX	:= .dll
 	BIN_SUFFIX	:= .exe
-	SYSROOT		:= /usr/$(MACHINE)/
 endif
 
 CFLAGS	+= -DOS=\"$(OS)\"
@@ -687,7 +680,6 @@
 	@echo "  GCOV:          $(GCOV)"
 	@echo "  GPROF:         $(GPROF)"
 	@echo "  CROSS_COMPILE: $(CROSS_COMPILE)"
-	@echo "  SYSROOT:       $(SYSROOT)"
 	@echo "  SYSROOT_ALT:   $(SYSROOT_ALT)"
 	@echo "  LIB_SUFFIX:    $(LIB_SUFFIX)"
 	@echo "  MOD_SUFFIX:    $(MOD_SUFFIX)"
--- libre-0.5.9.orig/mk/re.mk
+++ libre-0.5.9/mk/re.mk
@@ -191,23 +191,10 @@
 # OS section
 #
 
-MACHINE   := $(shell $(CC) --print-multiarch)
-
 ifeq ($(CROSS_COMPILE),)
 OS        := $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 endif
 
-
-ifneq ($(strip $(filter i386-mingw32 i486-mingw32 i586-mingw32msvc \
-	i686-w64-mingw32 x86_64-w64-mingw32 mingw32, \
-	$(MACHINE))),)
-	OS   := win32
-ifeq ($(MACHINE), mingw32)
-	CROSS_COMPILE :=
-endif
-endif
-
-
 # default
 LIB_SUFFIX	:= .so
 MOD_SUFFIX	:= .so
@@ -326,7 +313,6 @@
 	APP_LFLAGS	+= -Wl,--export-all-symbols
 	AR		:= ar
 	AFLAGS		:= cru
-	CROSS_COMPILE	?= $(MACHINE)-
 	RANLIB		:= $(CROSS_COMPILE)ranlib
 	LIB_SUFFIX	:= .dll
 	MOD_SUFFIX	:= .dll
@@ -654,7 +640,6 @@
 	@echo "info - $(PROJECT) version $(VERSION)"
 	@echo "  MODULES:       $(MODULES)"
 #	@echo "  SRCS:          $(SRCS)"
-	@echo "  MACHINE:       $(MACHINE)"
 	@echo "  ARCH:          $(ARCH)"
 	@echo "  OS:            $(OS)"
 	@echo "  BUILD:         $(BUILD)"

Reply via email to