aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 98fe87acb5a459bf21bb70b2a613637360263419 (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
.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 

default: pkgit

pkgit: $(OBJS)
	${CC} -o $@ $^ $(shell pkg-config --libs luajit)

$(OBJDIR):
	@mkdir -p $(OBJDIR)

$(OBJDIR)/%.o: src/%.c | $(OBJDIR)
	${CC} $(CFLAGS) -c -o $@ $<

debug: CFLAGS += -g -O0
debug: pkgit

install: pkgit
	install -d ${DESTDIR}${PREFIX}/bin
	install -m 755 pkgit ${DESTDIR}${PREFIX}/bin/pkgit

uninstall: ${DESTDIR}${PREFIX}/bin/pkgit
	${RM} ${DESTDIR}${PREFIX}/bin/pkgit

defconfig:
	@if [ "$$(id -u)" -eq 0 ]; then dir=/etc/pkgit; else dir=~/.config/pkgit; fi; \
	echo "installing default config to $$dir ..."; \
	mkdir -p $$dir; \
	cp -r ./config/* $$dir/; \
	echo "default config installed"

clean:
	${RM} -r $(OBJDIR) pkgit