Bug 60290

Summary: rules.mk defeats CC for configure
Product: Tomcat Native Reporter: Michael Osipov <michaelo>
Component: LibraryAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 1.2.10   
Target Milestone: ---   
Hardware: HP   
OS: HP-UX   

Description Michael Osipov 2016-10-21 12:17:02 UTC
Note: I have selected HP-UX because my problem is on HP-UX but this is probably the case on all Unix platforms with different compilers.

My configuration:

tcnative 1.2.10:
$ uname -a
HP-UX blnn724x B.11.31 U ia64 HP-UX
$ export CC=/opt/aCC/bin/aCC
$ $CC --version
aCC: HP C/aC++ B3910B A.06.25.01 [May 17 2010]

$ ./build/buildcheck.sh
buildconf: checking installation...
buildconf: python version 2.7.12 (ok)
buildconf: autoconf version 2.69 (ok)
buildconf: libtool version 2.4.6 (ok)

$ /usr/local/apr/bin/apr-1-config --version
1.5.1

$./configure --with-ssl=/opt/openssl --with-apr=/usr/local/apr --with-java-home=/opt/java8 --prefix=/tmp/tcnative --libdir=/tmp/tcnative/lib/hpux32

$ gmake
gmake[1]: Entering directory '/tmp/tomcat-native-1.2.10-src/native'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile cc -Ae +Z -mt  -O -I/usr/local/include -I/usr/contrib/X11R6/include -DHAVE_CONFIG_H  -DHPUX11 -D_REENTRANT -D_HPUX_SOURCE -D_LARGEFILE64_SOURCE  -O -I/usr/local/include -I/usr/contrib/X11R6/include -g -DHAVE_OPENSSL -I/tmp/tomcat-native-1.2.10-src/native/include -I/opt/java8/include -I/opt/java8/include/hpux -I/opt/openssl/include  -I/usr/local/apr/include/apr-1   -o src/address.lo -c src/address.c && touch src/address.lo
(Bundled) cc: warning 922: "-Ae" is unsupported in the bundled compiler, ignored.
(Bundled) cc: warning 922: "-O" is unsupported in the bundled compiler, ignored.
(Bundled) cc: warning 922: "-O" is unsupported in the bundled compiler, ignored.
(Bundled) cc: warning 922: "-g" is unsupported in the bundled compiler, ignored.
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile cc -Ae +Z -mt  -O -I/usr/local/include -I/usr/contrib/X11R6/include -DHAVE_CONFIG_H  -DHPUX11 -D_REENTRANT -D_HPUX_SOURCE -D_LARGEFILE64_SOURCE  -O -I/usr/local/include -I/usr/contrib/X11R6/include -g -DHAVE_OPENSSL -I/tmp/tomcat-native-1.2.10-src/native/include -I/opt/java8/include -I/opt/java8/include/hpux -I/opt/openssl/include  -I/usr/local/apr/include/apr-1   -o src/bb.lo -c src/bb.c && touch src/bb.lo
(Bundled) cc: warning 922: "-Ae" is unsupported in the bundled compiler, ignored.
(Bundled) cc: warning 922: "-O" is unsupported in the bundled compiler, ignored.
(Bundled) cc: warning 922: "-O" is unsupported in the bundled compiler, ignored.
(Bundled) cc: warning 922: "-g" is unsupported in the bundled compiler, ignored.
ed) cc: warning 922: "-g" is unsupported in the bundled compiler, ignored.
...

As you can see, my CC is completely ignored and cc (bundled) is used by default. APR has been obtained from the HP-UX Porting Archive [1].
The reason for this is the apr-rules.mk copied to build/rules.mk which has CC=cc statically set defeats the CC set for configure.

A possible fix is to store CC in CC_OLD, run AC_SUBST(INCLUDE_RULES) and compare both variables. Similar to APR_SETIFNULL.


[1] http://hpux.connect.org.uk/hppd/hpux/Development/Libraries/apr-1.5.2/
Comment 1 Michael Osipov 2016-10-24 13:03:15 UTC
After further investigation this must be handled in Makefile.in. A simple fix:

Index: Makefile.in
===================================================================
--- Makefile.in (Revision 1766400)
+++ Makefile.in (Arbeitskopie)
@@ -21,6 +21,7 @@

 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
+CC_OLD = @CC@

 # gets substituted into some targets
 TCNATIVE_MAJOR_VERSION=@TCNATIVE_MAJOR_VERSION@
@@ -47,6 +48,10 @@
 @INCLUDE_RULES@
 @INCLUDE_OUTPUTS@

+ifneq ($(CC_OLD),$(CC))
+       CC=$(CC_OLD)
+endif
+
 LINK          = $(LIBTOOL) $(LTFLAGS) --mode=link $(LT_LDFLAGS) $(COMPILE) -version-info $(TCNATIVE_LIBTOOL_VERSION) $(ALL_LDFLAGS) -o $@
 CLEAN_SUBDIRS = test
Comment 2 Mark Thomas 2017-08-23 17:45:42 UTC
Thanks for the patch. This has been fixed for 1.2.13 onwards.