ctpv/Makefile
2022-07-06 03:08:26 +05:00

81 lines
1.6 KiB
Makefile

PREFIX := /usr/local
BINPREFIX := $(DESTDIR)$(PREFIX)/bin
MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1
SRC := $(wildcard src/*.c)
OBJ := $(SRC:.c=.o)
DEP := $(OBJ:.o=.d)
PRE := $(wildcard sh/prev/*)
GEN := gen/prev/scripts.h gen/server.h gen/helpers.h
O := -O2
LIBS := magic crypto
CFLAGS += $(O) -MD -Wall -Wextra -Wno-unused-parameter
LDFLAGS += $(LIBS:%=-l%)
all: ctpv
options:
@echo "CC = $(CC)"
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
install: install.bin install.man
install.bin: ctpv ctpvclear
install -d $(BINPREFIX)
install $^ $(BINPREFIX)
install.man: doc/ctpv.1
install -d $(MANPREFIX)
install -m 0644 $^ $(MANPREFIX)
uninstall:
$(RM) $(BINPREFIX)/ctpv $(BINPREFIX)/ctpvclear $(MANPREFIX)/ctpv.1
clean:
$(RM) ctpv $(OBJ) $(DEP) $(GEN)
$(MAKE) -C embed clean
docs: README.md doc/ctpv.1
make_embed:
$(MAKE) -C embed
ctpv: $(OBJ)
$(CC) -o $@ $+ $(LDFLAGS)
# Exclicit rules for generated header files
src/ctpv.c: gen/prev/scripts.h
src/shell.c: gen/helpers.h
src/server.c: gen/server.h
gen/prev/scripts.h: $(PRE) embed/embed
@mkdir -p $(@D)
embed/embed -p prev_scr_ $(PRE) > $@
gen/server.h: sh/clear.sh sh/end.sh embed/embed
@mkdir -p $(@D)
embed/embed -p scr_ sh/clear.sh sh/end.sh > $@
gen/helpers.h: sh/helpers.sh embed/embed
@mkdir -p $(@D)
embed/embed -p scr_ sh/helpers.sh > $@
README.md: $(PRE)
./deplist.awk $^ | ./deplist.md.sh | ./deplistadd.sh $@
doc/ctpv.1: $(PRE)
./deplist.awk $^ | ./deplist.1.sh | ./deplistadd.sh $@
embed/embed: make_embed
@ # do nothing
-include $(DEP)
.PHONY: all options install install.bin install.man uninstall \
clean docs make_embed
.DELETE_ON_ERROR: