]> mj.ucw.cz Git - libucw.git/commitdiff
Example of extern project
authorMichal Vaner <vorner@ucw.cz>
Sun, 9 Nov 2008 18:24:09 +0000 (19:24 +0100)
committerMichal Vaner <vorner@ucw.cz>
Sun, 9 Nov 2008 18:24:09 +0000 (19:24 +0100)
A project that does not carry libucw with itself, not even it's build
system, but uses its build system installed locally.

free/libs/examples/external-ucw-build/Makefile [new file with mode: 0644]
free/libs/examples/external-ucw-build/configure [new file with mode: 0755]
free/libs/examples/external-ucw-build/default.cfg [new file with mode: 0644]
free/libs/examples/external-ucw-build/test.c [new file with mode: 0644]

diff --git a/free/libs/examples/external-ucw-build/Makefile b/free/libs/examples/external-ucw-build/Makefile
new file mode 100644 (file)
index 0000000..db4d124
--- /dev/null
@@ -0,0 +1,34 @@
+# Example Makefile for a stand-alone program using the libucw build system
+# (c) 2007 Martin Mares <mj@ucw.cz>
+# (c) 2008 Michal Vaner <vorner@ucw.cz>
+
+# 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 (executable)
index 0000000..f87fcc7
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+# Configure script for the libucw example
+# (c) 2008 Michal Vaner <vorner@ucw.cz>
+# A lot copyed from ../external/configure
+# (c) 2007 Martin Mares <mj@ucw.cz>
+
+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 (file)
index 0000000..48f5ec2
--- /dev/null
@@ -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 (file)
index 0000000..19a2685
--- /dev/null
@@ -0,0 +1,8 @@
+#include <ucw/lib.h>
+
+int main(void)
+{
+       log_init("test");
+       msg(L_INFO, "Hoooot!");
+       return 0;
+}