Author: vedge
Date: 2008-10-21 11:10:38 -0300 (Tue, 21 Oct 2008)
New Revision: 749
Modified:
trunk/BSDBuild/Core.pm
trunk/BSDBuild/cc.pm
Log:
autodetect executable suffix into $EXECSUFFIX
Modified: trunk/BSDBuild/Core.pm
===================================================================
--- trunk/BSDBuild/Core.pm 2008-10-21 08:30:37 UTC (rev 748)
+++ trunk/BSDBuild/Core.pm 2008-10-21 14:10:38 UTC (rev 749)
@@ -321,7 +321,7 @@
echo "\$$define" > \${cache}/ctest-$define
echo \$MK_COMPILE_STATUS > \${cache}/ctest-status-$define
fi
-rm -f \$testdir/conftest conftest.c
+rm -f conftest.c \$testdir/conftest\$EXECSUFFIX
EOF
}
@@ -358,7 +358,7 @@
echo "-> failed ($?)" >> config.log
MK_COMPILE_STATUS="FAIL($?)"
fi
-rm -f $testdir/conftest conftest.c
+rm -f conftest.c $testdir/conftest$EXECSUFFIX
EOF
MkIf('"${MK_COMPILE_STATUS}" = "OK"');
MkDefine($def, 'yes');
@@ -426,7 +426,7 @@
fi
EOF
MkIf('"${MK_COMPILE_STATUS}" = "OK"');
- print '(cd $testdir && ./conftest) >> config.log', "\n";
+ print '(cd $testdir && ./conftest$EXECSUFFIX) >> config.log',
"\n";
MkIf('"$?" = "0"');
MkPrint('yes');
MkSaveCompileSuccess($define);
@@ -446,7 +446,7 @@
echo \$MK_COMPILE_STATUS > \${cache}/ctest-status-$define
echo \$MK_RUN_STATUS > \${cache}/ctest-runstatus-$define
fi
-rm -f \$testdir/conftest conftest.c
+rm -f conftest.c \$testdir/conftest$EXECSUFFIX
EOF
}
@@ -483,7 +483,7 @@
fi
EOF
MkIf('"${MK_COMPILE_STATUS}" = "OK"');
- print '(cd $testdir && ./conftest) >> config.log', "\n";
+ print '(cd $testdir && ./conftest$EXECSUFFIX) >> config.log',
"\n";
MkIf('"$?" = "0"');
MkPrint('yes');
MkSaveCompileSuccess($define);
@@ -501,7 +501,7 @@
echo "\$$define" > \${cache}/cxxtest-$define
echo \$MK_COMPILE_STATUS > \${cache}/cxxtest-status-$define
fi
-rm -f \$testdir/conftest conftest.cpp
+rm -f conftest.cpp \$testdir/conftest\$EXECSUFFIX
EOF
}
@@ -545,7 +545,7 @@
echo "\$$define" > \${cache}/ctest-$define
echo \$MK_COMPILE_STATUS > \${cache}/ctest-status-$define
fi
-rm -f \$testdir/conftest conftest.c
+rm -f conftest.c \$testdir/conftest$EXECSUFFIX
EOF
}
@@ -588,7 +588,7 @@
echo "\$$define" > \${cache}/cxxtest-$define
echo \$MK_COMPILE_STATUS > \${cache}/cxxtest-status-$define
fi
-rm -f \$testdir/conftest conftest.cpp
+rm -f conftest.cpp \$testdir/conftest\$EXECSUFFIX
EOF
}
@@ -639,7 +639,7 @@
echo "\$$define" > \${cache}/ctest-$define
echo \$MK_COMPILE_STATUS > \${cache}/ctest-status-$define
fi
-rm -f \$testdir/conftest conftest.c
+rm -f conftest.c \$testdir/conftest\$EXECSUFFIX
EOF
}
@@ -689,7 +689,7 @@
echo "\$$define" > \${cache}/cxxtest-$define
echo \$MK_COMPILE_STATUS > \${cache}/cxxtest-status-$define
fi
-rm -f \$testdir/conftest conftest.cpp
+rm -f conftest.cpp \$testdir/conftest\$EXECSUFFIX
EOF
}
Modified: trunk/BSDBuild/cc.pm
===================================================================
--- trunk/BSDBuild/cc.pm 2008-10-21 08:30:37 UTC (rev 748)
+++ trunk/BSDBuild/cc.pm 2008-10-21 14:10:38 UTC (rev 749)
@@ -40,33 +40,53 @@
fi
done
if [ "$CC" = "" ]; then
- echo "Could not find a C compiler, try setting CC."
- echo "CC is unset and cc/gcc is not in PATH." >> config.log
+ echo "Unable to find a C compiler in PATH. Please set your
compiler"
+ echo "explicitely with the CC environment variable."
+ echo "Unable to find a C compiler in PATH." >> config.log
exit 1
fi
fi
-cat << 'EOT' > cc-test.c
-int
-main(int argc, char *argv[])
-{
- return (0);
-}
+cat << 'EOT' > conftest.c
+int main(int argc, char *argv[]) { return (0); }
EOT
-$CC -o cc-test cc-test.c 2>>config.log
+$CC -o conftest conftest.c 2>>config.log
if [ $? != 0 ]; then
echo "no"
- echo "The test C program failed to compile."
- rm -f cc-test cc-test.c
+ echo "Test C program (conftest.c) failed to compile."
+ echo "Test C program (conftest.c) failed to compile." >> config.log
exit 1
fi
+
+EXECSUFFIX=""
+for OUTFILE in conftest.exe conftest conftest.*; do
+ if [ -f $OUTFILE ]; then
+ case $OUTFILE in
+ *.c | *.o | *.obj | *.bb | *.bbg | *.d | *.pdb | *.tds |
*.xcoff | *.dSYM | *.xSYM )
+ ;;
+ *.* )
+ EXECSUFFIX=`expr "$OUTFILE" : '[^.]*\(\..*\)'`
+ break ;;
+ * )
+ break ;;
+ esac;
+ fi
+done
+if [ "$EXECSUFFIX" != "" ]; then
+ echo "Detected executable suffix: $EXECSUFFIX" >> config.log
+fi
+echo "EXECSUFFIX=$EXECSUFFIX" >> Makefile.config
+echo "#ifndef EXECSUFFIX" > config/execsuffix.h
+echo "#define EXECSUFFIX \"${EXECSUFFIX}\"" >> config/execsuffix.h
+echo "#endif /* EXECSUFFIX */" >> config/execsuffix.h
+
echo "yes"
-rm -f cc-test cc-test.c
+rm -f conftest.c conftest$EXECSUFFIX
TEST_CFLAGS=""
EOF
-
- MkPrintN('checking for compiler warnings...');
+
+ MkPrintN('checking for compiler warning options...');
MkCompileC('HAVE_CC_WARNINGS', '-Wall -Werror', '', << 'EOF');
int main(int argc, char *argv[]) { return (0); }
EOF
@@ -203,8 +223,11 @@
print << 'EOF';
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
if [ "${with_cygwin}" != "yes" ]; then
+ echo "* Disabling cygwin compatibility layer"
CFLAGS="$CFLAGS -mno-cygwin"
echo "CFLAGS=$CFLAGS" >> Makefile.config
+ else
+ echo "* Using cygwin compatibility layer"
fi
fi
EOF
_______________________________________________
BSDBuild-Commits mailing list
[email protected]
http://mail231.csoft.net/mailman/listinfo/bsdbuild-commits