mirror of
https://github.com/frida/tinycc
synced 2024-12-24 22:16:49 +03:00
Create config-print program to test $cc
Create a helper program called config-print to print informations relative to the BUILD/HOST environment in the case of native compilation.
This commit is contained in:
parent
a4cbd9b002
commit
e298f60838
35
config-print.c
Normal file
35
config-print.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
switch(argc == 2 ? argv[1][0] : 0) {
|
||||
case 'v':
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
puts("4");
|
||||
# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
|
||||
puts("3");
|
||||
# else
|
||||
puts("2");
|
||||
# endif
|
||||
#else
|
||||
puts("0");
|
||||
#endif
|
||||
break;
|
||||
case 'm':
|
||||
#ifdef __GNUC__
|
||||
printf("%d\n", __GNUC_MINOR__);
|
||||
#else
|
||||
puts("-1");
|
||||
#endif
|
||||
break;
|
||||
case 'e':
|
||||
{
|
||||
volatile uint32_t i=0x01234567;
|
||||
if ((*((uint8_t*)(&i))) == 0x67)
|
||||
puts("yes");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
52
configure
vendored
52
configure
vendored
@ -22,10 +22,7 @@ fi
|
||||
# bashism: TMPN="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.c"
|
||||
TMPN="./conftest-$$"
|
||||
|
||||
TMPC=$TMPN.c
|
||||
TMPH=$TMPN.h
|
||||
TMPO=$TMPN.o
|
||||
TMPE=$TMPN
|
||||
|
||||
# default parameters
|
||||
build_cross="no"
|
||||
@ -206,20 +203,11 @@ fi
|
||||
|
||||
if test -z "$cross_prefix" ; then
|
||||
|
||||
# ---
|
||||
# big/little endian test
|
||||
cat > $TMPC << EOF
|
||||
#include <inttypes.h>
|
||||
int main(int argc, char ** argv){
|
||||
volatile uint32_t i=0x01234567;
|
||||
return (*((uint8_t*)(&i))) == 0x67;
|
||||
}
|
||||
EOF
|
||||
|
||||
if $cc -o $TMPE $TMPC 2>/dev/null ; then
|
||||
$TMPE && bigendian="yes"
|
||||
if ! $cc -o config-print config-print.c 2>/dev/null ; then
|
||||
echo "$cc is not able to compile TCC"
|
||||
else
|
||||
echo big/little test failed
|
||||
bigendian="$(./config-print e)"
|
||||
gcc_major="$(./config-print v)"
|
||||
fi
|
||||
|
||||
else
|
||||
@ -231,37 +219,8 @@ esac
|
||||
|
||||
fi
|
||||
|
||||
# check gcc version
|
||||
cat > $TMPC <<EOF
|
||||
int main(void) {
|
||||
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
|
||||
return 0;
|
||||
#else
|
||||
#error gcc < 3.2
|
||||
#endif
|
||||
}
|
||||
EOF
|
||||
|
||||
gcc_major="2"
|
||||
if $cc -o $TMPO $TMPC 2> /dev/null ; then
|
||||
gcc_major="3"
|
||||
fi
|
||||
cat > $TMPC <<EOF
|
||||
int main(void) {
|
||||
#if __GNUC__ >= 4
|
||||
return 0;
|
||||
#else
|
||||
#error gcc < 4
|
||||
#endif
|
||||
}
|
||||
EOF
|
||||
|
||||
if $cc -o $TMPO $TMPC 2> /dev/null ; then
|
||||
gcc_major="4"
|
||||
fi
|
||||
|
||||
if test -z "$cross_prefix" ; then
|
||||
libc_dir="$(ldd $TMPO | grep libc.so | sed 's|[^/]*/\(.*/\)[^/]*|\1|')"
|
||||
libc_dir="$(ldd ./config-print | grep libc.so | sed 's|[^/]*/\(.*/\)[^/]*|\1|')"
|
||||
multiarch_triplet=${libc_dir#*/}
|
||||
multiarch_triplet=${multiarch_triplet%/}
|
||||
lddir="${libc_dir%%/*}"
|
||||
@ -269,6 +228,7 @@ if test -z "$cross_prefix" ; then
|
||||
lddir="$lddir/$multiarch_triplet"
|
||||
fi
|
||||
fi
|
||||
rm config-print
|
||||
|
||||
if test x"$show_help" = "xyes" ; then
|
||||
cat << EOF
|
||||
|
Loading…
Reference in New Issue
Block a user