diff --git a/build/rmkdepend/mainroot.cxx b/build/rmkdepend/mainroot.cxx index a63aa03ad958f2005d2808d2088acbb86d9505fe..23df7c1ae4e288c22ac3b05c6cfa8d847e65a9d6 100644 --- a/build/rmkdepend/mainroot.cxx +++ b/build/rmkdepend/mainroot.cxx @@ -38,6 +38,7 @@ extern "C" { #include <unistd.h> #else extern "C" int unlink(const char *FILENAME); +#include "../../core/utils/src/cygpath.h" #endif extern "C" int main_orig(int argc, char **argv); @@ -168,6 +169,20 @@ int main(int argc, char **argv) } argv[1] = argv[0]; // keep program name + +#ifdef _WIN32 + for (int i = 2; i < argc; ++i) { + std::string arg(argv[i]); + if (FromCygToNativePath(arg)) { + size_t len = arg.length(); + // yes, we leak. + char* argvi = new char[len + 1]; + strncpy(argvi, arg.c_str(), len + 1); + argv[i] = argvi; + } + } +#endif + int ret = main_orig(argc-1, &argv[1]); if (ret) { // delete output file diff --git a/build/win/rootcint_tmp.sh b/build/win/rootcint_tmp.sh index e9b43dfa765cc1d3feed048a058634949ec2953b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100755 --- a/build/win/rootcint_tmp.sh +++ b/build/win/rootcint_tmp.sh @@ -1,19 +0,0 @@ -#! /bin/sh - -# Convert /cygdrive/ and /home/ to windows-style paths. - -args=core/utils/src/rootcint_tmp.exe - -while [ "$1" != "" ]; do - case "$1" in - -I*) narg=`echo $1 | sed -e s/-I//`; args="$args -I`cygpath -m -- $narg`" ;; - /*) args="$args `cygpath -m -- $1`" ;; - *) args="$args $1" ;; - esac - shift -done - -$args -stat=$? - -exit $stat diff --git a/config/Makefile.win32 b/config/Makefile.win32 index 6d45345bedd7bbacde7d4924ad11ff2585274d88..093c053ef32a18c53f1adc51aa2455c0ba2b8e89 100644 --- a/config/Makefile.win32 +++ b/config/Makefile.win32 @@ -114,4 +114,3 @@ F77LIBS = endif # Extras -ROOTCINTTMP = build/win/rootcint_tmp.sh -$(ROOTDICTTYPE) diff --git a/core/utils/src/cygpath.h b/core/utils/src/cygpath.h new file mode 100644 index 0000000000000000000000000000000000000000..369fd38da262f6bc0c87d8654cb71af14e9f54ca --- /dev/null +++ b/core/utils/src/cygpath.h @@ -0,0 +1,61 @@ +/* @(#)build/win:$Id$ */ + +/************************************************************************* + * Copyright (C) 1995-2010, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_CygPath +#include <stdio.h> +#include <stdlib.h> +#include <string> + +static const char *GetCygwinRootDir() { + // Get the install location of cygwin. + static char buf[512] = {0}; + + if (!buf[0]) { + FILE *pipe = _popen( "cygpath -m /", "rt" ); + + if (!pipe) return 0; + fgets(buf, sizeof(buf), pipe); + int len = strlen(buf); + while (buf[len - 1] == '\n' || buf[len - 1] == '\r') { + buf[len - 1] = 0; + } + if (!feof(pipe)) _pclose(pipe); + else fprintf(stderr, "GetCygwinRootDir() error: Failed to read the pipe to the end.\n"); + } + return buf; +} + +static bool FromCygToNativePath(std::string& path) { + // Convert a cygwin path (/cygdrive/x/...,/home) + // to a native Windows path. Return whether the path was changed. + + size_t posCygDrive = path.find("/cygdrive/"); + if (posCygDrive != std::string::npos) { + path[posCygDrive] = path[posCygDrive + 10]; + path[posCygDrive + 1] = ':'; + path.erase(posCygDrive + 2, 9); + return true; + } else { + size_t posHome = path.find("/home/"); + if (posHome != std::string::npos) { + std::string fname = GetCygwinRootDir(); + if (fname[fname.length() - 1] == '/') { + fname += posHome + 1; + } else { + fname += posHome; + } + path = fname; + return true; + } + } + return false; +} + +#endif // ROOT_CygPath diff --git a/core/utils/src/rlibmap.cxx b/core/utils/src/rlibmap.cxx index 7381dadf81980c5e18e668ff90ae2cc0a412b462..0ec9051baa7a940172539b092fbe826072d933af 100644 --- a/core/utils/src/rlibmap.cxx +++ b/core/utils/src/rlibmap.cxx @@ -36,6 +36,7 @@ # define ssize_t int # include <io.h> # include <sys/types.h> +# include "cygpath.h" #endif #ifdef __APPLE__ @@ -380,9 +381,15 @@ int main(int argc, char **argv) } if (!strcmp(argv[ic], "-o")) { ic++; +#ifdef WIN32 + std::string outfile(argv[ic]); + FromCygToNativePath(outfile); + fp = fopen(outfile.c_str(), "w"); +#else fp = fopen(argv[ic], "w"); +#endif if (!fp) { - fprintf(stderr, "cannot open output file %s\n", argv[ic]); + fprintf(stderr, "cannot open output file %s\n", outfile.c_str()); return 1; } ic++; @@ -390,9 +397,15 @@ int main(int argc, char **argv) if (!strcmp(argv[ic], "-r")) { replace = true; ic++; - fp = fopen(argv[ic], "a+"); +#ifdef WIN32 + std::string outfile(argv[ic]); + FromCygToNativePath(outfile); + fp = fopen(outfile.c_str(), "a+"); +#else + fp = fopen(outfile.c_str(), "a+"); +#endif if (!fp) { - fprintf(stderr, "cannot open output file %s\n", argv[ic]); + fprintf(stderr, "cannot open output file %s\n", outfile.c_str()); return 1; } ic++; @@ -400,6 +413,9 @@ int main(int argc, char **argv) if (!strcmp(argv[ic], "-l")) { ic++; solib = argv[ic]; +#ifdef WIN32 + FromCygToNativePath(solib); +#endif #ifdef __APPLE__ string::size_type i = solib.find(".dylib"); if (i != string::npos) @@ -411,6 +427,9 @@ int main(int argc, char **argv) ic++; for (int i = ic; i < argc && argv[i][0] != '-'; i++) { string dl = argv[i]; +#ifdef WIN32 + FromCygToNativePath(dl); +#endif #ifdef __APPLE__ string::size_type j = dl.find(".dylib"); if (j != string::npos) @@ -423,7 +442,13 @@ int main(int argc, char **argv) if (!strcmp(argv[ic], "-c")) { ic++; for (int i = ic; i < argc; i++) { +#ifdef WIN32 + std::string linkdef(argv[i]); + FromCygToNativePath(linkdef); + linkdefs.push_back(linkdef); +#else linkdefs.push_back(argv[i]); +#endif ic++; } } diff --git a/core/utils/src/rootcint.cxx b/core/utils/src/rootcint.cxx index 53077ef4c9846d93c75f46561be8e25efd7ac458..b5aa74e3ceb833506a681bf1346147b1e6f01a92 100644 --- a/core/utils/src/rootcint.cxx +++ b/core/utils/src/rootcint.cxx @@ -2,7 +2,7 @@ // Author: Fons Rademakers 13/07/96 /************************************************************************* - * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * + * Copyright (C) 1995-2010, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * @@ -175,6 +175,10 @@ #include <mach-o/dyld.h> #endif +#if defined(R__WIN32) +#include "cygpath.h" +#endif + #ifdef fgets // in G__ci.h # undef fgets # undef printf @@ -4296,6 +4300,21 @@ int main(int argc, char **argv) force = 0; } +#if defined(R__WIN32) && !defined(R__WINGCC) + // cygwin's make is presenting us some cygwin paths even though + // we are windows native. Convert them as good as we can. + for (int iic = ic; iic < argc; ++iic) { + std::string iiarg(argv[iic]); + if (FromCygToNativePath(iiarg)) { + size_t len = iiarg.length(); + // yes, we leak. + char* argviic = new char[len + 1]; + strlcpy(argviic, iiarg.c_str(), len + 1); + argv[iic] = argviic; + } + } +#endif + string header(""); if (strstr(argv[ic],".C") || strstr(argv[ic],".cpp") || strstr(argv[ic],".cp") || strstr(argv[ic],".cxx") ||