Commit 357547fa1261b435c0f974aa8e839eb83247956d

Vicent Marti 2010-11-19T17:07:34

Change to waf as the buildsystem Signed-off-by: Vicent Marti <tanoku@gmail.com>

diff --git a/waf b/waf
new file mode 100755
index 0000000..ff85ad3
Binary files /dev/null and b/waf differ
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..0e514c8
--- /dev/null
+++ b/wscript
@@ -0,0 +1,70 @@
+CFLAGS = ["-g", "-O2", "-Wall", "-Wextra"]
+
+def options(opt):
+	opt.load('compiler_c')
+	opt.add_option('--sha1', action='store', default='builtin', help='TODO')
+
+def configure(conf):
+	conf.load('compiler_c')
+
+	if conf.options.sha1 not in ['openssh', 'ppc', 'builtin']:
+		ctx.fatal('Invalid SHA1 option')
+
+	conf.env.sha1 = conf.options.sha1
+
+
+def build(bld):
+	import glob, sys
+
+	sources = glob.glob('src/*.c')
+	flags = CFLAGS
+	defines = []
+	visibility = True
+	os = 'unix'
+
+	if sys.platform == 'win32':
+		# windows configuration
+		flags = flags + ['-TC', '-W4', '-RTC1', '-Zi']
+		defines = defines = ['WIN32', '_DEBUG', '_LIB']
+		visibility = False
+		os = 'win32'
+
+	elif sys.platform == 'cygwin':
+		visibility = False
+
+	elif sys.platform == 'mingw': # TODO
+		pass
+
+	if bld.env.sha1 == "openssh":
+		defines.append('OPENSSL_SHA1')
+
+	elif bld.env.sha1 == "ppc":
+		defines.append('PPC_SHA1')
+		sources.append('src/ppc/sha1.c')
+
+	else:
+		sources.append('src/block-sha1/sha1.c')
+
+	if not visibility:
+		flags.append('-fvisibility=hidden')
+
+	sources = sources + glob.glob('src/%s/*.c' % os)
+
+	bld.stlib(
+		source=sources,
+		target='git2',
+		includes='src',
+		cflags=flags,
+		defines=defines
+	)
+
+	bld.shlib(
+		source=sources,
+		target='git2',
+		includes='src',
+		cflags=flags,
+		defines=defines
+	)
+
+	bld.install_files('${PREFIX}/include/git', glob.glob('src/git/*.h'))
+