summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Souza <pedro@masba.net>2024-04-02 17:34:34 -0300
committerPedro Souza <pedro@masba.net>2024-04-02 17:34:34 -0300
commitd735c3c05ea1640aa9134dc58cdad90310d1cc26 (patch)
tree0fa06d0f6d0b33669ada45506f445966c668d2d4
parent83dc0d3875e0092c529d1260af4434818f912972 (diff)
Added Makefile
-rw-r--r--.gitignore1
-rw-r--r--Makefile48
-rw-r--r--main.c6
3 files changed, 55 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e660fd9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+bin/
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2e857bc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,48 @@
+MKDIR := mkdir
+RMDIR := rm -r
+RM := rm
+CC := gcc
+BINDIR := ./bin
+TESTDIR := ./test
+SRCDIRS := ./
+SRCS := $(foreach fd, $(SRCDIRS), $(wildcard $(fd)/*.c))
+OBJS := $(patsubst %.c,$(BINDIR)/%.o,$(SRCS))
+ARCFIND := $(BINDIR)/arcfind
+EXES := $(ARCFIND)
+CFLAGS := $(addprefix -I,$(SRCDIRS)) $(XTRAFLAGS)
+LDLIBS :=
+
+ARCFIND_O := $(addprefix ./bin/, main.o)
+
+all: $(EXES)
+.PHONY: all
+
+$(BINDIR)/%.o: %.c | $(BINDIR)
+ $(CC) $(CFLAGS) -c -o $@ $^ $(LDLIBS)
+
+include $(DEPS)
+
+$(ARCFIND): $(ARCFIND_O) | $(BINDIR)
+ $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
+
+# TODO: one good rule for the test bins
+
+$(BINDIR):
+ $(MKDIR) $@
+
+$(TESTDIR):
+ $(MKDIR) $@
+
+debug:
+ $(MAKE) XTRAFLAGS:="-g -fsanitize=undefined -fsanitize-undefined-trap-on-error -fno-omit-frame-pointer -O0 -DDEBUG -Wuninitialized"
+.PHONY: debug
+
+release:
+ $(MAKE) XTRAFLAGS:="-O3"
+.PHONY: release
+
+clean:
+ -$(RM) $(OBJS)
+ -$(RM) $(EXES)
+.PHONY: clean
+
diff --git a/main.c b/main.c
index e69de29..bfea3b3 100644
--- a/main.c
+++ b/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void) {
+ printf("arcfind!\n");
+ return 0;
+}