From: Tommi Rantala Subject: [PATCH 7/9] Check headers with the compiler in configure.sh Date: Mon, 1 Apr 2013 21:58:37 +0300 Message-ID: <1364842720-24127-7-git-send-email-tt.rantala@gmail.com> References: <1364842720-24127-1-git-send-email-tt.rantala@gmail.com> Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=VMXj2C/9Oc06PpSr4+sXOyBY4HZhAXlqseSq3G7Sqmg=; b=d1ZES3u6QJ8QspN9L0aFrxSPCVNBTBeX83WLrg1feK85Ae6QTTUe+x/AmcByHwM/4R 1zbBqyQwbVVKwXg32r2sxIiBIXYnvavecmMCgk6Dc9cBb+0ZM9/8lCvIEBBka2+ET1nq Iwwri2J3aeZg1itgfMCjnYDh9mcVv5zZcguCf3eGYGQXU3muNW7SbErw+7zfgeEEUAcD HhP0RTc3VucZ5choXhi8jqADKOD7aXt1/9PEXqdXjw2NJXA6b9MUwVhubS+cRQIw+wnq ZT4ArU93/0XPXFDjVqs5YOEYAt7YPFvE5WDwawldxzASSlPn4Kjn0bSDn6/IaB9+T15Q ejzA== In-Reply-To: <1364842720-24127-1-git-send-email-tt.rantala@gmail.com> Sender: trinity-owner@vger.kernel.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: davej@redhat.com, trinity@vger.kernel.org Cc: Tommi Rantala To allow for proper cross compilation support, pass the headers to the compiler to see if they are available. Checking the return value from the pre-processing (-E) seems to do the trick. --- configure.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/configure.sh b/configure.sh index 98b740d..f5f6fc9 100755 --- a/configure.sh +++ b/configure.sh @@ -12,10 +12,15 @@ echo "/* This file is auto-generated by configure.sh */" > config.h TMP=$(mktemp) -file_exists() +check_header() { - echo -n "[*] Checking $1 exists... " - if [ -f /usr/include/$1 ]; then + echo -n "[*] Checking header $1 ... " + + rm -f "$TMP" || exit 1 + echo "#include <$1>" >"$TMP.c" + + ${CC} "$TMP.c" -E &>"$TMP.log" + if [ $? -eq 0 ]; then echo $GREEN "[YES]" $COL_RESET echo "#define $2 1" >> config.h else @@ -170,15 +175,15 @@ fi ############################################################################################# -file_exists linux/caif/caif_socket.h USE_CAIF -file_exists linux/if_alg.h USE_IF_ALG -file_exists linux/rds.h USE_RDS -file_exists linux/vfio.h USE_VFIO -file_exists linux/btrfs.h USE_BTRFS -file_exists drm/drm.h USE_DRM -file_exists drm/exynos_drm.h USE_DRM_EXYNOS -file_exists sound/compress_offload.h USE_SNDDRV_COMPRESS_OFFLOAD -file_exists linux/vhost.h USE_VHOST +check_header linux/caif/caif_socket.h USE_CAIF +check_header linux/if_alg.h USE_IF_ALG +check_header linux/rds.h USE_RDS +check_header linux/vfio.h USE_VFIO +check_header linux/btrfs.h USE_BTRFS +check_header drm/drm.h USE_DRM +check_header drm/exynos_drm.h USE_DRM_EXYNOS +check_header sound/compress_offload.h USE_SNDDRV_COMPRESS_OFFLOAD +check_header linux/vhost.h USE_VHOST rm -f "$TMP" "$TMP.log" "$TMP.c" -- 1.7.9.5