From patchwork Tue Apr 23 16:04:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 1098 Return-Path: Received: from mail.micronovasrl.com (mail.micronovasrl.com [212.103.203.10]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9643660004 for ; Tue, 23 Apr 2019 18:04:50 +0200 (CEST) Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 4AC90B00C38 for ; Tue, 23 Apr 2019 18:04:50 +0200 (CEST) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=x-mailer:message-id:date:date:subject:subject:to:from:from; s=dkim; t=1556035489; x=1556899490; bh=4WBbbeE/OiJ7BsdHib94EyxJ UF49GbEq1eeC0xagwqY=; b=fnuhKZFQF+OQbKwbJnhqTrqIk+KpTONdxWKl5kFA epfwxqPuCrZzXZjc0yL3QYDwsa2bY/KtmJlwXs1omjO/wtN8kYMBdSNFMmwFByO3 PiGwClFsIXl5pPdbxbwkdDU4gR75Mn35FVlygPfEhtQVFq8cC2u2AK7OjpghJ8i6 xok= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-10 required=4.5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham autolearn_force=no Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xd61gAVfjUVI for ; Tue, 23 Apr 2019 18:04:49 +0200 (CEST) Received: from ubuntu.localdomain (88-149-228-83.v4.ngi.it [88.149.228.83]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 8838DB00AA1; Tue, 23 Apr 2019 18:04:49 +0200 (CEST) From: Giulio Benetti To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Apr 2019 18:04:48 +0200 Message-Id: <20190423160448.116834-1-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.1 Subject: [libcamera-devel] [PATCH] meson: fix build when sys/auxv.h and getauxval() are not present X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Apr 2019 16:04:50 -0000 On some libc sys/auxv.h could not be present and getauxval() too. This way build will fail. Check in meson if they are present and add HAVE_SYS_AUXV_H and HAVE_GETAUXVAL defines to cxx arguments. Add #ifdef HAVE_ statements around #include and getauxval() in utils.cpp. Signed-off-by: Giulio Benetti --- meson.build | 12 ++++++++++++ src/libcamera/utils.cpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/meson.build b/meson.build index 6e68c3e..72a3652 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,18 @@ common_arguments = [ c_arguments = common_arguments cpp_arguments = common_arguments +cxx = meson.get_compiler('cpp') + +# check for header sys/auxv.h +if cxx.has_header('sys/auxv.h') + cpp_arguments += ['-DHAVE_SYS_AUXV_H'] +endif + +# check for function getauxval() +if cxx.has_function('getauxval') + cpp_arguments += ['-DHAVE_GETAUXVAL'] +endif + add_project_arguments(c_arguments, language: 'c') add_project_arguments(cpp_arguments, language: 'cpp') diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 66123b1..ae574ab 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -8,7 +8,9 @@ #include "utils.h" #include +#ifdef HAVE_SYS_AUXV_H #include +#endif /** * \file utils.h @@ -57,8 +59,10 @@ const char *basename(const char *path) */ char *secure_getenv(const char *name) { +#ifdef HAVE_GETAUXVAL if (getauxval(AT_SECURE)) return NULL; +#endif return getenv(name); }