summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile30
1 files changed, 30 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..7d08771
--- /dev/null
+++ b/makefile
@@ -0,0 +1,30 @@
+bin:=$(notdir $(shell pwd))
+src:=$(shell ls *.c)
+obj:=$(src:.c=.o)
+
+libs:=luajit
+
+CFLAGS?=\
+ -march=native -O3 -flto \
+ -Wall -Wextra -pedantic \
+ -D_GNU_SOURCE
+
+LDFLAGS?=\
+ -O3 -s -flto \
+ -lmosquitto
+
+CFLAGS+=$(shell pkg-config --cflags $(libs))
+LDFLAGS+=$(shell pkg-config --libs $(libs))
+
+all: $(bin)
+
+$(bin): $(obj)
+ $(CC) $^ $(LDFLAGS) -o $@
+
+%.o: %.c *.h
+ $(CC) -c $< $(CFLAGS) -o $@
+
+clean:
+ -rm $(bin) $(obj)
+
+.PHONY: all clean