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>2011-12-09 01:25:50 +0400
committerJason Perkins <starkos@industriousone.com>2011-12-09 01:25:50 +0400
commit090384b603afbcf8605552f00923a1eeea1498bd (patch)
tree244260ce631f6bb22fff6c8c41cb6a2a45d0ddab
parent06a6ff6d302f57e294d25488a4d0f11175a31272 (diff)
Patch 3430158: Reorder LINKCMD for Gmake (rjmyst3)
-rw-r--r--CHANGES.txt1
-rw-r--r--src/actions/make/make_cpp.lua84
-rw-r--r--tests/test_gmake_cpp.lua6
3 files changed, 47 insertions, 44 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index b42f84c..c975806 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -48,6 +48,7 @@
* Patch 3445049: Build fix for FreeBSD (Konstantin Tokarev)
* Bug 3121217: Test suite fails on Linux x86_64: os.findlib broken
* Patch 3428348: Add .gitignore file (Konstantin Tokarev)
+* Patch 3430158: Reorder LINKCMD for Gmake (rjmyst3)
-------
diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua
index f50eb93..78bcaec 100644
--- a/src/actions/make/make_cpp.lua
+++ b/src/actions/make/make_cpp.lua
@@ -7,15 +7,15 @@
premake.make.cpp = { }
local cpp = premake.make.cpp
local make = premake.make
-
+
function premake.make_cpp(prj)
-- create a shortcut to the compiler interface
local cc = premake.gettool(prj)
-
+
-- build a list of supported target platforms that also includes a generic build
local platforms = premake.filterplatforms(prj.solution, cc.platforms, "Native")
-
+
premake.gmake_cpp_header(prj, cc, platforms)
for _, platform in ipairs(platforms) do
@@ -23,7 +23,7 @@
premake.gmake_cpp_config(cfg, cc)
end
end
-
+
-- list intermediate files
_p('OBJECTS := \\')
for _, file in ipairs(prj.files) do
@@ -32,7 +32,7 @@
end
end
_p('')
-
+
_p('RESOURCES := \\')
for _, file in ipairs(prj.files) do
if path.isresourcefile(file) then
@@ -40,7 +40,7 @@
end
end
_p('')
-
+
-- identify the shell type
_p('SHELLTYPE := msdos')
_p('ifeq (,$(ComSpec)$(COMSPEC))')
@@ -50,7 +50,7 @@
_p(' SHELLTYPE := posix')
_p('endif')
_p('')
-
+
-- main build rule(s)
_p('.PHONY: clean prebuild prelink')
_p('')
@@ -69,12 +69,12 @@
_p('\t$(SILENT) $(LINKCMD)')
_p('\t$(POSTBUILDCMDS)')
_p('')
-
+
-- Create destination directories. Can't use $@ for this because it loses the
-- escaping, causing issues with spaces and parenthesis
_p('$(TARGETDIR):')
premake.make_mkdirrule("$(TARGETDIR)")
-
+
_p('$(OBJDIR):')
premake.make_mkdirrule("$(OBJDIR)")
@@ -101,14 +101,14 @@
_p('prebuild:')
_p('\t$(PREBUILDCMDS)')
_p('')
-
+
_p('prelink:')
_p('\t$(PRELINKCMDS)')
_p('')
-- precompiler header rule
cpp.pchrules(prj)
-
+
-- per-file rules
for _, file in ipairs(prj.files) do
if path.iscppfile(file) then
@@ -122,7 +122,7 @@
end
end
_p('')
-
+
-- include the dependencies, built by GCC (with the -MMD flag)
_p('-include $(OBJECTS:%%.o=%%.d)')
end
@@ -141,28 +141,28 @@
_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))
_p('endif')
_p('')
-
+
_p('ifndef verbose')
_p(' SILENT = @')
_p('endif')
_p('')
-
+
_p('ifndef CC')
_p(' CC = %s', cc.cc)
_p('endif')
_p('')
-
+
_p('ifndef CXX')
_p(' CXX = %s', cc.cxx)
_p('endif')
_p('')
-
+
_p('ifndef AR')
_p(' AR = %s', cc.ar)
_p('endif')
_p('')
end
-
+
--
-- Write a block of configuration settings.
@@ -171,25 +171,25 @@
function premake.gmake_cpp_config(cfg, cc)
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))
-
+
-- if this platform requires a special compiler or linker, list it here
cpp.platformtools(cfg, cc)
- _p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))
+ _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), " "))
- -- CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, and RESFLAGS
+ -- CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, and RESFLAGS
cpp.flags(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)')
@@ -197,11 +197,13 @@
_p(' LINKCMD = $(AR) -rcs $(TARGET) $(OBJECTS)')
end
else
- -- this was $(TARGET) $(LDFLAGS) $(OBJECTS) ... but was having trouble linking to certain
- -- static libraries so $(OBJECTS) was moved up
- _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)', iif(cfg.language == "C", "CC", "CXX"))
+ -- 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) $(LDFLAGS)', iif(cfg.language == "C", "CC", "CXX"))
end
-
+
_p(' define PREBUILDCMDS')
if #cfg.prebuildcommands > 0 then
_p('\t@echo Running pre-build commands')
@@ -222,19 +224,19 @@
_p('\t%s', table.implode(cfg.postbuildcommands, "", "", "\n\t"))
end
_p(' endef')
-
+
-- write out config-level makesettings blocks
make.settings(cfg, cc)
-
+
_p('endif')
_p('')
end
-
-
+
+
--
-- Platform support
--
-
+
function cpp.platformtools(cfg, cc)
local platform = cc.platforms[cfg.platform]
if platform.cc then
@@ -247,8 +249,8 @@
_p(' AR = %s', platform.ar)
end
end
-
-
+
+
--
-- Configurations
--
@@ -257,16 +259,16 @@
_p(' CPPFLAGS += %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), " "))
_p(' CFLAGS += $(CPPFLAGS) $(ARCH) %s', table.concat(table.join(cc.getcflags(cfg), cfg.buildoptions), " "))
_p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " "))
-
+
-- Patch #3401184 changed the order
_p(' LDFLAGS += %s', table.concat(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions), " "))
-
- _p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s',
+
+ _p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s',
table.concat(table.join(cc.getdefines(cfg.resdefines),
cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " "))
end
-
-
+
+
--
-- Precompiled header support
--
@@ -286,7 +288,7 @@
if not cfg.flags.NoPCH and cfg.pchheader then
_p(' PCH = %s', _MAKE.esc(path.getrelative(cfg.location, cfg.pchheader)))
- _p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader)))
+ _p(' GCH = $(OBJDIR)/%s.gch', _MAKE.esc(path.getname(cfg.pchheader)))
_p(' CPPFLAGS += -I$(OBJDIR) -include $(OBJDIR)/%s', _MAKE.esc(path.getname(cfg.pchheader)))
end
end
@@ -304,7 +306,7 @@
_p('endif')
_p('')
end
-
+
--
-- Build command for a single file.
@@ -314,5 +316,5 @@
local flags = iif(iscfile, '$(CC) $(CFLAGS)', '$(CXX) $(CXXFLAGS)')
_p('\t$(SILENT) %s -o "$@" -MF $(@:%%.o=%%.d) -c "$<"', flags)
end
-
+
diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua
index 8c80411..529a6da 100644
--- a/tests/test_gmake_cpp.lua
+++ b/tests/test_gmake_cpp.lua
@@ -85,7 +85,7 @@ ifeq ($(config),debug)
RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
- LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
+ LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
define PREBUILDCMDS
endef
define PRELINKCMDS
@@ -119,7 +119,7 @@ ifeq ($(config),debugps3)
RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
- LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
+ LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
define PREBUILDCMDS
endef
define PRELINKCMDS
@@ -150,7 +150,7 @@ ifeq ($(config),debug64)
RESFLAGS += $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
- LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)
+ LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
define PREBUILDCMDS
endef
define PRELINKCMDS