blob: fb247c1144103c8369fbd7a03e1e47f2316657f1 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# pkgit - package it!
# Copyright (C) 2026 dacctal
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
.PHONY: default debug install defconfig rmconfig clean uninstall
CC ?= cc
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
# 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)
$(Q) echo " LINK " $@
$(Q) ${CC} -o $@ $^ $(shell pkg-config --libs luajit) $(LDFLAGS) -g
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(OBJDIR)/%.o: src/%.c | $(OBJDIR)
$(Q) echo " CC " $@
$(Q) ${CC} $(CFLAGS) -c -o $@ $<
gdb: CFLAGS += -g -O0 -Wall -Wextra -Werror -Wvla -pedantic
gdb: pkgit
debug: CFLAGS += -g -O0 -Wall -Wextra -Werror -Wvla -pedantic -fsanitize=address
debug: LDFLAGS += -fsanitize=address
debug: pkgit
install: pkgit
$(Q) echo " 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:
$(Q) echo " 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="$$HOME/.config/pkgit"; fi; \
echo "installing default config to $$dir ..."; \
mkdir -p "$$dir"; \
cp -r ./config/* "$$dir/"; \
echo "default config installed"
rmconfig:
$(Q) if [ "$$(id -u)" -eq 0 ]; then dir=/etc/pkgit; else dir="$$HOME/.config/pkgit"; fi; \
echo "removing config from $$dir ..."; \
rm -rf "$$dir"; \
echo "config successfully removed"
clean:
$(Q) echo " CLEAN"
$(Q) ${RM} -r $(OBJDIR) pkgit
|