2009-04-11 11:33:32 +00:00
|
|
|
--
|
|
|
|
-- make_cpp.lua
|
|
|
|
-- Generate a C/C++ project makefile.
|
2013-08-11 18:22:24 +00:00
|
|
|
-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
|
2009-04-11 11:33:32 +00:00
|
|
|
--
|
|
|
|
|
2012-09-27 14:16:42 +00:00
|
|
|
premake.make.cpp = {}
|
2011-09-15 20:45:48 +00:00
|
|
|
local make = premake.make
|
2012-04-30 20:42:03 +00:00
|
|
|
local cpp = premake.make.cpp
|
2012-05-18 00:41:28 +00:00
|
|
|
local project = premake5.project
|
|
|
|
local config = premake5.config
|
2013-07-12 15:07:26 +00:00
|
|
|
local fileconfig = premake5.fileconfig
|
2012-04-30 20:42:03 +00:00
|
|
|
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
---
|
|
|
|
-- Add namespace for element definition lists for premake.callarray()
|
|
|
|
---
|
2012-05-08 22:08:42 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
cpp.elements = {}
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-05-08 22:08:42 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
--
|
|
|
|
-- Generate a GNU make C++ project makefile, with support for the new platforms API.
|
|
|
|
--
|
2012-05-08 22:08:42 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
cpp.elements.makefile = {
|
|
|
|
"header",
|
|
|
|
"phonyRules",
|
|
|
|
"cppConfigs",
|
|
|
|
"cppObjects",
|
|
|
|
"shellType",
|
|
|
|
"cppTargetRules",
|
|
|
|
"targetDirRules",
|
|
|
|
"objDirRules",
|
|
|
|
"cppCleanRules",
|
|
|
|
"preBuildRules",
|
|
|
|
"preLinkRules",
|
|
|
|
"pchRules",
|
|
|
|
"cppFileRules",
|
|
|
|
"cppDependencies",
|
|
|
|
}
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function make.cpp.generate(prj)
|
|
|
|
premake.callarray(make, cpp.elements.makefile, prj)
|
2012-04-30 20:42:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-05-18 00:41:28 +00:00
|
|
|
--
|
|
|
|
-- Write out the settings for a particular configuration.
|
|
|
|
--
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
cpp.elements.configuration = {
|
|
|
|
"cppTools",
|
|
|
|
"target",
|
|
|
|
"objdir",
|
|
|
|
"defines",
|
|
|
|
"includes",
|
|
|
|
"forceIncludes",
|
|
|
|
"cppFlags",
|
|
|
|
"cFlags",
|
|
|
|
"cxxFlags",
|
|
|
|
"resFlags",
|
|
|
|
"pch",
|
|
|
|
"libs",
|
|
|
|
"ldDeps",
|
|
|
|
"ldFlags",
|
|
|
|
"linkCmd",
|
|
|
|
"preBuildCmds",
|
|
|
|
"preLinkCmds",
|
|
|
|
"postBuildCmds",
|
|
|
|
"cppAllRules",
|
|
|
|
"settings",
|
|
|
|
}
|
|
|
|
|
|
|
|
function make.cppConfigs(prj)
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
-- identify the toolset used by this configurations (would be nicer if
|
|
|
|
-- this were computed and stored with the configuration up front)
|
2012-05-18 00:41:28 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
local toolset = premake.tools[cfg.toolset or "gcc"]
|
|
|
|
if not toolset then
|
|
|
|
error("Invalid toolset '" + cfg.toolset + "'")
|
|
|
|
end
|
2012-05-18 00:41:28 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
_x('ifeq ($(config),%s)', cfg.shortname)
|
|
|
|
premake.callarray(make, cpp.elements.configuration, cfg, toolset)
|
|
|
|
_p('endif')
|
|
|
|
_p('')
|
2012-05-18 00:41:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-06-14 19:55:46 +00:00
|
|
|
--
|
|
|
|
-- Build command for a single file.
|
|
|
|
--
|
|
|
|
|
2013-05-02 12:36:11 +00:00
|
|
|
function cpp.buildcommand(prj, objext, node)
|
|
|
|
local iscfile = node and path.iscfile(node.abspath) or false
|
|
|
|
local flags = iif(prj.language == "C" or iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')
|
2012-09-05 22:37:53 +00:00
|
|
|
_p('\t$(SILENT) %s -o "$@" -MF $(@:%%.%s=%%.d) -c "$<"', flags, objext)
|
2012-06-14 19:55:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-06-19 19:58:16 +00:00
|
|
|
--
|
|
|
|
-- Output the list of file building rules.
|
|
|
|
--
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function make.cppFileRules(prj)
|
2012-06-19 19:58:16 +00:00
|
|
|
local tr = project.getsourcetree(prj)
|
|
|
|
premake.tree.traverse(tr, {
|
|
|
|
onleaf = function(node, depth)
|
2012-06-29 13:05:20 +00:00
|
|
|
-- check to see if this file has custom rules
|
|
|
|
local rules
|
|
|
|
for cfg in project.eachconfig(prj) do
|
2013-07-12 15:07:26 +00:00
|
|
|
local filecfg = fileconfig.getconfig(node, cfg)
|
|
|
|
if fileconfig.hasCustomBuildRule(filecfg) then
|
2012-06-29 13:05:20 +00:00
|
|
|
rules = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- if it has custom rules, need to break them out
|
|
|
|
-- into individual configurations
|
|
|
|
if rules then
|
2013-08-11 18:22:24 +00:00
|
|
|
cpp.customFileRules(prj, node)
|
2012-06-29 13:05:20 +00:00
|
|
|
else
|
2013-08-11 18:22:24 +00:00
|
|
|
cpp.standardFileRules(prj, node)
|
2012-06-19 19:58:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
_p('')
|
|
|
|
end
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function cpp.standardFileRules(prj, node)
|
2012-06-29 13:05:20 +00:00
|
|
|
-- C/C++ file
|
|
|
|
if path.iscppfile(node.abspath) then
|
2013-06-21 21:32:33 +00:00
|
|
|
_x('$(OBJDIR)/%s.o: %s', node.objname, node.relpath)
|
2012-06-29 13:05:20 +00:00
|
|
|
_p('\t@echo $(notdir $<)')
|
2013-05-02 12:36:11 +00:00
|
|
|
cpp.buildcommand(prj, "o", node)
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-29 13:05:20 +00:00
|
|
|
-- resource file
|
|
|
|
elseif path.isresourcefile(node.abspath) then
|
2013-06-21 21:32:33 +00:00
|
|
|
_x('$(OBJDIR)/%s.res: %s', node.objname, node.relpath)
|
2012-06-29 13:05:20 +00:00
|
|
|
_p('\t@echo $(notdir $<)')
|
2013-01-23 16:50:54 +00:00
|
|
|
_p('\t$(SILENT) $(RESCOMP) $< -O coff -o "$@" $(ALL_RESFLAGS)')
|
2012-06-29 13:05:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function cpp.customFileRules(prj, node)
|
2012-06-29 13:05:20 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2013-07-12 15:07:26 +00:00
|
|
|
local filecfg = fileconfig.getconfig(node, cfg)
|
2012-07-04 18:13:01 +00:00
|
|
|
if filecfg then
|
2013-05-22 15:15:48 +00:00
|
|
|
_x('ifeq ($(config),%s)', cfg.shortname)
|
2013-04-09 19:12:04 +00:00
|
|
|
|
|
|
|
local output = project.getrelative(prj, filecfg.buildoutputs[1])
|
2013-05-22 15:15:48 +00:00
|
|
|
_x('%s: %s', output, filecfg.relpath)
|
2013-04-09 19:12:04 +00:00
|
|
|
_p('\t@echo "%s"', filecfg.buildmessage or ("Building " .. filecfg.relpath))
|
|
|
|
for _, cmd in ipairs(filecfg.buildcommands) do
|
2012-07-04 18:13:01 +00:00
|
|
|
_p('\t$(SILENT) %s', cmd)
|
|
|
|
end
|
|
|
|
_p('endif')
|
2012-06-29 13:05:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-19 19:58:16 +00:00
|
|
|
|
2012-06-15 22:42:10 +00:00
|
|
|
--
|
|
|
|
-- List the objects file for the project, and each configuration.
|
|
|
|
--
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function make.cppObjects(prj)
|
2012-06-22 13:27:03 +00:00
|
|
|
-- create lists for intermediate files, at the project level and
|
|
|
|
-- for each configuration
|
|
|
|
local root = { objects={}, resources={} }
|
2013-01-23 16:50:54 +00:00
|
|
|
local configs = {}
|
2012-06-15 22:42:10 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2012-06-22 13:27:03 +00:00
|
|
|
configs[cfg] = { objects={}, resources={} }
|
2012-06-15 22:42:10 +00:00
|
|
|
end
|
2012-06-22 13:27:03 +00:00
|
|
|
|
|
|
|
-- now walk the list of files in the project
|
2012-06-15 22:42:10 +00:00
|
|
|
local tr = project.getsourcetree(prj)
|
|
|
|
premake.tree.traverse(tr, {
|
|
|
|
onleaf = function(node, depth)
|
2012-06-29 13:05:20 +00:00
|
|
|
-- figure out what configurations contain this file, and
|
|
|
|
-- if it uses custom build rules
|
2012-07-04 16:52:25 +00:00
|
|
|
local incfg = {}
|
2012-06-29 13:05:20 +00:00
|
|
|
local inall = true
|
|
|
|
local custom = false
|
2012-06-15 22:42:10 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2013-07-12 15:07:26 +00:00
|
|
|
local filecfg = fileconfig.getconfig(node, cfg)
|
2013-02-07 15:58:31 +00:00
|
|
|
if filecfg and not filecfg.flags.ExcludeFromBuild then
|
2012-06-29 13:05:20 +00:00
|
|
|
incfg[cfg] = filecfg
|
2013-07-12 15:07:26 +00:00
|
|
|
custom = fileconfig.hasCustomBuildRule(filecfg)
|
2012-06-29 13:05:20 +00:00
|
|
|
else
|
|
|
|
inall = false
|
2012-06-15 22:42:10 +00:00
|
|
|
end
|
|
|
|
end
|
2012-06-22 13:27:03 +00:00
|
|
|
|
2012-06-29 13:05:20 +00:00
|
|
|
if not custom then
|
|
|
|
-- identify the file type
|
|
|
|
local kind
|
|
|
|
if path.iscppfile(node.abspath) then
|
|
|
|
kind = "objects"
|
|
|
|
elseif path.isresourcefile(node.abspath) then
|
|
|
|
kind = "resources"
|
|
|
|
end
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-29 13:05:20 +00:00
|
|
|
-- skip files that aren't compiled
|
|
|
|
if not custom and not kind then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- assign a unique object file name to avoid collisions
|
2013-06-21 21:32:33 +00:00
|
|
|
objectname = "$(OBJDIR)/" .. node.objname .. iif(kind == "objects", ".o", ".res")
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-29 13:05:20 +00:00
|
|
|
-- if this file exists in all configurations, write it to
|
|
|
|
-- the project's list of files, else add to specific cfgs
|
|
|
|
if inall then
|
|
|
|
table.insert(root[kind], objectname)
|
|
|
|
else
|
|
|
|
for cfg in project.eachconfig(prj) do
|
|
|
|
if incfg[cfg] then
|
|
|
|
table.insert(configs[cfg][kind], objectname)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-15 22:42:10 +00:00
|
|
|
else
|
|
|
|
for cfg in project.eachconfig(prj) do
|
2012-06-29 13:05:20 +00:00
|
|
|
local filecfg = incfg[cfg]
|
2013-01-23 16:50:54 +00:00
|
|
|
if filecfg then
|
2012-06-29 13:05:20 +00:00
|
|
|
-- if the custom build outputs an object file, add it to
|
|
|
|
-- the link step automatically to match Visual Studio
|
2013-04-09 19:12:04 +00:00
|
|
|
local output = project.getrelative(prj, filecfg.buildoutputs[1])
|
2012-06-29 13:05:20 +00:00
|
|
|
if path.isobjectfile(output) then
|
|
|
|
table.insert(configs[cfg].objects, output)
|
|
|
|
end
|
2012-06-15 22:42:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-15 22:42:10 +00:00
|
|
|
end
|
|
|
|
})
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-22 13:27:03 +00:00
|
|
|
-- now I can write out the lists, project level first...
|
2012-06-29 13:05:20 +00:00
|
|
|
function listobjects(var, list)
|
2012-06-22 13:27:03 +00:00
|
|
|
_p('%s \\', var)
|
|
|
|
for _, objectname in ipairs(list) do
|
2013-05-22 15:15:48 +00:00
|
|
|
_x('\t%s \\', objectname)
|
2012-06-22 13:27:03 +00:00
|
|
|
end
|
|
|
|
_p('')
|
|
|
|
end
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-22 13:27:03 +00:00
|
|
|
listobjects('OBJECTS :=', root.objects, 'o')
|
|
|
|
listobjects('RESOURCES :=', root.resources, 'res')
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-22 13:27:03 +00:00
|
|
|
-- ...then individual configurations, as needed
|
2012-06-15 22:42:10 +00:00
|
|
|
for cfg in project.eachconfig(prj) do
|
2012-06-22 13:27:03 +00:00
|
|
|
local files = configs[cfg]
|
|
|
|
if #files.objects > 0 or #files.resources > 0 then
|
2013-05-22 15:15:48 +00:00
|
|
|
_x('ifeq ($(config),%s)', cfg.shortname)
|
2012-06-22 13:27:03 +00:00
|
|
|
if #files.objects > 0 then
|
2012-06-29 13:05:20 +00:00
|
|
|
listobjects(' OBJECTS +=', files.objects)
|
2012-06-22 13:27:03 +00:00
|
|
|
end
|
|
|
|
if #files.resources > 0 then
|
2012-06-29 13:05:20 +00:00
|
|
|
listobjects(' RESOURCES +=', files.resources)
|
2012-06-15 22:42:10 +00:00
|
|
|
end
|
|
|
|
_p('endif')
|
|
|
|
_p('')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
---------------------------------------------------------------------------
|
2012-06-12 19:57:45 +00:00
|
|
|
--
|
2013-08-11 18:22:24 +00:00
|
|
|
-- Handlers for individual makefile elements
|
2012-06-12 19:57:45 +00:00
|
|
|
--
|
2013-08-11 18:22:24 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function make.cFlags(cfg, toolset)
|
|
|
|
_p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(toolset.getcflags(cfg), cfg.buildoptions)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.cppAllRules(cfg, toolset)
|
|
|
|
if cfg.system == premake.MACOSX and cfg.kind == premake.WINDOWEDAPP then
|
|
|
|
_p('all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist')
|
|
|
|
_p('\t@:')
|
|
|
|
_p('')
|
|
|
|
_p('$(dir $(TARGETDIR))PkgInfo:')
|
|
|
|
_p('$(dir $(TARGETDIR))Info.plist:')
|
|
|
|
else
|
|
|
|
_p('all: $(TARGETDIR) $(OBJDIR) prebuild prelink $(TARGET)')
|
|
|
|
_p('\t@:')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.cppFlags(cfg, toolset)
|
|
|
|
_p(' ALL_CPPFLAGS += $(CPPFLAGS)%s $(DEFINES) $(INCLUDES) $(FORCE_INCLUDE)', make.list(toolset.getcppflags(cfg)))
|
|
|
|
end
|
2012-06-12 19:57:45 +00:00
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
|
|
|
|
function make.cxxFlags(cfg, toolset)
|
|
|
|
_p(' ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)%s', make.list(toolset.getcxxflags(cfg)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.cppCleanRules(prj)
|
|
|
|
_p('clean:')
|
|
|
|
_p('\t@echo Cleaning %s', prj.name)
|
|
|
|
_p('ifeq (posix,$(SHELLTYPE))')
|
|
|
|
_p('\t$(SILENT) rm -f $(TARGET)')
|
|
|
|
_p('\t$(SILENT) rm -rf $(OBJDIR)')
|
|
|
|
_p('else')
|
|
|
|
_p('\t$(SILENT) if exist $(subst /,\\\\,$(TARGET)) del $(subst /,\\\\,$(TARGET))')
|
|
|
|
_p('\t$(SILENT) if exist $(subst /,\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\,$(OBJDIR))')
|
|
|
|
_p('endif')
|
|
|
|
_p('')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.cppDependencies(prj)
|
|
|
|
-- include the dependencies, built by GCC (with the -MMD flag)
|
|
|
|
_p('-include $(OBJECTS:%%.o=%%.d)')
|
|
|
|
_p('ifneq (,$(PCH))')
|
|
|
|
_p(' -include $(OBJDIR)/$(notdir $(PCH)).d')
|
|
|
|
_p('endif')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.cppTargetRules(prj)
|
|
|
|
_p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES)')
|
|
|
|
_p('\t@echo Linking %s', prj.name)
|
|
|
|
_p('\t$(SILENT) $(LINKCMD)')
|
|
|
|
_p('\t$(POSTBUILDCMDS)')
|
|
|
|
_p('')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.cppTools(cfg, toolset)
|
|
|
|
local tool = toolset.gettoolname(cfg, "cc")
|
|
|
|
if tool then
|
|
|
|
_p(' CC = %s', tool)
|
|
|
|
end
|
|
|
|
|
|
|
|
tool = toolset.gettoolname(cfg, "cxx")
|
|
|
|
if tool then
|
|
|
|
_p(' CXX = %s', tool)
|
|
|
|
end
|
|
|
|
|
|
|
|
tool = toolset.gettoolname(cfg, "ar")
|
|
|
|
if tool then
|
|
|
|
_p(' AR = %s', tool)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.defines(cfg, toolset)
|
|
|
|
_p(' DEFINES +=%s', make.list(toolset.getdefines(cfg.defines)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.forceIncludes(cfg, toolset)
|
|
|
|
local includes = toolset.getforceincludes(cfg)
|
|
|
|
_x(' FORCE_INCLUDE +=%s', make.list(includes))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.includes(cfg, toolset)
|
|
|
|
local includes = premake.esc(toolset.getincludedirs(cfg, cfg.includedirs))
|
|
|
|
_p(' INCLUDES +=%s', make.list(includes))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.ldDeps(cfg, toolset)
|
|
|
|
local deps = config.getlinks(cfg, "siblings", "fullpath")
|
|
|
|
_p(' LDDEPS +=%s', make.list(premake.esc(deps)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.ldFlags(cfg, toolset)
|
|
|
|
_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(toolset.getldflags(cfg), cfg.linkoptions)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.libs(cfg, toolset)
|
|
|
|
local flags = toolset.getlinks(cfg)
|
|
|
|
_p(' LIBS +=%s', make.list(flags))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.linkCmd(cfg, toolset)
|
|
|
|
if cfg.kind == premake.STATICLIB then
|
|
|
|
if cfg.architecture == premake.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; $(OBJECTS) moved up
|
|
|
|
-- $(LDFLAGS) moved to end (http://sourceforge.net/p/premake/patches/107/)
|
|
|
|
-- $(LIBS) moved to end (http://sourceforge.net/p/premake/bugs/279/)
|
|
|
|
|
|
|
|
local cc = iif(cfg.language == "C", "CC", "CXX")
|
|
|
|
_p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)', cc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function make.pch(cfg, toolset)
|
2012-06-12 19:57:45 +00:00
|
|
|
if not cfg.flags.NoPCH and cfg.pchheader then
|
2013-08-11 18:22:24 +00:00
|
|
|
-- Try to locate the header on the include search paths
|
2012-06-12 19:57:45 +00:00
|
|
|
local pchheader = cfg.pchheader
|
|
|
|
for _, incdir in ipairs(cfg.includedirs) do
|
|
|
|
local testname = path.join(incdir, cfg.pchheader)
|
|
|
|
if os.isfile(testname) then
|
|
|
|
pchheader = testname
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-22 15:15:48 +00:00
|
|
|
local gch = path.getname(pchheader)
|
2013-08-11 18:22:24 +00:00
|
|
|
_x(' PCH = %s', project.getrelative(cfg.project, pchheader))
|
|
|
|
_x(' GCH = $(OBJDIR)/%s.gch', gch)
|
2013-05-22 15:15:48 +00:00
|
|
|
_x(' ALL_CPPFLAGS += -I$(OBJDIR) -include $(OBJDIR)/%s', gch)
|
2012-06-12 19:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function make.pchRules(prj)
|
2012-06-12 19:57:45 +00:00
|
|
|
_p('ifneq (,$(PCH))')
|
|
|
|
_p('$(GCH): $(PCH)')
|
|
|
|
_p('\t@echo $(notdir $<)')
|
|
|
|
_p('ifeq (posix,$(SHELLTYPE))')
|
|
|
|
_p('\t-$(SILENT) cp $< $(OBJDIR)')
|
|
|
|
_p('else')
|
|
|
|
_p('\t$(SILENT) xcopy /D /Y /Q "$(subst /,\\,$<)" "$(subst /,\\,$(OBJDIR))" 1>nul')
|
|
|
|
_p('endif')
|
2012-09-05 22:37:53 +00:00
|
|
|
cpp.buildcommand(prj, "gch")
|
2012-06-12 19:57:45 +00:00
|
|
|
_p('endif')
|
|
|
|
_p('')
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-08-11 18:22:24 +00:00
|
|
|
function make.resFlags(cfg, toolset)
|
|
|
|
local resflags = table.join(toolset.getdefines(cfg.resdefines), toolset.getincludedirs(cfg, cfg.resincludedirs), cfg.resoptions)
|
|
|
|
_p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s', make.list(resflags))
|
2012-06-12 19:57:45 +00:00
|
|
|
end
|