commit 7d8235cc4e3c173b19461ff5eaf5991a43f15994
parent b942851b8d877294a2efc68efa8447b4d580cd7f
Author: lumidify <nobody@lumidify.org>
Date: Mon, 22 Feb 2021 21:05:26 +0100
Move source files to src
Diffstat:
33 files changed, 57 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,7 +1,11 @@
-VERSION = -999
+.POSIX:
+.SUFFIXES: .c .o
-# FIXME: Using DEBUG here doesn't work because it somehow interferes with a predefined macro,
-# at least on OpenBSD
+NAME = ltk
+VERSION = -999-prealpha0
+
+# FIXME: Using DEBUG here doesn't work because it somehow
+# interferes with a predefined macro, at least on OpenBSD.
DEV = 0
USE_PANGO = 0
@@ -17,10 +21,10 @@ LDFLAGS += -lm `pkg-config --libs x11 fontconfig`
DEV_1 = -g -Wall -Werror -Wextra -pedantic
# stb rendering
-EXTRA_OBJ_0 = stb_truetype.o text_stb.o
+EXTRA_OBJ_0 = src/stb_truetype.o src/text_stb.o
# pango rendering
-EXTRA_OBJ_1 = text_pango.o
+EXTRA_OBJ_1 = src/text_pango.o
EXTRA_CFLAGS_1 += -DUSE_PANGO `pkg-config --cflags pangoxft`
EXTRA_LDFLAGS_1 += `pkg-config --libs pangoxft`
@@ -28,22 +32,57 @@ EXTRA_OBJ = $(EXTRA_OBJ_$(USE_PANGO))
EXTRA_CFLAGS = $(EXTRA_CFLAGS_$(USE_PANGO)) $(DEV_$(DEV))
EXTRA_LDFLAGS = $(EXTRA_LDFLAGS_$(USE_PANGO))
-OBJ = strtonum.o util.o memory.o color.o ltkd.o ini.o grid.o box.o scrollbar.o button.o label.o draw.o $(EXTRA_OBJ)
+OBJ = \
+ src/strtonum.o \
+ src/util.o \
+ src/memory.o \
+ src/color.o \
+ src/ltkd.o \
+ src/ini.o \
+ src/grid.o \
+ src/box.o \
+ src/scrollbar.o \
+ src/button.o \
+ src/label.o \
+ src/draw.o \
+ $(EXTRA_OBJ)
+
+# Note: This could be improved so a change in a header only causes the .c files
+# which include that header to be recompiled, but the compile times are
+# currently so short that I don't really care.
+HDR = \
+ src/box.h \
+ src/button.h \
+ src/color.h \
+ src/draw.h \
+ src/grid.h \
+ src/ini.h \
+ src/khash.h \
+ src/label.h \
+ src/ltk.h \
+ src/memory.h \
+ src/scrollbar.h \
+ src/stb_truetype.h \
+ src/text.h \
+ src/util.h
+
CFLAGS += $(EXTRA_CFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
-all: ltkd ltkc
+all: src/ltkd src/ltkc
-ltkd: $(OBJ)
+src/ltkd: $(OBJ)
$(CC) -o $@ $(OBJ) $(LDFLAGS)
-ltkc: ltkc.o util.o memory.o
- $(CC) -o $@ ltkc.o util.o memory.o
+src/ltkc: src/ltkc.o src/util.o src/memory.o
+ $(CC) -o $@ src/ltkc.o src/util.o src/memory.o
+
+$(OBJ) : $(HDR)
-%.o: %.c
+.c.o:
$(CC) -c -o $@ $< $(CFLAGS)
.PHONY: clean
clean:
- rm -f *.o ltkd ltkc ltk.sock *.core
+ rm -f src/*.o src/ltkd src/ltkc
diff --git a/box.c b/src/box.c
diff --git a/box.h b/src/box.h
diff --git a/button.c b/src/button.c
diff --git a/button.h b/src/button.h
diff --git a/color.c b/src/color.c
diff --git a/color.h b/src/color.h
diff --git a/draw.c b/src/draw.c
diff --git a/draw.h b/src/draw.h
diff --git a/grid.c b/src/grid.c
diff --git a/grid.h b/src/grid.h
diff --git a/ini.c b/src/ini.c
diff --git a/ini.h b/src/ini.h
diff --git a/khash.h b/src/khash.h
diff --git a/label.c b/src/label.c
diff --git a/label.h b/src/label.h
diff --git a/ltk.h b/src/ltk.h
diff --git a/ltkc.c b/src/ltkc.c
diff --git a/ltkd.c b/src/ltkd.c
diff --git a/memory.c b/src/memory.c
diff --git a/memory.h b/src/memory.h
diff --git a/scrollbar.c b/src/scrollbar.c
diff --git a/scrollbar.h b/src/scrollbar.h
diff --git a/stb_truetype.c b/src/stb_truetype.c
diff --git a/stb_truetype.h b/src/stb_truetype.h
diff --git a/strtonum.c b/src/strtonum.c
diff --git a/text.h b/src/text.h
diff --git a/text_pango.c b/src/text_pango.c
diff --git a/text_stb.c b/src/text_stb.c
diff --git a/util.c b/src/util.c
diff --git a/util.h b/src/util.h
diff --git a/test.sh b/test.sh
@@ -7,13 +7,13 @@
# supported yet.
export LTKDIR="`pwd`/.ltk"
-ltk_id=`./ltkd -t "Cool Window"`
+ltk_id=`./src/ltkd -t "Cool Window"`
if [ $? -ne 0 ]; then
echo "Unable to start ltkd." >&2
exit 1
fi
-cat test.gui | ./ltkc $ltk_id | while read cmd
+cat test.gui | ./src/ltkc $ltk_id | while read cmd
do
case "$cmd" in
"btn1 button_click")
@@ -23,4 +23,4 @@ do
printf "%s\n" "$cmd" >&2
;;
esac
-done | ./ltkc $ltk_id
+done | ./src/ltkc $ltk_id
diff --git a/testbox.sh b/testbox.sh
@@ -1,7 +1,7 @@
#!/bin/sh
export LTKDIR="`pwd`/.ltk"
-ltk_id=`./ltkd -t "Cool Window"`
+ltk_id=`./src/ltkd -t "Cool Window"`
if [ $? -ne 0 ]; then
echo "Unable to start ltkd." >&2
exit 1
@@ -12,7 +12,7 @@ $(curl -s gopher://lumidify.org | awk -F'\t' '
BEGIN {btn = 0; lbl = 0;}
/^i/ { printf "label lbl%s create \"%s\"\nbox box1 add lbl%s w\n", lbl, substr($1, 2), lbl; lbl++ }
/^[1gI]/ { printf "button btn%s create \"%s\"\nbox box1 add btn%s w\n", btn, substr($1, 2), btn; btn++ }')"
-echo "$cmds" | ./ltkc $ltk_id | while read cmd
+echo "$cmds" | ./src/ltkc $ltk_id | while read cmd
do
case "$cmd" in
"exit_btn button_click")
@@ -25,4 +25,4 @@ do
printf "%s\n" "$cmd" >&2
;;
esac
-done | ./ltkc $ltk_id > /dev/null
+done | ./src/ltkc $ltk_id > /dev/null