aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure159
-rw-r--r--libtcc.c24
-rw-r--r--tcc.h34
-rw-r--r--tccelf.c10
4 files changed, 74 insertions, 153 deletions
diff --git a/configure b/configure
index 0ab2a3d..c9bc83a 100755
--- a/configure
+++ b/configure
@@ -31,7 +31,6 @@ includedir=""
mandir=""
infodir=""
sysroot=""
-multiarch_triplet=""
cross_prefix=""
cc="gcc"
host_cc="gcc"
@@ -121,8 +120,6 @@ for opt do
;;
--sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
;;
- --multiarch-triplet=*) multiarch_triplet=`echo $opt | cut -d '=' -f 2`
- ;;
--source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
;;
--cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
@@ -238,37 +235,36 @@ Options: [defaults in brackets after descriptions]
EOF
echo "Standard options:"
-echo " --help print this message"
-echo " --prefix=PREFIX install in PREFIX [$prefix]"
-echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
-echo " [same as prefix]"
-echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
-echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
-echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
-echo " --includedir=DIR C header files in DIR [PREFIX/include]"
-echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
-echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
-echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
-echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
+echo " --help print this message"
+echo " --prefix=PREFIX install in PREFIX [$prefix]"
+echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
+echo " [same as prefix]"
+echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
+echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
+echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
+echo " --includedir=DIR C header files in DIR [PREFIX/include]"
+echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
+echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
+echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
+echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
echo ""
echo "Advanced options (experts only):"
-echo " --source-path=PATH path of source code [$source_path]"
-echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
-echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
-echo " --multiarch-triplet=SUFFIX append SUFFIX to library/include paths []"
-echo " --cc=CC use C compiler CC [$cc]"
-echo " --disable-static make libtcc.so instead of libtcc.a"
-echo " --disable-rpath disable use of -rpath with the above"
-echo " --strip-binaries strip symbol tables from resulting binaries"
-echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
-echo " --enable-mingw32 build windows version on linux with mingw32"
-echo " --enable-cygwin build windows version on windows with cygwin"
-echo " [requires cygwin and mingw32-make]"
-echo " --enable-cross build cross compilers"
-echo " --extra-cflags= extra compiler flags"
-echo " --extra-ldflags= extra linker options"
-echo " --with-selinux use mmap instead of exec mem"
-echo " [requires write access to /tmp]"
+echo " --source-path=PATH path of source code [$source_path]"
+echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
+echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
+echo " --cc=CC use C compiler CC [$cc]"
+echo " --disable-static make libtcc.so instead of libtcc.a"
+echo " --disable-rpath disable use of -rpath with the above"
+echo " --strip-binaries strip symbol tables from resulting binaries"
+echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
+echo " --enable-mingw32 build windows version on linux with mingw32"
+echo " --enable-cygwin build windows version on windows with cygwin"
+echo " [requires cygwin and mingw32-make]"
+echo " --enable-cross build cross compilers"
+echo " --extra-cflags= extra compiler flags"
+echo " --extra-ldflags= extra linker options"
+echo " --with-selinux use mmap instead of exec mem"
+echo " [requires write access to /tmp]"
echo ""
#echo "NOTE: The object files are build at the place where configure is launched"
exit 1
@@ -334,14 +330,13 @@ echo "Manual directory $mandir"
echo "Info directory $infodir"
echo "Doc directory $docdir"
echo "Target root prefix $sysroot"
-echo "Multiarch triplet $multiarch_triplet"
-echo "Source path $source_path"
-echo "C compiler $cc"
-echo "CPU $cpu"
-echo "Big Endian $bigendian"
-echo "gprof enabled $gprof"
-echo "cross compilers $build_cross"
-echo "use libgcc $use_libgcc"
+echo "Source path $source_path"
+echo "C compiler $cc"
+echo "CPU $cpu"
+echo "Big Endian $bigendian"
+echo "gprof enabled $gprof"
+echo "cross compilers $build_cross"
+echo "use libgcc $use_libgcc"
echo "Creating config.mak and config.h"
@@ -361,93 +356,9 @@ echo "docdir=\$(DESTDIR)$docdir" >> config.mak
echo "#ifndef CONFIG_SYSROOT" >> $TMPH
echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
echo "#endif" >> $TMPH
-echo "" >> $TMPH
-
-# Set default include and library paths
-win_incpaths="\\\b/include;\\\b/include/winapi"
-unix_incpaths="/usr/local/include:/usr/include:\\\b/include"
-win_libpaths="\\\b/lib"
-unix_libpaths="CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX"
-unix_libpaths="$unix_libpaths\":\"CONFIG_SYSROOT CONFIG_TCC_LDDIR"
-unix_libpaths="$unix_libpaths\":\"CONFIG_SYSROOT \"/usr/local\" CONFIG_TCC_LDDIR"
-
-# sep: path separator in paths
-# tmp: paths multiarchified (one path per line)
-# q: quote (if sep contains ")
-# r: carriage return pattern (if sep contains ")
-# s: space (if sep contains ")
-multiarchify()
-{
- local sep tmp
-
- paths="$1"
- sep="$2"
- tmp=""
- q=""
- r=""
- s=""
- if [ -z "${sep%%\"*}" ] ; then
- q="\""
- r=" \\\\\n "
- s=" "
- fi
- paths="$paths$sep"
- while test -n "$paths" ; do
- tmp="$tmp${tmp:+$r$sep$s}${paths%%$sep*}$s$q/$multiarch_triplet$q"
- tmp="$tmp$r$sep$s${paths%%$sep*}"
- paths="${paths#*$sep}"
- done
- paths="$tmp"
-}
-
-if test -n "$multiarch_triplet" ; then
- multiarchify "$win_incpaths" ";"
- win_incpaths="\"$paths\""
- multiarchify "$unix_incpaths" ":"
- unix_incpaths="\"$paths\""
- multiarchify "$win_libpaths" ";"
- win_libpaths="\"$paths\""
- multiarchify "$unix_libpaths" "\":\""
- unix_libpaths="$paths"
- echo "#define CONFIG_TCC_MULTIARCH_TRIPLET \"$multiarch_triplet\"" >> $TMPH
-fi
-
-echo "#ifndef CONFIG_TCC_LDDIR" >> $TMPH
-echo " #if defined(TCC_TARGET_X86_64_CENTOS)" >> $TMPH
-echo " #define CONFIG_TCC_LDDIR \"/lib64\"" >> $TMPH
-echo " #else" >> $TMPH
-echo " #define CONFIG_TCC_LDDIR \"/lib\"" >> $TMPH
-echo " #endif" >> $TMPH
-echo "#endif" >> $TMPH
-echo "" >> $TMPH
-
-echo "/* path to find crt1.o, crti.o and crtn.o */" >> $TMPH
-echo "#ifndef CONFIG_TCC_CRT_PREFIX" >> $TMPH
-echo "# define CONFIG_TCC_CRT_PREFIX \"/usr\" CONFIG_TCC_LDDIR" >> $TMPH
-echo "#endif" >> $TMPH
-echo "" >> $TMPH
-
-echo "#ifndef CONFIG_TCC_SYSINCLUDE_PATHS" >> $TMPH
-echo "# ifdef TCC_TARGET_PE" >> $TMPH
-echo "# define CONFIG_TCC_SYSINCLUDE_PATHS $win_incpaths" >> $TMPH
-echo "# else" >> $TMPH
-echo "# define CONFIG_TCC_SYSINCLUDE_PATHS $unix_incpaths" >> $TMPH
-echo "# endif" >> $TMPH
-echo "#endif" >> $TMPH
-echo "" >> $TMPH
-echo "#ifndef CONFIG_TCC_LIBPATH" >> $TMPH
-echo "# ifdef TCC_TARGET_PE" >> $TMPH
-echo "# define CONFIG_TCC_LIBPATH $win_libpaths" >> $TMPH
-echo "# else" >> $TMPH
-echo "# define CONFIG_TCC_LIBPATH $unix_libpaths" >> $TMPH
-echo "# endif" >> $TMPH
-echo "#endif" >> $TMPH
-echo "" >> $TMPH
-
echo "#ifndef CONFIG_TCCDIR" >> $TMPH
echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
echo "#endif" >> $TMPH
-echo "" >> $TMPH
echo "CC=$cc" >> config.mak
echo "GCC_MAJOR=$gcc_major" >> config.mak
echo "#define GCC_MAJOR $gcc_major" >> $TMPH
diff --git a/libtcc.c b/libtcc.c
index f97149d..bcef2a6 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1226,19 +1226,14 @@ the_end:
return ret;
}
-static int tcc_add_file_noerror(TCCState *s, const char *filename, int extra_flags)
+LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename)
{
dynarray_add((void ***)&s->input_files, &s->nb_input_files, tcc_strdup(filename));
if (s->output_type == TCC_OUTPUT_PREPROCESS)
- return tcc_add_file_internal(s, filename, extra_flags | AFF_PREPROCESS);
+ return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR | AFF_PREPROCESS);
else
- return tcc_add_file_internal(s, filename, extra_flags);
-}
-
-LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename)
-{
- return tcc_add_file_noerror(s, filename, AFF_PRINT_ERROR);
+ return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);
}
LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname)
@@ -1352,16 +1347,9 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
#else
if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&
!s->nostdlib) {
- if (output_type != TCC_OUTPUT_DLL) {
-#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
- if (tcc_add_file_noerror(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/" CONFIG_TCC_MULTIARCH_TRIPLET "/crt1.o", 0))
-#endif
- tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crt1.o");
- }
-#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
- if (tcc_add_file_noerror(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/" CONFIG_TCC_MULTIARCH_TRIPLET "/crti.o", 0))
-#endif
- tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crti.o");
+ if (output_type != TCC_OUTPUT_DLL)
+ tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crt1.o");
+ tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crti.o");
}
#endif
return 0;
diff --git a/tcc.h b/tcc.h
index 6cf60d8..f8ad00c 100644
--- a/tcc.h
+++ b/tcc.h
@@ -139,9 +139,37 @@
#define true 1
typedef int BOOL;
-/* See definition of default values of CONFIG_TCC_LDDIR, CONFIG_TCC_CRT_PREFIX,
- CONFIG_TCC_SYSINCLUDE_PATHS and CONFIG_TCC_LIBPATH in config.h or configure
- */
+#ifndef CONFIG_TCC_LDDIR
+ #if defined(TCC_TARGET_X86_64_CENTOS)
+ #define CONFIG_TCC_LDDIR "/lib64"
+ #else
+ #define CONFIG_TCC_LDDIR "/lib"
+ #endif
+#endif
+
+/* path to find crt1.o, crti.o and crtn.o */
+#ifndef CONFIG_TCC_CRT_PREFIX
+# define CONFIG_TCC_CRT_PREFIX "/usr" CONFIG_TCC_LDDIR
+#endif
+
+#ifndef CONFIG_TCC_SYSINCLUDE_PATHS
+# ifdef TCC_TARGET_PE
+# define CONFIG_TCC_SYSINCLUDE_PATHS "\b/include;\b/include/winapi"
+# else
+# define CONFIG_TCC_SYSINCLUDE_PATHS "/usr/local/include:/usr/include:\b/include"
+# endif
+#endif
+
+#ifndef CONFIG_TCC_LIBPATH
+# ifdef TCC_TARGET_PE
+# define CONFIG_TCC_LIBPATH "\b/lib"
+# else
+# define CONFIG_TCC_LIBPATH \
+ CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX \
+ ":" CONFIG_SYSROOT CONFIG_TCC_LDDIR \
+ ":" CONFIG_SYSROOT "/usr/local" CONFIG_TCC_LDDIR
+# endif
+#endif
#define INCLUDE_STACK_SIZE 32
#define IFDEF_STACK_SIZE 64
diff --git a/tccelf.c b/tccelf.c
index f58ae83..c0f1c94 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1238,10 +1238,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
if (!s1->nostdlib) {
#ifdef CONFIG_USE_LIBGCC
tcc_add_library(s1, "c");
-#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
- if (tcc_add_file_internal(s1, CONFIG_SYSROOT CONFIG_TCC_LDDIR "/" CONFIG_TCC_MULTIARCH_TRIPLET "/libgcc_s.so.1", 0))
-#endif
- tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_LDDIR"/libgcc_s.so.1");
+ tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_LDDIR"/libgcc_s.so.1");
#else
tcc_add_library(s1, "c");
#ifndef WITHOUT_LIBTCC
@@ -1255,10 +1252,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
}
/* add crt end if not memory output */
if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) {
-#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
- if (tcc_add_file_internal(s1, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/" CONFIG_TCC_MULTIARCH_TRIPLET "/crtn.o", 0))
-#endif
- tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crtn.o");
+ tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crtn.o");
}
}