File: Makefile

package info (click to toggle)
reform-tools 1.82-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,380 kB
  • sloc: sh: 3,523; ansic: 989; python: 908; makefile: 169
file content (174 lines) | stat: -rw-r--r-- 10,444 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/make -f
# SPDX-License-Identifier: GPL-3.0+
# Copyright 2024-2025 Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>

SHELL = /bin/sh
INSTALL = /usr/bin/install
INSTALLDATA = /usr/bin/install -m 644

prefix = /usr
datadir = $(prefix)/share
bindir = $(prefix)/bin
libexecdir = $(prefix)/libexec
libdir = $(prefix)/lib
libdirarch = $(prefix)/lib/$(shell $(CC) --print-multiarch)
statedir = /var
sysconfdir = /etc

BINPROGS=$(wildcard bin/*)
MAN1=$(patsubst bin/%,man/%.1,$(BINPROGS))



.PHONY: all
all: $(MAN1) plymouth/background.png plymouth/monobar.so

man/%.1: bin/%
	set -e;                                                               \
	mkdir -p man;                                                         \
	tool2whatis () { case $${1#reform-} in                                \
		boot-config)    echo "choose rootfs to boot from" ;;          \
		chat)           echo "chat on #mnt-reform" ;;                 \
		check)          echo "check your setup" ;;                    \
		compstat)       echo "system statistics for waybar" ;;        \
		config)         echo "select keyboard and timezone" ;;        \
		display-config) echo "select single/dual display" ;;          \
		emmc-bootstrap) echo "set up /boot on emmc for / on nvme" ;;  \
		flash-rescue)   echo "flash rescue image to eMMC" ;;          \
		flash-uboot)    echo "download and flash u-boot" ;;           \
		gnome-config)   echo "apply default config to GNOME" ;;       \
		handbook)       echo "show Reform Handbook" ;;                \
		pocket-reform-handbook) echo "show Pocket Reform Handbook" ;; \
		help)           echo "help with MNT Reform" ;;                \
		hw-setup)       echo "perform hardware tweaks" ;;             \
		migrate)        echo "copy rootfs to device" ;;               \
		mcu-tool)       echo "manage microcontrollers" ;;             \
		pavucontrol)    echo "kill and restart pavucontrol" ;;        \
		setup-encrypted-disk) echo "setup encrypted disk" ;;          \
		setup-encrypted-nvme) echo "use setup-encrypted-disk" ;;      \
		standby)        echo "suspend/wakeup tweaks" ;;               \
		waybar-icon-wedge) echo "launch waybar with custom icon theme" ;; \
		*) echo "unknown tool: $$1" 2>&1; exit 1 ;;                   \
	esac; };                                                              \
	whatis="$$(tool2whatis "$*")";                                        \
	version=$$(head -c4 CHANGELOG.md);                                    \
	case $$version in 1.[0-9][0-9]) : ;; *) echo invalid;exit 1;; esac;   \
	env "PATH=./bin:$$PATH" help2man                                      \
		--section=1                                                   \
		--name="$$whatis"                                             \
		--no-info --version-string="$$version"                        \
		--no-discard-stderr "$*"                                      \
		--output="$@";                                                \

plymouth/monobar.so: plymouth/monobar.c
	$(CC) $< -o $@ $(CPPFLAGS) $(CFLAGS) $(shell pkgconf --cflags --libs ply-splash-core) -Wall -fPIC -pedantic -Wextra -std=c23 -shared $(LDFLAGS)

plymouth/background.png: ./share/backgrounds/mnt-reform-next-y2k.jpg
	convert $< -resize 1920x1080 $@

.PHONY: install
install: $(MAN1) plymouth/background.png plymouth/monobar.so
	$(INSTALL)     -d $(DESTDIR)$(libdir)/NetworkManager/conf.d
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/NetworkManager/conf.d NetworkManager/default-wifi-powersave-off.conf
	$(INSTALL)     -d $(DESTDIR)$(libdir)/udev/rules.d
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/udev/rules.d audio/99-reform-audio.rules
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/udev/rules.d udev/reform-ttymxc-wakeup.rules
	$(INSTALL)     -d $(DESTDIR)$(datadir)/pulseaudio/alsa-mixer/paths
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/pulseaudio/alsa-mixer/paths audio/analog-input-reform.conf
	$(INSTALL)     -d $(DESTDIR)$(statedir)/lib/alsa
	$(INSTALLDATA) -t $(DESTDIR)$(statedir)/lib/alsa audio/asound.state
	$(INSTALL)     -d $(DESTDIR)$(datadir)/pulseaudio/alsa-mixer/profile-sets
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/pulseaudio/alsa-mixer/profile-sets audio/reform.conf
	$(INSTALL)     -d $(DESTDIR)$(bindir)
	$(INSTALL)     -t $(DESTDIR)$(bindir) $(BINPROGS)
	$(INSTALL)     -d $(DESTDIR)$(datadir)/flash-kernel/preboot.d
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/flash-kernel/preboot.d flash-kernel/preboot.d/00reform2_preboot
	$(INSTALL)     -d $(DESTDIR)$(datadir)/flash-kernel/ubootenv.d
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/flash-kernel/ubootenv.d flash-kernel/ubootenv.d/00reform2_ubootenv
	$(INSTALL)     -d $(DESTDIR)$(datadir)/initramfs-tools/hooks
	$(INSTALL)     -t $(DESTDIR)$(datadir)/initramfs-tools/hooks initramfs-tools/hooks/reform
	$(INSTALL)     -t $(DESTDIR)$(datadir)/initramfs-tools/hooks initramfs-tools/hooks/reform-plymouth
	$(INSTALL)     -d $(DESTDIR)$(datadir)/initramfs-tools/modules.d
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/initramfs-tools/modules.d initramfs-tools/reform.conf
	$(INSTALL)     -d $(DESTDIR)$(datadir)/initramfs-tools/scripts/init-top
	$(INSTALL)     -t $(DESTDIR)$(datadir)/initramfs-tools/scripts/init-top initramfs-tools/scripts/reform
	$(INSTALL)     -d $(DESTDIR)$(datadir)/kernel/postinst.d
	$(INSTALL)     -t $(DESTDIR)$(datadir)/kernel/postinst.d kernel/zz-reform-tools
	$(INSTALL)     -d $(DESTDIR)$(libexecdir)/reform-tools
	$(INSTALL)     -t $(DESTDIR)$(libexecdir)/reform-tools libexec/reform-tools/reform-tray.py
	$(INSTALL)     -t $(DESTDIR)$(libexecdir)/reform-tools libexec/reform-tools/reform-wallpaper.py
	$(INSTALL)     -t $(DESTDIR)$(libexecdir)/reform-tools libexec/reform-tools/reform-power-daemon
	$(INSTALL)     -d $(DESTDIR)$(datadir)/reform-tools/machines
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/reform-tools/machines machines/*
	$(INSTALL)     -d $(DESTDIR)$(libdir)/modprobe.d
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/modprobe.d modprobe.d/reform.conf
	$(INSTALL)     -d $(DESTDIR)$(datadir)/glib-2.0/schemas
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/glib-2.0/schemas schemas/20_reform.gschema.override
	$(INSTALL)     -d $(DESTDIR)$(datadir)/gdm/dconf
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/gdm/dconf share/gdm/dconf/95-mnt-reform-settings
	$(INSTALL)     -d $(DESTDIR)$(datadir)/backgrounds
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/backgrounds share/backgrounds/reform-mountains.jpg
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/backgrounds share/backgrounds/mnt-reform-next-y2k.jpg
	$(INSTALL)     -d $(DESTDIR)$(libdir)/systemd/sleep.conf.d
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/systemd/sleep.conf.d systemd/reform-sleep.conf
	$(INSTALL)     -d $(DESTDIR)$(libdir)/systemd/system
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/systemd/system systemd/reform-hw-setup.service systemd/reform-sleep.service systemd/reform-power-daemon.service
	$(INSTALL)     -d $(DESTDIR)$(datadir)/u-boot-menu/conf.d
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/u-boot-menu/conf.d u-boot-menu/reform.conf
	$(INSTALL)     -d $(DESTDIR)$(libdir)/dracut/dracut.conf.d
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/dracut/dracut.conf.d dracut/20-pocket-reform.conf
	$(INSTALL)     -d $(DESTDIR)$(libdir)/sddm/sddm.conf.d
	$(INSTALLDATA) -t $(DESTDIR)$(libdir)/sddm/sddm.conf.d sddm/10-wayland.conf
	$(INSTALL)     -d $(DESTDIR)$(datadir)/man/man1
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/man/man1 $(MAN1)
	$(INSTALL)     -d $(DESTDIR)$(datadir)/alsa/ucm2/conf.d/rk3588-tlv320ai/
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/alsa/ucm2/conf.d/rk3588-tlv320ai/ audio/ucm2.conf.d/rk3588-tlv320ai/rk3588-tlv320aic3100.conf
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/alsa/ucm2/conf.d/rk3588-tlv320ai/ audio/ucm2.conf.d/rk3588-tlv320ai/HiFi.conf
	$(INSTALL)     -d $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k
	set -e; for f in bullet capslock entry keyboard keymap-render lock; do \
		ln --force --symbolic --no-target-directory ../spinner/$${f}.png $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k/$${f}.png; \
	done
		#$(INSTALLDATA) -t $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k/ "plymouth/$${f}.png";
	set -e; for i in $$(seq 1 36); do \
		filename=$$(printf "animation-%04d.png" "$$i"); \
		ln --force --symbolic --no-target-directory ../spinner/$$filename $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k/$$filename; \
	done
		#$(INSTALLDATA) -t $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k/ "plymouth/$$filename";
	set -e; for i in $$(seq 1 30); do \
		filename=$$(printf "throbber-%04d.png" "$$i"); \
		ln --force --symbolic --no-target-directory ../spinner/$$filename $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k/$$filename; \
	done
		#$(INSTALLDATA) -t $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k/ "plymouth/$$filename";
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k plymouth/background.png
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/plymouth/themes/reform-y2k plymouth/reform-y2k.plymouth
	$(INSTALL)     -d $(DESTDIR)$(datadir)/wireplumber/wireplumber.conf.d
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/wireplumber/wireplumber.conf.d audio/reform-hdmi-audio-priority.conf
	$(INSTALL)     -d $(DESTDIR)$(sysconfdir)/profile.d
	$(INSTALLDATA) -t $(DESTDIR)$(sysconfdir)/profile.d etc/profile.d/reform-kwin.sh
	$(INSTALL)     -d $(DESTDIR)$(datadir)/doc/reform-tools/examples
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/doc/reform-tools/examples examples/keyboard_rainbow.py
	$(INSTALL)     -d $(DESTDIR)$(libdirarch)/plymouth
	$(INSTALLDATA) -t $(DESTDIR)$(libdirarch)/plymouth plymouth/monobar.so
	$(INSTALL)     -d $(DESTDIR)$(datadir)/plymouth/themes/monobar/
	$(INSTALLDATA) -t $(DESTDIR)$(datadir)/plymouth/themes/monobar/ plymouth/monobar.plymouth

.PHONY: clean
clean:
	rm -f man/*.1 plymouth/background.png

.PHONY: lint
lint:
	clang-format lpc/reform2_lpc.c | diff -u lpc/reform2_lpc.c -
	shfmt --posix --simplify --binary-next-line --case-indent --indent 2 --diff \
		bin kernel/* initramfs-tools/*/* flash-kernel/*/*
	black --check --diff bin/reform-compstat libexec/reform-tools/reform-tray.py libexec/reform-tools/reform-wallpaper.py examples/keyboard_rainbow.py
	black --line-length 120 --check --diff bin/reform-mcu-tool
	shellcheck bin/* kernel/* initramfs-tools/*/* flash-kernel/*/*

test:
	# check the validity of gschema overrides
	# Create a dummy placeholder file to convince glib-compile-schemas to
	# not skip processing this directory
	echo '<schemalist></schemalist>' > schemas/dummy.gschema.xml
	glib-compile-schemas --dry-run --strict schemas
	rm schemas/dummy.gschema.xml