2022-05-22 09:55:04 +02:00
|
|
|
PREFIX := /usr/local
|
2022-06-18 12:27:20 +02:00
|
|
|
BINPREFIX := $(DESTDIR)$(PREFIX)/bin
|
2022-06-21 16:11:56 +02:00
|
|
|
MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-08 12:41:30 +02:00
|
|
|
SRC := $(wildcard src/*.c)
|
2022-05-22 09:55:04 +02:00
|
|
|
OBJ := $(SRC:.c=.o)
|
|
|
|
DEP := $(OBJ:.o=.d)
|
2022-06-20 22:18:04 +02:00
|
|
|
PRE := $(wildcard sh/prev/*)
|
2022-07-06 00:09:35 +02:00
|
|
|
GEN := gen/previews.h gen/server.h gen/helpers.h
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-12 12:25:43 +02:00
|
|
|
O := -O2
|
2022-06-09 06:56:37 +02:00
|
|
|
LIBS := magic crypto
|
|
|
|
|
|
|
|
CFLAGS += $(O) -MD -Wall -Wextra -Wno-unused-parameter
|
2022-07-14 20:43:45 +02:00
|
|
|
LDFLAGS += $(addprefix -l,$(LIBS))
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-07-14 21:26:49 +02:00
|
|
|
INSTALL := install
|
|
|
|
|
2022-06-24 14:52:03 +02:00
|
|
|
all: ctpv
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
options:
|
|
|
|
@echo "CC = $(CC)"
|
|
|
|
@echo "CFLAGS = $(CFLAGS)"
|
|
|
|
@echo "LDFLAGS = $(LDFLAGS)"
|
|
|
|
|
2022-06-14 14:50:15 +02:00
|
|
|
install: install.bin install.man
|
|
|
|
|
|
|
|
install.bin: ctpv ctpvclear
|
2022-07-14 21:26:49 +02:00
|
|
|
$(INSTALL) -d $(BINPREFIX)
|
|
|
|
$(INSTALL) $^ $(BINPREFIX)
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-14 14:50:15 +02:00
|
|
|
install.man: doc/ctpv.1
|
2022-07-14 21:26:49 +02:00
|
|
|
$(INSTALL) -d $(MANPREFIX)
|
|
|
|
$(INSTALL) -m 0644 $^ $(MANPREFIX)
|
2022-06-14 14:50:15 +02:00
|
|
|
|
2022-05-22 09:55:04 +02:00
|
|
|
uninstall:
|
2022-06-21 17:06:46 +02:00
|
|
|
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvclear $(MANPREFIX)/ctpv.1
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) ctpv $(OBJ) $(DEP) $(GEN)
|
|
|
|
$(MAKE) -C embed clean
|
|
|
|
|
2022-06-24 14:52:03 +02:00
|
|
|
docs: README.md doc/ctpv.1
|
2022-07-14 21:00:52 +02:00
|
|
|
deptable/list.awk $(PRE) | deptable/markdown.sh | deptable/insert.sh README.md
|
|
|
|
deptable/list.awk $(PRE) | deptable/roff.sh | deptable/insert.sh doc/ctpv.1
|
2022-06-24 14:52:03 +02:00
|
|
|
|
2022-05-22 09:55:04 +02:00
|
|
|
ctpv: $(OBJ)
|
2022-06-24 13:28:39 +02:00
|
|
|
$(CC) -o $@ $+ $(LDFLAGS)
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-07-06 00:08:26 +02:00
|
|
|
# Exclicit rules for generated header files
|
2022-07-15 10:55:05 +02:00
|
|
|
src/ctpv.o: gen/previews.h
|
|
|
|
src/shell.o: gen/helpers.h
|
|
|
|
src/server.o: gen/server.h
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-07-06 00:09:35 +02:00
|
|
|
gen/previews.h: $(PRE) embed/embed
|
2022-05-28 19:33:18 +02:00
|
|
|
embed/embed -p prev_scr_ $(PRE) > $@
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-18 19:29:56 +02:00
|
|
|
gen/server.h: sh/clear.sh sh/end.sh embed/embed
|
|
|
|
embed/embed -p scr_ sh/clear.sh sh/end.sh > $@
|
2022-05-28 19:33:18 +02:00
|
|
|
|
2022-06-18 19:29:56 +02:00
|
|
|
gen/helpers.h: sh/helpers.sh embed/embed
|
|
|
|
embed/embed -p scr_ sh/helpers.sh > $@
|
2022-05-25 23:57:50 +02:00
|
|
|
|
2022-07-14 20:43:45 +02:00
|
|
|
$(GEN): | gen
|
|
|
|
|
|
|
|
gen:
|
|
|
|
mkdir $@
|
|
|
|
|
|
|
|
embed/embed: .force
|
|
|
|
$(MAKE) -C embed
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
-include $(DEP)
|
|
|
|
|
2022-06-24 14:52:03 +02:00
|
|
|
.PHONY: all options install install.bin install.man uninstall \
|
2022-07-14 20:43:45 +02:00
|
|
|
clean docs .force
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
.DELETE_ON_ERROR:
|