diff --git a/mkfiles.pl b/mkfiles.pl index 76b29a25..1845945a 100755 --- a/mkfiles.pl +++ b/mkfiles.pl @@ -448,14 +448,9 @@ if (defined $makefiles{'clangcl'}) { # using the real Visual Studio header files and libraries. In # order to run it, you will need: # - # - MinGW windres on your PATH. - # * On Ubuntu as of 16.04, you can apt-get install - # binutils-mingw-w64-x86-64 and binutils-mingw-w64-i686 - # which will provide (respectively) 64- and 32-bit versions, - # under the names to which RCCMD is defined below. - # - clang-cl and lld-link on your PATH. + # - clang-cl, llvm-rc and lld-link on your PATH. # * I built these from the up-to-date LLVM project trunk git - # repositories, as of 2017-02-05. + # repositories, as of 2018-05-29. # - case-mashed copies of the Visual Studio include directories. # * On a real VS installation, run vcvars32.bat and look at # the resulting value of %INCLUDE%. Take a full copy of each @@ -521,23 +516,22 @@ if (defined $makefiles{'clangcl'}) { open OUT, ">$makefiles{'clangcl'}"; select OUT; print "# Makefile for cross-compiling $project_name using clang-cl, lld-link,\n". - "# and MinGW's windres, using GNU make on Linux.\n". + "# and llvm-rc, using GNU make on Linux.\n". "#\n# This file was created by `mkfiles.pl' from the `Recipe' file.\n". "# DO NOT EDIT THIS FILE DIRECTLY; edit Recipe or mkfiles.pl instead.\n"; print $help; print "\n". "CCCMD = clang-cl\n". + "RCCMD = llvm-rc\n". "ifeq (\$(Platform),x64)\n". "CCTARGET = x86_64-pc-windows-msvc18.0.0\n". - "RCCMD = x86_64-w64-mingw32-windres\n". "else\n". "CCTARGET = i386-pc-windows-msvc18.0.0\n". - "RCCMD = i686-w64-mingw32-windres\n". "endif\n". "CC = \$(CCCMD) --target=\$(CCTARGET)\n". - &splitline("RC = \$(RCCMD) --preprocessor=\$(CCCMD) ". - "--preprocessor-arg=/TC --preprocessor-arg=/E")."\n". + "RC = \$(RCCMD) /c 1252 \n". + "RCPREPROC = \$(CCCMD) /P /TC\n". "LD = lld-link\n". "\n". "# C compilation flags\n". @@ -547,8 +541,8 @@ if (defined $makefiles{'clangcl'}) { "/D_CRT_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS"). "\n". "LFLAGS = /incremental:no /dynamicbase /nxcompat\n". - &splitline("RCFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs). - " -DWIN32 -D_WIN32 -DWINVER=0x0400")."\n". + &splitline("RCPPFLAGS = ".(join " ", map {"-I$dirpfx$_"} @srcdirs). + " -DWIN32 -D_WIN32 -DWINVER=0x0400")." \$(RCFL)\n". "\n". &def($makefile_extra{'clangcl'}->{'vars'}) . "\n". @@ -568,17 +562,29 @@ if (defined $makefiles{'clangcl'}) { "/subsystem:$subsys\$(SUBSYSVER) ". "\$(EXTRA_$subsys) $objstr")."\n\n"; } + my $rc_pp_rules = ""; foreach $d (&deps("\$(BUILDDIR)X.obj", "\$(BUILDDIR)X.res", $dirpfx, "/", "vc")) { $extradeps = $forceobj{$d->{obj_orig}} ? ["*.c","*.h","*.rc"] : []; - print &splitline(sprintf("%s: %s", $d->{obj}, - join " ", @$extradeps, @{$d->{deps}})), "\n"; + my $rule; + my @deps = @{$d->{deps}}; if ($d->{obj} =~ /\.res$/) { - print "\t\$(RC) \$(RCFLAGS) ".$d->{deps}->[0]." -o ".$d->{obj}."\n\n"; + my $rc = $deps[0]; + my $rcpp = $rc; + $rcpp =~ s!.*/!!; + $rcpp =~ s/\.rc$/.rcpp/; + $rcpp = "\$(BUILDDIR)" . $rcpp; + $rule = "\$(RC) ".$rcpp." /FO ".$d->{obj}; + $rc_pp_rules .= "$rcpp: $rc\n" . + "\t\$(RCPREPROC) \$(RCPPFLAGS) /Fi\$\@ \$<\n\n"; + $deps[0] = $rcpp; } else { - print "\t\$(CC) /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<\n\n"; + $rule = "\$(CC) /Fo\$(BUILDDIR) \$(COMPAT) \$(CFLAGS) \$(XFLAGS) /c \$<"; } + print &splitline(sprintf("%s: %s", $d->{obj}, + join " ", @$extradeps, @deps)), "\n"; + print "\t" . $rule . "\n\n"; } - print "\n"; + print "\n" . $rc_pp_rules; print &def($makefile_extra{'clangcl'}->{'end'}); print "\nclean:\n". &splitline("\trm -f \$(BUILDDIR)*.obj \$(BUILDDIR)*.exe ".