]> git.cworth.org Git - fips/commitdiff
configure: Test whether compiler can create both 32 and 64-bit binaries
authorCarl Worth <cworth@cworth.org>
Fri, 14 Jun 2013 04:57:38 +0000 (21:57 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 14 Jun 2013 04:57:38 +0000 (21:57 -0700)
If not, tell the user and recommend installing gcc-multilib. Then simply
don't attempt to compile the unspoorted library.

Makefile.local
configure

index 123de57cef310a1cd6fde4bcf75b1793728dcf1e..179700ee8da9bceff4062acdf93eb00fc4ba7a6f 100644 (file)
@@ -8,8 +8,18 @@ FINAL_FIPS_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
 FINAL_LIBFIPS_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS) -ldl
 FINAL_FIPS_LINKER = CC
 
+ALL_TARGETS = fips
+
+ifeq ($(COMPILER_SUPPORTS_32),Yes)
+ALL_TARGETS += libfips-32.so
+endif
+
+ifeq ($(COMPILER_SUPPORTS_64),Yes)
+ALL_TARGETS += libfips-64.so
+endif
+
 .PHONY: all
-all: fips libfips-64.so libfips-32.so
+all: $(ALL_TARGETS)
 
 ifeq ($(MAKECMDGOALS),)
 ifeq ($(shell cat .first-build-message 2>/dev/null),)
index 679f543ed2f93cea6f4feb2fd37409be134f7c5f..c584c93a349ad7023f58f4112bc942d4d734c6f8 100755 (executable)
--- a/configure
+++ b/configure
@@ -345,6 +345,43 @@ printf "\t${WARN_CFLAGS}\n"
 
 rm -f minimal minimal.c
 
+printf "#include <features.h>\nint main(void){return 0;}\n" > arch-minimal.c
+
+printf "Checking for machine-dependent compiler support:\n"
+
+printf "       Compiler can create 32-bit binaries... "
+have_m32=Yes
+if ${CC} -m32 -o arch-minimal arch-minimal.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+else
+    printf "No.\n"
+    have_m32=No
+fi
+
+printf "       Compiler can create 64-bit binaries... "
+have_m64=Yes
+if ${CC} -m64 -o arch-minimal arch-minimal.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+else
+    printf "No.\n"
+    have_m64=No
+fi
+
+if [ "$have_m32" = "No" ] || [ "$have_m64" = "No" ]; then
+    cat <<EOF
+
+* Warning: Cannot create both 32 and 64-bit fips libraries. Fips will not
+           support applications of the non-native size. Fixing this may be
+           as simple as running a command such as:
+
+               sudo apt-get install gcc-multilib
+EOF
+fi
+
+rm -f arch-minimal arch-minimal.c
+
 if [ $errors -gt 0 ]; then
     cat <<EOF
 
@@ -474,6 +511,10 @@ mandir = ${MANDIR:=\$(prefix)/share/man}
 # The directory to which read-only (configuration) files should be installed
 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
 
+# Whether compiler can create 32 or 64-bit binaries
+COMPILER_SUPPORTS_32 = ${have_m32}
+COMPILER_SUPPORTS_64 = ${have_m64}
+
 # Flags needed to compile and link against talloc
 TALLOC_CFLAGS = ${talloc_cflags}
 TALLOC_LDFLAGS = ${talloc_ldflags}