2022-05-22 09:55:04 +02:00
|
|
|
PREFIX := /usr/local
|
2022-06-18 12:27:20 +02:00
|
|
|
BINPREFIX := $(DESTDIR)$(PREFIX)/bin
|
|
|
|
MANPREFIX := $(DESTDIR)$(PREFIX)/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-05-28 19:33:18 +02:00
|
|
|
GEN := gen/prev/scripts.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
|
|
|
|
LDFLAGS += $(LIBS:%=-l%)
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-18 17:50:57 +02:00
|
|
|
all: ctpv README.md doc/ctpv.1
|
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-05-22 09:55:04 +02:00
|
|
|
install -d $(BINPREFIX)
|
2022-05-25 23:57:50 +02:00
|
|
|
install $^ $(BINPREFIX)
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-14 14:50:15 +02:00
|
|
|
install.man: doc/ctpv.1
|
|
|
|
install -d $(MANPREFIX)
|
|
|
|
install -m 0644 $^ $(MANPREFIX)
|
|
|
|
|
2022-05-22 09:55:04 +02:00
|
|
|
uninstall:
|
2022-05-26 01:48:27 +02:00
|
|
|
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvclear
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) ctpv $(OBJ) $(DEP) $(GEN)
|
|
|
|
$(MAKE) -C embed clean
|
|
|
|
|
|
|
|
make_embed:
|
|
|
|
$(MAKE) -C embed
|
|
|
|
|
|
|
|
ctpv: $(OBJ)
|
2022-06-08 12:41:30 +02:00
|
|
|
$(CC) $(LDFLAGS) $+ -o $@
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-06-08 12:41:30 +02:00
|
|
|
src/ctpv.c: $(GEN)
|
2022-05-22 09:55:04 +02:00
|
|
|
|
2022-05-28 19:33:18 +02:00
|
|
|
gen/prev/scripts.h: $(PRE) embed/embed
|
2022-05-22 09:55:04 +02:00
|
|
|
@mkdir -p $(@D)
|
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
|
2022-05-25 23:57:50 +02:00
|
|
|
@mkdir -p $(@D)
|
2022-06-18 19:29:56 +02:00
|
|
|
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
|
2022-05-28 19:33:18 +02:00
|
|
|
@mkdir -p $(@D)
|
2022-06-18 19:29:56 +02:00
|
|
|
embed/embed -p scr_ sh/helpers.sh > $@
|
2022-05-25 23:57:50 +02:00
|
|
|
|
2022-06-18 17:50:57 +02:00
|
|
|
README.md: $(PRE)
|
|
|
|
./deplist.awk $^ | ./deplist.md.sh | ./deplistadd.sh $@
|
|
|
|
|
|
|
|
doc/ctpv.1: $(PRE)
|
|
|
|
./deplist.awk $^ | ./deplist.1.sh | ./deplistadd.sh $@
|
|
|
|
|
2022-05-22 09:55:04 +02:00
|
|
|
embed/embed: make_embed
|
2022-06-09 06:56:37 +02:00
|
|
|
@ # do nothing
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
-include $(DEP)
|
|
|
|
|
2022-06-14 14:50:15 +02:00
|
|
|
.PHONY: all options install install.bin install.man uninstall clean make_embed
|
2022-05-22 09:55:04 +02:00
|
|
|
|
|
|
|
.DELETE_ON_ERROR:
|