From 0c6a4ebe19047ddfda7c2afad0d549fbee0e6d77 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Sun, 9 Nov 2008 19:24:09 +0100 Subject: [PATCH] Example of extern project A project that does not carry libucw with itself, not even it's build system, but uses its build system installed locally. --- .../libs/examples/external-ucw-build/Makefile | 34 ++++++++++++++ .../examples/external-ucw-build/configure | 46 +++++++++++++++++++ .../examples/external-ucw-build/default.cfg | 5 ++ free/libs/examples/external-ucw-build/test.c | 8 ++++ 4 files changed, 93 insertions(+) create mode 100644 free/libs/examples/external-ucw-build/Makefile create mode 100755 free/libs/examples/external-ucw-build/configure create mode 100644 free/libs/examples/external-ucw-build/default.cfg create mode 100644 free/libs/examples/external-ucw-build/test.c diff --git a/free/libs/examples/external-ucw-build/Makefile b/free/libs/examples/external-ucw-build/Makefile new file mode 100644 index 00000000..db4d1243 --- /dev/null +++ b/free/libs/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_PATH is not set +# (means noone yet called configure and it reported above) +ifdef BUILDSYS_PATH + +# We will use the libucw build system +include $(BUILDSYS_PATH)/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_PATH)/Makebottom + +endif diff --git a/free/libs/examples/external-ucw-build/configure b/free/libs/examples/external-ucw-build/configure new file mode 100755 index 00000000..f87fcc73 --- /dev/null +++ b/free/libs/examples/external-ucw-build/configure @@ -0,0 +1,46 @@ +#!/usr/bin/perl +# Configure script for the libucw example +# (c) 2008 Michal Vaner +# A lot copyed from ../external/configure +# (c) 2007 Martin Mares + +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."; + } + } + # Ask pkg-config for the rest of configure + $libdir=`pkg-config libucw --variable=perl_modules_dir`; + chomp $libdir; + die "libUCW not found. Is PKG_CONFIG_PATH set properly?" 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 new file mode 100644 index 00000000..48f5ec23 --- /dev/null +++ b/free/libs/examples/external-ucw-build/default.cfg @@ -0,0 +1,5 @@ + +# 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 new file mode 100644 index 00000000..19a26850 --- /dev/null +++ b/free/libs/examples/external-ucw-build/test.c @@ -0,0 +1,8 @@ +#include + +int main(void) +{ + log_init("test"); + msg(L_INFO, "Hoooot!"); + return 0; +} -- 2.39.2