all: local # Configuration (override on the commandline) LUA_VER := 5.1 LUA := /usr/bin/lua$(LUA_VER) PREFIX ?= /usr/local INST_ROOT := $(PREFIX) # Internal stuff LUA_MOD_PATH := $(INST_ROOT)/share/lua/$(LUA_VER) LUA_MOD_INST_PATH := $(DESTDIR)$(LUA_MOD_PATH) BIN_PATH := $(INST_ROOT)/bin BIN_INST_PATH := $(DESTDIR)$(BIN_PATH) LIB_BIN_PATH := $(INST_ROOT)/lib/gitano/bin LIB_BIN_INST_PATH := $(DESTDIR)$(LIB_BIN_PATH) SHARE_PATH := $(INST_ROOT)/share/gitano SHARE_INST_PATH := $(DESTDIR)$(SHARE_PATH) SKEL_INST_PATH := $(SHARE_INST_PATH)/skel LIB_BINS := gitano-auth gitano-post-receive-hook gitano-update-hook \ gitano-update-ssh gitano-pre-receive-hook BINS := gitano-setup MODS := gitano \ \ gitano.util \ gitano.actions gitano.config gitano.lace gitano.log \ gitano.markdown gitano.repository gitano.supple \ gitano.command gitano.admincommand gitano.usercommand SKEL_FILES := gitano-admin/rules/selfchecks.lace \ gitano-admin/rules/aschecks.lace \ gitano-admin/rules/siteadmin.lace \ gitano-admin/rules/destroyrepo.lace \ gitano-admin/rules/remoteconfigchecks.lace \ gitano-admin/rules/core.lace \ gitano-admin/rules/renamerepo.lace \ gitano-admin/rules/defines.lace \ gitano-admin/rules/project.lace \ gitano-admin/rules/adminchecks.lace \ gitano-admin/rules/createrepo.lace MOD_DIRS := gitano MOD_FILES := $(patsubst %,%.lua,$(subst .,/,$(MODS))) SRC_MOD_FILES := $(patsubst %,lib/%,$(MOD_FILES)) LOCAL_BINS := $(patsubst %,bin/%,$(BINS) $(LIB_BINS)) LIB_BIN_SRCS := $(patsubst %,bin/%.in,$(LIB_BINS)) GEN_BIN := utils/install-lua-bin RUN_GEN_BIN := $(LUA) $(GEN_BIN) $(LUA) define GEN_LOCAL_BIN $(RUN_GEN_BIN) $(shell pwd) $(shell pwd)/bin $(shell pwd)/lib $1 $2 chmod 755 $2 endef define GEN_INSTALL_BIN $(RUN_GEN_BIN) $(SHARE_PATH) $(LIB_BIN_PATH) $(LUA_MOD_PATH) $1 $2 chmod 755 $2 endef define GEN_INSTALL_MOD install -m 644 $1 $2 endef local: $(LOCAL_BINS) clean: @echo "CLEAN: local binaries" @$(RM) $(LOCAL_BINS) bin/%: bin/%.in $(GEN_BIN) $(call GEN_LOCAL_BIN,$<,$@) install: install-bins install-lib-bins install-mods install-skel install-bins: $(BIN_SRCS) $(GEN_BIN) mkdir -p $(BIN_INST_PATH) $(foreach BIN,$(BINS),$(call GEN_INSTALL_BIN,bin/$(BIN).in,$(BIN_INST_PATH)/$(BIN))) install-lib-bins: $(LIB_BIN_SRCS) $(GEN_BIN) mkdir -p $(LIB_BIN_INST_PATH) $(foreach BIN,$(LIB_BINS),$(call GEN_INSTALL_BIN,bin/$(BIN).in,$(LIB_BIN_INST_PATH)/$(BIN))) install-mods: $(SRC_MOD_FILES) mkdir -p $(patsubst %,$(LUA_MOD_INST_PATH)/%,$(MOD_DIRS)) $(foreach MOD,$(MOD_FILES),$(call GEN_INSTALL_MOD,lib/$(MOD),$(LUA_MOD_INST_PATH)/$(MOD))) install-skel: mkdir -p $(SKEL_INST_PATH)/gitano-admin/rules for SKELFILE in $(SKEL_FILES); do \ install -m 644 skel/$$SKELFILE $(SKEL_INST_PATH)/$$SKELFILE; \ done