summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-03 20:55:42 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-03 20:55:42 -0500
commit16ab3629d435d52539b6345d79433e27c367ce83 (patch)
tree44fb3c7a13870dbd748e0f35d5236d6b3a31cb9a /Makefile
parent35cb8b8cfbd141d4ba2e3f1435a9550864d9e2e1 (diff)
make install, command line arguments
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 16 insertions, 1 deletions
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)