A prefix for default library/include search paths
This patch is useful for cross compilers. Without this patch tcc tries to use the host's libraries, crt*.o and include files. The patch prepends a string to all default paths. The string can be passed to configure with --sysroot=string. Daniel
This commit is contained in:
parent
e8039673ad
commit
256f6e6200
2 changed files with 12 additions and 6 deletions
6
configure
vendored
6
configure
vendored
|
@ -26,6 +26,7 @@ libdir=""
|
||||||
tccdir=""
|
tccdir=""
|
||||||
includedir=""
|
includedir=""
|
||||||
mandir=""
|
mandir=""
|
||||||
|
sysroot=""
|
||||||
cross_prefix=""
|
cross_prefix=""
|
||||||
cc="gcc"
|
cc="gcc"
|
||||||
host_cc="gcc"
|
host_cc="gcc"
|
||||||
|
@ -102,6 +103,8 @@ for opt do
|
||||||
;;
|
;;
|
||||||
--mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
|
--mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
|
||||||
;;
|
;;
|
||||||
|
--sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
|
||||||
|
;;
|
||||||
--source-path=*) source_path=`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`
|
--cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
|
||||||
|
@ -218,6 +221,7 @@ echo ""
|
||||||
echo "Advanced options (experts only):"
|
echo "Advanced options (experts only):"
|
||||||
echo " --source-path=PATH path of source code [$source_path]"
|
echo " --source-path=PATH path of source code [$source_path]"
|
||||||
echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
|
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 " --cc=CC use C compiler CC [$cc]"
|
||||||
echo " --make=MAKE use specified make [$make]"
|
echo " --make=MAKE use specified make [$make]"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -267,6 +271,7 @@ echo "Library directory $libdir"
|
||||||
echo "Include directory $includedir"
|
echo "Include directory $includedir"
|
||||||
echo "Manual directory $mandir"
|
echo "Manual directory $mandir"
|
||||||
echo "Doc directory $docdir"
|
echo "Doc directory $docdir"
|
||||||
|
echo "Target root prefix $sysroot"
|
||||||
echo "Source path $source_path"
|
echo "Source path $source_path"
|
||||||
echo "C compiler $cc"
|
echo "C compiler $cc"
|
||||||
echo "make $make"
|
echo "make $make"
|
||||||
|
@ -287,6 +292,7 @@ echo "libdir=$libdir" >> config.mak
|
||||||
echo "includedir=$includedir" >> config.mak
|
echo "includedir=$includedir" >> config.mak
|
||||||
echo "mandir=$mandir" >> config.mak
|
echo "mandir=$mandir" >> config.mak
|
||||||
echo "docdir=$docdir" >> config.mak
|
echo "docdir=$docdir" >> config.mak
|
||||||
|
echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
|
||||||
echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
|
echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
|
||||||
echo "MAKE=$make" >> config.mak
|
echo "MAKE=$make" >> config.mak
|
||||||
echo "CC=$cc" >> config.mak
|
echo "CC=$cc" >> config.mak
|
||||||
|
|
12
tcc.c
12
tcc.c
|
@ -113,7 +113,7 @@ typedef int BOOL;
|
||||||
|
|
||||||
/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
|
/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
|
||||||
executables or dlls */
|
executables or dlls */
|
||||||
#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
|
#define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr/lib"
|
||||||
|
|
||||||
#define INCLUDE_STACK_SIZE 32
|
#define INCLUDE_STACK_SIZE 32
|
||||||
#define IFDEF_STACK_SIZE 64
|
#define IFDEF_STACK_SIZE 64
|
||||||
|
@ -10190,9 +10190,9 @@ TCCState *tcc_new(void)
|
||||||
|
|
||||||
#ifndef TCC_TARGET_PE
|
#ifndef TCC_TARGET_PE
|
||||||
/* default library paths */
|
/* default library paths */
|
||||||
tcc_add_library_path(s, "/usr/local/lib");
|
tcc_add_library_path(s, CONFIG_SYSROOT "/usr/local/lib");
|
||||||
tcc_add_library_path(s, "/usr/lib");
|
tcc_add_library_path(s, CONFIG_SYSROOT "/usr/lib");
|
||||||
tcc_add_library_path(s, "/lib");
|
tcc_add_library_path(s, CONFIG_SYSROOT "/lib");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* no section zero */
|
/* no section zero */
|
||||||
|
@ -10469,8 +10469,8 @@ int tcc_set_output_type(TCCState *s, int output_type)
|
||||||
/* default include paths */
|
/* default include paths */
|
||||||
/* XXX: reverse order needed if -isystem support */
|
/* XXX: reverse order needed if -isystem support */
|
||||||
#ifndef TCC_TARGET_PE
|
#ifndef TCC_TARGET_PE
|
||||||
tcc_add_sysinclude_path(s, "/usr/local/include");
|
tcc_add_sysinclude_path(s, CONFIG_SYSROOT "/usr/local/include");
|
||||||
tcc_add_sysinclude_path(s, "/usr/include");
|
tcc_add_sysinclude_path(s, CONFIG_SYSROOT "/usr/include");
|
||||||
#endif
|
#endif
|
||||||
snprintf(buf, sizeof(buf), "%s/include", tcc_lib_path);
|
snprintf(buf, sizeof(buf), "%s/include", tcc_lib_path);
|
||||||
tcc_add_sysinclude_path(s, buf);
|
tcc_add_sysinclude_path(s, buf);
|
||||||
|
|
Loading…
Reference in a new issue