blob: 318dd35dbb46c50f8da8446e860e4b9d7a8752ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
.PHONY: default debug install defconfig clean
CC ?= clang
RM = rm -f
PREFIX ?= /usr/local
OBJDIR = obj
SRCS = $(wildcard src/*.c)
OBJS = $(SRCS:src/%.c=$(OBJDIR)/%.o)
CFLAGS += $(shell pkg-config --cflags luajit) -I./include -Wno-format-truncation -std=c99 -D_XOPEN_SOURCE=700 -Wall -Wextra
# pretty print for compilation. To enable verbose (show commands), run with
# `make V=1`
ifeq ($(strip $(V)),)
E = @echo
Q = @
else
E = @\#
Q =
endif
default: pkgit
pkgit: $(OBJS)
$(E) " LINK " $@
$(Q) ${CC} -o $@ $^ $(shell pkg-config --libs luajit)
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(OBJDIR)/%.o: src/%.c | $(OBJDIR)
$(E) " CC " $@
$(Q) ${CC} $(CFLAGS) -c -o $@ $<
debug: CFLAGS += -g -O0
debug: pkgit
install: pkgit
$(E) " INSTALL" ${DESTDIR}${PREFIX}
$(Q) install -d ${DESTDIR}${PREFIX}/bin
$(Q) install -m 755 pkgit ${DESTDIR}${PREFIX}/bin/pkgit
$(Q) install -d ${DESTDIR}${PREFIX}/share/man/man1
$(Q) install -m 644 docs/pkgit.1 ${DESTDIR}${PREFIX}/share/man/man1/pkgit.1
uninstall: ${DESTDIR}${PREFIX}/bin/pkgit
$(E) " UNINSTALL" ${DESTDIR}${PREFIX}
$(Q) ${RM} ${DESTDIR}${PREFIX}/bin/pkgit
$(Q) ${RM} ${DESTDIR}${PREFIX}/share/man/man1/pkgit.1
defconfig:
$(Q) @if [ "$$(id -u)" -eq 0 ]; then dir=/etc/pkgit; else dir=~/.config/pkgit; fi; \
$(Q) echo "installing default config to $$dir ..."; \
$(Q) mkdir -p $$dir; \
$(Q) cp -r ./config/* $$dir/; \
$(Q) echo "default config installed"
rmconfig:
$(Q) @if [ "$$(id -u)" -eq 0 ]; then dir=/etc/pkgit; else dir=~/.config/pkgit; fi; \
$(Q) echo "removing config from $$dir ..."; \
$(Q) rm -rf $$dir; \
$(Q) echo "config successfully removed"
clean:
$(E) " CLEAN"
$(Q) ${RM} -r $(OBJDIR) pkgit
|