From ca915283cb63068f2fb6bb03ec8faf9c97d009d0 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Fri, 6 Mar 2026 21:21:55 -0500 Subject: feat: templates for libs Added GNU Makefile templates for quick building programs, static libraries, & shared libraries. --- example/libfib/Makefile | 12 ++++++++++++ example/libfib/fib.c | 11 +++++++++++ example/libfib/fib.h | 9 +++++++++ example/libfib/fib.o | Bin 0 -> 640 bytes example/libfib/libfib.a | Bin 0 -> 824 bytes example/libfib/libfib.so.1.1 | Bin 0 -> 16784 bytes 6 files changed, 32 insertions(+) create mode 100644 example/libfib/Makefile create mode 100644 example/libfib/fib.c create mode 100644 example/libfib/fib.h create mode 100644 example/libfib/fib.o create mode 100644 example/libfib/libfib.a create mode 100755 example/libfib/libfib.so.1.1 (limited to 'example/libfib') diff --git a/example/libfib/Makefile b/example/libfib/Makefile new file mode 100644 index 0000000..c610923 --- /dev/null +++ b/example/libfib/Makefile @@ -0,0 +1,12 @@ +LIB = fib +SHLIB_MAJOR = 1 +SHLIB_MINOR = 1 +CFLAGS = -Wall \ + -Werror \ + -Wextra \ + -Wpedantic \ + -std=c17 +SRCS = fib.c + +include ../tools/mcd.lib.mk + diff --git a/example/libfib/fib.c b/example/libfib/fib.c new file mode 100644 index 0000000..707215d --- /dev/null +++ b/example/libfib/fib.c @@ -0,0 +1,11 @@ +#include "fib.h" + +uint64_t fib(const uint64_t n) { + if (n <= 0) { + return 0; + } else if (n == 1) { + return 1; + } + return (fib(n - 1) + fib(n - 2)); +} + diff --git a/example/libfib/fib.h b/example/libfib/fib.h new file mode 100644 index 0000000..66615c5 --- /dev/null +++ b/example/libfib/fib.h @@ -0,0 +1,9 @@ +#ifndef FIB_H_ +#define FIB_H_ + +#include + +uint64_t fib(uint64_t); + +#endif // FIB_H_ + diff --git a/example/libfib/fib.o b/example/libfib/fib.o new file mode 100644 index 0000000..9380b6f Binary files /dev/null and b/example/libfib/fib.o differ diff --git a/example/libfib/libfib.a b/example/libfib/libfib.a new file mode 100644 index 0000000..1fe78c4 Binary files /dev/null and b/example/libfib/libfib.a differ diff --git a/example/libfib/libfib.so.1.1 b/example/libfib/libfib.so.1.1 new file mode 100755 index 0000000..2ed114c Binary files /dev/null and b/example/libfib/libfib.so.1.1 differ -- cgit v1.2.3