From c06a92db6e2b2338d862021be96a23b144357277 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 23 Jun 2018 01:43:14 -0700 Subject: [PATCH] Fixed and simplified makefile a bit. --- Makefile | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index a09d83e..a65ca4e 100644 --- a/Makefile +++ b/Makefile @@ -35,27 +35,24 @@ test: build optimize @./nomsu_latest -c $< .PHONY: check_header -check_header: version +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)/$$(cat version)/?.lua;]]..package.path\\npackage.nomsupath = [[$(NOMSU_LIB_DIR)/$$(cat version)]]"; \ + NOMSU_HEADER="#!$(LUA_BIN)\\npackage.path = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`/?.lua;]]..package.path\\npackage.nomsupath = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`]]"; \ if [ "`head -n 3 nomsu_latest 2>/dev/null`" != "`echo $$NOMSU_HEADER`" ]; then \ rm -f nomsu_latest; \ fi; \ fi; -version: $(PEG_FILE) nomsu.lua $(CORE_NOM_FILES) $(LIB_NOM_FILES) - @$(LUA_BIN) nomsu.lua --version > version - nomsu_latest: nomsu.lua @rm -f nomsu_latest - @NOMSU_HEADER="#!$(LUA_BIN)\\npackage.path = [[$(NOMSU_LIB_DIR)/$$(cat version)/?.lua;]]..package.path\\npackage.nomsupath = [[$(NOMSU_LIB_DIR)/$$(cat version)]]"; \ + @NOMSU_HEADER="#!$(LUA_BIN)\\npackage.path = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`/?.lua;]]..package.path\\npackage.nomsupath = [[$(NOMSU_LIB_DIR)/`$(GET_VERSION)`]]"; \ echo $$NOMSU_HEADER | cat - nomsu.lua > nomsu_latest @chmod +x nomsu_latest - @mv -f nomsu_latest nomsu`./nomsu_latest --version` - @ln -s nomsu`$(LUA_BIN) nomsu.lua --version` nomsu_latest + @mv -f nomsu_latest nomsu`$(GET_VERSION)` + @ln -s nomsu`$(GET_VERSION)` nomsu_latest @echo "Built nomsu binary" -build: $(LUA_FILES) version check_header nomsu_latest +build: $(LUA_FILES) check_header nomsu_latest .PHONY: optimize optimize: build $(CORE_LUA_FILES) $(LIB_LUA_FILES) @@ -63,12 +60,12 @@ optimize: build $(CORE_LUA_FILES) $(LIB_LUA_FILES) .PHONY: clean clean: @echo "Deleting..." - @rm -rvf nomsu`./nomsu_latest --version 2>/dev/null` nomsu_latest core/*.lua lib/*.lua + @rm -rvf nomsu`$(GET_VERSION)` nomsu_latest core/*.lua lib/*.lua .PHONY: install install: all - mkdir -pv $(NOMSU_BIN_DIR) && cp -v nomsu nomsu`./nomsu_latest --version` $(NOMSU_BIN_DIR) - mkdir -pv $(NOMSU_LIB_DIR)/`./nomsu_latest --version` && cp -rv $(LUA_FILES) $(PEG_FILE) core lib $(NOMSU_LIB_DIR)/`./nomsu_latest --version` + 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)` .PHONY: uninstall uninstall: all