Skip to content
Snippets Groups Projects
Commit f31e3ba4 authored by nicolas's avatar nicolas
Browse files

Move sections around to allow porting to windows

We will need to use the environment's CC variable to make decisions
that apply to windows compiling and linking. Therefore we move some
existing sections below the set up of env["CC"] and env["CXX"]
parent 45eea0d9
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ import os.path
import platform
import sys
vars = Variables(None, ARGUMENTS)
vars.Add(PathVariable('DESTDIR', "Root directory to install in (useful for packaging scripts)", None, PathVariable.PathIsDirCreate))
vars.Add(PathVariable('prefix', "Where to install in the FHS", "/usr/local", PathVariable.PathAccept))
......@@ -49,15 +48,6 @@ env['backendsincpath'] = calcInstallPath("$prefix", "include", "hammer", "backen
env['pkgconfigpath'] = calcInstallPath("$prefix", "lib", "pkgconfig")
env.ScanReplace('libhammer.pc.in')
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable")
if env['PLATFORM'] == 'darwin':
env.Append(SHLINKFLAGS = '-install_name ' + env["libpath"] + '/${TARGET.file}')
elif os.uname()[0] == "OpenBSD":
pass
else:
env.MergeFlags("-lrt")
AddOption("--variant",
dest="variant",
nargs=1, type="choice",
......@@ -78,20 +68,23 @@ AddOption("--in-place",
action="store_true",
help="Build in-place, rather than in the build/<variant> tree")
env["CC"] = os.getenv("CC") or env["CC"]
env["CXX"] = os.getenv("CXX") or env["CXX"]
dbg = env.Clone(VARIANT='debug')
dbg.Append(CCFLAGS=['-g'])
if os.getenv("CC") == "clang" or env['PLATFORM'] == 'darwin':
env.Replace(CC="clang",
CXX="clang++")
opt = env.Clone(VARIANT='opt')
opt.Append(CCFLAGS=["-O3"])
# Language standard and warnings
env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attributes -Wno-unused-variable")
if GetOption("variant") == 'debug':
env = dbg
# Linker options
if env['PLATFORM'] == 'darwin':
env.Append(SHLINKFLAGS = '-install_name ' + env["libpath"] + '/${TARGET.file}')
elif platform.system() == "OpenBSD":
pass
else:
env = opt
env["CC"] = os.getenv("CC") or env["CC"]
env["CXX"] = os.getenv("CXX") or env["CXX"]
env.MergeFlags("-lrt")
if GetOption("coverage"):
env.Append(CFLAGS=["--coverage"],
......@@ -102,9 +95,16 @@ if GetOption("coverage"):
else:
env.ParseConfig('llvm-config --ldflags')
if os.getenv("CC") == "clang" or env['PLATFORM'] == 'darwin':
env.Replace(CC="clang",
CXX="clang++")
dbg = env.Clone(VARIANT='debug')
dbg.Append(CCFLAGS=['-g'])
opt = env.Clone(VARIANT='opt')
opt.Append(CCFLAGS=["-O3"])
if GetOption("variant") == 'debug':
env = dbg
else:
env = opt
env["ENV"].update(x for x in os.environ.items() if x[0].startswith("CCC_"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment