From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 111574A09A for ; Tue, 19 Mar 2024 18:58:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E334668D40C; Tue, 19 Mar 2024 20:58:23 +0200 (EET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D84FC68C0A2 for ; Tue, 19 Mar 2024 20:58:17 +0200 (EET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dffa5e3f2dso20461745ad.2 for ; Tue, 19 Mar 2024 11:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710874695; x=1711479495; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=avWlACgMaNpc7Upg92wFZtBlAM8PcdyGhrX0W9xFPag=; b=Yq95U5PRYTVJABnq7bX2KW1VAEv7dIKmqzGD4FJ9wgUnWpcwleFgcwODLoPEFNr8np ADqrmLkrB92u+DfLvngC0fi5m9xmf3pyVfQ/HDJJ0cCjqqoLZ6bUO42+3g6O5zoUBdA7 wm+gVkztciVoM6CRvQqB/x0+o3W1qdOcmyIk+r3OIoy/PNoKRCi8buk/Q1tj1ok8JvGj M8So69dvryN8LB4sSA1qh6MUDfzFT0lj+9q04Z7LLlahSp8+YKdd1JEauEvwaCmeXZym x+0aZmBTuLNggK6NO5UssuHjgl0w7JAtMwFIQ8nPKZMYEYX0RvWEfqlrHErIosZDbuyU qZcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710874695; x=1711479495; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=avWlACgMaNpc7Upg92wFZtBlAM8PcdyGhrX0W9xFPag=; b=bHIplhaQIx15T2msu+F/UZboWGKS1ic4Ll+PQU+IuLO+GizYjH9TZLOKE51cqH4VR8 nJUXTMYbgx6shN6ApQwhmyndHG5I6Qk0XAclSUxOiFIKkd06CXNnGKChBiu+TIX4HCT3 oevKtZRgwsn44HJg3p/grno6ZGR6l82/NGyEMrLvvWHjo3EcjthCkpxyJvRJRpHc9wfe Q9872iwxtiaVIlXhPLZNTFigtJ/Vn5AQS8Swp5MjcS7qejqkW+H3DewpDC6empsRppZ1 5xVj7c7f847JrVSVHx6QmwKfQ+TUZJO6GHL78nMqXMN75/3jn+NNh4+7pkNwTHgIEUBh NzUA== X-Gm-Message-State: AOJu0Yxrr9HRZisMilIjjLfMUiGlUr5IEPFMjTVFq4E7nje7Own7aqRT 6mkWyDE/IGvr8Buqr6P4XXEa9BjWM/4GACOCrKgCYcUiBoc6CdbGFEbnzVdP X-Google-Smtp-Source: AGHT+IF1CkMN3G+upwicU3+nZjRnGLl0C8X4bzvju54tAPku6rgSiWuR6ob289BvCtf3szcJD0ZrRA== X-Received: by 2002:a17:90a:ff91:b0:29f:db93:68b4 with SMTP id hf17-20020a17090aff9100b0029fdb9368b4mr2033488pjb.47.1710874694796; Tue, 19 Mar 2024 11:58:14 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id sy12-20020a17090b2d0c00b0029c7a11ebddsm10170708pjb.16.2024.03.19.11.58.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 11:58:14 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 19 Mar 2024 15:58:17 -0300 Message-ID: <20240319185818.25400-1-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] configure: make the C and C++ standard settable X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fallback to C11, the minimum supported version, if the requested standard is not supported by the compliler. Also, enforce C11 on the host compiler, same as we already do for C11 on the target compiler. Signed-off-by: James Almer --- configure | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/configure b/configure index e019d1b996..b10d081549 100755 --- a/configure +++ b/configure @@ -387,7 +387,9 @@ Toolchain options: --windres=WINDRES use windows resource compiler WINDRES [$windres_default] --x86asmexe=EXE use nasm-compatible assembler EXE [$x86asmexe_default] --cc=CC use C compiler CC [$cc_default] + --stdc=STDC use C standard STDC [$stdc_default] --cxx=CXX use C compiler CXX [$cxx_default] + --stdcxx=STDCXX use C standard STDCXX [$stdcxx_default] --objcc=OCC use ObjC compiler OCC [$cc_default] --dep-cc=DEPCC use dependency generator DEPCC [$cc_default] --nvcc=NVCC use Nvidia CUDA compiler NVCC or clang [$nvcc_default] @@ -1454,6 +1456,21 @@ test_cflags_cc(){ EOF } +test_cxxflags_cc(){ + log test_cxxflags_cc "$@" + flags=$1 + header=$2 + condition=$3 + shift 3 + set -- $($cflags_filter "$flags") + test_cxx "$@" < +#if !($condition) +#error "unsatisfied condition: $condition" +#endif +EOF +} + check_lib(){ log check_lib "$@" name="$1" @@ -1695,6 +1712,21 @@ int x; EOF } +test_host_cflags_cc(){ + log test_host_cflags_cc "$@" + flags=$1 + header=$2 + condition=$3 + shift 3 + set -- $($host_cflags_filter "$flags") + test_host_cc "$@" < +#if !($condition) +#error "unsatisfied condition: $condition" +#endif +EOF +} + test_host_cpp_condition(){ log test_host_cpp_condition "$@" header=$1 @@ -3980,6 +4012,8 @@ mandir_default='${prefix}/share/man' # toolchain ar_default="ar" cc_default="gcc" +stdc_default="c11" +stdcxx_default="c++11" cxx_default="g++" host_cc_default="gcc" doxygen_default="doxygen" @@ -4587,7 +4621,7 @@ if enabled cuda_nvcc; then fi set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \ - target_exec x86asmexe metalcc metallib + target_exec x86asmexe metalcc metallib stdc stdcxx enabled cross_compile || host_cc_default=$cc set_default host_cc @@ -4757,7 +4791,7 @@ icl_flags(){ # Despite what Intel's documentation says -Wall, which is supported # on Windows, does enable remarks so disable them here. -Wall) echo $flag -Qdiag-disable:remark ;; - -std=c11) echo -Qstd=c11 ;; + -std=$stdc) echo -Qstd=$stdc ;; -flto*) echo -ipo ;; esac done @@ -4805,7 +4839,7 @@ suncc_flags(){ athlon*) echo -xarch=pentium_proa ;; esac ;; - -std=c11) echo -xc11 ;; + -std=$stdc) echo -x$stdc ;; -fomit-frame-pointer) echo -xregs=frameptr ;; -fPIC) echo -KPIC -xcode=pic32 ;; -W*,*) echo $flag ;; @@ -4894,8 +4928,8 @@ probe_cc(){ _type=suncc _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-) _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)' - _DEPFLAGS='-xM1 -xc11' - _ldflags='-std=c11' + _DEPFLAGS='-xM1 -x$stdc' + _ldflags='-std=$stdc' _cflags_speed='-O5' _cflags_size='-O5 -xspace' _flags_filter=suncc_flags @@ -5526,18 +5560,21 @@ fi add_cppflags -D_ISOC11_SOURCE add_cxxflags -D__STDC_CONSTANT_MACROS -check_cxxflags -std=c++11 || check_cxxflags -std=c++0x +test_cxxflags_cc -std=$stdcxx ctype.h "__cplusplus >= 201103L" && + add_cxxflags -std=$stdcxx || { check_cxxflags -std=c++11 || check_cxxflags -std=c++0x; } # some compilers silently accept -std=c11, so we also need to check that the # version macro is defined properly -test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" && - add_cflags -std=c11 || die "Compiler lacks C11 support" +test_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" && + add_cflags -std=$stdc || die "Compiler lacks C11 support" check_cppflags -D_FILE_OFFSET_BITS=64 check_cppflags -D_LARGEFILE_SOURCE add_host_cppflags -D_ISOC11_SOURCE -check_host_cflags -std=c11 +test_host_cflags_cc -std=$stdc ctype.h "__STDC_VERSION__ >= 201112L" && + add_host_cflags -std=$stdc || die "Host compiler lacks C11 support" + check_host_cflags -Wall check_host_cflags $host_cflags_speed -- 2.44.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".