Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2013-01-24 22:19:06 +0400
committerJason Perkins <starkos@industriousone.com>2013-01-24 22:19:06 +0400
commit53b6b39a8d1db9b6cabaf190c326a42064217266 (patch)
treefc1303ee86c8abfd9b6c12ddfc47506a5a3670df /src/actions/make
parenta3829657a1d29e7f863f8618414cf898cebf52a5 (diff)
Clean up GMake link tests in preparation for a bug fix
Diffstat (limited to 'src/actions/make')
-rw-r--r--src/actions/make/_make.lua42
-rw-r--r--src/actions/make/make_cpp.lua67
2 files changed, 66 insertions, 43 deletions
diff --git a/src/actions/make/_make.lua b/src/actions/make/_make.lua
index 0bf80f6..13facf2 100644
--- a/src/actions/make/_make.lua
+++ b/src/actions/make/_make.lua
@@ -26,13 +26,13 @@
result = result:gsub(" ", "\\ ")
result = result:gsub("%(", "\\%(")
result = result:gsub("%)", "\\%)")
-
+
-- leave $(...) shell replacement sequences alone
result = result:gsub("$\\%((.-)\\%)", "$%(%1%)")
return result
end
end
-
+
--
@@ -59,8 +59,20 @@
_p('endif')
_p('')
end
-
-
+
+
+--
+-- Format a list of values to be safely written as part of a variable assignment.
+--
+
+ function make.list(value)
+ if #value > 0 then
+ return " " .. table.concat(value, " ")
+ else
+ return ""
+ end
+ end
+
--
-- Get the makefile file name for a solution or a project. If this object is the
@@ -79,14 +91,14 @@
end
end
end
-
+
if (count == 1) then
return "Makefile"
else
return this.name .. ".make"
end
end
-
+
--
-- Returns a list of object names, properly escaped to be included in the makefile.
@@ -99,7 +111,7 @@
end
return result
end
-
+
--
@@ -112,7 +124,7 @@
_p(value)
end
end
-
+
local toolsettings = cc.platforms[cfg.platform].cfgsettings
if toolsettings then
_p(toolsettings)
@@ -128,20 +140,20 @@
trigger = "gmake",
shortname = "GNU Make",
description = "Generate GNU makefiles for POSIX, MinGW, and Cygwin",
-
+
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
-
+
valid_languages = { "C", "C++", "C#" },
-
+
valid_tools = {
cc = { "gcc" },
dotnet = { "mono", "msnet", "pnet" },
},
-
+
onsolution = function(sln)
premake.generate(sln, _MAKE.getmakefilename(sln, false), premake.make_solution)
end,
-
+
onproject = function(prj)
local makefile = _MAKE.getmakefilename(prj, true)
if premake.isdotnetproject(prj) then
@@ -150,11 +162,11 @@
premake.generate(prj, makefile, premake.make_cpp)
end
end,
-
+
oncleansolution = function(sln)
premake.clean.file(sln, _MAKE.getmakefilename(sln, false))
end,
-
+
oncleanproject = function(prj)
premake.clean.file(prj, _MAKE.getmakefilename(prj, true))
end
diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua
index 7f9f6b2..8f34455 100644
--- a/src/actions/make/make_cpp.lua
+++ b/src/actions/make/make_cpp.lua
@@ -154,7 +154,7 @@
_p('CXX = %s', cc.cxx)
_p('AR = %s', cc.ar)
_p('')
-
+
_p('ifndef RESCOMP')
_p(' ifdef WINDRES')
_p(' RESCOMP = $(WINDRES)')
@@ -162,7 +162,7 @@
_p(' RESCOMP = windres')
_p(' endif')
_p('endif')
- _p('')
+ _p('')
end
--
@@ -179,32 +179,18 @@
_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))
_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))
- _p(' DEFINES += %s', table.concat(cc.getdefines(cfg.defines), " "))
- _p(' INCLUDES += %s', table.concat(cc.getincludedirs(cfg.includedirs), " "))
+ _p(' DEFINES +=%s', make.list(cc.getdefines(cfg.defines)))
+ _p(' INCLUDES +=%s', make.list(cc.getincludedirs(cfg.includedirs)))
- -- CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, and RESFLAGS
+ -- CPPFLAGS, CFLAGS, CXXFLAGS, and RESFLAGS
cpp.flags(cfg, cc)
+ -- write out libraries, linker flags, and the link command
+ cpp.linker(cfg, cc)
+
-- set up precompiled headers
cpp.pchconfig(cfg)
- _p(' LIBS += %s', table.concat(cc.getlinkflags(cfg), " "))
- _p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")), " "))
-
- if cfg.kind == "StaticLib" then
- if cfg.platform:startswith("Universal") then
- _p(' LINKCMD = libtool -o $(TARGET) $(OBJECTS)')
- else
- _p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)')
- end
- else
- -- this was $(TARGET) $(LDFLAGS) $(OBJECTS)
- -- but had trouble linking to certain static libs so $(OBJECTS) moved up
- -- then $(LDFLAGS) moved to end
- -- https://sourceforge.net/tracker/?func=detail&aid=3430158&group_id=71616&atid=531880
- _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS)', iif(cfg.language == "C", "CC", "CXX"))
- end
-
_p(' define PREBUILDCMDS')
if #cfg.prebuildcommands > 0 then
_p('\t@echo Running pre-build commands')
@@ -258,15 +244,40 @@
function cpp.flags(cfg, cc)
_p(' ALL_CPPFLAGS += $(CPPFLAGS) %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), " "))
- _p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), " "))
- _p(' ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " "))
+ _p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions)))
+ _p(' ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)%s', make.list(cc.getcxxflags(cfg)))
+
+ _p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s',
+ make.list(table.join(cc.getdefines(cfg.resdefines),
+ cc.getincludedirs(cfg.resincludedirs), cfg.resoptions)))
+ end
+
+
+--
+-- Linker settings, including the libraries to link, the linker flags,
+-- and the linker command.
+--
+ function cpp.linker(cfg, cc)
-- Patch #3401184 changed the order
- _p(' ALL_LDFLAGS += $(LDFLAGS) %s', table.concat(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions), " "))
+ _p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions)))
- _p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s',
- table.concat(table.join(cc.getdefines(cfg.resdefines),
- cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " "))
+ _p(' LIBS +=%s', make.list(cc.getlinkflags(cfg)))
+ _p(' LDDEPS +=%s', make.list(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath"))))
+
+ if cfg.kind == "StaticLib" then
+ if cfg.platform:startswith("Universal") then
+ _p(' LINKCMD = libtool -o $(TARGET) $(OBJECTS)')
+ else
+ _p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)')
+ end
+ else
+ -- this was $(TARGET) $(LDFLAGS) $(OBJECTS)
+ -- but had trouble linking to certain static libs so $(OBJECTS) moved up
+ -- then $(LDFLAGS) moved to end
+ -- https://sourceforge.net/tracker/?func=detail&aid=3430158&group_id=71616&atid=531880
+ _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS)', iif(cfg.language == "C", "CC", "CXX"))
+ end
end