Makefile: add a dist target to generate a tarball
This commit is contained in:
parent
6686d5513e
commit
fc86acd9f0
27
src/Makefile
27
src/Makefile
|
@ -20,6 +20,8 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
version ?= $(shell if [ -f .version ]; then cat .version; elif [ -d ../.git ]; then git rev-parse --short HEAD; else echo "unknown"; fi )
|
||||||
|
|
||||||
sources := $(sort $(wildcard *.cc))
|
sources := $(sort $(wildcard *.cc))
|
||||||
objects := $(addprefix ., $(sources:.cc=$(suffix).o))
|
objects := $(addprefix ., $(sources:.cc=$(suffix).o))
|
||||||
deps := $(addprefix ., $(sources:.cc=$(suffix).d))
|
deps := $(addprefix ., $(sources:.cc=$(suffix).d))
|
||||||
|
@ -75,14 +77,21 @@ all : kak
|
||||||
kak : kak$(suffix)
|
kak : kak$(suffix)
|
||||||
ln -sf $< $@
|
ln -sf $< $@
|
||||||
|
|
||||||
kak$(suffix) : $(objects)
|
kak$(suffix) : $(objects) .version.o
|
||||||
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@
|
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) .version.o $(LIBS) -o $@
|
||||||
|
|
||||||
-include $(deps)
|
-include $(deps)
|
||||||
|
|
||||||
.%$(suffix).o: %.cc
|
.%$(suffix).o: %.cc
|
||||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
|
||||||
|
|
||||||
|
.version.o: .version.cc
|
||||||
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
.version.cc: FORCE
|
||||||
|
@printf "%s" 'namespace Kakoune { const char* version = "$(version)"; }' > .version.cc.tmp
|
||||||
|
@if cmp -s .version.cc.tmp .version.cc; then rm .version.cc.tmp; else mv .version.cc.tmp .version.cc; fi
|
||||||
|
|
||||||
# Generate the man page
|
# Generate the man page
|
||||||
ifeq ($(gzip_man),yes)
|
ifeq ($(gzip_man),yes)
|
||||||
../doc/kak.1.gz: ../doc/kak.1.asciidoc
|
../doc/kak.1.gz: ../doc/kak.1.asciidoc
|
||||||
|
@ -106,6 +115,16 @@ tags:
|
||||||
clean:
|
clean:
|
||||||
rm -f .*.o .*.d
|
rm -f .*.o .*.d
|
||||||
|
|
||||||
|
dist:
|
||||||
|
@if ! [ -d ../.git ]; then echo "make dist can only run from a git repo"; false; fi
|
||||||
|
@if git status -s | grep -qEv '^\?\?'; then echo "working tree is not clean"; false; fi
|
||||||
|
cd ../; \
|
||||||
|
git archive --format=tar --prefix=kakoune-$(version)/ HEAD -o kakoune-$(version).tar; \
|
||||||
|
echo "$(version)" > src/.version; \
|
||||||
|
tar --transform "s,^,kakoune-$(version)/," -rf kakoune-$(version).tar src/.version; \
|
||||||
|
rm src/.version; \
|
||||||
|
bzip2 kakoune-$(version).tar;
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f kak kak$(suffix)
|
rm -f kak kak$(suffix)
|
||||||
find ../doc -type f \( -name \*\\.gz -o -name \*\\.1 \) -exec rm -f '{}' +
|
find ../doc -type f \( -name \*\\.gz -o -name \*\\.1 \) -exec rm -f '{}' +
|
||||||
|
@ -146,5 +165,5 @@ uninstall:
|
||||||
$(mandir)/kak.1.gz \
|
$(mandir)/kak.1.gz \
|
||||||
$(mandir)/kak.1
|
$(mandir)/kak.1
|
||||||
|
|
||||||
.PHONY: check TAGS clean distclean installdirs install install-strip uninstall
|
.PHONY: check TAGS clean dist distclean installdirs install install-strip uninstall
|
||||||
.PHONY: tags test man kak
|
.PHONY: tags test man kak FORCE
|
||||||
|
|
Loading…
Reference in New Issue
Block a user