configure: pass CONFIG_xxxDIR/PATH options via commandline
authorgrischka <grischka>
Thu, 14 Feb 2013 16:43:24 +0000 (14 17:43 +0100)
committergrischka <grischka>
Thu, 14 Feb 2013 16:43:24 +0000 (14 17:43 +0100)
- except for CONFIG_SYSROOT and CONFIG_TCCDIR

Strictly neccessary it is only for CONFIG_MULTIARCHDIR
because otherwise if it's in config.h it is impossible to
leave it undefined.

But it is also nicer not to use these definitions for
cross-compilers.

- Also:
lib/Makefile : include ../Makefile for CFLAGS
lib/libtcc1.c : fix an issue compiling tcc with tcc on x64

Makefile
configure
lib/Makefile
lib/libtcc1.c
tcc.c
tcc.h

index 21632fc..1750a40 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,13 +42,13 @@ endif
 endif
 
 ifeq ($(ARCH),i386)
-NATIVE_DEFINES=-DTCC_TARGET_I386
+NATIVE_DEFINES+=-DTCC_TARGET_I386
 else ifeq ($(ARCH),x86-64)
-NATIVE_DEFINES=-DTCC_TARGET_X86_64
+NATIVE_DEFINES+=-DTCC_TARGET_X86_64
 endif
 
 ifeq ($(ARCH),arm)
-NATIVE_DEFINES=-DTCC_TARGET_ARM
+NATIVE_DEFINES+=-DTCC_TARGET_ARM
 NATIVE_DEFINES+=-DWITHOUT_LIBTCC
 ifneq (,$(wildcard /lib/ld-linux-armhf.so.3 /lib/arm-linux-gnueabihf/ld-linux.so.3))
 NATIVE_DEFINES+=-DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
index 22fbfbe..8e6782c 100755 (executable)
--- a/configure
+++ b/configure
@@ -304,15 +304,6 @@ if test -z "$cross_prefix" ; then
         tcc_lddir="lib64"
       fi
 
-# gr: FIXME
-#  ldd $CONFTEST gives (ubuntu 8)
-#        linux-gate.so.1 =>  (0xb7fc3000)
-#        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e37000)
-#       /lib/ld-linux.so.2 (0xb7fa9000)
-#  result is crap:
-#        CONFIG_LDDIR="lib/tls/i686/cmov"
-#        CONFIG_MUADIR="tls/i686/cmov"
-#
 #      multiarch_triplet=${libc_dir#*/}
 #      multiarch_triplet=${multiarch_triplet%/}
 #      tcc_lddir="${libc_dir%%/*}"
@@ -321,8 +312,8 @@ if test -z "$cross_prefix" ; then
 #      fi
 
 # gr: maybe for after the release:
-#      tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
-#      #echo "elfinterp           $tcc_elfinterp"
+#       tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
+       # echo "elfinterp           $tcc_elfinterp"
 
     fi
   fi
@@ -333,18 +324,6 @@ else
   esac
 fi
 
-# gr: maybe for after the release:
-# run compiler to see if it supports FLAG, if yes add to CFLAGS
-#cc_option() {
-#  if $cc $CFLAGS $1 -S -o /dev/null -xc conftest.c >/dev/null 2>&1; then
-#    CFLAGS="$CFLAGS $1"; else if test -n "$2"; then
-#      CFLAGS="$CFLAGS $2"; fi; fi
-#}
-#cc_option -fno-strict-aliasing
-#cc_option -Wno-pointer-sign
-#cc_option -Wno-sign-compare
-#cc_option -Wno-unused-result -D_FORTIFY_SOURCE=0
-
 cat <<EOF
 Binary  directory   $bindir
 TinyCC directory    $tccdir
@@ -389,24 +368,29 @@ LIBSUF=$LIBSUF
 EXESUF=$EXESUF
 EOF
 
-print_def() {
+print_inc() {
   if test -n "$2"; then
     echo "#ifndef $1" >> $TMPH
     echo "# define $1 \"$2\"" >> $TMPH
     echo "#endif" >> $TMPH
   fi
 }
+print_mak() {
+  if test -n "$2"; then
+    echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
+  fi
+}
 
 echo "/* Automatically generated by configure - do not modify */" > $TMPH
 
-print_def CONFIG_SYSROOT "$sysroot"
-print_def CONFIG_TCCDIR "$tccdir"
-print_def CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
-print_def CONFIG_TCC_LIBPATHS "$tcc_libpaths"
-print_def CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
-print_def CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
-print_def CONFIG_MULTIARCHDIR "$multiarch_triplet"
-print_def CONFIG_LDDIR "$tcc_lddir"
+print_inc CONFIG_SYSROOT "$sysroot"
+print_inc CONFIG_TCCDIR "$tccdir"
+print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
+print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths"
+print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
+print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
+print_mak CONFIG_LDDIR "$tcc_lddir"
+print_mak CONFIG_MULTIARCHDIR "$multiarch_triplet"
 
 echo "#define GCC_MAJOR $gcc_major" >> $TMPH
 echo "#define GCC_MINOR $gcc_minor" >> $TMPH
index e125f2c..dfac0f8 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 TOP = ..
-include $(TOP)/config.mak
+include $(TOP)/Makefile
 VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
 
 ifndef TARGET
@@ -91,7 +91,7 @@ $(DIR)/%.o : %.c
 $(DIR)/%.o : %.S
        $(XCC) -c $< -o $@ $(XFLAGS)
 $(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
-       $(CC) -Os -s -o $@ $< $(XFLAGS) $(LDFLAGS)
+       $(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)
 
 $(OBJ) $(XAR) : $(DIR)/exists
 $(DIR)/exists :
index 946c6c8..6964cd1 100644 (file)
@@ -609,8 +609,11 @@ unsigned long long __fixunsxfdi (long double a1)
 
 /* helper functions for stdarg.h */
 
-#include <stdio.h>
 #include <stdlib.h>
+#ifndef __TINYC__
+/* gives "incompatible types for redefinition of __va_arg" below */
+#include <stdio.h>
+#endif
 
 enum __va_arg_type {
     __va_gen_reg, __va_float_reg, __va_stack
@@ -665,7 +668,9 @@ void *__va_arg(struct __va_list_struct *ap,
         return ap->overflow_arg_area - size;
 
     default:
+#ifndef __TINYC__
         fprintf(stderr, "unknown ABI type for __va_arg\n");
+#endif
         abort();
     }
 }
diff --git a/tcc.c b/tcc.c
index 7c1b133..cd306b0 100644 (file)
--- a/tcc.c
+++ b/tcc.c
@@ -223,6 +223,7 @@ static void display_info(TCCState *s, int what)
         print_paths("crt", s->crt_paths, s->nb_crt_paths);
         print_paths("libraries", s->library_paths, s->nb_library_paths);
         print_paths("include", s->sysinclude_paths, s->nb_sysinclude_paths);
+        printf("elfinterp:\n  %s\n",  CONFIG_TCC_ELFINTERP);
         break;
     }
 }
diff --git a/tcc.h b/tcc.h
index 638540a..1f0343e 100644 (file)
--- a/tcc.h
+++ b/tcc.h
 #  define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
 # elif defined(TCC_UCLIBC)
 #  define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0"
+# elif defined(TCC_TARGET_PE)
+#  define CONFIG_TCC_ELFINTERP "-"
 # else
 #  define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
 # endif