aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-07 02:02:45 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-11-07 02:02:45 +0300
commite3a41da5a0a3d70ac53591f2b66144f2be2b3871 (patch)
tree789cc69b05f2447c11f04dbb6ae972ffa0acd1c9 /Makefile
downloadrevela-e3a41da5a0a3d70ac53591f2b66144f2be2b3871.tar.gz
revela-e3a41da5a0a3d70ac53591f2b66144f2be2b3871.zip
Initial commit.
Almost functional but still missing features and lacking testing.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile47
1 files changed, 47 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ed44d6e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+CC?=gcc
+XFLAGS=-D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L
+CFLAGS?=-std=c99 -O2 -Wall $(XFLAGS)
+
+LIBS:=-lexif
+LIBS+=$(shell pkg-config --cflags --libs GraphicsMagickWand)
+IDIRS:=$(addprefix -iquote,include unja/src unja parcini/include)
+
+BUILDIR?=build/release
+
+ifdef DEBUG
+BUILDIR:=build/debug
+CFLAGS:=-std=c99 -O0 -g -DDEBUG $(XFLAGS)
+endif
+
+OBJDIR=$(BUILDIR)/obj
+
+UNJA_SRCS+=$(shell find unja -name '*.c' -not -path '*/tests/*')
+UNJA_OBJS:=$(UNJA_SRCS:%.c=$(OBJDIR)/%.o)
+PARCINI_SRCS:=$(wildcard parcini/src/*.c)
+PARCINI_OBJS:=$(PARCINI_SRCS:%.c=$(OBJDIR)/%.o)
+REVELA_SRCS:=$(shell find src -name '*.c' -not -path '*/tests/*')
+REVELA_OBJS:=$(REVELA_SRCS:%.c=$(OBJDIR)/%.o)
+ALL_OBJS:=$(UNJA_OBJS) $(PARCINI_OBJS) $(REVELA_OBJS)
+TEST_OBJS:=$(filter-out $(OBJDIR)/src/revela.o,$(ALL_OBJS))
+
+all: revela
+
+test: tests/config tests/fs
+
+tests/%: $(OBJDIR)/src/tests/%.o $(TEST_OBJS)
+ mkdir -p $(BUILDIR)/$(@D)
+ $(CC) -o $(BUILDIR)/$@ $^ $(LDFLAGS) $(IDIRS) $(LIBS)
+
+$(OBJDIR)/%.o: %.c
+ mkdir -p $(@D)
+ $(CC) -c $(CFLAGS) $(IDIRS) -o $@ $< $(LIBS)
+
+revela: $(ALL_OBJS)
+ $(CC) $(LDFLAGS) -o $(BUILDIR)/$@ $^ $(LIBS) $(CFLAGS)
+
+clean:
+ rm -r build
+
+.PHONY: clean all test
+
+.PRECIOUS: $(OBJDIR)/src/tests/%.o