summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-30 14:11:05 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-30 14:11:05 +0100
commita797a8a9d11b0f0ca9bc738192475b06d5aacc9a (patch)
tree91d4ee70d1842d3487f32712278b7c9c56139005 /Makefile
parentf853bbf411c5bddfc3c4b46ad1c0593fcf56d93b (diff)
downloadgitano-a797a8a9d11b0f0ca9bc738192475b06d5aacc9a.tar.gz
BUILD: Start of a build system and thus installer
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile74
1 files changed, 74 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0328947
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,74 @@
+all: local
+
+# Configuration (override on the commandline)
+
+LUA_VER := 5.1
+LUA := /usr/bin/lua$(LUA_VER)
+INST_ROOT := /usr/local
+
+# 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)
+
+BINS := gitano-auth gitano-post-receive-hook gitano-update-hook \
+ gitano-update-ssh
+
+MODS := gitano \
+ \
+ gitano.util \
+ gitano.actions gitano.config gitano.lace gitano.log \
+ gitano.markdown gitano.repository gitano.supple \
+ gitano.command gitano.admincommand gitano.usercommand \
+ \
+ gitano.git gitano.git.commit gitano.git.ll gitano.git.object \
+ gitano.git.repository gitano.git.tag gitano.git.tree
+
+MOD_DIRS := gitano gitano/git
+MOD_FILES := $(patsubst %,%.lua,$(subst .,/,$(MODS)))
+SRC_MOD_FILES := $(patsubst %,lib/%,$(MOD_FILES))
+
+LOCAL_BINS := $(patsubst %,bin/%,$(BINS))
+BIN_SRCS := $(patsubst %,bin/%.in,$(BINS))
+
+GEN_BIN := utils/install-lua-bin
+RUN_GEN_BIN := $(LUA) $(GEN_BIN) $(LUA)
+define GEN_LOCAL_BIN
+
+$(RUN_GEN_BIN) $(shell pwd)/lib $1 $2
+chmod 755 $2
+
+endef
+
+define GEN_INSTALL_BIN
+
+$(RUN_GEN_BIN) $(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-mods
+
+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-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)))