commit d2769d3
uint
·
2026-10-03 17:43:02 +0000 UTC
parent e847a24
replace Makefile and configure scripts with meson and subproject
6 files changed,
+69,
-102
+3,
-1
1@@ -3,7 +3,9 @@ cterm
2 *.o
3 *.swp
4 *.swo
5-platform.mk
6+build/
7+subprojects/*
8+!subprojects/*.wrap
9 *.ttf
10 *.bdf
11 *.tar
D
Makefile
+0,
-32
1@@ -1,32 +0,0 @@
2-CC = cc
3-CFLAGS = -std=c99 -Wall -Wextra
4-CPPFLAGS = -Iinclude -Ilibmaus/include
5-LDFLAGS =
6-
7-include platform.mk
8-
9-SRCS = source/cterm.c \
10- source/utils.c \
11- source/font.c \
12- source/term.c \
13- source/draw.c
14-
15-OUT = cterm
16-
17-all:
18- if [ ! -e config.h ]; then cp config.def.h config.h; fi
19- ${CC} ${CFLAGS} -O2 ${CPPFLAGS} ${SRCS} ${LDFLAGS} -o ${OUT} ${LDLIBS}
20-
21-debug:
22- if [ ! -e config.h ]; then cp config.def.h config.h; fi
23- ${CC} ${CFLAGS} -g ${CPPFLAGS} ${SRCS} ${LDFLAGS} -o ${OUT} ${LDLIBS}
24-
25-clean:
26- rm -f ${OUT}
27-
28-compile_flags:
29- rm -f compile_flags.txt
30- for f in ${CPPFLAGS} ${CFLAGS}; do echo $$f >> compile_flags.txt; done
31-
32-.PHONY: all debug clean compile_flags
33-
+0,
-69
1@@ -1,69 +0,0 @@
2-#!/bin/sh
3-set -eu
4-
5-PLATFORM=$(uname -s)
6-BACKEND=${1:-}
7-CPPFLAGS=
8-LDFLAGS="-Llibmaus/build"
9-LDLIBS=
10-
11-if [ "$#" -gt 1 ]; then
12- echo "Usage: ./configure [x11|wayland|mac]" >&2
13- exit 1
14-fi
15-
16-case "$PLATFORM" in
17- Darwin)
18- : "${BACKEND:=mac}"
19- ;;
20- Linux|FreeBSD|OpenBSD)
21- if [ -z "$BACKEND" ] && [ -n "${WAYLAND_DISPLAY:-}" ]; then
22- BACKEND=wayland
23- elif [ -z "$BACKEND" ] && [ -n "${DISPLAY:-}" ]; then
24- BACKEND=x11
25- elif [ -z "$BACKEND" ]; then
26- echo "No X11 or Wayland display found" >&2
27- exit 1
28- fi
29- ;;
30- *)
31- echo "Unsupported platform: $PLATFORM" >&2
32- exit 1
33- ;;
34-esac
35-
36-case "$PLATFORM" in
37- Linux)
38- CPPFLAGS="-D_XOPEN_SOURCE=700"
39- ;;
40- FreeBSD)
41- LDLIBS="-lutil"
42- ;;
43- OpenBSD)
44- CPPFLAGS="-I/usr/X11R6/include"
45- LDFLAGS="-L/usr/X11R6/lib $LDFLAGS"
46- LDLIBS="-lutil"
47- ;;esac
48-
49-(
50- cd libmaus
51- rm -rf build/
52- ./configure "$BACKEND"
53- make
54-)
55-
56-CONF_CPPFLAGS=$(sed -n 's/^CONF_CPPFLAGS = //p' libmaus/config.mk)
57-CONF_LDFLAGS=$(sed -n 's/^CONF_LDFLAGS = //p' libmaus/config.mk)
58-CONF_LIB_NAME=$(sed -n 's/^CONF_LIB_NAME = //p' libmaus/config.mk)
59-CONF_LIB=${CONF_LIB_NAME#lib}
60-CONF_LIB=${CONF_LIB%.a}
61-
62-cat >platform.mk <<EOF
63-CPPFLAGS += $CPPFLAGS $CONF_CPPFLAGS
64-LDFLAGS += $LDFLAGS
65-LDLIBS += -l$CONF_LIB
66-LDLIBS += ${CONF_LDFLAGS} $LDLIBS
67-EOF
68-
69-echo "Configuration done"
70-
+54,
-0
1@@ -0,0 +1,54 @@
2+project(
3+ 'cterm',
4+ 'c',
5+ meson_version: '>=1.1.0',
6+ default_options: [
7+ 'c_std=c99',
8+ 'warning_level=2',
9+ 'optimization=2',
10+ ],
11+)
12+
13+cc = meson.get_compiler('c')
14+fs = import('fs')
15+
16+backend = get_option('window_backend')
17+
18+maus_project = subproject(
19+ 'libmaus',
20+ default_options: ['window_backend=' + backend],
21+)
22+maus_dep = maus_project.get_variable('maus_dep')
23+
24+if not fs.exists('config.h')
25+ configure_file(input: 'config.def.h', output: 'config.h', copy: true,)
26+endif
27+
28+inc = include_directories('.', 'include')
29+
30+deps = [maus_dep]
31+c_args = []
32+
33+if host_machine.system() == 'linux'
34+ c_args += ['-D_XOPEN_SOURCE=700']
35+elif host_machine.system() == 'freebsd' or host_machine.system() == 'openbsd'
36+ deps += cc.find_library('util')
37+endif
38+
39+sources = [
40+ 'source/cterm.c',
41+ 'source/draw.c',
42+ 'source/font.c',
43+ 'source/term.c',
44+ 'source/utils.c',
45+]
46+
47+executable(
48+ 'cterm',
49+ sources,
50+ include_directories: inc,
51+ dependencies: deps,
52+ c_args: c_args,
53+ install: true,
54+)
55+
+8,
-0
1@@ -0,0 +1,8 @@
2+option(
3+ 'window_backend',
4+ type: 'combo',
5+ choices: ['auto', 'x11', 'wayland'],
6+ value: 'auto',
7+ description: 'libmaus window backend',
8+)
9+
+4,
-0
1@@ -0,0 +1,4 @@
2+[wrap-git]
3+url = https://github.com/uint23/maus.git
4+revision = master
5+depth = 1