MaKL is a Prerequisite

LibU needs MaKL to configure and build.

The following commands should be sufficient to get MaKL installed on any Linux flavour or Darwin/MacOSX:

$ wget
$ tar zxf makl-1.8.1.tar.gz && cd makl-1.8.1
$ sh
$ su 
Password: ****
# make install

Should your platform be one of Solaris, OpenSolaris, FreeBSD, PC-BSD, OpenBSD, NetBSD, DragonflyBSD or Windows (MinGW or Gygwin) take a look at the INSTALL file in the top-level MaKL sources directory to track down specific variations on the theme.


Once MaKL is there, you can start downloading the package (always check the official LibU page for the latest version and related ChangeLog) and tailor it to your specific needs:

$ wget
$ tar zxf libu-2.0.0.tar.gz && cd libu-2.0.0


E.g. should you need to change the default installation path (which is /usr/local), use:

$ makl-conf --prefix="/my/install/base/dir"

Debug symbols and warnings from the compiler can be switched on via --enable_debug and --enable_warns (use --enable_icc_warns instead when working with the Intel C compiler):

$ makl-conf --enable_debug --enable_warns

Code profiling using gprof(1) can be activated via --enable_profile, and in general any compiler flag can be passed to the build stage in the following way:

$ makl-conf --extra-cflags="-Wformat -Wno-format-extra-args -Wformat-security -Wformat-nonliteral -Wformat=2"

The --extra-xxx="val" is indeed a powerful mechanism by which any Makefile variable XXX (uppercase!) can be given an additional value val: (ab)use it to tweak LDFLAGS, SHLIB_LDFLAGS, etc. as needed. Anyway if in doubt, or in search for exotic features, type "makl-conf -h" to display the complete list of options: it's likely that what you are trying to achieve is already there.

By default LibU is compiled as static library, to also enable shared library build, supply the --enable_shared flag.

Pick Up What Needs to be Included

The default is to build all the modules, but you can disable the inclusion of specific bits selectively using the following switches:

Also, some specific features regarding the networking code can be disabled at configuration:

If you need to enable compatibility with (some, not all) 1.X interfaces, specify the --compat_1x command line switch.

Building and Encoding

When you are done with the configure step, you can build LibU bits and optionally test them:

$ makl
$ makl -C test

And finally install it:

$ su
Password: ****
# makl install

Hello LibU !

You now are ready to play with your first LibU program:

$ cat main.c
#include <u/libu.h>

int facility = LOG_LOCAL0;

int main (void)
    u_con("Hello LibU world !");
    return 0;

Write a Makefile like the following:

$ cat Makefile

PROG = hellolibu
SRCS = main.c

LDADD += /path/to/install/prefix/lib/libu.a
CFLAGS += -I/path/to/install/prefix/include


Then type:

$ makl && ./hellolibu

and enjoy !

© 2005-2012 - KoanLogic S.r.l. - All rights reserved