Makefile (4609B)
1 # Yes, I know this is a mess. 2 3 .POSIX: 4 .SUFFIXES: .c .o 5 6 NAME = test 7 VERSION = -999-prealpha0 8 9 # NOTE/FIXME: stb backend is currently broken 10 # Note: The stb backend should not be used with untrusted font files. 11 # FIXME: Using DEBUG here doesn't work because it somehow 12 # interferes with a predefined macro, at least on OpenBSD. 13 DEV = 1 14 MEMDEBUG = 0 15 SANITIZE = 0 16 USE_PANGO = 1 17 USE_XRANDR = 1 18 19 # Note: this macro magic for debugging and pango rendering seems ugly; it should probably be changed 20 21 # debug 22 DEV_CFLAGS_1 = -g -Wall -Wextra -pedantic 23 SANITIZE_FLAGS_1 = -g -fsanitize=address,undefined 24 # don't include default flags when debugging so possible 25 # optimization flags don't interfere with it 26 DEV_CFLAGS_0 = $(CFLAGS) 27 DEV_LDFLAGS_0 = $(LDFLAGS) 28 29 # stb rendering 30 EXTRA_OBJ_0 = src/ltk/stb_truetype.o src/ltk/text_stb.o 31 32 # pango rendering 33 EXTRA_OBJ_1 = src/ltk/text_pango.o 34 EXTRA_CFLAGS_1 = `pkg-config --cflags pangoxft` 35 EXTRA_LDFLAGS_1 = `pkg-config --libs pangoxft` 36 37 # xrandr support (dynamic dpi) 38 EXTRA_CFLAGS_XRANDR_0 = 39 EXTRA_CFLAGS_XRANDR_1 = `pkg-config --cflags xrandr` 40 EXTRA_LDFLAGS_XRANDR_0 = 41 EXTRA_LDFLAGS_XRANDR_1 = `pkg-config --libs xrandr` 42 43 EXTRA_OBJ = $(EXTRA_OBJ_$(USE_PANGO)) 44 EXTRA_CFLAGS = $(SANITIZE_FLAGS_$(SANITIZE)) $(DEV_CFLAGS_$(DEV)) $(EXTRA_CFLAGS_$(USE_PANGO)) $(EXTRA_CFLAGS_XRANDR_$(USE_XRANDR)) 45 EXTRA_LDFLAGS = $(SANITIZE_FLAGS_$(SANITIZE)) $(DEV_LDFLAGS_$(DEV)) $(EXTRA_LDFLAGS_$(USE_PANGO)) $(EXTRA_LDFLAGS_XRANDR_$(USE_XRANDR)) 46 47 LTK_CFLAGS = $(EXTRA_CFLAGS) -DUSE_XRANDR=$(USE_XRANDR) -DUSE_PANGO=$(USE_PANGO) -DDEV=$(DEV) -DMEMDEBUG=$(MEMDEBUG) -I ./src -std=c99 `pkg-config --cflags x11 fontconfig xext xcursor imlib2` -D_POSIX_C_SOURCE=200809L 48 LTK_LDFLAGS = $(EXTRA_LDFLAGS) -lm `pkg-config --libs x11 fontconfig xext xcursor imlib2` 49 50 OBJ_LTK = \ 51 src/ltk/num.o \ 52 src/ltk/util.o \ 53 src/ltk/memory.o \ 54 src/ltk/window.o \ 55 src/ltk/color_xlib.o \ 56 src/ltk/rect.o \ 57 src/ltk/widget.o \ 58 src/ltk/ltk.o \ 59 src/ltk/button.o \ 60 src/ltk/checkbutton.o \ 61 src/ltk/radiobutton.o \ 62 src/ltk/combobox.o \ 63 src/ltk/graphics_xlib.o \ 64 src/ltk/surface_cache.o \ 65 src/ltk/event_xlib.o \ 66 src/ltk/grid.o \ 67 src/ltk/config.o \ 68 src/ltk/clipboard_xlib.o \ 69 src/ltk/txtbuf.o \ 70 src/ltk/ctrlsel.o \ 71 src/ltk/label.o \ 72 src/ltk/image_imlib.o \ 73 src/ltk/image_widget.o \ 74 src/ltk/entry.o \ 75 src/ltk/menu.o \ 76 src/ltk/box.o \ 77 src/ltk/scrollbar.o \ 78 $(EXTRA_OBJ) 79 80 OBJ_LTKD = \ 81 src/ltkd/box.o \ 82 src/ltkd/button.o \ 83 src/ltkd/cmd.o \ 84 src/ltkd/entry.o \ 85 src/ltkd/err.o \ 86 src/ltkd/grid.o \ 87 src/ltkd/image_widget.o \ 88 src/ltkd/label.o \ 89 src/ltkd/ltkd.o \ 90 src/ltkd/menu.o \ 91 src/ltkd/util.o \ 92 src/ltkd/widget.o 93 94 OBJ_TEST = examples/ltk/test.o 95 # Note: This could be improved so a change in a header only causes the .c files 96 # which include that header to be recompiled, but the compile times are 97 # currently so short that I don't really care. 98 HDR_LTK = \ 99 src/ltk/button.h \ 100 src/ltk/checkbutton.h \ 101 src/ltk/radiobutton.h \ 102 src/ltk/combobox.h \ 103 src/ltk/color.h \ 104 src/ltk/label.h \ 105 src/ltk/rect.h \ 106 src/ltk/widget.h \ 107 src/ltk/ltk.h \ 108 src/ltk/grid.h \ 109 src/ltk/memory.h \ 110 src/ltk/stb_truetype.h \ 111 src/ltk/text.h \ 112 src/ltk/util.h \ 113 src/ltk/widget_internal.h \ 114 src/ltk/graphics.h \ 115 src/ltk/surface_cache.h \ 116 src/ltk/macros.h \ 117 src/ltk/event.h \ 118 src/ltk/eventdefs.h \ 119 src/ltk/graphics_xlib.h \ 120 src/ltk/label.h \ 121 src/ltk/config.h \ 122 src/ltk/array.h \ 123 src/ltk/clipboard_xlib.h \ 124 src/ltk/clipboard.h \ 125 src/ltk/txtbuf.h \ 126 src/ltk/ctrlsel.h \ 127 src/ltk/image.h \ 128 src/ltk/image_widget.h \ 129 src/ltk/entry.h \ 130 src/ltk/menu.h \ 131 src/ltk/box.h \ 132 src/ltk/scrollbar.h 133 134 HDR_LTKD = \ 135 src/ltkd/cmd.h \ 136 src/ltkd/cmd_helpers.h \ 137 src/ltkd/err.h \ 138 src/ltkd/khash.h \ 139 src/ltkd/ltkd.h \ 140 src/ltkd/proto_types.h \ 141 src/ltkd/widget.h 142 143 all: examples/ltk/test src/ltkd/ltkd src/ltkd/ltkc src/ltkd/ltkc_img 144 145 test: examples/ltk/test 146 147 ltkd: src/ltkd/ltkd 148 149 ltkc: src/ltkd/ltkc 150 151 ltkc_img: src/ltkd/ltkc_img 152 153 examples/ltk/test: $(OBJ_LTK) $(OBJ_TEST) 154 $(CC) -o $@ $(OBJ_LTK) $(OBJ_TEST) $(LTK_LDFLAGS) 155 156 src/ltkd/ltkd: $(OBJ_LTK) $(OBJ_LTKD) 157 $(CC) -o $@ $(OBJ_LTK) $(OBJ_LTKD) $(LTK_LDFLAGS) 158 159 src/ltkd/ltkc: $(OBJ_LTK) src/ltkd/ltkc.o src/ltkd/util.o 160 $(CC) -o $@ $(OBJ_LTK) src/ltkd/ltkc.o src/ltkd/util.o $(LTK_LDFLAGS) 161 162 src/ltkd/ltkc_img: $(OBJ_LTK) src/ltkd/ltkc_img.o 163 $(CC) -o $@ $(OBJ_LTK) src/ltkd/ltkc_img.o $(LTK_LDFLAGS) 164 165 $(OBJ_LTK) : $(HDR_LTK) 166 167 $(OBJ_TEST) : $(HDR_LTK) 168 169 $(OBJ_LTKD) : $(HDR_LTK) $(HDR_LTKD) 170 171 .c.o: 172 $(CC) -c -o $@ $< $(LTK_CFLAGS) 173 174 .PHONY: clean 175 176 clean: 177 rm -f src/ltkd/*.o src/ltk/*.o src/ltkd/ltkd src/ltkd/ltkc src/ltkd/ltkc_img examples/ltk/test examples/ltk/*.o