Makefile.in 5.49 KB
TOP := $(shell pwd)
PREFIX := @prefix@
SRC := @srcdir@
CC := @CC@
GUILE := @GUILE@
VERSION := @PACKAGE_VERSION@
CFLAGS := @GUILE_CFLAGS@ -fPIC -MD -DHAVE_CONFIG_H $(INCLUDES)
LIBS := @GUILE_LIBS@ -shared
LDFLAGS := @GUILE_LDFLAGS@ -fPIC -shared
SHELL := /bin/bash
RELEASE_TYPE := beta
PREV_VER := 0.1.1
GPG_KEY := EE78E925
BOOT_TOOLS := autoconf,guile
URL_DIR := "http://alpha.gnu.org/gnu/artanis/"
INCLUDES := -I$(TOP)
OBJ := obj
MOD := $(SRC)/artanis
MOD_OBJ := $(OBJ)/artanis
BIN := bin
TEMP_LIB_PATH := $(OBJ)
MOD_COMPILED_PATH := $(shell guile -c "(display (%site-ccache-dir))")

ifdef DESTDIR
INFO_DIR := $(DESTDIR)/share/info/
MOD_PATH := $(DESTDIR)/$(shell guile -c "(display (%site-dir))")
MOD_TARGET_PATH := $(DESTDIR)/$(MOD_COMPILED_PATH)
else
INFO_DIR := $(PREFIX)/share/info/
MOD_PATH := $(shell guile -c "(display (%site-dir))")
MOD_TARGET_PATH := $(MOD_COMPILED_PATH)
endif

GUILE_CFLAGS := -Wunsupported-warning -Wunbound-variable -Warity-mismatch -Wduplicate-case-datum -Wbad-case-datum -Wformat
GUILEC := GUILE_LOAD_COMPILED_PATH=$(TEMP_LIB_PATH) guild compile $(GUILE_CFLAGS)
ARTANIS_ETC := $(SRC)/etc/artanis
ARTANIS_PAGES := $(SRC)/pages
INSTALL := install -c
HEADER := $(SRC)/.HEAD
DOCS := $(SRC)/docs
DOCS_OBJ := $(OBJ)/docs/
MANUALS := $(DOCS_OBJ)/manuals/
TEXI_SRC := $(DOCS)/artanis.texi
BUILD_AUX := $(SRC)/build-aux
GENDOCS :=$(BUILD_AUX)/gendocs.sh
CHK_TEXINFO := $(BUILD_AUX)/check_texinfo.scm
CP := cp -frd -P
TARBALL_NAME := artanis-$(VERSION)
TMP_DIR := $(shell mktemp -d)
ANN_GEN := $(BUILD_AUX)/announce-gen
DIRE_GEN := $(BUILD_AUX)/gen-directive.scm
GNUPLOAD := $(BUILD_AUX)/gnupload
TEST_SUITE := $(SRC)/test-suite
TESTS := $(TEST_SUITE)/tests
CMDCOMP := $(BUILD_AUX)/show-cmds.sh

ifndef VERBOSE
V := @ # "V = " for verbose, "V = @" for non-verbose
else
V :=
endif

mod-sfile := $(sort $(shell find $(MOD) -name *.scm))
mod-ofile := $(mod-sfile:.scm=.go)
mod-ofile := $(subst $(MOD)/,$(MOD_OBJ)/,$(mod-ofile))

test-cases := $(shell find $(TESTS) -name *.test)

ALL_TARGETS :=	version \
		modules \
		scripts

all: $(ALL_TARGETS)

$(MOD_OBJ)/%.go: $(MOD)/%.scm
	$(V)$(eval AELOG=build.err.$(shell basename $@))
	$(V)-rm -f $(AELOG)
	$(V)echo -ne "+ compiling $<\n\r"
	$(V)mkdir -p $(@D)
	$(V)script -e -c "$(GUILEC) -L $(SRC) $< -o $@" -f $(AELOG) > /dev/null || (cat $(AELOG) && exit 15)
	$(V)if [ -e $(AELOG) ]; then cat $(AELOG) | grep warning; rm $(AELOG); :; fi

$(MOD)/version.scm:
	$(V)echo -ne "Regenerating artanis/version.scm\n\r"
	$(V)-rm -f $@
	$(V)cat $(HEADER) > $@
	$(V)$(GUILE) -c '(let ((port (open-file "$@" "a")))(format port "(define-module (artanis version) #:export (artanis-version)) (define artanis-version \"GNU Artanis-~a\")~%" "$(VERSION)"))'

.PHONY: upload upload.gz upload.bz2 announce release.gz release.bz2 prepare clean modules install distclean distclean-mk bin version test docs scripts clean-obj

announce: release.gz release.bz2
	$(V) $(ANN_GEN) --release-type=$(RELEASE_TYPE) --package-name=artanis --previous-version=$(PREV_VER) --current-version=$(VERSION) --gpg-key-id=$(GPG_KEY) --url-directory=$(URL_DIR) --news=NEWS --bootstrap-tools=$(BOOT_TOOLS)

release.gz: $(TARBALL_NAME).tar.gz

release.bz2: $(TARBALL_NAME).tar.bz2

upload: release.gz release.bz2
	$(V) $(GUILE) -c '(exit (if (string=? "yes I am crazy" (getpass "Are you sure? ")) 0 233))' && \
	$(GNUPLOAD) --to $(RELEASE_TYPE).gnu.org:artanis \
	--symlink-regex \
	artanis-$(VERSION).tar.gz artanis-$(VERSION).tar.bz2

prepare:
	$(V) rm -fr $(TARBALL_NAME)
	$(V) cp -fr $(TOP)/. $(TMP_DIR)
	$(V) $(MAKE) -C $(TMP_DIR) distclean
	$(V) git --git-dir=$(TMP_DIR)/.git --work-tree=$(TMP_DIR) clean -fdqX
	$(V) rm -fr $(TMP_DIR)/.git
	$(V) mv $(TMP_DIR) $(TOP)/$(TARBALL_NAME)

$(TARBALL_NAME).tar.bz2:
	$(V) $(MAKE) prepare
	$(V) tar cjf $@ $(TARBALL_NAME)
	$(V) rm -fr $(TMP_DIR) $(TOP)/$(TARBALL_NAME)

$(TARBALL_NAME).tar.gz:
	$(V) $(MAKE) prepare
	$(V) tar czf $@ $(TARBALL_NAME)
	$(V) rm -fr $(TMP_DIR) $(TOP)/$(TARBALL_NAME)

clean:
	-rm -fr $(OBJ) autom4te.cache
	-rm -f *.log build.err.* *.info
	-rm -f $(MOD)/version.scm
	find . -name "*~" -exec rm {} \;

clean-tarball:
	-rm -f *.bz2 *.gz *.sig *.directive *.asc

clean-config:
	-rm -f config.{h,log}

install: $(ALL_TARGETS)
	mkdir -p $(MOD_PATH)
	$(CP) $(MOD) $(MOD_PATH)/
	mkdir -p $(MOD_TARGET_PATH)/
	$(CP) $(MOD_OBJ) $(MOD_TARGET_PATH)/

ifdef DESTDIR
	$(CP) $(ARTANIS_ETC) $(DESTDIR)/etc/
	$(CP) $(ARTANIS_PAGES) $(DESTDIR)/etc/artanis/
	mkdir -p $(DESTDIR)/bin/
	$(CP) $(BIN)/art $(DESTDIR)/bin/
	mkdir -p $(DESTDIR)/etc/bash_completion.d/
	$(CP) $(CMDCOMP) $(DESTDIR)/etc/bash_completion.d/
else
	$(CP) $(ARTANIS_ETC) $(PREFIX)/etc/
	$(CP) $(ARTANIS_PAGES) $(PREFIX)/etc/artanis/
	mkdir -p $(PREFIX)/bin/
	$(CP) $(BIN)/art $(PREFIX)/bin/
	mkdir -p $(PREFIX)/etc/bash_completion.d/
	$(CP) $(CMDCOMP) $(PREFIX)/etc/bash_completion.d/
endif

	if [ -e /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi
	if [ -e artanis.info ]; then mkdir -p $(INFO_DIR); $(CP) artanis.info $(INFO_DIR)/; fi

distclean: distclean-mk clean clean-config clean-tarball
	-rm -f $(BIN)/art

clean-obj:
	-rm -fr $(MOD_TARGET_PATH)/{artanis,art.go}

distclean-mk:
	-rm -f Makefile

version: $(MOD)/version.scm

modules: $(MOD_OBJ)/version.go $(mod-ofile)

test: modules
	$(V)for t in $(test-cases); do $(GUILE) -L $(SRC) -L $(TEST_SUITE) -C $(OBJ) $$t; done

docs: $(TEXI_SRC)
	$(CHK_TEXINFO)
	GENDOCS_TEMPLATE_DIR=$(BUILD_AUX) $(GENDOCS) --email bug-artanis@gnu.org -s $< -o $(MANUALS) "GNU Artanis Manual" --html --no-headers
	-rm -f ./*.{cp,ky,tp,aux,fn,log,pg,toc,vr}

scripts:
	$(V)echo -ne "Generating bin/art\n\r"
	$(V)chmod +x $(BIN)/art