Skip to content
Snippets Groups Projects
Commit 50047cdd authored by Donald Stufft's avatar Donald Stufft
Browse files

Fix compilation on gcc systems

parent 5eb226d6
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
import os
import os.path import os.path
import shlex import shlex
import shutil import shutil
...@@ -22,6 +23,25 @@ def here(*paths): ...@@ -22,6 +23,25 @@ def here(*paths):
return os.path.abspath(os.path.join(os.path.dirname(__file__), *paths)) return os.path.abspath(os.path.join(os.path.dirname(__file__), *paths))
def which(name, flags=os.X_OK): # Taken from twisted
result = []
exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
path = os.environ.get('PATH', None)
if path is None:
return []
for p in os.environ.get('PATH', '').split(os.pathsep):
p = os.path.join(p, name)
if os.access(p, flags):
result.append(p)
for e in exts:
pext = p + e
if os.access(pext, flags):
result.append(pext)
return result
try: try:
import nacl.nacl import nacl.nacl
except ImportError: except ImportError:
...@@ -132,6 +152,23 @@ class build_clib(_build_clib): ...@@ -132,6 +152,23 @@ class build_clib(_build_clib):
if self._include_asm and not ".S" in self.compiler.src_extensions: if self._include_asm and not ".S" in self.compiler.src_extensions:
self.compiler.src_extensions.append(".S") self.compiler.src_extensions.append(".S")
# If we have a unix compiler see if it's gcc so we can enable certain
# flags for it.
if self.compiler.compiler_type == "unix":
cc = which(self.compiler.executables["compiler"][0])[0]
cc = os.path.realpath(cc)
if "gcc" in os.path.basename(cc):
real_compile = self.compiler._compile
def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
if "-std=c99" not in cc_args:
cc_args += ["-std=c99"]
return real_compile(
obj, src, ext, cc_args, extra_postargs, pp_opts)
self.compiler._compile = _compile
return _build_clib.build_libraries(self, libraries) return _build_clib.build_libraries(self, libraries)
......
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