1 ## libderp, yet another C collection library
5 * builds with any variant of make, any C99 compiler
6 * a proper library that you can link against
7 * no abuse of translation units, no weird macros
8 * includes proper man pages (TODO)
9 * shared and static library
10 * pkg-config interface
11 * developer friendly ISC license
13 Why you might avoid it
15 * containers use void pointers, e.g. no vector of ints
16 * pedestrian algorithms, not cutting edge
17 * hard-coded to use malloc/free
18 * not (yet) thread safe
22 Compile the shared and static libraries:
25 # detect proper way to generate shared library
28 # create static and shared libs in build/release
32 #### Installing development assets (for the linker)
34 To install libraries that an application would link with, along with headers,
35 and pkg-config specifications, use the `install-dev.sh` script:
38 # (if path is omitted, it defaults to /opt)
39 ./install-dev.sh /path
42 The result will be a folder structure like this:
45 /path/libderp-dev.x.y.z
53 │ ├── libderp.so (or dylib or dll)
61 The easiest way to build against these files is to use pkg-config, which will
62 provide the correct compiler/linker flags.
65 # make desired libderp version visible to pkg-config
66 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/path/libderp.x.y.z"
68 # compile foo.c and link with libderp
69 cc `pkg-config --cflags --libs-only-L libderp` \
70 -o foo foo.c `pkg-config --libs-only-l libderp`
73 To link statically against the library, change the pkg-config name `libderp` to
76 #### Installing runtime assets (for the loader)
78 To install the shared library for loading, use the `install.sh` script.
81 # (if path is omitted, it defaults to /usr/local/lib)
85 This copies the shared library, and creates symbolic links to match the soname
86 that applications are built against.
88 ### Contributing to Libderp
90 To build in `build/dev` with warnings, profiling, debugging information, and
91 code coverage data, use the "dev" variant:
94 # requires clang specifically
98 Object files for the dev and release variants can coexist. There is no `make
99 clean` target because there shouldn't be a need to do that manually. The
100 Makefile has an accurate dependency graph, so running `make` should always know
106 make VARIANT=dev tests
111 On platforms where Clang supports memory leak checks, you can activate them
115 ASAN_OPTIONS=detect_leaks=1 ./build/dev/test/run
118 To see test coverage for a data structure, run the cov script:
121 ./build/dev/test/cov hashmap
126 The macros `CC`, `AR` and `EXTRA_CFLAGS` can be used to cross-compile for other
127 architectures. For instance, below is how to compile a static library for ARM
128 Cortex M4 with hardware floating point.
131 make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar \
132 EXTRA_CFLAGS="-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16" \
133 build/release/libderp.a