aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-23 17:22:23 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-23 17:22:43 -0700
commit863983202ce4ef92d9e3a296a682535d157c245d (patch)
tree288411a534c8a64542ce1b101b9532cb12f11c7d /Makefile
parent0d888db6324ecd879ba770880173255b6c3f7ae5 (diff)
Fixed up nomsupath behavior and refactored file stuff into its own file.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile53
1 files changed, 43 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index a65ca4e..fc11273 100644
--- a/Makefile
+++ b/Makefile
@@ -9,11 +9,12 @@ LUA_BIN= $(shell which $(LUA))
PREFIX=/usr/local
NOMSU_BIN_DIR= $(PREFIX)/bin
NOMSU_LIB_DIR= $(PREFIX)/lib/nomsu
+NOMSU_SHARE_DIR= $(PREFIX)/share/nomsu
# ========= You shouldn't need to mess with any of these variables below ================
-MOON_FILES= code_obj.moon error_handling.moon nomsu.moon nomsu_compiler.moon nomsu_tree.moon parser.moon
-LUA_FILES= code_obj.lua consolecolors.lua error_handling.lua nomsu.lua nomsu_compiler.lua \
+MOON_FILES= code_obj.moon error_handling.moon files.moon nomsu.moon nomsu_compiler.moon nomsu_tree.moon parser.moon
+LUA_FILES= code_obj.lua consolecolors.lua error_handling.lua files.lua nomsu.lua nomsu_compiler.lua \
nomsu_tree.lua parser.lua utils.lua uuid.lua
CORE_NOM_FILES= $(wildcard core/*.nom)
CORE_LUA_FILES= $(patsubst %.nom,%.lua,$(CORE_NOM_FILES))
@@ -37,7 +38,7 @@ test: build optimize
.PHONY: check_header
check_header: $(PEG_FILE) nomsu.lua $(CORE_NOM_FILES) $(LIB_NOM_FILES)
@if [ -f nomsu_latest ]; then \
- NOMSU_HEADER="#!$(LUA_BIN)\\npackage.path = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`/?.lua;]]..package.path\\npackage.nomsupath = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`]]"; \
+ NOMSU_HEADER="#!$(LUA_BIN)\\nlocal NOMSU_VERSION, NOMSU_LIB, NOMSU_SHARE = [[`$(GET_VERSION)`]], [[$(NOMSU_LIB_DIR)]], [[$(NOMSU_SHARE_DIR)]]"; \
if [ "`head -n 3 nomsu_latest 2>/dev/null`" != "`echo $$NOMSU_HEADER`" ]; then \
rm -f nomsu_latest; \
fi; \
@@ -45,7 +46,7 @@ check_header: $(PEG_FILE) nomsu.lua $(CORE_NOM_FILES) $(LIB_NOM_FILES)
nomsu_latest: nomsu.lua
@rm -f nomsu_latest
- @NOMSU_HEADER="#!$(LUA_BIN)\\npackage.path = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`/?.lua;]]..package.path\\npackage.nomsupath = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`]]"; \
+ @NOMSU_HEADER="#!$(LUA_BIN)\\nlocal NOMSU_VERSION, NOMSU_LIB, NOMSU_SHARE = [[`$(GET_VERSION)`]], [[$(NOMSU_LIB_DIR)]], [[$(NOMSU_SHARE_DIR)]]"; \
echo $$NOMSU_HEADER | cat - nomsu.lua > nomsu_latest
@chmod +x nomsu_latest
@mv -f nomsu_latest nomsu`$(GET_VERSION)`
@@ -64,14 +65,46 @@ clean:
.PHONY: install
install: all
- mkdir -pv $(NOMSU_BIN_DIR) && cp -v nomsu nomsu`$(GET_VERSION)` $(NOMSU_BIN_DIR)
- mkdir -pv $(NOMSU_LIB_DIR)/`$(GET_VERSION)` && cp -rv $(LUA_FILES) $(PEG_FILE) core lib $(NOMSU_LIB_DIR)/`$(GET_VERSION)`
+ @echo "Nomsu will be installed to:"
+ @echo " $(NOMSU_BIN_DIR)"
+ @echo " $(NOMSU_LIB_DIR)"
+ @echo " $(NOMSU_SHARE_DIR)"
+ @read -p "is that okay? [Y/n] " ans; \
+ if [[ ! $$ans =~ ^[Nn] ]]; then \
+ mkdir -pv $(NOMSU_BIN_DIR) $(NOMSU_LIB_DIR)/`$(GET_VERSION)` $(NOMSU_SHARE_DIR)/`$(GET_VERSION)` \
+ && cp -v nomsu nomsu`$(GET_VERSION)` $(NOMSU_BIN_DIR) \
+ && cp -rv $(LUA_FILES) $(PEG_FILE) core lib tests $(NOMSU_SHARE_DIR)/`$(GET_VERSION)`; \
+ fi
.PHONY: uninstall
uninstall: all
- @echo "Deleting..."
- @rm -rvf $(NOMSU_LIB_DIR)/`$(GET_VERSION)` $(NOMSU_BIN_DIR)/nomsu`$(GET_VERSION)`
- @if [ "`ls $(NOMSU_BIN_DIR)/nomsu*`" == "nomsu" ]; then rm -v $(NOMSU_BIN_DIR)/nomsu; fi
- @if [ "`ls $(NOMSU_LIB_DIR) 2>/dev/null`" == "" ]; then rm -rvf $(NOMSU_LIB_DIR); fi
+ @echo "Nomsu will be uninstalled from:"
+ @echo " $(NOMSU_BIN_DIR)"
+ @echo " $(NOMSU_LIB_DIR)"
+ @echo " $(NOMSU_SHARE_DIR)"
+ @read -p "is that okay? [Y/n] " ans; \
+ if [[ ! $$ans =~ ^[Nn] ]]; then \
+ echo "Deleting..."; \
+ rm -rvf $(NOMSU_LIB_DIR)/`$(GET_VERSION)` $(NOMSU_SHARE_DIR)/`$(GET_VERSION)` $(NOMSU_BIN_DIR)/nomsu`$(GET_VERSION)`; \
+ if [ "`ls $(NOMSU_BIN_DIR)/nomsu* 2> /dev/null`" == "nomsu" ]; then \
+ rm -vf $(NOMSU_BIN_DIR)/nomsu; \
+ else \
+ if [ "`ls $(NOMSU_BIN_DIR)/nomsu* 2> /dev/null`" != "" ]; then \
+ read -p "It looks like there are other versions of Nomsu installed. Is it okay to leave the 'nomsu' cross-version launcher in place? (recommended) [Y/n]" ans; \
+ if [[ $$ans =~ ^[Nn] ]]; then \
+ echo "Deleting..."; \
+ rm -vf $(NOMSU_BIN_DIR)/nomsu; \
+ fi; \
+ fi; \
+ fi; \
+ if [ "`ls $(NOMSU_LIB_DIR) 2>/dev/null`" == "" ]; then rm -rvf $(NOMSU_LIB_DIR);\
+ else \
+ echo "Retaining $(NOMSU_LIB_DIR), since there are other files there."; \
+ fi; \
+ if [ "`ls $(NOMSU_SHARE_DIR) 2>/dev/null`" == "" ]; then rm -rvf $(NOMSU_SHARE_DIR);\
+ else \
+ echo "Retaining $(NOMSU_SHARE_DIR), since there are other files there."; \
+ fi; \
+ fi
# eof