commit 775319a46ef431de38b08ba07d12a3d41a1c391e
parent b0d838aeffa170ffb9e037f6208ad036aa14e383
Author: Louis Burda <quent.burda@gmail.com>
Date: Mon, 29 May 2023 14:19:15 +0200
Template build.jst for debug configuration
Diffstat:
4 files changed, 78 insertions(+), 45 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,3 +1,4 @@
.cache
build
+build.jst
compile_commands.json
diff --git a/build.jst b/build.jst
@@ -1,45 +0,0 @@
-cc = clang
-
-cflags = -Wunused-function -Wunused-variable -Wconversion -Wformat
- -I include -I lib/liballoc/include
-
-rule liba
- $cc -o $out.tmp.o $in $cflags -r
- objcopy --keep-global-symbols=libstr.api $out.tmp.o $out.fixed.o
- ar rcs $out $out.fixed.o
- rm $out.tmp.o $out.fixed.o
-
-rule libso
- $cc -o $out $in $cflags -shared -Wl,-version-script libstr.lds
-
-rule cc
- $cc -o $out $in $cflags
-
-rule mkdir
- mkdir $out
-
-target build
- mkdir
-
-target lib/liballoc/build/liballoc.a
- just lib/liballoc
-
-target build/libstr.a
- liba src/str.c | include/str.h build
-
-target build/libstr.so
- libso src/str.c | include/str.h build
-
-target build/test
- cc src/test.c build/libstr.a lib/liballoc/build/liballoc.a | build
-
-command clean
- rm -rf build
-
-command cleanall
- just clean
- just -C lib/liballoc cleanall
-
-command all
- just build/libstr.a build/libstr.so build/test
-
diff --git a/build.jst.tmpl b/build.jst.tmpl
@@ -0,0 +1,69 @@
+#default PREFIX /usr/local
+#default INCLDIR /include
+#default LIBDIR /lib
+#default CC gcc
+
+#ifdef LIBSTR_DEBUG
+#define DEBUG 1
+#endif
+
+#ifdef DEBUG
+#define OPT_CFLAGS -Og -g
+#else
+#define OPT_CFLAGS -O2
+#endif
+
+cflags = -Wunused-function -Wunused-variable -Wconversion -Wformat
+ -I include -I lib/liballoc/include #{OPT_CFLAGS}
+ #{EXTRA_CFLAGS} #{LIBSTR_EXTRA_CFLAGS}
+
+rule liba
+ #{CC} -o $out.tmp.o $in $cflags -r
+ objcopy --keep-global-symbols=libstr.api $out.tmp.o $out.fixed.o
+ ar rcs $out $out.fixed.o
+ rm $out.tmp.o $out.fixed.o
+
+rule libso
+ #{CC} -o $out $in $cflags -shared -Wl,-version-script libstr.lds
+
+rule cc
+ #{CC} -o $out $in $cflags
+
+rule mkdir
+ mkdir $out
+
+target build
+ mkdir
+
+target lib/liballoc/build/liballoc.a
+ just lib/liballoc
+
+target build/libstr.a
+ liba src/str.c | include/str.h build
+
+target build/libstr.so
+ libso src/str.c | include/str.h build
+
+target build/test
+ cc src/test.c build/libstr.a lib/liballoc/build/liballoc.a | build
+
+command clean
+ rm -rf build
+
+command cleanall
+ just clean
+ just -C lib/liballoc cleanall
+
+command install
+ install -m755 build/libstr.a -t "#{DESTDIR}#{PREFIX}#{LIBDIR}"
+ install -m755 build/libstr.so -t "#{DESTDIR}#{PREFIX}#{LIBDIR}"
+ install -m755 include/str.h -t "#{DESTDIR}#{PREFIX}#{INCLDIR}"
+
+command uninstall
+ rm -f "#{DESTDIR}#{PREFIX}#{LIBDIR}/libstr.a"
+ rm -f "#{DESTDIR}#{PREFIX}#{LIBDIR}/libstr.so"
+ rm -f "#{DESTDIR}#{PREFIX}#{INCLDIR}/str.h"
+
+command all
+ just build/libstr.a build/libstr.so build/test
+
diff --git a/configure b/configure
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+tmpl "$@" build.jst.tmpl > build.jst
+for lib in ./lib/*; do
+ pushd $lib
+ ./configure
+ popd
+done