Browse Source

fixup makefile

pull/434/head
Antonio SJ Musumeci 7 years ago
parent
commit
ebe737e995
  1. 40
      Makefile

40
Makefile

@ -29,7 +29,14 @@ GZIP = $(shell which gzip)
RPMBUILD = $(shell which rpmbuild) RPMBUILD = $(shell which rpmbuild)
GIT2DEBCL = ./tools/git2debcl GIT2DEBCL = ./tools/git2debcl
ifeq ($(PANDOC),"")
GIT_REPO = 0
ifneq ($(GIT),)
ifeq ($(shell test -e .git; echo $$?),0)
GIT_REPO = 1
endif
endif
ifeq ($(PANDOC),)
$(warning "pandoc does not appear available: manpage won't be buildable") $(warning "pandoc does not appear available: manpage won't be buildable")
endif endif
@ -85,13 +92,23 @@ mount.mergerfs: $(TARGET)
$(LN) -fs "$<" "$@" $(LN) -fs "$<" "$@"
changelog: changelog:
ifeq ($(GIT_REPO),1)
$(GIT2DEBCL) --name $(TARGET) > ChangeLog $(GIT2DEBCL) --name $(TARGET) > ChangeLog
endif
authors: authors:
ifeq ($(GIT_REPO),1)
$(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS $(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS
endif
src/version.hpp:
version:
ifeq ($(GIT_REPO),1)
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty)) $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
@echo "$(VERSION)" > VERSION
endif
src/version.hpp: version
$(eval VERSION := $(shell cat VERSION))
@echo "#pragma once" > src/version.hpp @echo "#pragma once" > src/version.hpp
@echo "static const char MERGERFS_VERSION[] = \"$(VERSION)\";" >> src/version.hpp @echo "static const char MERGERFS_VERSION[] = \"$(VERSION)\";" >> src/version.hpp
@ -103,20 +120,17 @@ obj/%.o: src/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@ $(CXX) $(CFLAGS) -c $< -o $@
clean: rpm-clean libfuse_Makefile clean: rpm-clean libfuse_Makefile
ifneq ($(GIT),)
ifeq ($(shell test -e .git; echo $$?),0)
$(RM) -f src/version.hpp $(RM) -f src/version.hpp
endif
endif
$(RM) -rf obj $(RM) -rf obj
$(RM) -f "$(TARGET)" mount.mergerfs $(RM) -f "$(TARGET)" mount.mergerfs
$(FIND) . -name "*~" -delete $(FIND) . -name "*~" -delete
cd libfuse && $(MAKE) clean cd libfuse && $(MAKE) clean
distclean: clean libfuse_Makefile distclean: clean libfuse_Makefile
cd libfuse && $(MAKE) distclean cd libfuse && $(MAKE) distclean
ifeq ($(GIT_REPO),1)
$(GIT) clean -fd $(GIT) clean -fd
endif
install: install-base install-mount.mergerfs install-man install: install-base install-mount.mergerfs install-man
@ -147,14 +161,14 @@ uninstall-man:
$(RM) -f "$(INSTALLMAN1DIR)/$(MANPAGE)" $(RM) -f "$(INSTALLMAN1DIR)/$(MANPAGE)"
$(MANPAGE): README.md $(MANPAGE): README.md
ifneq (,$(PANDOC))
ifneq ($(PANDOC),)
$(PANDOC) -s -t man -o "man/$(MANPAGE)" README.md $(PANDOC) -s -t man -o "man/$(MANPAGE)" README.md
endif endif
man: $(MANPAGE) man: $(MANPAGE)
tarball: clean man changelog authors src/version.hpp
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
tarball: distclean man changelog authors version
$(eval VERSION := $(shell cat VERSION))
$(eval VERSION := $(subst -,_,$(VERSION))) $(eval VERSION := $(subst -,_,$(VERSION)))
$(eval FILENAME := $(TARGET)-$(VERSION)) $(eval FILENAME := $(TARGET)-$(VERSION))
$(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX)) $(eval TMPDIR := $(shell $(MKTEMP) --tmpdir -d .$(FILENAME).XXXXXXXX))
@ -164,7 +178,11 @@ tarball: clean man changelog authors src/version.hpp
$(RM) -rf $(TMPDIR) $(RM) -rf $(TMPDIR)
debian-changelog: debian-changelog:
ifeq ($(GIT_REPO),1)
$(GIT2DEBCL) --name $(TARGET) > debian/changelog $(GIT2DEBCL) --name $(TARGET) > debian/changelog
else
cp ChangeLog debian/changelog
endif
signed-deb: debian-changelog signed-deb: debian-changelog
dpkg-buildpackage dpkg-buildpackage
@ -176,7 +194,7 @@ rpm-clean:
$(RM) -rf rpmbuild $(RM) -rf rpmbuild
rpm: tarball rpm: tarball
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
$(eval VERSION := $(shell cat VERSION))
$(eval VERSION := $(subst -,_,$(VERSION))) $(eval VERSION := $(subst -,_,$(VERSION)))
$(MKDIR) -p rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SOURCES $(MKDIR) -p rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SOURCES
$(SED) 's/__VERSION__/$(VERSION)/g' $(TARGET).spec > \ $(SED) 's/__VERSION__/$(VERSION)/g' $(TARGET).spec > \

Loading…
Cancel
Save