From 16ab3629d435d52539b6345d79433e27c367ce83 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 3 Jan 2021 20:55:42 -0500 Subject: make install, command line arguments --- Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0b720c0..6dc6b3e 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,24 @@ ALL_CFLAGS=$(CFLAGS) -Wall -Wextra -Wshadow -Wconversion -Wpedantic -pedantic -s -Wno-unused-function -Wno-fixed-enum-extension -Wimplicit-fallthrough LIBS=-lSDL2 -lGL -ldl -lm DEBUG_CFLAGS=$(ALL_CFLAGS) -DDEBUG -O0 -g +RELEASE_CFLAGS=$(ALL_CFLAGS) -O3 +GLOBAL_DATA_DIR=/usr/share/ted +LOCAL_DATA_DIR=/home/`logname`/.local/share/ted +INSTALL_BIN_DIR=/usr/bin ted: *.[ch] text.o - $(CC) main.c text.o -o $@ $(DEBUG_CFLAGS) $(LIBS) + $(CC) main.c text.o -o ted $(DEBUG_CFLAGS) $(LIBS) +release: *.[ch] + $(CC) main.c text.o -o ted $(RELEASE_CFLAGS) $(LIBS) text.o: text.c text.h base.h lib/stb_truetype.h $(CC) text.c -c -o $@ $(DEBUG_CFLAGS) clean: rm -f ted *.o +install: release + @[ -w `dirname $(GLOBAL_DATA_DIR)` ] || { echo "You need permission to write to $(GLOBAL_DATA_DIR). Try running with sudo/as root." && exit 1; } + @[ -w `dirname $(INSTALL_BIN_DIR)` ] || { echo "You need permission to write to $(INSTALL_BIN_DIR). Try running with sudo/as root." && exit 1; } + + mkdir -p $(GLOBAL_DATA_DIR) $(LOCAL_DATA_DIR) + cp -r assets $(GLOBAL_DATA_DIR) + install -m 644 ted.cfg $(GLOBAL_DATA_DIR) + [ ! -e $(LOCAL_DATA_DIR)/ted.cfg ] && install -o `logname` -g `logname` -m 644 ted.cfg $(LOCAL_DATA_DIR) || : + install ted $(INSTALL_BIN_DIR) -- cgit v1.2.3