summaryrefslogtreecommitdiff
blob: c3f740d5aa7f2c31a523166100e517c818c83073 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--- uwsgiconfig.py
+++ uwsgiconfig.py
@@ -20,7 +20,6 @@
 PLUGINS = []
 UNBIT=False
 UWSGI_BIN_NAME = 'uwsgi'
-GCC='gcc'
 
 # specific compilation flags
 # libxml2 or expat
@@ -46,17 +45,22 @@
 
 from distutils import sysconfig
 
+GCC = os.environ.get('CC', sysconfig.get_config_var('CC'))
+if not GCC:
+	GCC = 'gcc'
+
 gcc_list = ['utils', 'pyutils', 'protocol', 'socket', 'logging', 'wsgi_handlers', 'wsgi_headers', 'uwsgi_handlers', 'uwsgi']
 
 # large file support
 try:
-	cflags = ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + sysconfig.get_config_var('CFLAGS').split()
+	cflags = ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split()
 except:
 	print("You need python headers to build uWSGI.")
 	sys.exit(1)
 
 cflags = cflags + ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True) ]
-ldflags = ['-lpthread', '-rdynamic'] + sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split()
+ldflags = os.environ.get("LDFLAGS", "").split()
+libs = ['-lpthread', '-rdynamic'] + sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split()
 
 def depends_on(what, dep):
 	for d in dep:
@@ -97,7 +101,7 @@
 			print(plugin)
 
 	print("*** uWSGI linking ***")
-	ldline = "%s -o %s %s %s" % (GCC, bin_name, ' '.join(map(add_o, gcc_list)), ' '.join(ldflags))
+	ldline = "%s -o %s %s %s %s" % (GCC, bin_name, ' '.join(ldflags), ' '.join(map(add_o, gcc_list)), ' '.join(libs))
 	print(ldline)
 	ret = os.system(ldline)
 	if ret != 0:
@@ -141,19 +145,19 @@
 	version = sys.version_info
 	uver = "%d.%d" % (version[0], version[1])
 
-	ldflags.append('-lpython' + uver)
+	libs.append('-lpython' + uver)
 
 	if str(PYLIB_PATH) != '':
-		ldflags.insert(0,'-L' + PYLIB_PATH)
+		libs.insert(0,'-L' + PYLIB_PATH)
 
 	kvm_list = ['FreeBSD', 'OpenBSD', 'NetBSD', 'DragonFly']
 
 	if uwsgi_os == 'SunOS':
-		ldflags.append('-lsendfile')
-		ldflags.remove('-rdynamic')
+		libs.append('-lsendfile')
+		libs.remove('-rdynamic')
 
 	if uwsgi_os in kvm_list:
-		ldflags.append('-lkvm')
+		libs.append('-lkvm')
 
 	if uwsgi_os == 'OpenBSD':
 		UGREEN = False
@@ -221,7 +225,7 @@
 				print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
 				sys.exit(1)
 			else:
-				ldflags.append(xmlconf)
+				libs.append(xmlconf)
 				xmlconf = spcall("xml2-config --cflags")
 				if xmlconf is None:
 					print("*** libxml2 headers unavailable. uWSGI build is interrupted. You have to install libxml2 development package or use libexpat or disable XML")
@@ -232,20 +236,20 @@
 					gcc_list.append('xmlconf')
 		elif XML_IMPLEMENTATION == 'expat':
 			cflags.append("-DUWSGI_XML -DUWSGI_XML_EXPAT")
-			ldflags.append('-lexpat')
+			libs.append('-lexpat')
 			gcc_list.append('xmlconf')
 			
 
 	if ERLANG:
 		depends_on("ERLANG", ['EMBEDDED'])
 		cflags.append("-DUWSGI_ERLANG")
-		ldflags.append(ERLANG_LDFLAGS)
+		libs.append(ERLANG_LDFLAGS)
 		if str(ERLANG_CFLAGS) != '':
 			cflags.append(ERLANG_CFLAGS)
 		gcc_list.append('erlang')
 
 	if SCTP:
-		ldflags.append("-lsctp")
+		libs.append("-lsctp")
 		cflags.append("-DUWSGI_SCTP")
 
 	if SPOOLER:
@@ -263,13 +267,13 @@
 	import uwsgiplugin as up
 
 	cflags.append(up.CFLAGS)
-	ldflags.append(up.LDFLAGS)
+	libs.append(up.LDFLAGS)
 
 	cflags.insert(0, '-I.')
 
 	plugin_base = path + '/' + up.NAME + '_plugin'
 
-	gccline = "%s -fPIC -shared -o %s.so %s %s.c %s" % (GCC, plugin_base, ' '.join(cflags), plugin_base, ' '.join(ldflags))
+	gccline = "%s -fPIC -shared -o %s.so %s %s %s.c %s" % (GCC, plugin_base, ' '.join(cflags), ' '.join(ldflags), plugin_base, ' '.join(libs))
 	print(gccline)
 
 	ret = os.system(gccline)
@@ -297,6 +301,8 @@
 		print(' '.join(cflags))
 	if cmd == '--ldflags':
 		print(' '.join(ldflags))
+	if cmd == '--libs':
+		print(' '.join(libs))
 	elif cmd == '--build':
 		parse_vars()
 		build_uwsgi(UWSGI_BIN_NAME)