From: Fan WenJie fanwj@mail.ustc.edu.cn
Signed-off-by: Fan WenJie fanwj@mail.ustc.edu.cn --- configure | 86 +++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 28 ++++++++++++++-- tools/makedep.c | 24 +++++++++++--- 3 files changed, 129 insertions(+), 9 deletions(-)
diff --git a/configure b/configure index e6fa429c8bf..461a2b9a784 100755 --- a/configure +++ b/configure @@ -803,6 +803,10 @@ SED_CMD RUNTESTFLAGS MAKEDEP toolsdir +ac_ct_TOOLS_CC +TOOLS_LDFLAGS +TOOLS_CFLAGS +TOOLS_CC x86_64_DISABLED_SUBDIRS x86_64_DELAYLOADFLAG x86_64_TARGET @@ -6446,6 +6450,11 @@ case "$host_cpu" in esac
+ + + +# AC_CHECK_HOST_TOOLS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the directory containing the Wine tools" >&5 printf %s "checking for the directory containing the Wine tools... " >&6; } if test ${wine_cv_toolsdir+y} @@ -6455,7 +6464,70 @@ else $as_nop wine_cv_toolsdir="$with_wine_tools" if test -z "$with_wine_tools"; then if test "$cross_compiling" = "yes"; then - as_fn_error $? "you must use the --with-wine-tools option when cross-compiling." "$LINENO" 5 + if test -z "$TOOLS_CC"; then + ac_ct_TOOLS_CC=$TOOLS_CC + for ac_prog in cc clang gcc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_TOOLS_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_TOOLS_CC"; then + ac_cv_prog_ac_ct_TOOLS_CC="$ac_ct_TOOLS_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_TOOLS_CC="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_TOOLS_CC=$ac_cv_prog_ac_ct_TOOLS_CC +if test -n "$ac_ct_TOOLS_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_TOOLS_CC" >&5 +printf "%s\n" "$ac_ct_TOOLS_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$ac_ct_TOOLS_CC" && break +done + + if test "x$ac_ct_TOOLS_CC" = x; then + TOOLS_CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + TOOLS_CC=$ac_ct_TOOLS_CC + fi +fi + + TOOLS_CFLAGS=-O2 + TOOLS_LDFLAGS= elif test -n "$with_wine64"; then wine_cv_toolsdir="$with_wine64" fi @@ -11789,6 +11861,12 @@ fi } LDFLAGS=$saved_LDFLAGS done
+if test -z $TOOLS_CC ; then + TOOLS_CC=$CC + TOOLS_CFLAGS=$CFLAGS + TOOLS_LDFLAGS=$LDFLAGS +fi + if test $HOST_ARCH = aarch64 then test "x$PE_ARCHS" != x || as_fn_error $? "PE cross-compilation is required for ARM64, please install clang/llvm-dlltool/lld, or llvm-mingw." "$LINENO" 5 @@ -23273,7 +23351,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 wine_fn_output_makedep () { as_dir=tools; as_fn_mkdir_p - $CC -I${wine_srcdir}tools -Iinclude -I${wine_srcdir}include -D__WINESRC__ -DWINE_UNIX_LIB $EXTRACFLAGS $CPPFLAGS $CFLAGS -o tools/makedep$ac_exeext ${wine_srcdir}tools/makedep.c $LDFLAGS + $TOOLS_CC -I${wine_srcdir}tools -Iinclude -I${wine_srcdir}include -D__WINESRC__ -DWINE_UNIX_LIB $EXTRACFLAGS $TOOLS_CFLAGS -o tools/makedep$ac_exeext ${wine_srcdir}tools/makedep.c $TOOLS_LDFLAGS } wine_fn_output_makefile () { @@ -23400,6 +23478,10 @@ x86_64_DEBUG = $x86_64_DEBUG x86_64_TARGET = $x86_64_TARGET x86_64_DELAYLOADFLAG = $x86_64_DELAYLOADFLAG x86_64_DISABLED_SUBDIRS = $x86_64_DISABLED_SUBDIRS +TOOLS_CC = $TOOLS_CC +TOOLS_CFLAGS = $TOOLS_CFLAGS +TOOLS_LDFLAGS = $TOOLS_LDFLAGS +ac_ct_TOOLS_CC = $ac_ct_TOOLS_CC toolsdir = $toolsdir MAKEDEP = $MAKEDEP RUNTESTFLAGS = $RUNTESTFLAGS diff --git a/configure.ac b/configure.ac index 8d92e4c8ab2..3258744ea39 100644 --- a/configure.ac +++ b/configure.ac @@ -214,11 +214,29 @@ esac m4_set_add_all([_AC_SUBST_VARS],[HOST_ARCH]m4_foreach([cpu],[aarch64,arm,arm64ec,i386,x86_64], [m4_foreach([var],[CC,CFLAGS,EXTRACFLAGS,LDFLAGS,DEBUG,TARGET,DELAYLOADFLAG,DISABLED_SUBDIRS],[,cpu[_]var])]))
+AC_SUBST(TOOLS_CC) +AC_SUBST(TOOLS_CFLAGS) +AC_SUBST(TOOLS_LDFLAGS) +AC_DEFUN([AC_CHECK_HOST_TOOLS], +[if test -z "$$1"; then + ac_ct_$1=$$1 + AC_CHECK_PROGS([ac_ct_$1], [$2], [], [$4]) + if test "x$ac_ct_$1" = x; then + $1="$3" + else + _AC_TOOL_WARN + $1=$ac_ct_$1 + fi +fi +])# AC_CHECK_HOST_TOOLS + AC_CACHE_CHECK([for the directory containing the Wine tools], wine_cv_toolsdir, [wine_cv_toolsdir="$with_wine_tools" if test -z "$with_wine_tools"; then if test "$cross_compiling" = "yes"; then - AC_MSG_ERROR([you must use the --with-wine-tools option when cross-compiling.]) + AC_CHECK_HOST_TOOLS(TOOLS_CC, [cc clang gcc]) + TOOLS_CFLAGS=-O2 + TOOLS_LDFLAGS= elif test -n "$with_wine64"; then wine_cv_toolsdir="$with_wine64" fi @@ -1015,6 +1033,12 @@ This is an error since --enable-archs=$wine_arch was requested.])]) LDFLAGS=$saved_LDFLAGS done
+if test -z $TOOLS_CC ; then + TOOLS_CC=$CC + TOOLS_CFLAGS=$CFLAGS + TOOLS_LDFLAGS=$LDFLAGS +fi + if test $HOST_ARCH = aarch64 then test "x$PE_ARCHS" != x || AC_MSG_ERROR([PE cross-compilation is required for ARM64, please install clang/llvm-dlltool/lld, or llvm-mingw.]) @@ -3517,7 +3541,7 @@ then [wine_fn_output_makedep () { AS_MKDIR_P(tools) - $CC -I${wine_srcdir}tools -Iinclude -I${wine_srcdir}include -D__WINESRC__ -DWINE_UNIX_LIB $EXTRACFLAGS $CPPFLAGS $CFLAGS -o tools/makedep$ac_exeext ${wine_srcdir}tools/makedep.c $LDFLAGS + $TOOLS_CC -I${wine_srcdir}tools -Iinclude -I${wine_srcdir}include -D__WINESRC__ -DWINE_UNIX_LIB $EXTRACFLAGS $TOOLS_CFLAGS -o tools/makedep$ac_exeext ${wine_srcdir}tools/makedep.c $TOOLS_LDFLAGS }]) fi
diff --git a/tools/makedep.c b/tools/makedep.c index 8ce575b15ca..e95a68d526b 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -3148,6 +3148,11 @@ static void output_source_xml( struct makefile *make, struct incl_file *source, } }
+static int is_tools(const char* filename) +{ + static const char prefix[] = "tools/"; + return !strncmp(filename, prefix, sizeof(prefix) - 1); +}
/******************************************************************* * output_source_one_arch @@ -3158,6 +3163,7 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou { const char *obj_name;
+ const int tool = is_tools(source->filename); if (make->disabled[arch] && !(source->file->flags & FLAG_C_IMPLIB)) return;
if (arch) @@ -3188,7 +3194,7 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou strarray_add( &make->clean_files, obj_name );
output( "%s: %s\n", obj_dir_path( make, obj_name ), source->filename ); - output( "\t%s%s -c -o $@ %s", cmd_prefix( "CC" ), arch_make_variable( "CC", arch ), source->filename ); + output( "\t%s%s -c -o $@ %s", cmd_prefix( "CC" ), tool ? "$(TOOLS_CC)" : arch_make_variable( "CC", arch ), source->filename ); output_filenames( defines ); if (!source->use_msvcrt) output_filenames( make->unix_cflags ); output_filenames( make->extlib ? extra_cflags_extlib[arch] : extra_cflags[arch] ); @@ -3211,8 +3217,15 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou if (make->module && is_crt_module( make->module )) output_filename( "-fno-builtin" ); }
- output_filenames( cpp_flags ); - output_filename( arch_make_variable( "CFLAGS", arch )); + if (tool) + { + output_filename( "$(TOOLS_CFLAGS)"); + } + else + { + output_filenames( cpp_flags ); + output_filename( arch_make_variable( "CFLAGS", arch )); + } output( "\n" );
if (make->testdll && strendswith( source->name, ".c" ) && @@ -3586,6 +3599,7 @@ static void output_programs( struct makefile *make ) { char *program_installed = NULL; char *program = strmake( "%s%s", make->programs.str[i], exe_ext ); + const int tool = is_tools(make->obj_dir); struct strarray deps = get_local_dependencies( make, make->programs.str[i], make->in_files ); struct strarray all_libs = get_expanded_file_local_var( make, make->programs.str[i], "LDFLAGS" ); struct strarray objs = get_expanded_file_local_var( make, make->programs.str[i], "OBJS" ); @@ -3602,10 +3616,10 @@ static void output_programs( struct makefile *make ) output_filenames_obj_dir( make, objs ); output_filenames( deps ); output( "\n" ); - output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" )); + output( "\t%s%s -o $@", cmd_prefix( "CCLD" ), tool ? "$(TOOLS_CC)" : "$(CC)"); output_filenames_obj_dir( make, objs ); output_filenames( all_libs ); - output_filename( "$(LDFLAGS)" ); + output_filename( tool ? "$(TOOLS_LDFLAGS)" : "$(LDFLAGS)" ); output( "\n" ); strarray_add( &make->all_targets[arch], program );