From owner-freebsd-ports@freebsd.org Tue Oct 13 18:35:02 2015 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF029A12ADF for ; Tue, 13 Oct 2015 18:35:02 +0000 (UTC) (envelope-from papowell@astart.com) Received: from astart2.astart.com (wsip-72-214-30-30.sd.sd.cox.net [72.214.30.30]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0E621F7C for ; Tue, 13 Oct 2015 18:35:01 +0000 (UTC) (envelope-from papowell@astart.com) Received: from laptop_93.private (localhost [127.0.0.1]) by astart2.astart.com (8.14.9/8.14.9) with ESMTP id t9DIDBee003139 for ; Tue, 13 Oct 2015 11:13:11 -0700 (PDT) (envelope-from papowell@astart.com) Message-ID: <561D49B7.9070900@astart.com> Date: Tue, 13 Oct 2015 11:13:11 -0700 From: Patrick Powell Reply-To: papowell@astart.com Organization: Astart Technologies User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: FreeBSD Ports ML Subject: 9.3 to 10.2 migration, determining if clang is used Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2015 18:35:03 -0000 I just started doing a 9.3 to 10.2 migration of a bunch of applications and discovered that some of the options used to generate the applications were slightly different. I just know that this has been covered before, but I could not find a definitive method or set of methods to use to determine if the old GCC compiler or the new CLANG compiler is being used. Could the ports wizards (and/or autoconf experts) help me a bit? (Aside: the clang compiler diagnostics and warnings are very thorough and quite clear. Nicely done, especially the addition of the information about the flag to turn this warning off. I also like the pragmas to control warnings and the push/pop pragma facility. This may have been in the GCC compiler but I missed it.) 1. If the application is to be generated via the PORT infrastructure, what do you put in the port Makefile to determine if CLANG (10.2) or GCC (9.3) is being used? Something like below. Note: the examples below are a bit contrived, but the idea is to set some MAKE variable to different values depending on CLANG or GCC in use. .if defined(CC_IS_CLANG) MYFLAGS+= -Wall -Werror -Wno-error=unused .else .if defined(CC_IS_GCC) MYFLAGS+= -Wall -Werror -Wno-unused .endif .endif 2. A simple test for configure that checks the for the CLANG compiler: # Check for programs AC_PROG_CC # we may need to add this to the configure macro set? AC_PROG_CLANG if test "$ac_cv_using_clang" = yes; then CFLAGS="$CFLAGS -Wall -Werror -Wno-error=unused" else if test "$ac_cv_c_compiler_gnu" = yes; then CFLAGS="$CFLAGS -Wall -Werror -Wno-unused" fi; fi; It could even be something simpler if the AC_PROG_CC configure macro sets, for example, the $ac_gcc_version shell variable with a value that indicates CLANG in use then the following would be useful: if test "$ac_gcc_version" -gt 999 ; then ... fi; -- Patrick Powell Astart Technologies papowell@astart.com 1530 Jamacha Rd, Suite X Network and System San Diego, CA 92019 Consulting 858-874-6543 FAX 858-751-2435 Web: www.astart.com