Patch 3430158: Reorder LINKCMD for Gmake (rjmyst3)

This commit is contained in:
Jason Perkins 2011-12-08 16:25:50 -05:00
parent 1350e205fd
commit acebe2cc9c
3 changed files with 47 additions and 44 deletions

View File

@ -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)
-------

View File

@ -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

View File

@ -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