ctpv/Makefile

88 lines
1.9 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-09 06:56:37 +02:00
LIBS := magic crypto
2022-10-10 09:21:45 +02:00
ALL_CFLAGS := -O2 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS)
ALL_LDFLAGS := $(addprefix -l,$(LIBS)) $(CFLAGS) $(LDFLAGS)
2022-05-22 09:55:04 +02:00
MKDIR := mkdir -p
INSTALL := install
INSTALL_EXE := $(INSTALL)
INSTALL_DATA := $(INSTALL) -m 0644
2022-07-14 21:26:49 +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 = $(ALL_CFLAGS)"
@echo "LDFLAGS = $(ALL_LDFLAGS)"
2022-05-22 09:55:04 +02:00
2022-06-14 14:50:15 +02:00
install: install.bin install.man
install.bin: ctpv quit/ctpvquit ctpvclear
$(MKDIR) $(BINPREFIX)
$(INSTALL_EXE) $^ $(BINPREFIX)
2022-05-22 09:55:04 +02:00
2022-06-14 14:50:15 +02:00
install.man: doc/ctpv.1
$(MKDIR) $(MANPREFIX)
$(INSTALL_DATA) $^ $(MANPREFIX)
2022-06-14 14:50:15 +02:00
2022-05-22 09:55:04 +02:00
uninstall:
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvquit $(BINPREFIX)/ctpvclear \
$(MANPREFIX)/ctpv.1
2022-05-22 09:55:04 +02:00
clean:
$(RM) ctpv $(OBJ) $(DEP) $(GEN)
$(MAKE) -C embed clean
$(MAKE) -C quit clean
2022-05-22 09:55:04 +02:00
2022-06-24 14:52:03 +02:00
docs: README.md doc/ctpv.1
2022-07-25 19:11:40 +02:00
deptable/list.awk $(PRE) | deptable/markdown.sed | deptable/insert.awk README.md
deptable/list.awk $(PRE) | deptable/roff.sed | deptable/insert.awk doc/ctpv.1
2022-06-24 14:52:03 +02:00
2022-05-22 09:55:04 +02:00
ctpv: $(OBJ)
$(CC) -o $@ $+ $(ALL_LDFLAGS)
.c.o:
$(CC) -o $@ $< -c $(ALL_CFLAGS)
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
gen/previews.h: $(PRE) embed/embed
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-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) $@
2022-07-14 20:43:45 +02:00
embed/embed: .force
$(MAKE) -C embed
2022-05-22 09:55:04 +02:00
quit/ctpvquit: .force
$(MAKE) -C quit
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: