summaryrefslogtreecommitdiff
path: root/Host/patches/patch-libnxt-sconstruct-libusb-legacy.diff
blob: 52b276c237edaf4eca7219e9488f0e3a1bc425ef (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
--- SConstruct.orig	2007-04-22 12:41:39.000000000 +0800
+++ SConstruct	2010-12-22 17:21:51.000000000 +0800
@@ -1,6 +1,31 @@
+#####
+# Note: For Macports, libusb-legacy need to be used?
+# 	I can't get it to build with libusb-compat
+####
+
+import os
+import os.path
 from glob import glob
 
-auto_libs = ''
+###############################################################
+# Utility functions.
+###############################################################
+
+# Similar to env.WhereIs, but always searches os.environ.
+def find_on_path(filename):
+    paths = os.environ.get('PATH')
+    if not paths:
+        return None
+    for p in paths.split(':'):
+        path = os.path.abspath(os.path.join(p, filename))
+        if os.path.isfile(path):
+            return p
+    return None
+
+auto_libs = 'libusb-legacy'
+
+cmdname = 'pkg-config'
+pkg_config_path = find_on_path(cmdname) + ('/%s' % cmdname)
 
 # Detect the system's endianness
 from sys import byteorder
@@ -12,19 +37,28 @@
 BuildEnv = Environment(CCFLAGS=['-Wall', '-std=gnu99',
 				'-g', '-ggdb', '-D' + endian])
 if auto_libs:
-	BuildEnv.ParseConfig('pkg-config --cflags --libs ' + auto_libs)
+	cmdstr = '%s --cflags --libs ' % pkg_config_path
+	BuildEnv.ParseConfig(cmdstr + ' --cflags --libs ' + auto_libs)
 
 BuildEnv.Command('flash_routine.h',
 		 'flash_routine.h.base',
 		 './make_flash_header.py')
 
-Default(BuildEnv.Library('nxt',
+BuildEnv.Append(LIBPATH='.')
+libnxt = Default(BuildEnv.Library('nxt',
 			 [x for x in glob('*.c')
 			  if not x.startswith('main_')],
-			 LIBS='usb'))
+			 LIBS='usb-legacy'))
+
+fwflash = Default(BuildEnv.Program('fwflash', 'main_fwflash.c',
+			 LIBS=['usb-legacy', 'nxt']))
+
+fwexec = Default(BuildEnv.Program('fwexec', 'main_fwexec.c',
+			 LIBS=['usb-legacy', 'nxt']))
+
+# the install target
+#BuildEnv.Alias("install", BuildEnv.Install(os.path.join(os.environ['DESTDIR'], "lib"), libnxt))
+#BuildEnv.Alias("install", BuildEnv.Install(os.path.join(os.environ['DESTDIR'], "bin"), fwflash, fwexec))
+#BuildEnv.Command("uninstall", None, Delete(FindInstalledFiles()))
 
-Default(BuildEnv.Program('fwflash', 'main_fwflash.c',
-			 LIBS=['usb', 'nxt'], LIBPATH='.'))
 
-Default(BuildEnv.Program('fwexec', 'main_fwexec.c',
-			 LIBS=['usb', 'nxt'], LIBPATH='.'))