From 6121d80a1e22dcbca7c4010772447d8a4c11fec1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 15 Jun 2014 21:44:16 +0200 Subject: [PATCH] Switched to UCW configure and build system --- Makefile | 100 +++++++-------- build/Makebottom | 230 ++++++++++++++++++++++++++++++++++ build/Maketop | 97 +++++++++++++++ gen-dict => build/gen-dict | 0 build/lib-flags | 24 ++++ build/mergedeps | 21 ++++ configure | 39 ++++++ default.cfg | 10 ++ perl/UCW/Configure.pm | 226 +++++++++++++++++++++++++++++++++ perl/UCW/Configure/Build.pm | 26 ++++ perl/UCW/Configure/C.pm | 240 ++++++++++++++++++++++++++++++++++++ perl/UCW/Configure/Paths.pm | 58 +++++++++ perl/UCW/Configure/Pkg.pm | 120 ++++++++++++++++++ 13 files changed, 1135 insertions(+), 56 deletions(-) create mode 100644 build/Makebottom create mode 100644 build/Maketop rename gen-dict => build/gen-dict (100%) create mode 100755 build/lib-flags create mode 100755 build/mergedeps create mode 100755 configure create mode 100644 default.cfg create mode 100644 perl/UCW/Configure.pm create mode 100644 perl/UCW/Configure/Build.pm create mode 100644 perl/UCW/Configure/C.pm create mode 100644 perl/UCW/Configure/Paths.pm create mode 100644 perl/UCW/Configure/Pkg.pm diff --git a/Makefile b/Makefile index c0b1642..2221454 100644 --- a/Makefile +++ b/Makefile @@ -1,63 +1,51 @@ -LIBUCW:=$(shell cd /home/mj/src/libucw/run && pwd) -UCWCF:=$(shell PKG_CONFIG_PATH=$(LIBUCW)/lib/pkgconfig pkg-config --cflags libucw libucw-charset libucw-xml) -UCWLF:=$(shell PKG_CONFIG_PATH=$(LIBUCW)/lib/pkgconfig pkg-config --libs libucw libucw-charset libucw-xml) -FTCF:=$(shell freetype-config --cflags) -FTLF:=$(shell freetype-config --libs) -PANGOCF:=$(shell pkg-config pangoft2 --cflags) -PANGOLF:=$(shell pkg-config pangoft2 --libs) - -CC=gcc -LD=gcc -COPT=-O2 -CFLAGS=$(COPT) -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wredundant-decls -Wno-missing-field-initializers -std=gnu99 $(UCWCF) -ggdb -DDEBUG_ASSERTS -LDLIBS+=$(FTLF) $(PANGOLF) $(UCWLF) -lproj - -all: leo - -leo: leo.o xml.o osm.o svg.o svg-icon.o css-parse.o css-lex.o style.o css.o dict.o sym.o sym-point.o sym-line.o sym-text.o map.o shp.o - -INC=leo.h dict-keys.h dict-values.h dict-props.h osm.h svg.h style.h css.h dict.h map.h sym.h - -leo.o: leo.c $(INC) -xml.o: xml.c $(INC) -osm.o: osm.c $(INC) -svg.o: svg.c $(INC) -svg-icon.o: svg-icon.c $(INC) -style.o: style.c $(INC) -css.o: css.c $(INC) -dict.o: dict.c $(INC) -sym.o: sym.c $(INC) -sym-point.o: sym-point.c $(INC) -sym-line.o: sym-line.c $(INC) -sym-text.o: sym-text.c $(INC) -css-parse.o: css-parse.c $(INC) -css-lex.o: css-lex.c $(INC) css-parse.c -map.o: map.c $(INC) -shp.o: shp.c $(INC) - -sym-text.o: CFLAGS+=$(FTCF) $(PANGOCF) - -css-parse.c: css-parse.y - bison --name-prefix=css_ --token-table --verbose --defines -o $@ $^ +# Makefile for Hic Est Leo + +all: runtree programs extras configs + +# Include configuration +s=. +-include obj/config.mk +obj/config.mk: + @echo "You need to run configure first." && false + +BUILDSYS=$(s)/build + +# We will use the libucw build system +include $(BUILDSYS)/Maketop -dict-%.h: dict-%.t gen-dict - ./gen-dict <$< >$@ +PROGS+=$(o)/leo +CFLAGS+=$(LIBUCW_CFLAGS) -clean: - rm -f leo *.o css-parse.c css-parse.h css-parse.output tags - rm -f dict-keys.h dict-values.h dict-props.h +LEO_MODULES=leo xml osm svg svg-icon css-parse css-lex style css dict sym sym-point sym-line sym-text map shp +LEO_OBJECTS=$(addprefix $(o)/, $(addsuffix .o, $(LEO_MODULES))) +$(o)/leo: $(LEO_OBJECTS) -tags: - ctags *.[chy] +$(o)/leo: LIBS+=$(LIBUCW_LIBS) $(LIBUCW_CHARSET_LIBS) $(LIBUCW_XML_LIBS) $(PANGOFT2_LIBS) $(FREETYPE_LIBS) -lproj + +$(o)/sym-text.o: CFLAGS+=$(FREETYPE_CFLAGS) $(PANGOFT2_CFLAGS) +$(o)/svg-icon.o: CFLAGS+=$(LIBUCW_XML_CFLAGS) +$(o)/xml.o: CFLAGS+=$(LIBUCW_XML_CFLAGS) + +$(LEO_OBJECTS): $(o)/dict-keys.h $(o)/dict-props.h $(o)/dict-values.h + +$(o)/css-parse.c: css-parse.y + bison --name-prefix=css_ --token-table --verbose --defines -o $@ $^ -upload: - rs output.pdf ps:poskole-beta/www/tmp/2014/mapa.pdf +$(o)/dict-%.h: dict-%.t $(BUILDSYS)/gen-dict + build/gen-dict <$< >$@ -backup: - rs . camelot:a/priv/poskole/map/new/$$(date '+%Y%m%d-%H%M%S')/ +ifndef CONFIG_LOCAL +install: all $(INSTALL_TARGETS) +else +install: + @echo "Nothing to install, this is a local build." && false +endif +.PHONY: install -output.svg: leo dump.osm poskole.css - ./leo +#output.svg: leo dump.osm poskole.css +# ./leo +# +#output.pdf: output.svg +# inkscape --export-pdf=output.pdf output.svg -output.pdf: output.svg - inkscape --export-pdf=output.pdf output.svg +include $(BUILDSYS)/Makebottom diff --git a/build/Makebottom b/build/Makebottom new file mode 100644 index 0000000..7ada953 --- /dev/null +++ b/build/Makebottom @@ -0,0 +1,230 @@ +# Bottom part of Makefile for the UCW Libraries +# (c) 1997--2008 Martin Mares + +# The run tree + +DOCDIR=doc + +runtree: run/.tree-stamp $(addsuffix /.dir-stamp,$(addprefix $(o)/,$(DIRS)) $(addprefix run/$(DOCDIR)/,$(DOC_MODULES))) + +run/.tree-stamp: $(o)/config.mk + $(M)Creating runtree + $(Q)mkdir -p run $(addprefix run/, $(CONFIG_DIR) $(EXTRA_RUNDIRS) $(INSTALL_RUNDIRS)) + $(Q)touch run/.tree-stamp + +# Miscellaneous targets + +programs: $(PROGS) +datafiles: $(DATAFILES) +tests: $(TESTS) +configs: $(addprefix run/$(CONFIG_DIR)/,$(CONFIGS)) +docs: runtree $(DOCS) $(DOC_INDICES) + +tags: + etags `find . -name "*.[ch]"` + +# Black magic with dependencies. It would be more correct to make "depend.new" +# a prerequisite for "depend", but "depend.new" often has the same timestamp +# as "depend" which would confuse make a lot and either force remaking anyway +# or (as in current versions of GNU make) erroneously skipping the remaking. + +-include $(o)/depend + +$(o)/depend: force + $(Q)if [ -s $(o)/depend.new ] ; then $(BUILDSYS)/mergedeps $(o)/depend $(o)/depend.new ; >$(o)/depend.new ; fi + +force: + +# Rules for directories + +%.dir-stamp: + $(Q)mkdir -p $(@D) && touch $@ + +# Rules for configuration files + +run/$(CONFIG_DIR)/%: $(s)/$(CONFIG_SRC_DIR)/% $(o)/config.mk $(BUILDSYS)/genconf + $(M)CF $< + $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk + +$(o)/%.cf: $(s)/%.cf $(o)/config.mk $(BUILDSYS)/genconf + $(M)CF $< + $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk + $(Q)cp $@ run/$(CONFIG_DIR)/$(basename $(@F)) + +# Rules for libraries + +%.a: + $(M)AR $@ + $(Q)rm -f $@ + $(Q)ar rcs $@ $^ +ifdef CONFIG_INSTALL_API + $(Q)$(call symlink-alias,$@,run/lib,$(*F)$(LIBNAME_INFIX).a) +endif + +%.so: + $(M)LD $@ + $(Q)$(CC) $(LSHARED) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS) + $(Q)$(call symlink-alias,$@,run/$(SO_RUNDIR),$(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX)) + $(Q)ln -fs $(*F)$(SONAME_INFIX).so$(SONAME_SUFFIX) run/$(SO_RUNDIR)/$(*F)$(SONAME_INFIX).so + +# On Darwin, gcc expects shared libraries in *.dylib instead of *.so. +# Surprisingly, when a program is run, it suffices to have *.so files. +# We don't want to mess up the whole build system with configurable +# suffices and we also don't want to incur an overhead on Linux, so we +# just create symbolic links on Darwin, if requested. +%.dylib: %.so + cd $(dir $<) && ln -fs $(notdir $<) $(notdir $@) + +$(o)/%.pc: $(s)/%.pc $(o)/%$(LV).$(LS) + $(M)PC $< + $(Q)DEPS="$(shell $(BUILDSYS)/lib-deps $^)" LIBDIR=$(@D) $(BUILDSYS)/genconf $< $@ $(o)/config.mk + $(Q)mkdir -p $(o)/pkgconfig + $(Q)$(call symlink,$@,$(o)/pkgconfig) + +# Rules for public API + +ifdef CONFIG_INSTALL_API + +ifdef CONFIG_LOCAL +# Need an absolute path +API_ROOT:=$(shell pwd)/run +API_LIBDIR=$(API_ROOT)/lib +API_INCDIR=$(API_ROOT)/include +else +API_LIBDIR=$(INSTALL_LIB_DIR) +API_INCDIR=$(INSTALL_INCLUDE_DIR) +endif +INSTALL_RUNDIRS+=include lib/pkgconfig +api: $(API_INCLUDES) $(addprefix run/lib/pkgconfig/,$(addsuffix .pc,$(API_LIBS))) + +$(o)/%/.include-stamp: + $(Q)$(BUILDSYS)/install-includes $($@ "s@^libdir=.*@libdir=$(API_LIBDIR)@;s@^incdir=.*@incdir=$(API_INCDIR)@" + +else +api: +endif + +# Rules for compiling C + +$(o)/%.o: $(s)/%.c $(o)/autoconf.h + $(M)CC $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $< + +$(o)/%.o: %.c $(o)/autoconf.h + $(M)CC $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $< + +%.o: %.c $(o)/autoconf.h + $(M)CC $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -c -o $@ $< + +$(o)/%.oo: $(s)/%.c $(o)/autoconf.h + $(M)CC-SO $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $< + +$(o)/%.oo: %.c $(o)/autoconf.h + $(M)CC-SO $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $< + +%.oo: %.c $(o)/autoconf.h + $(M)CC-SO $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) $(CSHARED) -c -o $@ $< + +$(o)/%-tt.o: $(s)/%.c $(o)/autoconf.h + $(M)CC-TEST $< + $(Q)DEPENDENCIES_OUTPUT="$(o)/depend.new $@" $(CC) $(CFLAGS) -DTEST -c -o $@ $< + +# Rules for testing + +$(o)/%-t: $(o)/%-tt.o $(TESTING_DEPS) + $(M)LD-TEST $@ + $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS) + +$(o)/%.test: $(s)/%.t $(BUILDSYS)/tester + $(M)TEST $@ + $(Q)$(BUILDSYS)/tester --rundir=run $(TESTERFLAGS) $< && touch $@ + +# Rules for binaries + +BINDIR=bin + +$(o)/%: $(o)/%.o + $(M)LD $@ + $(Q)$(CC) $(LDFLAGS) -o $@ $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" PKG_CONFIG_OPTS="$(PKG_CONFIG_OPTS)" $(BUILDSYS)/lib-flags $^) $(LIBS) + $(Q)$(call symlink,$@,run/$(BINDIR)) + +$(o)/%: $(s)/%.sh $(o)/config.mk $(BUILDSYS)/genconf + $(M)PP $< + $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk + $(Q)chmod +x $@ + $(Q)$(call symlink,$@,run/$(BINDIR)) + +$(o)/%: %.sh $(o)/config.mk $(BUILDSYS)/genconf + $(M)PP $< + $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk + $(Q)chmod +x $@ + $(Q)$(call symlink,$@,run/$(BINDIR)) + +$(o)/%: $(s)/%.pl $(o)/config.mk $(BUILDSYS)/genconf + $(M)PP $< + $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk + $(Q)chmod +x $@ + $(Q)$(call symlink,$@,run/$(BINDIR)) + +$(o)/%: %.pl $(o)/config.mk $(BUILDSYS)/genconf + $(M)PP $< + $(Q)$(BUILDSYS)/genconf $< $@ $(o)/config.mk + $(Q)chmod +x $@ + $(Q)$(call symlink,$@,run/$(BINDIR)) + +PERL_MODULE_DIR=UCW + +$(o)/%.pm: $(s)/%.pm + $(M)"PM $< -> run/lib/perl5/$(PERL_MODULE_DIR)/$(@F)" + $(Q)cp $^ $@ + $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR)) + +$(o)/%.pm: %.pm + $(M)"PM $< -> run/lib/perl/$(PERL_MODULE_DIR)/$(@F)" + $(Q)cp $^ $@ + $(Q)$(call symlink,$@,run/lib/perl5/$(PERL_MODULE_DIR)) + +# Rules for data files + +DATADIR=lib + +$(DATAFILES): $(o)/%: $(s)/% + $(M)DATA $< + $(Q)cp $^ $@ + $(Q)$(call symlink,$@,run/$(DATADIR)) + +# Rules for documentation + +$(o)/%.html: $(o)/%.txt $(BUILDSYS)/asciidoc.conf $(BUILDSYS)/asciidoc-xhtml.conf run/$(DOCDIR)/$(DOC_MODULE)/.dir-stamp + $(M)"DOC-HTML $<" + $(Q)asciidoc -e -f $(BUILDSYS)/asciidoc.conf -f $(BUILDSYS)/asciidoc-xhtml.conf -f $(HOST_PREFIX)/etc/asciidoc/asciidoc.conf -f $(HOST_PREFIX)/etc/asciidoc/xhtml11.conf $< + $(Q)$(call symlink,$@,run/$(DOCDIR)/$(DOC_MODULE)) + +# In reality, we do not depend on the .txt files, but on the corresponding .deflist's. +# However, the Makefile language cannot express that doc-extract generates both .txt +# and .deflist, so we always use the .txt's in dependencies. +$(patsubst %.html,%.txt,$(DOC_INDICES)): $(o)/%.txt: $(patsubst %.html,%.txt,$(DOCS)) $(BUILDSYS)/doc-defs + $(M)"DOC-DEFS $@" + $(Q)echo $@: $(DOC_HEAD) $(DOC_LIST) >> $(o)/depend.new + $(Q)$(BUILDSYS)/doc-defs $(DOC_HEAD) $@ $(DOC_LIST) + +$(patsubst %.html,%.txt,$(DOCS)): $(o)/%.txt: $(s)/%.txt $(BUILDSYS)/doc-extract + $(M)"DOC-EXT $<" + $(Q)$(BUILDSYS)/doc-extract $< $@ $(o)/depend.new $(s) $(patsubst %.txt,%.deflist,$@) + +# Don't delete intermediate targets. There shouldn't be any, but due to bugs +# in GNU Make rules with targets in not-yet-existing directories are ignored +# when searching for implicit rules and thence targets considered intermediate. +.SECONDARY: + +.PHONY: all clean distclean runtree programs api datafiles force tags configs dust install docs tests diff --git a/build/Maketop b/build/Maketop new file mode 100644 index 0000000..b45187a --- /dev/null +++ b/build/Maketop @@ -0,0 +1,97 @@ +# Top part of Makefile for the UCW Libraries +# (c) 1997--2008 Martin Mares + +# Set to 1 if you want verbose output +V=0 + +# Set to 'y' (or 'n') if you want to auto-confirm (auto-reject) all questions in build/installer +CONFIRM= + +# Disable all built-in rules and variables. Speeds up make and simplifies debugging. +MAKEFLAGS+=-rR + +CFLAGS=$(CLANG) $(COPT) $(CDEBUG) $(CWARNS) $(CEXTRA) -I. -I$(o) -I$(s) +LDFLAGS=$(LOPT) $(LEXTRA) + +DIRS= +PROGS= +CONFIGS= +CONFIG_SRC_DIR=$(CONFIG_DIR) +TESTS= +EXTRA_RUNDIRS=tmp log +INSTALL_RUNDIRS=bin lib +API_INCLUDES= +API_LIBS= + +# Various files whose type does not fit into PROGS +DATAFILES= + +ifdef CONFIG_DARWIN +DYNAMIC_LIBRARIES=dylib +SOEXT=bundle +HOST_PREFIX=/sw +else +DYNAMIC_LIBRARIES=so +SOEXT=so +HOST_PREFIX= +endif + +ifdef CONFIG_SHARED +LS=$(DYNAMIC_LIBRARIES) +OS=oo +PKG_CONFIG_OPTS= +else +LS=a +OS=o +PKG_CONFIG_OPTS=--static +endif +LV=$(UCW_ABI_SUFFIX) + +SO_RUNDIR=lib + +# Whenever "make -s" (silent) is run, turn on verbose mode (paradoxical, but gives the right result) +ifneq ($(findstring s,$(MAKEFLAGS)),) +V=1 +endif + +# Define M (message) and Q (quiet command prefix) macros and also MAKESILENT passed to sub-makes +ifeq ($(V),1) +M=@\# +Q= +MAKESILENT= +else +M=@echo # +Q=@ +MAKESILENT=-s +endif + +# Clean needs to be a double-colon rule since we want sub-makefiles to be able +# to define their own cleanup actions. +dust:: + rm -f `find . -path "*~" -or -name "\#*\#"` + rm -f allocs.tmp cscope.out TAGS + +clean:: dust + rm -rf `find obj/ucw -mindepth 1 -maxdepth 1 -not -name autoconf.h` + rm -rf `find obj -mindepth 1 -maxdepth 1 -not \( -name config.mk -o -name autoconf.h -o -name ucw \)` + rm -rf tests run/{bin,lib,include,.tree-stamp,doc} + +distclean:: clean + rm -rf obj run debian-tmp + +testclean:: + rm -f `find obj -name "*.test"` + +docclean:: + rm -f $(DOCS) $(patsubst %.html,%.txt,$(DOCS)) + +# Extra default rules (appended to by submakefiles) +extras:: + +# Relative symlinks and other pathname manipulation macros +empty:= +space:=$(empty) $(empty) +backref=$(subst $(space),/,$(patsubst %,..,$(subst /,$(space),$(1)))) +tack-on=$(if $(patsubst /%,,$(2)),$(1)/$(2),$(2)) +symlink=ln -sf $(call tack-on,$(call backref,$(2)),$(1)) $(2)/ +symlink-alias=ln -sf $(call tack-on,$(call backref,$(2)),$(1)) $(2)/$(3) diff --git a/gen-dict b/build/gen-dict similarity index 100% rename from gen-dict rename to build/gen-dict diff --git a/build/lib-flags b/build/lib-flags new file mode 100755 index 0000000..29bb4e8 --- /dev/null +++ b/build/lib-flags @@ -0,0 +1,24 @@ +#!/bin/bash +# +# A preprocessor for linker arguments, which replaces references to .pc +# files by results of the proper calls to pkg-config. +# +# (c) 2007 Martin Mares , placed under GNU LGPL +# + +set -e + +PC= +while [ -n "$1" ] ; do + case "$1" in + *.pc) PC="$PC `basename $1 .pc`" + ;; + *) echo -n " $1" + ;; + esac + shift +done +if [ -n "$PC" ] ; then + echo -n " " + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:obj/pkgconfig" pkg-config $PKG_CONFIG_OPTS --libs $PC +fi diff --git a/build/mergedeps b/build/mergedeps new file mode 100755 index 0000000..e1c467d --- /dev/null +++ b/build/mergedeps @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +@ARGV == 2 or die "Usage: mergedeps "; +foreach $a (@ARGV) { + open F, "$a" or next; + $t = ""; + while () { + $t .= $_; + if (! /\\$/) { + ($t =~ /^(.*):/) || die "Parse error at $t"; + $rules{$1} = $t; + $t = ""; + } + } + close F; +} +open(F,">" . $ARGV[0]) || die "Unable to write output file"; +foreach $a (sort keys %rules) { + print F $rules{$a}; +} +close F; diff --git a/configure b/configure new file mode 100755 index 0000000..4b2d61e --- /dev/null +++ b/configure @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# Configure Script for Hic Est Leo +# (c) 2014 Martin Mares + +use warnings; +use strict; + +our $srcdir; +BEGIN { + my $pkgfile = "sym-line.c"; + if (!defined ($srcdir = $ENV{"SRCDIR"})) { + if (-f $pkgfile) { + $srcdir="."; + } elsif ($0 =~ m@^(.*)/configure$@ && -f "$1/$pkgfile") { + $srcdir=$1; + } else { + die "Don't know how to find myself. Please set SRCDIR manually.\n"; + } + } +} + +use lib "$srcdir/perl/"; +use UCW::Configure; + +Init($srcdir, "default.cfg"); +Log "### Configuring Hic Est Leo with configuration " . Get("CONFIG") . "\n"; +Include Get("CONFIG"); +require UCW::Configure::Paths; +require UCW::Configure::C; +require UCW::Configure::Pkg; + +UCW::Configure::Pkg::PkgConfig("libucw") or Fail("libucw is required"); +UCW::Configure::Pkg::PkgConfig("libucw-charset") or Fail("libucw-charset is required"); +UCW::Configure::Pkg::PkgConfig("libucw-xml") or Fail("libucw-xml is required"); +UCW::Configure::Pkg::PkgConfig("pangoft2") or Fail("pangoft2 is required"); +UCW::Configure::Pkg::TrivConfig("freetype", script => "freetype-config") or Fail("freetype2 is required"); + +Finish(); +Log "\nConfigured, run `make' to build everything.\n"; diff --git a/default.cfg b/default.cfg new file mode 100644 index 0000000..cf3ab41 --- /dev/null +++ b/default.cfg @@ -0,0 +1,10 @@ +# Default configuration of Hic Est Leo + +# By default, compile everything for local use without installation +Set("CONFIG_LOCAL"); + +# Include debugging code +Set("CONFIG_DEBUG"); + +# Return success +1; diff --git a/perl/UCW/Configure.pm b/perl/UCW/Configure.pm new file mode 100644 index 0000000..5d458ad --- /dev/null +++ b/perl/UCW/Configure.pm @@ -0,0 +1,226 @@ +# Perl module for UCW Configure Scripts +# +# (c) 2005--2010 Martin Mares +# +# This software may be freely distributed and used according to the terms +# of the GNU Lesser General Public License. + +package UCW::Configure; + +use strict; +use warnings; + +BEGIN { + # The somewhat hairy Perl export mechanism + use Exporter(); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + $VERSION = 1.0; + @ISA = qw(Exporter); + @EXPORT = qw(&Init &Log &Notice &Warn &Fail &IsSet &IsGiven &Set &UnSet &Append &Override &Get &Test &TestBool &Include &Finish &FindFile &TryFindFile &DebugDump &PostConfig &AtWrite); + @EXPORT_OK = qw(); + %EXPORT_TAGS = (); +} + +our %vars; +our %overriden; +our @postconfigs; +our @atwrites; + +sub DebugDump() { + print "VARS:\n"; + print "$_: $vars{$_}\n" foreach( keys %vars ); +} + +sub Log($) { + print @_; +} + +sub Notice($) { + print @_ if $vars{"VERBOSE"}; +} + +sub Warn($) { + print "WARNING: ", @_; +} + +sub Fail($) { + Log("ERROR: " . (shift @_) . "\n"); + exit 1; +} + +sub IsSet($) { + my ($x) = @_; + return exists $vars{$x}; +} + +sub IsGiven($) { + my ($x) = @_; + return exists $overriden{$x}; +} + +sub Get($) { + my ($x) = @_; + return $vars{$x}; +} + +sub Set($;$) { + my ($x,$y) = @_; + $y=1 unless defined $y; + $vars{$x}=$y unless $overriden{$x}; +} + +sub UnSet($) { + my ($x) = @_; + delete $vars{$x} unless $overriden{$x}; +} + +sub Append($$) { + my ($x,$y) = @_; + Set($x, (IsSet($x) ? (Get($x) . " $y") : $y)); +} + +sub Override($;$) { + my ($x,$y) = @_; + $y=1 unless defined $y; + $vars{$x}=$y; + $overriden{$x} = 1; +} + +sub Test($$$) { + my ($var,$msg,$sub) = @_; + Log "$msg ... "; + if (IsSet($var)) { + Log Get($var) . " (preset)\n"; + } else { + my $val = &$sub(); + Set($var, $val); + Log "$val\n"; + } +} + +sub TestBool($$$) { + my ($var,$msg,$sub) = @_; + Log "$msg ... "; + if (IsSet($var) || IsGiven($var)) { + Log ((Get($var) ? "yes" : "no") . " (set)\n"); + } else { + my ($val, $comment) = &$sub(); + Set($var, $val); + Log (($val ? "yes" : "no") . "\n"); + } +} + +sub TryFindFile($) { + my ($f) = @_; + if (-f $f) { + return $f; + } elsif ($f !~ /^\// && -f (Get("SRCDIR")."/$f")) { + return Get("SRCDIR")."/$f"; + } else { + return undef; + } +} + +sub FindFile($) { + my ($f) = @_; + my $F; + defined ($F = TryFindFile($f)) or Fail "Cannot find file $f"; + return $F; +} + +sub Init($$) { + my ($srcdir,$defconfig) = @_; + sub usage($) { + my ($dc) = @_; + print STDERR "Usage: [/]configure " . (defined $dc ? "[" : "") . "" . (defined $dc ? "]" : "") . + " [