ENH: Support for spaces in paths during make install.
This commit is contained in:
parent
94a8d00199
commit
5bb1a79c9f
|
@ -319,26 +319,14 @@ std::string cmLocalUnixMakefileGenerator::GetOutputExtension(const char*)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::string cmLocalUnixMakefileGenerator::GetFullTargetName(const char* n,
|
||||||
|
const cmTarget& t)
|
||||||
// Output the rules for any targets
|
|
||||||
void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
|
||||||
{
|
{
|
||||||
// for each target add to the list of targets
|
const char* targetPrefix = t.GetProperty("PREFIX");
|
||||||
fout << "TARGETS = ";
|
const char* targetSuffix = t.GetProperty("SUFFIX");
|
||||||
const cmTargets &tgts = m_Makefile->GetTargets();
|
|
||||||
// list libraries first
|
|
||||||
for(cmTargets::const_iterator l = tgts.begin();
|
|
||||||
l != tgts.end(); l++)
|
|
||||||
{
|
|
||||||
if (l->second.IsInAll())
|
|
||||||
{
|
|
||||||
const char* targetPrefix = l->second.GetProperty("PREFIX");
|
|
||||||
const char* targetSuffix = l->second.GetProperty("SUFFIX");
|
|
||||||
std::string path = m_LibraryOutputPath;
|
|
||||||
const char* prefixVar = 0;
|
const char* prefixVar = 0;
|
||||||
const char* suffixVar = 0;
|
const char* suffixVar = 0;
|
||||||
switch(l->second.GetType())
|
switch(t.GetType())
|
||||||
{
|
{
|
||||||
case cmTarget::STATIC_LIBRARY:
|
case cmTarget::STATIC_LIBRARY:
|
||||||
prefixVar = "CMAKE_STATIC_LIBRARY_PREFIX";
|
prefixVar = "CMAKE_STATIC_LIBRARY_PREFIX";
|
||||||
|
@ -354,26 +342,46 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
||||||
break;
|
break;
|
||||||
case cmTarget::EXECUTABLE:
|
case cmTarget::EXECUTABLE:
|
||||||
case cmTarget::WIN32_EXECUTABLE:
|
case cmTarget::WIN32_EXECUTABLE:
|
||||||
|
targetSuffix = cmSystemTools::GetExecutableExtension();
|
||||||
case cmTarget::UTILITY:
|
case cmTarget::UTILITY:
|
||||||
case cmTarget::INSTALL_FILES:
|
case cmTarget::INSTALL_FILES:
|
||||||
case cmTarget::INSTALL_PROGRAMS:
|
case cmTarget::INSTALL_PROGRAMS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if it is a library this will be set
|
|
||||||
if(prefixVar)
|
|
||||||
{
|
|
||||||
// if there is no prefix on the target use the cmake definition
|
// if there is no prefix on the target use the cmake definition
|
||||||
if(!targetPrefix)
|
if(!targetPrefix && prefixVar)
|
||||||
{
|
{
|
||||||
targetPrefix = this->GetSafeDefinition(prefixVar);
|
targetPrefix = this->GetSafeDefinition(prefixVar);
|
||||||
}
|
}
|
||||||
// if there is no suffix on the target use the cmake definition
|
// if there is no suffix on the target use the cmake definition
|
||||||
if(!targetSuffix)
|
if(!targetSuffix && suffixVar)
|
||||||
{
|
{
|
||||||
targetSuffix = this->GetSafeDefinition(suffixVar);
|
targetSuffix = this->GetSafeDefinition(suffixVar);
|
||||||
}
|
}
|
||||||
path +=
|
std::string name = targetPrefix?targetPrefix:"";
|
||||||
targetPrefix + l->first + targetSuffix;
|
name += n;
|
||||||
|
name += targetSuffix?targetSuffix:"";
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output the rules for any targets
|
||||||
|
void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
||||||
|
{
|
||||||
|
// for each target add to the list of targets
|
||||||
|
fout << "TARGETS = ";
|
||||||
|
const cmTargets &tgts = m_Makefile->GetTargets();
|
||||||
|
// list libraries first
|
||||||
|
for(cmTargets::const_iterator l = tgts.begin();
|
||||||
|
l != tgts.end(); l++)
|
||||||
|
{
|
||||||
|
if (l->second.IsInAll())
|
||||||
|
{
|
||||||
|
if((l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||||
|
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||||
|
(l->second.GetType() == cmTarget::MODULE_LIBRARY))
|
||||||
|
{
|
||||||
|
std::string path = m_LibraryOutputPath;
|
||||||
|
path += this->GetFullTargetName(l->first.c_str(), l->second);
|
||||||
fout << " \\\n"
|
fout << " \\\n"
|
||||||
<< cmSystemTools::ConvertToOutputPath(path.c_str());
|
<< cmSystemTools::ConvertToOutputPath(path.c_str());
|
||||||
}
|
}
|
||||||
|
@ -387,8 +395,8 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
||||||
l->second.GetType() == cmTarget::WIN32_EXECUTABLE) &&
|
l->second.GetType() == cmTarget::WIN32_EXECUTABLE) &&
|
||||||
l->second.IsInAll())
|
l->second.IsInAll())
|
||||||
{
|
{
|
||||||
std::string path = m_ExecutableOutputPath + l->first +
|
std::string path = m_ExecutableOutputPath;
|
||||||
cmSystemTools::GetExecutableExtension();
|
path += this->GetFullTargetName(l->first.c_str(), l->second);
|
||||||
fout << " \\\n" << cmSystemTools::ConvertToOutputPath(path.c_str());
|
fout << " \\\n" << cmSystemTools::ConvertToOutputPath(path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2052,45 +2060,34 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
|
||||||
if (l->second.GetInstallPath() != "")
|
if (l->second.GetInstallPath() != "")
|
||||||
{
|
{
|
||||||
// first make the directories for each target
|
// first make the directories for each target
|
||||||
fout << "\t@if [ ! -d $(DESTDIR)" << prefix << l->second.GetInstallPath() <<
|
fout << "\t@if [ ! -d \"$(DESTDIR)\"" << prefix << l->second.GetInstallPath() <<
|
||||||
" ] ; then \\\n";
|
" ] ; then \\\n";
|
||||||
fout << "\t echo \"Making directory $(DESTDIR)" << prefix
|
fout << "\t echo \"Making directory \"$(DESTDIR)\"" << prefix
|
||||||
<< l->second.GetInstallPath() << " \"; \\\n";
|
<< l->second.GetInstallPath() << " \"; \\\n";
|
||||||
fout << "\t mkdir -p $(DESTDIR)" << prefix << l->second.GetInstallPath()
|
fout << "\t mkdir -p \"$(DESTDIR)\"" << prefix << l->second.GetInstallPath()
|
||||||
<< "; \\\n";
|
<< "; \\\n";
|
||||||
fout << "\t chmod 755 $(DESTDIR)" << prefix << l->second.GetInstallPath()
|
fout << "\t chmod 755 \"$(DESTDIR)\"" << prefix << l->second.GetInstallPath()
|
||||||
<< "; \\\n";
|
<< "; \\\n";
|
||||||
fout << "\t else true; \\\n";
|
fout << "\t else true; \\\n";
|
||||||
fout << "\t fi\n";
|
fout << "\t fi\n";
|
||||||
|
std::string fname;
|
||||||
// now install the target
|
// now install the target
|
||||||
switch (l->second.GetType())
|
switch (l->second.GetType())
|
||||||
{
|
{
|
||||||
case cmTarget::STATIC_LIBRARY:
|
case cmTarget::STATIC_LIBRARY:
|
||||||
fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib"
|
|
||||||
<< l->first;
|
|
||||||
fout << ".a";
|
|
||||||
fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
|
|
||||||
break;
|
|
||||||
case cmTarget::SHARED_LIBRARY:
|
case cmTarget::SHARED_LIBRARY:
|
||||||
fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath
|
|
||||||
<< this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX")
|
|
||||||
<< l->first;
|
|
||||||
fout << this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX");
|
|
||||||
fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
|
|
||||||
break;
|
|
||||||
case cmTarget::MODULE_LIBRARY:
|
case cmTarget::MODULE_LIBRARY:
|
||||||
fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath
|
fname = m_LibraryOutputPath;
|
||||||
<< this->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX")
|
fname += this->GetFullTargetName(l->first.c_str(), l->second);
|
||||||
<< l->first;
|
fout << "\t$(INSTALL_DATA) " << cmSystemTools::ConvertToOutputPath(fname.c_str())
|
||||||
fout << this->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX");
|
<< " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n";
|
||||||
fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
|
|
||||||
break;
|
break;
|
||||||
case cmTarget::WIN32_EXECUTABLE:
|
case cmTarget::WIN32_EXECUTABLE:
|
||||||
case cmTarget::EXECUTABLE:
|
case cmTarget::EXECUTABLE:
|
||||||
fout << "\t$(INSTALL_PROGRAM) " << m_ExecutableOutputPath
|
fname = m_ExecutableOutputPath;
|
||||||
<< l->first
|
fname += this->GetFullTargetName(l->first.c_str(), l->second);
|
||||||
<< cmSystemTools::GetExecutableExtension()
|
fout << "\t$(INSTALL_PROGRAM) " << cmSystemTools::ConvertToOutputPath(fname.c_str())
|
||||||
<< " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
|
<< " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n";
|
||||||
break;
|
break;
|
||||||
case cmTarget::INSTALL_FILES:
|
case cmTarget::INSTALL_FILES:
|
||||||
{
|
{
|
||||||
|
@ -2122,8 +2119,9 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
|
||||||
{
|
{
|
||||||
fout << "\t @$(INSTALL_DATA) ";
|
fout << "\t @$(INSTALL_DATA) ";
|
||||||
}
|
}
|
||||||
fout << *i
|
|
||||||
<< " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
|
fout << cmSystemTools::ConvertToOutputPath(i->c_str())
|
||||||
|
<< " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2157,8 +2155,8 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout)
|
||||||
{
|
{
|
||||||
fout << "\t @$(INSTALL_PROGRAM) ";
|
fout << "\t @$(INSTALL_PROGRAM) ";
|
||||||
}
|
}
|
||||||
fout << *i
|
fout << cmSystemTools::ConvertToOutputPath(i->c_str())
|
||||||
<< " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n";
|
<< " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -196,6 +196,9 @@ protected:
|
||||||
|
|
||||||
///! for existing files convert to output path and short path if spaces
|
///! for existing files convert to output path and short path if spaces
|
||||||
std::string ConvertToOutputForExisting(const char*);
|
std::string ConvertToOutputForExisting(const char*);
|
||||||
|
|
||||||
|
/** Get the full name of the target's file, without path. */
|
||||||
|
std::string GetFullTargetName(const char* n, const cmTarget& t);
|
||||||
protected:
|
protected:
|
||||||
int m_MakefileVariableSize;
|
int m_MakefileVariableSize;
|
||||||
std::map<cmStdString, cmStdString> m_MakeVariableMap;
|
std::map<cmStdString, cmStdString> m_MakeVariableMap;
|
||||||
|
|
|
@ -113,10 +113,10 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$dir_arg" != x ]; then
|
if [ x"$dir_arg" != x ]; then
|
||||||
dst=$src
|
dst="$src"
|
||||||
src=""
|
src=""
|
||||||
|
|
||||||
if [ -d $dst ]; then
|
if [ -d "$dst" ]; then
|
||||||
instcmd=:
|
instcmd=:
|
||||||
chmodcmd=""
|
chmodcmd=""
|
||||||
else
|
else
|
||||||
|
@ -128,7 +128,7 @@ else
|
||||||
# might cause directories to be created, which would be especially bad
|
# might cause directories to be created, which would be especially bad
|
||||||
# if $src (and thus $dsttmp) contains '*'.
|
# if $src (and thus $dsttmp) contains '*'.
|
||||||
|
|
||||||
if [ -f $src -o -d $src ]
|
if [ -f "$src" -o -d "$src" ]
|
||||||
then
|
then
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
@ -147,16 +147,16 @@ else
|
||||||
# If destination is a directory, append the input filename; if your system
|
# If destination is a directory, append the input filename; if your system
|
||||||
# does not like double slashes in filenames, you may need to add some logic
|
# does not like double slashes in filenames, you may need to add some logic
|
||||||
|
|
||||||
if [ -d $dst ]
|
if [ -d "$dst" ]
|
||||||
then
|
then
|
||||||
dst="$dst"/`basename $src`
|
dst="$dst"/`basename "$src"`
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## this sed command emulates the dirname command
|
## this sed command emulates the dirname command
|
||||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||||
|
|
||||||
# Make sure that the destination directory exists.
|
# Make sure that the destination directory exists.
|
||||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||||
|
@ -192,42 +192,42 @@ fi
|
||||||
|
|
||||||
if [ x"$dir_arg" != x ]
|
if [ x"$dir_arg" != x ]
|
||||||
then
|
then
|
||||||
$doit $instcmd $dst &&
|
$doit $instcmd "$dst" &&
|
||||||
|
|
||||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else true ; fi &&
|
||||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else true ; fi &&
|
||||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else true ; fi &&
|
||||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else true ; fi
|
||||||
else
|
else
|
||||||
|
|
||||||
# If we're going to rename the final executable, determine the name now.
|
# If we're going to rename the final executable, determine the name now.
|
||||||
|
|
||||||
if [ x"$transformarg" = x ]
|
if [ x"$transformarg" = x ]
|
||||||
then
|
then
|
||||||
dstfile=`basename $dst`
|
dstfile=`basename "$dst"`
|
||||||
else
|
else
|
||||||
dstfile=`basename $dst $transformbasename |
|
dstfile=`basename "$dst" "$transformbasename" |
|
||||||
sed $transformarg`$transformbasename
|
sed "$transformarg"`"$transformbasename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# don't allow the sed command to completely eliminate the filename
|
# don't allow the sed command to completely eliminate the filename
|
||||||
|
|
||||||
if [ x"$dstfile" = x ]
|
if [ x"$dstfile" = x ]
|
||||||
then
|
then
|
||||||
dstfile=`basename $dst`
|
dstfile=`basename "$dst"`
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make a temp file name in the proper directory.
|
# Make a temp file name in the proper directory.
|
||||||
|
|
||||||
dsttmp=$dstdir/#inst.$$#
|
dsttmp="$dstdir/#inst.$$#"
|
||||||
|
|
||||||
# Move or copy the file name to the temp name
|
# Move or copy the file name to the temp name
|
||||||
|
|
||||||
$doit $instcmd $src $dsttmp &&
|
$doit $instcmd "$src" "$dsttmp" &&
|
||||||
|
|
||||||
trap "rm -f ${dsttmp}" 0 &&
|
trap "rm -f \"${dsttmp}\"" 0 &&
|
||||||
|
|
||||||
# and set any options; do chmod last to preserve setuid bits
|
# and set any options; do chmod last to preserve setuid bits
|
||||||
|
|
||||||
|
@ -235,15 +235,15 @@ else
|
||||||
# ignore errors from any of these, just make sure not to ignore
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||||
|
|
||||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi &&
|
||||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi &&
|
||||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else true;fi &&
|
||||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi &&
|
||||||
|
|
||||||
# Now rename the file to the real destination.
|
# Now rename the file to the real destination.
|
||||||
|
|
||||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
$doit $rmcmd -f "$dstdir/$dstfile" &&
|
||||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||||
|
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue