summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorVicente <vicente@masba.net>2024-04-02 17:38:25 -0300
committerVicente <vicente@masba.net>2024-04-02 17:38:25 -0300
commitf5c501f0c151079a7207ee9b06b779b39e17c55e (patch)
tree0e539f5c74e8df9a4aba89f5a40bb81fabdf104a /Makefile
parentf84aaa169191ecc2c1ee8f928c6b1b963232bc61 (diff)
parentd735c3c05ea1640aa9134dc58cdad90310d1cc26 (diff)
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 48 insertions, 0 deletions
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
+