2009-04-11 11:33:32 +00:00
|
|
|
--
|
|
|
|
-- make_solution.lua
|
|
|
|
-- Generate a solution-level makefile.
|
|
|
|
-- Copyright (c) 2002-2009 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
function premake.make_solution(sln)
|
|
|
|
-- write a header showing the build options
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('# %s solution makefile autogenerated by Premake', premake.actions[_ACTION].shortname)
|
|
|
|
_p('# Usage: make [ config=config_name ]')
|
|
|
|
_p('# Where {config_name} is one of: %s.', table.implode(sln.configurations, '"', '"', ', '):lower())
|
|
|
|
_p('')
|
2009-04-11 11:33:32 +00:00
|
|
|
|
|
|
|
-- set a default configuration
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('ifndef config')
|
|
|
|
_p(' config=%s', _MAKE.esc(sln.configurations[1]:lower()))
|
|
|
|
_p('endif')
|
|
|
|
_p('export config')
|
|
|
|
_p('')
|
2009-04-11 11:33:32 +00:00
|
|
|
|
|
|
|
-- list the projects included in the solution
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('PROJECTS := %s', table.concat(_MAKE.esc(table.extract(sln.projects, "name")), " "))
|
|
|
|
_p('')
|
|
|
|
_p('.PHONY: all clean $(PROJECTS)')
|
|
|
|
_p('')
|
|
|
|
_p('all: $(PROJECTS)')
|
2009-04-11 11:33:32 +00:00
|
|
|
|
|
|
|
-- write the project build rules
|
|
|
|
for _, prj in ipairs(sln.projects) do
|
|
|
|
for cfg in premake.eachconfig(prj) do
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('ifeq ($(config),%s)', _MAKE.esc(cfg.name:lower()))
|
|
|
|
_p(' DEPENDENCIES := %s', table.concat(_MAKE.esc(table.extract(premake.getdependencies(cfg), "name")), " "))
|
|
|
|
_p('endif')
|
2009-04-11 11:33:32 +00:00
|
|
|
end
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('')
|
2009-04-11 11:33:32 +00:00
|
|
|
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('%s: ${DEPENDENCIES}', _MAKE.esc(prj.name))
|
|
|
|
_p('\t@echo ==== Building %s ====', prj.name)
|
|
|
|
_p('\t@${MAKE} --no-print-directory -C %s -f %s', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))
|
|
|
|
_p('')
|
2009-04-11 11:33:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- clean rules
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('clean:')
|
2009-04-11 11:33:32 +00:00
|
|
|
for _ ,prj in ipairs(sln.projects) do
|
2009-04-11 11:49:07 +00:00
|
|
|
_p(' @${MAKE} --no-print-directory -C %s -f %s clean', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))
|
2009-04-11 11:33:32 +00:00
|
|
|
end
|
|
|
|
end
|