summaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: 589da04a99713da3a53c9ce463786404272d8f05 (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
CFLAGS+=-std=c11 -Wall -Wextra -Wpedantic -D_POSIX_C_SOURCE=200809L
CFLAGS+=`pkg-config --cflags lua5.4`
LDLIBS+=`pkg-config --libs lua5.4`

PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
DATADIR?=$(PREFIX)/share
MANDIR?=$(DATADIR)/man/man1
PLOP_DEFAULT_HANDLER?=$(DATADIR)/plop/default.lua

all: plop

plop: connection.o main.o plop.o stream.o buffer.o

main.o plop.o: CFLAGS+=-DPLOP_DEFAULT_HANDLER=\"$(PLOP_DEFAULT_HANDLER)\"
buffer.o: buffer.h
main.o: plop.h
plop.o: connection.h plop.h stream.h
connection.o: connection.h
stream.o: stream.h buffer.h

clean:
	rm -f plop *.o

install: plop
	mkdir -p $(DESTDIR)$(BINDIR)
	mkdir -p $(DESTDIR)$(MANDIR)
	mkdir -p $(DESTDIR)$(DATADIR)/plop
	cp -f plop $(DESTDIR)$(BINDIR)/plop
	cp -f plop.1 $(DESTDIR)$(MANDIR)/plop.1
	cp -f default.lua $(DESTDIR)$(DATADIR)/plop
	chmod 755 $(DESTDIR)$(BINDIR)/plop
	chmod 644 $(DESTDIR)$(MANDIR)/plop.1
	chmod 644 $(DESTDIR)$(DATADIR)/plop/default.lua

uninstall:
	rm -f $(DESTDIR)$(BINDIR)/plop
	rm -f $(DESTDIR)$(MANDIR)/plop.1
	rm -f $(DESTDIR)$(DATADIR)/plop/default.lua
	rmdir $(DESTDIR)$(DATADIR)/plop

env:
	@echo DESTDIR=$(DESTDIR)
	@echo PREFIX=$(PREFIX)
	@echo DATADIR=$(DATADIR)
	@echo MANDIR=$(MANDIR)
	@echo PLOP_DEFAULT_HANDLER=$(PLOP_DEFAULT_HANDLER)

.PHONY: all clean install uninstall env