File: configure.py

package info (click to toggle)
caps 0.9.26-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 924 kB
  • sloc: cpp: 10,867; ansic: 1,324; makefile: 78; python: 38
file content (44 lines) | stat: -rwxr-xr-x 1,241 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/env python
import os

CFLAGS = []
ARCH = []

def dude_we_think_so_different():
	try: return 'Darwin' == os.popen ('uname -s').read().strip()
	except: return 0
OSX = dude_we_think_so_different()
if OSX:
	OSX_LDFLAGS = "-bundle -undefined suppress -flat_namespace"
	ARCH += ("-arch","i386","-arch","x86_64")
	import ctypes as C
	libc = C.CDLL("libc.dylib")
	def osx_query(k):
		size = C.c_uint(0)
		libc.sysctlbyname(k,None,C.byref(size),None,0)
		buf = C.create_string_buffer(size.value)
		libc.sysctlbyname(k,buf,C.byref(size),None,0)
		return buf.value

def we_have_sse():
	if OSX: return osx_query("hw.optional.sse2")
	try: return 'sse' in open ('/proc/cpuinfo').read().split()
	except: return 0
def we_have_ssse3():
	if OSX: return osx_query("hw.optional.sse3")
	try: return 'ssse3' in open ('/proc/cpuinfo').read().split()
	except: return 0
	
def store():
	f = open ('defines.make', 'w')
	f.write ("_CFLAGS=" + ' '.join (CFLAGS) + "\n")
	f.write ("ARCH=" + ' '.join (ARCH) + "\n")
	if OSX:
		f.write ("_LDFLAGS=" + OSX_LDFLAGS + "\n")
		f.write ("STRIP = echo\n")
	os.system ("make clean")

if __name__ == '__main__':
	if we_have_sse(): CFLAGS += ('-msse', '-mfpmath=sse')
	if we_have_ssse3(): CFLAGS += ('-msse3',)
	store()