This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via c5bd4df27278ea3eb1369beca15f5ac5ddf060f9 (commit) from dca06a2b3d716c7a325793980f780c6d7052ab1b (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/c5bd4df27278ea3eb1369beca15f5ac5ddf06...
commit c5bd4df27278ea3eb1369beca15f5ac5ddf060f9 Author: Cyril Hrubis metan@ucw.cz Date: Mon Nov 14 20:07:28 2011 +0100
build: Quick and dirty configure script
diff --git a/Makefile b/Makefile index acc8543..d2d16f5 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,10 @@ build:
clean: ifdef VERBOSE + rm config.h config.gen.mk $(MAKE) -C build clean else + @rm config.h config.gen.mk @echo "/build" @$(MAKE) --no-print-directory -C build clean endif diff --git a/config.mk b/config.mk index b37929d..9718669 100644 --- a/config.mk +++ b/config.mk @@ -1,12 +1,9 @@ -CFLAGS+=-W -Wall -Wextra -fPIC -O2 +include $(TOPDIR)/config.gen.mk CFLAGS+=-I$(TOPDIR)/include/ -LDLIBS+=-ldl
# path to local module directory PYLIBSDIR=$(TOPDIR)/pylib
-# Python binary/version -PYTHON_BIN=python # To test with other python versions (example): #PYTHON_BIN=${TOPDIR}/virtualpy2.4/bin/python
diff --git a/configure b/configure new file mode 100755 index 0000000..13c700a --- /dev/null +++ b/configure @@ -0,0 +1,190 @@ +#!/usr/bin/env python +# +# This is simple script to detect libraries and configure +# standard features. +# +import os +import sys +from optparse import OptionParser + +def header_exists(cfg, filename): + fpath = cfg['include_path'][0] + '/' + filename + + sys.stderr.write("Checking for '{0}' ... ".format(fpath)) + + try: + st = os.stat(fpath) + sys.stderr.write("Yesn") + return True + except os.error: + sys.stderr.write("Non") + return False + +def c_try_compile(cfg, code, msg): + sys.stderr.write(msg) + + ret = os.system("echo '{0}' | {1} -x c -o /dev/null - &>/dev/null".format(code, cfg["CC"][0])) + + if ret: + sys.stderr.write("Non") + return False + else: + sys.stderr.write("Yesn") + return True + +def c_compiler_exists(cfg): + return c_try_compile(cfg, "int main(void) { return 0; }", + "Checking for working compiler ({0}) ... ".format(cfg["CC"][0])) + +def python_module_installed(cfg, module): + sys.stderr.write("Checking for python module {0} ... ".format(module)) + + ret = os.system("echo 'import {0}' | {1}".format(module, cfg['PYTHON_BIN'][0])) + + if ret: + sys.stderr.write('Non') + return False + else: + sys.stderr.write('Yesn') + return True + +# +# Library checking api +# +class libraries: + def __init__(self, libraries, cfg): + self.libraries = libraries + self.cfg = cfg; + # Create dictionary for check results + self.results = dict() + # + # Print summary + # + def print_summary(self): + sys.stderr.write("Libraries to link againstn") + sys.stderr.write("-------------------------n") + + for i in self.libraries: + sys.stderr.write("{0:10}".format(i[0])) + + if (self.results[i[0]]): + sys.stderr.write(" : Enabledn") + else: + sys.stderr.write(" : Disabledn") + + sys.stderr.write(" - {0}nn".format(i[1])) + # + # Enable/Disable library + # + def set(self, name, val): + if name not in map(lambda s: s[0], self.libraries): + sys.stderr.write("ERROR: Invalid library '{0}'n".format(name)) + exit(1) + else: + self.results[name] = val + # + # Calls a function on arguments, all is stored in array if + # not set previously + # (I know this smells like a lisp, but I can't help myself) + # + def check(self): + sys.stderr.write("Checking for librariesn") + sys.stderr.write("----------------------n") + for i in self.libraries: + if i[0] not in self.results: + self.results[i[0]] = i[2][0](self.cfg, *i[2][1:]) + sys.stderr.write("n") + # + # Writes '#define HAVE_XXX_H' into passed file + # + def write(self, f): + for i in self.libraries: + f.write("/*n * {0}n */n".format(i[1])) + if self.results[i[0]]: + f.write("#define HAVE_{0}n".format(i[0].upper())) + else: + f.write("//#define HAVE_{0}n".format(i[0].upper())) + f.write("n") + +def basic_checks(cfg): + sys.stderr.write("Basic checksn") + sys.stderr.write("------------n") + if not c_compiler_exists(cfg): + exit(1) + if not python_module_installed(cfg, 'jinja2'): + exit(1) + sys.stderr.write("n") + +# +# Write configuration files +# +def write_config_h(cfg, libs): + f = open("config.h", "w") + f.write("#ifndef CONFIG_Hn#define CONFIG_Hnn") + libs.write(f); + f.write("#endif /* CONFIG_H */n"); + sys.stderr.write("Config 'config.h' writtenn") + f.close() + +def write_config_mk(cfg, libs): + f = open('config.gen.mk', 'w') + for i in cfg: + f.write("#{0}n{1}={2}n".format(cfg[i][1], i, cfg[i][0])) + f.close() + sys.stderr.write("Config 'config.gen.mk' writtenn") + +if __name__ == '__main__': + # + # Dictionary for default configuration parameters + # + cfg = {'CC' : ['gcc', 'Path/name of the C compiler'], + 'CFLAGS' : ['-W -Wall -Wextra -fPIC -O2', 'C compiler flags'], + 'PYTHON_BIN' : ['python', 'Path/name of python interpreter'], + 'include_path': ['/usr/include', 'Path to the system headers']} + + # + # Library detection/enable disable + # + l = libraries([["libpng", + "Portable Network Graphics Library", + [header_exists, "png.h"]], + ["jpeg", + "Library to load, handle and manipulate images in the JPEG format", + [header_exists, "jpeglib.h"]]], cfg) + + parser = OptionParser(); + + # Enable disable libraries for linking + parser.add_option("-e", "--enable", dest="enable", action="append", + help="force enable library linking", metavar="libfoo") + parser.add_option("-d", "--disable", dest="disable", action="append", + help="disable library linking", metavar="libfoo") + + # Add cfg config options + for i in cfg: + parser.add_option("", "--"+i, dest=i, metavar=cfg[i][0], help=cfg[i][1]) + + (options, args) = parser.parse_args(); + + # + # Enable/Disable libraries as user requested + # These are not checked later + # + if options.enable: + for i in options.enable: + l.set(i, True); + if options.disable: + for i in options.disable: + l.set(i, False); + + for i in cfg: + if getattr(options, i): + cfg[i][0] = getattr(options, i) + + basic_checks(cfg); + + l.check() + l.print_summary() + + write_config_h(cfg, l); + write_config_mk(cfg, l);
-----------------------------------------------------------------------
Summary of changes: Makefile | 2 + config.mk | 5 +- configure | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 4 deletions(-) create mode 100755 configure
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.