From patchwork Tue Jan 2 18:13:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10141189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5F5396035E for ; Tue, 2 Jan 2018 18:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5213428DAA for ; Tue, 2 Jan 2018 18:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46F4028DAC; Tue, 2 Jan 2018 18:13:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5FE528DAA for ; Tue, 2 Jan 2018 18:13:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbeABSNs (ORCPT ); Tue, 2 Jan 2018 13:13:48 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:47620 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbeABSNp (ORCPT ); Tue, 2 Jan 2018 13:13:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1514918024; x=1546454024; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=EtuERCHIotHSqRwz5IMALAbZC9zK+iyRY5BFMrWBpA8=; b=HXTkW7QV7NMzbTnW1WgpGO8v+EUHx/qJ7+EhrkgsR0gldBCOgoIFfWZu NT+/p5L2ZQRdQcS8i6wP9nVAcAXmpAsd0NrLCixQtUK/PDXGjzZvECIZ/ rcekyWYhfP/J//bFlG1HLLBLIG0Pzc1NGmcfkZbgtbd0aG0DTNNy6FCv6 tz6sHlWoVeXngbd4VzOYO8wl/VIAaED6wAA16IUb4P7lxCYznEWRfmm8m 5aX6Mwcpg8OrDuaOq6gmm2W8FndU7dpXAdpOfyO9bIFY5VN4kJAnsPATW 0KJP82MTgAORUqKkgQAvw0qG3saYSI6MIjAajEq7VOVe5iU8/HQcG6Iff Q==; X-IronPort-AV: E=Sophos;i="5.45,498,1508774400"; d="scan'208";a="163812930" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Jan 2018 02:33:41 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 02 Jan 2018 10:09:53 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Jan 2018 10:13:42 -0800 From: Bart Van Assche To: Doug Gilbert Cc: Hannes Reinecke , Bean Huo , linux-scsi@vger.kernel.org, Bart Van Assche Subject: [PATCH for sg3_utils 3/4] configure.ac: Avoid code duplication Date: Tue, 2 Jan 2018 10:13:40 -0800 Message-Id: <20180102181341.13435-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180102181341.13435-1-bart.vanassche@wdc.com> References: <20180102181341.13435-1-bart.vanassche@wdc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that the code for checking the Linux NVMe headers occurs once. Signed-off-by: Bart Van Assche --- config.h.in | 2 +- configure | 124 ++++------------------------------------------------------- configure.ac | 45 ++++++---------------- 3 files changed, 21 insertions(+), 150 deletions(-) diff --git a/config.h.in b/config.h.in index b5c6715ade05..6050d85dfc1c 100644 --- a/config.h.in +++ b/config.h.in @@ -105,7 +105,7 @@ /* sg3_utils on FreeBSD */ #undef SG_LIB_FREEBSD -/* assume sg3_utils on linux */ +/* sg3_utils on linux */ #undef SG_LIB_LINUX /* also MinGW environment */ diff --git a/configure b/configure index 59b01f4fdf5b..ce82b6d23236 100755 --- a/configure +++ b/configure @@ -12418,18 +12418,8 @@ cat >>confdefs.h <<_ACEOF _ACEOF -case "${host}" in - *-*-linux-gnu*) - -cat >>confdefs.h <<_ACEOF -#define SG_LIB_LINUX 1 -_ACEOF - - os_cflags='' - - os_libs='' - - for ac_header in linux/nvme_ioctl.h +check_for_linux_nvme_headers() { + for ac_header in linux/nvme_ioctl.h do : ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default" if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then : @@ -12443,7 +12433,7 @@ fi done - for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h + for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H @@ -12459,48 +12449,10 @@ _ACEOF fi done - ;; - *-*-linux*) - -cat >>confdefs.h <<_ACEOF -#define SG_LIB_LINUX 1 -_ACEOF - - os_cflags='' - - os_libs='' - - for ac_header in linux/nvme_ioctl.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_NVME_IOCTL_H 1 -_ACEOF - -$as_echo "#define HAVE_NVME 1" >>confdefs.h - -fi - -done - - for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H - # include - #endif -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi +} -done - ;; +case "${host}" in *-*-android*) cat >>confdefs.h <<_ACEOF @@ -12516,37 +12468,7 @@ _ACEOF os_libs='' - for ac_header in linux/nvme_ioctl.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_NVME_IOCTL_H 1 -_ACEOF - -$as_echo "#define HAVE_NVME 1" >>confdefs.h - -fi - -done - - for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H - # include - #endif - -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - ;; + check_for_linux_nvme_headers;; *-*-freebsd*|*-*-kfreebsd*-gnu*) cat >>confdefs.h <<_ACEOF @@ -12605,7 +12527,7 @@ _ACEOF os_libs='' ;; - *) + *-*-linux-gnu* | *-*-linux* | *) cat >>confdefs.h <<_ACEOF #define SG_LIB_LINUX 1 @@ -12615,37 +12537,7 @@ _ACEOF os_libs='' - for ac_header in linux/nvme_ioctl.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "linux/nvme_ioctl.h" "ac_cv_header_linux_nvme_ioctl_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_nvme_ioctl_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_NVME_IOCTL_H 1 -_ACEOF - -$as_echo "#define HAVE_NVME 1" >>confdefs.h - -fi - -done - - for ac_header in linux/types.h linux/bsg.h linux/kdev_t.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_LINUX_TYPES_H - # include - #endif - -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - ;; + check_for_linux_nvme_headers;; esac # Define platform-specific symbol. diff --git a/configure.ac b/configure.ac index 6164850d0aa3..70cf98456339 100644 --- a/configure.ac +++ b/configure.ac @@ -39,41 +39,25 @@ AC_CANONICAL_HOST AC_DEFINE_UNQUOTED(SG_LIB_BUILD_HOST, "${host}", [sg3_utils Build Host]) -case "${host}" in - *-*-linux-gnu*) - AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux]) - AC_SUBST([os_cflags], ['']) - AC_SUBST([os_libs], ['']) - AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], []) - AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [], - [[#ifdef HAVE_LINUX_TYPES_H - # include - #endif - ]]) ;; - *-*-linux*) - AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux]) - AC_SUBST([os_cflags], ['']) - AC_SUBST([os_libs], ['']) - AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], []) - AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [], +check_for_linux_nvme_headers() { + AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], []) + AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [], [[#ifdef HAVE_LINUX_TYPES_H # include #endif - ]]) ;; + ]]) +} + +case "${host}" in *-*-android*) AC_DEFINE_UNQUOTED(SG_LIB_ANDROID, 1, [sg3_utils on android]) AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux]) AC_SUBST([os_cflags], ['']) AC_SUBST([os_libs], ['']) - AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], []) - AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [], - [[#ifdef HAVE_LINUX_TYPES_H - # include - #endif - ]]) ;; + check_for_linux_nvme_headers;; *-*-freebsd*|*-*-kfreebsd*-gnu*) AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sg3_utils on FreeBSD]) - AC_DEFINE(HAVE_NVME, 1, ['Found NVMe']) + AC_DEFINE(HAVE_NVME, 1, [Found NVMe]) AC_SUBST([os_cflags], ['']) AC_SUBST([os_libs], ['-lcam']);; *-*-solaris*) @@ -93,16 +77,11 @@ case "${host}" in AC_DEFINE_UNQUOTED(SG_LIB_MINGW, 1, [also MinGW environment]) AC_SUBST([os_cflags], ['']) AC_SUBST([os_libs], ['']) ;; - *) - AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [assume sg3_utils on linux]) + *-*-linux-gnu* | *-*-linux* | *) + AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sg3_utils on linux]) AC_SUBST([os_cflags], ['']) AC_SUBST([os_libs], ['']) - AC_CHECK_HEADERS([linux/nvme_ioctl.h], [AC_DEFINE(HAVE_NVME, 1, [Found NVMe])], [], []) - AC_CHECK_HEADERS([linux/types.h linux/bsg.h linux/kdev_t.h], [], [], - [[#ifdef HAVE_LINUX_TYPES_H - # include - #endif - ]]) ;; + check_for_linux_nvme_headers;; esac # Define platform-specific symbol.