commit f0bae2a
shrub
·
2026-07-16 11:56:43 +0000 UTC
parent 3e2dcb0
install better
3 files changed,
+19,
-32
+6,
-2
1@@ -4,12 +4,13 @@
2 # CC=clang ninja
3
4 cc = $${CC:-cc}
5-cflags = $${CFLAGS:--O2 -flto -std=gnu11 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -m64 -pthread $$(pkg-config --cflags wayland-client)}
6+cflags = $${CFLAGS:--O2 -flto -std=gnu11 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -m64 -pthread -DDATA_PATH=\"$${DATA_PATH:-$${PREFIX:-/usr}/share/blastem}\" $$(pkg-config --cflags wayland-client)}
7 ldflags = $${LDFLAGS:--O2 -flto -m64 -pthread}
8 libs = $${LIBS:--lm $$(pkg-config --libs wayland-client) -lasound -lz}
9 prefix = $${PREFIX:-/usr}
10 destdir = $${DESTDIR:-}
11 bindir = $${BINDIR:-$${DESTDIR:-}$${PREFIX:-/usr}/bin}
12+datadir = $${DESTDIR:-}$${DATA_PATH:-$${PREFIX:-/usr}/share/blastem}
13 xdg_shell_xml = $${XDG_SHELL_XML:-/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml}
14
15 rule wayland_client_header
16@@ -31,7 +32,7 @@ rule link
17 description = link $out
18
19 rule install
20- command = mkdir -p $bindir && cp $in $bindir/
21+ command = mkdir -p $outdir && cp $in $outdir/
22 description = install $in
23
24 build xdg-shell-client-protocol.h: wayland_client_header
25@@ -90,8 +91,11 @@ build z80_to_x86.o: cc z80_to_x86.c
26 build blastem: link blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o ppm.o controller_info.o render_wayland.o xdg-shell-protocol.o png.o io.o romdb.o hash.o menu.o xband.o realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o net.o serialize.o terminal.o config.o tern.o util.o paths.o gst.o 68kinst.o m68k_core.o m68k_core_x86.o gen.o backend.o mem.o arena.o gen_x86.o backend_x86.o ym2612.o psg.o wave.o saves.o zip.o bindings.o jcart.o sms.o z80inst.o z80_to_x86.o
27 build all: phony blastem
28 build install-blastem: install blastem
29+ outdir = $bindir
30 build install-default-config: install default.cfg
31+ outdir = $datadir
32 build install-rom-db: install rom.db
33+ outdir = $datadir
34 build install: phony install-blastem install-default-config install-rom-db
35
36 default all
M
config.c
+12,
-24
1@@ -178,13 +178,17 @@ uint8_t serialize_config_file(tern_node *config, char *path)
2 tern_node *parse_bundled_config(char *config_name)
3 {
4 tern_node *ret = NULL;
5-#ifdef CONFIG_PATH
6 if (!strcmp("default.cfg", config_name) || !strcmp("blastem.cfg", config_name)) {
7- char *confpath = path_append(CONFIG_PATH, config_name);
8- ret = parse_config_file(confpath);
9- free(confpath);
10- } else {
11-#endif
12+ char const *confdir = get_config_dir();
13+ if (confdir) {
14+ char *confpath = path_append(confdir, config_name);
15+ ret = parse_config_file(confpath);
16+ free(confpath);
17+ if (ret) {
18+ return ret;
19+ }
20+ }
21+ }
22 uint32_t confsize;
23 char *confdata = read_bundled_file(config_name, &confsize);
24 if (confdata) {
25@@ -192,9 +196,6 @@ tern_node *parse_bundled_config(char *config_name)
26 ret = parse_config(confdata);
27 free(confdata);
28 }
29-#ifdef CONFIG_PATH
30- }
31-#endif
32 return ret;
33 }
34
35@@ -222,28 +223,15 @@ tern_node *load_overrideable_config(char *name, char *bundled_name)
36
37 tern_node *load_config()
38 {
39- char const *confdir = get_config_dir();
40- char *confpath = NULL;
41 tern_node *ret = load_overrideable_config("blastem.cfg", "default.cfg");
42- if (confdir) {
43- confpath = path_append(confdir, "blastem.cfg");
44- ret = parse_config_file(confpath);
45- if (ret) {
46- free(confpath);
47- return ret;
48- }
49- }
50-
51- ret = parse_bundled_config("default.cfg");
52 if (ret) {
53- free(confpath);
54 return ret;
55 }
56
57 if (get_config_dir()) {
58- fatal_error("Failed to find a config file at %s or in the blastem executable directory\n", get_config_dir());
59+ fatal_error("Failed to find a config file at %s or a bundled default.cfg in the BlastEm data directory\n", get_config_dir());
60 } else {
61- fatal_error("Failed to find a config file in the BlastEm executable directory and the config directory path could not be determined\n");
62+ fatal_error("Failed to find a bundled default.cfg in the BlastEm data directory and the config directory path could not be determined\n");
63 }
64 //this will never get reached, but the compiler doesn't know that. Let's make it happy
65 return NULL;
M
util.c
+1,
-6
1@@ -681,6 +681,7 @@ char *read_bundled_file(char *name, uint32_t *sizeret)
2 }
3 return NULL;
4 }
5+#endif
6 char const *pieces[] = {data_dir, PATH_SEP, name};
7 char *path = alloc_concat_m(3, pieces);
8 FILE *f = fopen(path, "rb");
9@@ -740,9 +741,3 @@ char const *get_userdata_dir()
10 }
11 return savedir;
12 }
13-
14-
15-
16-
17-
18-#endif