ctpv/Makefile

81 lines
1.6 KiB
Makefile
Raw Normal View History

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/*)
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
LDFLAGS += $(LIBS:%=-l%)
2022-05-22 09:55:04 +02:00
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-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:
$(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-05-22 09:55:04 +02:00
make_embed:
$(MAKE) -C embed
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
src/ctpv.c: gen/previews.h
2022-07-06 00:08:26 +02:00
src/shell.c: gen/helpers.h
src/server.c: gen/server.h
2022-05-22 09:55:04 +02:00
gen/previews.h: $(PRE) embed/embed
2022-05-22 09:55:04 +02:00
@mkdir -p $(@D)
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-06-18 19:29:56 +02:00
gen/helpers.h: sh/helpers.sh embed/embed
@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-24 14:52:03 +02:00
.PHONY: all options install install.bin install.man uninstall \
clean docs make_embed
2022-05-22 09:55:04 +02:00
.DELETE_ON_ERROR: