commit 754551b924853a600a3cefa96619f31ac11d9842
Author: finwo <finwo@pm.me>
Date: Tue, 8 Aug 2017 20:57:46 +0200
Reasonable make setup
Diffstat:
9 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,5 @@
+*.o
+*.swp
+.zedstate
+/Makefile
+/cryptotest
diff --git a/configure b/configure
@@ -0,0 +1,30 @@
+#!bash -
+
+echo "Removing old makefile"
+rm -f Makefile
+
+echo "Building makefile"
+touch Makefile
+
+echo -n " - Detecting compiler... "
+FCC=$(command -v musl-gcc gcc 2>/dev/null | head -1)
+[[ ! -z $FCC ]] && {
+ echo $FCC
+ echo "CC="$FCC >> Makefile
+} || {
+ echo ""
+ echo "No C compiler detected!"
+ exit 1
+}
+
+
+echo " - C flags"
+echo "CFLAGS :=" >> Makefile
+command -v gcc &>/dev/null && echo "CFLAGS += -O3 -s" >> Makefile
+echo "CFLAGS += -I inc" >> Makefile
+
+echo " - Other variables"
+for i in $(ls make/0* | sort) ; do echo " - "$i ; cat $i >> Makefile ; done
+
+echo " - Build targets"
+for i in $(ls make/9* | sort) ; do echo " - "$i ; cat $i >> Makefile ; done
diff --git a/inc/base.h b/inc/base.h
@@ -0,0 +1,9 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+
diff --git a/make/00-deps b/make/00-deps
@@ -0,0 +1 @@
+DEPS = $(wildcard inc/*.h)
diff --git a/make/01-obj b/make/01-obj
@@ -0,0 +1 @@
+OBJ = $(patsubst src/%.c,src/%.o,$(wildcard src/*.c))
diff --git a/make/90-objects b/make/90-objects
@@ -0,0 +1,2 @@
+%.o: %.c $(DEPS)
+ $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/make/91-cryptotest b/make/91-cryptotest
@@ -0,0 +1,2 @@
+cryptotest: $(OBJ)
+ $(CC) $(CFLAGS) $^ -o $@
diff --git a/make/99-clean b/make/99-clean
@@ -0,0 +1,4 @@
+.PHONY: clean
+clean:
+ rm -f cryptotest
+ rm -f $(wildcard src/*.o)
diff --git a/src/main.c b/src/main.c
@@ -0,0 +1,13 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "base.h"
+
+int main( int argc, char **argv ) {
+ return 0;
+}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif