From: Martin Mares Date: Sat, 18 Feb 2012 17:09:18 +0000 (+0100) Subject: Exampled moved to a top-level directory X-Git-Tag: v5.0~23 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=3bf8dcea45ce5f185788a798e576276831b6432d;p=libucw.git Exampled moved to a top-level directory --- diff --git a/examples/external-ucw-build/Makefile b/examples/external-ucw-build/Makefile new file mode 100644 index 00000000..5715c257 --- /dev/null +++ b/examples/external-ucw-build/Makefile @@ -0,0 +1,34 @@ +# Example Makefile for a stand-alone program using the libucw build system +# (c) 2007 Martin Mares +# (c) 2008 Michal Vaner + +# The default target +all: runtree programs + +# Include configuration +s=. +-include obj/config.mk +obj/config.mk: + @echo "You need to run configure first." && false + +# Do not show strange errors if the BUILDSYS is not set +# (it happens if noone called configure as reported above) +ifdef BUILDSYS + +# We will use the libucw build system +include $(BUILDSYS)/Maketop + +# Add the detected flags to all the global flags +CFLAGS+=$(LIBUCW_CFLAGS) +LIBS+=$(LIBUCW_LIBS) + +# Programs we want to compile +PROGS+=$(o)/test + +# And how they are created +$(o)/test: $(o)/test.o $(LIBUCW) + +# And finally the default rules of the build system +include $(BUILDSYS)/Makebottom + +endif diff --git a/examples/external-ucw-build/configure b/examples/external-ucw-build/configure new file mode 100755 index 00000000..ec4b279e --- /dev/null +++ b/examples/external-ucw-build/configure @@ -0,0 +1,46 @@ +#!/usr/bin/perl +# Configure script for the libucw example (inspired by ../external/configure) +# (c) 2008 Michal Vaner + +use warnings; +use strict; + +our($srcdir, $libdir); +BEGIN { + # Find the sources + my $pkgfile = "test.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"; + } + } + # Ask pkg-config if libucw is installed and find its configure modules + `pkg-config libucw --atleast-version=3.13`; + !$? or die "Package `libucw' (version 3.13 or newer) not found. Is PKG_CONFIG_PATH set properly?\n"; + $libdir=`pkg-config libucw --variable=perl_modules_dir`; + chomp $libdir; + die "Unable to find the libucw configure system\n" if $? || not defined $libdir; +} +use lib $libdir; +use UCW::Configure; + +Init($srcdir, 'default.cfg'); +Log "### Configuring TestApp ###\n\n"; +Include Get("CONFIG"); +# What should be detected? +require UCW::Configure::Build; +require UCW::Configure::Paths; +require UCW::Configure::C; +require UCW::Configure::Pkg; +# You could generate your own documentation, too +# require UCW::Configure::Doc; + +# Get some libraries +UCW::Configure::Pkg::PkgConfig("libucw") or Fail("libUCW is required"); +Finish(); + +Log "\nConfigured, run `make' to build everything.\n"; diff --git a/examples/external-ucw-build/default.cfg b/examples/external-ucw-build/default.cfg new file mode 100644 index 00000000..48f5ec23 --- /dev/null +++ b/examples/external-ucw-build/default.cfg @@ -0,0 +1,5 @@ + +# You can specify default configuration here: +# Set("SOME_SYMBOL"); + +1; diff --git a/examples/external-ucw-build/test.c b/examples/external-ucw-build/test.c new file mode 100644 index 00000000..19a26850 --- /dev/null +++ b/examples/external-ucw-build/test.c @@ -0,0 +1,8 @@ +#include + +int main(void) +{ + log_init("test"); + msg(L_INFO, "Hoooot!"); + return 0; +} diff --git a/examples/external/Makefile b/examples/external/Makefile new file mode 100644 index 00000000..0cb26a12 --- /dev/null +++ b/examples/external/Makefile @@ -0,0 +1,8 @@ +# Example Makefile for a stand-alone program using libucw + +CFLAGS:=$(shell pkg-config --cflags libucw) +LDLIBS:=$(shell pkg-config --libs libucw) + +all: test + +test: test.c diff --git a/examples/external/test.c b/examples/external/test.c new file mode 100644 index 00000000..28e45c86 --- /dev/null +++ b/examples/external/test.c @@ -0,0 +1,8 @@ +#include + +int main(void) +{ + log_init("test"); + msg(L_INFO, "Hoooot!"); + return 0; +} diff --git a/examples/internal/Makefile b/examples/internal/Makefile new file mode 100644 index 00000000..633ca098 --- /dev/null +++ b/examples/internal/Makefile @@ -0,0 +1,37 @@ +# Example Makefile for a stand-alone program using the libucw build system +# (c) 2007 Martin Mares + +# The default target +all: runtree programs + +# 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 + +# Set up names of common libraries (to avoid forward references in rules) +LIBLANG=$(o)/lang/liblang.pc +LIBCHARSET=$(o)/charset/libcharset.pc +LIBIMAGES=$(o)/images/libimages.pc + +# Include makefiles of libraries we wish to use +include $(s)/ucw/Makefile +include $(s)/charset/Makefile +include $(s)/lang/Makefile +include $(s)/images/Makefile + +# Programs we want to compile +PROGS+=$(o)/test +$(o)/test: $(o)/test.o $(LIBUCW) $(LIBLANG) $(LIBCHARSET) $(LIBIMAGES) + +# All tests (%-t) get automatically linked with libucw +TESTING_DEPS=$(LIBUCW) + +# And finally the default rules of the build system +include $(BUILDSYS)/Makebottom diff --git a/examples/internal/configure b/examples/internal/configure new file mode 100755 index 00000000..d914789a --- /dev/null +++ b/examples/internal/configure @@ -0,0 +1,34 @@ +#!/usr/bin/perl +# Configure script for the libucw example +# (c) 2007 Martin Mares + +use warnings; +use strict; + +our $srcdir; +BEGIN { + my $pkgfile = "ucw/wildmatch.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/ucw/perl/"; +use UCW::Configure; + +Init($srcdir, "default.cfg"); +Include "ucw/default.cfg"; +Log "### Configuring TestApp ###\n\n"; +Include Get("CONFIG"); +require UCW::Configure::Paths; +require UCW::Configure::C; +require UCW::Configure::LibUCW; +Finish(); + +Log "\nConfigured, run `make' to build everything.\n"; diff --git a/examples/internal/default.cfg b/examples/internal/default.cfg new file mode 100644 index 00000000..a133ba26 --- /dev/null +++ b/examples/internal/default.cfg @@ -0,0 +1,24 @@ +# Default configuration file for our test application + +# Do a local build +Set("CONFIG_LOCAL"); + +# We want to build all libraries shared +Set("CONFIG_SHARED"); + +# Liblang settings +Set("CONFIG_LIBLANG"); +Set("CONFIG_LANG"); +Set("MAX_WORD_CHARS" => 64); +Set("MAX_WORD_BYTES" => 192); + +# Libimages settings +Set("CONFIG_IMAGES"); +Set("CONFIG_IMAGES_LIBJPEG"); +Set("CONFIG_IMAGES_LIBPNG"); +Set("CONFIG_IMAGES_LIBUNGIF"); +UnSet("CONFIG_IMAGES_LIBGIF"); +UnSet("CONFIG_IMAGES_LIBMAGICK"); + +# Return success +1; diff --git a/examples/internal/test.c b/examples/internal/test.c new file mode 100644 index 00000000..28e45c86 --- /dev/null +++ b/examples/internal/test.c @@ -0,0 +1,8 @@ +#include + +int main(void) +{ + log_init("test"); + msg(L_INFO, "Hoooot!"); + return 0; +} diff --git a/free/libs/examples/external-ucw-build/Makefile b/free/libs/examples/external-ucw-build/Makefile deleted file mode 100644 index 5715c257..00000000 --- a/free/libs/examples/external-ucw-build/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# Example Makefile for a stand-alone program using the libucw build system -# (c) 2007 Martin Mares -# (c) 2008 Michal Vaner - -# The default target -all: runtree programs - -# Include configuration -s=. --include obj/config.mk -obj/config.mk: - @echo "You need to run configure first." && false - -# Do not show strange errors if the BUILDSYS is not set -# (it happens if noone called configure as reported above) -ifdef BUILDSYS - -# We will use the libucw build system -include $(BUILDSYS)/Maketop - -# Add the detected flags to all the global flags -CFLAGS+=$(LIBUCW_CFLAGS) -LIBS+=$(LIBUCW_LIBS) - -# Programs we want to compile -PROGS+=$(o)/test - -# And how they are created -$(o)/test: $(o)/test.o $(LIBUCW) - -# And finally the default rules of the build system -include $(BUILDSYS)/Makebottom - -endif diff --git a/free/libs/examples/external-ucw-build/configure b/free/libs/examples/external-ucw-build/configure deleted file mode 100755 index ec4b279e..00000000 --- a/free/libs/examples/external-ucw-build/configure +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/perl -# Configure script for the libucw example (inspired by ../external/configure) -# (c) 2008 Michal Vaner - -use warnings; -use strict; - -our($srcdir, $libdir); -BEGIN { - # Find the sources - my $pkgfile = "test.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"; - } - } - # Ask pkg-config if libucw is installed and find its configure modules - `pkg-config libucw --atleast-version=3.13`; - !$? or die "Package `libucw' (version 3.13 or newer) not found. Is PKG_CONFIG_PATH set properly?\n"; - $libdir=`pkg-config libucw --variable=perl_modules_dir`; - chomp $libdir; - die "Unable to find the libucw configure system\n" if $? || not defined $libdir; -} -use lib $libdir; -use UCW::Configure; - -Init($srcdir, 'default.cfg'); -Log "### Configuring TestApp ###\n\n"; -Include Get("CONFIG"); -# What should be detected? -require UCW::Configure::Build; -require UCW::Configure::Paths; -require UCW::Configure::C; -require UCW::Configure::Pkg; -# You could generate your own documentation, too -# require UCW::Configure::Doc; - -# Get some libraries -UCW::Configure::Pkg::PkgConfig("libucw") or Fail("libUCW is required"); -Finish(); - -Log "\nConfigured, run `make' to build everything.\n"; diff --git a/free/libs/examples/external-ucw-build/default.cfg b/free/libs/examples/external-ucw-build/default.cfg deleted file mode 100644 index 48f5ec23..00000000 --- a/free/libs/examples/external-ucw-build/default.cfg +++ /dev/null @@ -1,5 +0,0 @@ - -# You can specify default configuration here: -# Set("SOME_SYMBOL"); - -1; diff --git a/free/libs/examples/external-ucw-build/test.c b/free/libs/examples/external-ucw-build/test.c deleted file mode 100644 index 19a26850..00000000 --- a/free/libs/examples/external-ucw-build/test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main(void) -{ - log_init("test"); - msg(L_INFO, "Hoooot!"); - return 0; -} diff --git a/free/libs/examples/external/Makefile b/free/libs/examples/external/Makefile deleted file mode 100644 index 0cb26a12..00000000 --- a/free/libs/examples/external/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# Example Makefile for a stand-alone program using libucw - -CFLAGS:=$(shell pkg-config --cflags libucw) -LDLIBS:=$(shell pkg-config --libs libucw) - -all: test - -test: test.c diff --git a/free/libs/examples/external/test.c b/free/libs/examples/external/test.c deleted file mode 100644 index 28e45c86..00000000 --- a/free/libs/examples/external/test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main(void) -{ - log_init("test"); - msg(L_INFO, "Hoooot!"); - return 0; -} diff --git a/free/libs/examples/internal/Makefile b/free/libs/examples/internal/Makefile deleted file mode 100644 index 633ca098..00000000 --- a/free/libs/examples/internal/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# Example Makefile for a stand-alone program using the libucw build system -# (c) 2007 Martin Mares - -# The default target -all: runtree programs - -# 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 - -# Set up names of common libraries (to avoid forward references in rules) -LIBLANG=$(o)/lang/liblang.pc -LIBCHARSET=$(o)/charset/libcharset.pc -LIBIMAGES=$(o)/images/libimages.pc - -# Include makefiles of libraries we wish to use -include $(s)/ucw/Makefile -include $(s)/charset/Makefile -include $(s)/lang/Makefile -include $(s)/images/Makefile - -# Programs we want to compile -PROGS+=$(o)/test -$(o)/test: $(o)/test.o $(LIBUCW) $(LIBLANG) $(LIBCHARSET) $(LIBIMAGES) - -# All tests (%-t) get automatically linked with libucw -TESTING_DEPS=$(LIBUCW) - -# And finally the default rules of the build system -include $(BUILDSYS)/Makebottom diff --git a/free/libs/examples/internal/configure b/free/libs/examples/internal/configure deleted file mode 100755 index d914789a..00000000 --- a/free/libs/examples/internal/configure +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -# Configure script for the libucw example -# (c) 2007 Martin Mares - -use warnings; -use strict; - -our $srcdir; -BEGIN { - my $pkgfile = "ucw/wildmatch.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/ucw/perl/"; -use UCW::Configure; - -Init($srcdir, "default.cfg"); -Include "ucw/default.cfg"; -Log "### Configuring TestApp ###\n\n"; -Include Get("CONFIG"); -require UCW::Configure::Paths; -require UCW::Configure::C; -require UCW::Configure::LibUCW; -Finish(); - -Log "\nConfigured, run `make' to build everything.\n"; diff --git a/free/libs/examples/internal/default.cfg b/free/libs/examples/internal/default.cfg deleted file mode 100644 index a133ba26..00000000 --- a/free/libs/examples/internal/default.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Default configuration file for our test application - -# Do a local build -Set("CONFIG_LOCAL"); - -# We want to build all libraries shared -Set("CONFIG_SHARED"); - -# Liblang settings -Set("CONFIG_LIBLANG"); -Set("CONFIG_LANG"); -Set("MAX_WORD_CHARS" => 64); -Set("MAX_WORD_BYTES" => 192); - -# Libimages settings -Set("CONFIG_IMAGES"); -Set("CONFIG_IMAGES_LIBJPEG"); -Set("CONFIG_IMAGES_LIBPNG"); -Set("CONFIG_IMAGES_LIBUNGIF"); -UnSet("CONFIG_IMAGES_LIBGIF"); -UnSet("CONFIG_IMAGES_LIBMAGICK"); - -# Return success -1; diff --git a/free/libs/examples/internal/test.c b/free/libs/examples/internal/test.c deleted file mode 100644 index 28e45c86..00000000 --- a/free/libs/examples/internal/test.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int main(void) -{ - log_init("test"); - msg(L_INFO, "Hoooot!"); - return 0; -}