1diff --git a/installed-tests/js/meson.build b/installed-tests/js/meson.build
2index 98475f7d..942d9eca 100644
3--- a/installed-tests/js/meson.build
4+++ b/installed-tests/js/meson.build
5@@ -10,7 +10,7 @@ jsunit_resources_files = gnome.compile_resources('jsunit-resources',
6 minijasmine = executable('minijasmine', '../minijasmine.cpp',
7 jsunit_resources_files, dependencies: libgjs_dep,
8 cpp_args: [
9- '-DINSTTESTDIR="@0@"'.format(prefix / installed_tests_execdir),
10+ '-DINSTTESTDIR="@0@"'.format(installed_tests_execdir),
11 ],
12 include_directories: top_include,
13 install: get_option('installed_tests'), install_dir: installed_tests_execdir)
14@@ -82,7 +82,7 @@ foreach test : jasmine_tests
15
16 test_description_subst = {
17 'name': 'test@0@.js'.format(test),
18- 'installed_tests_execdir': prefix / installed_tests_execdir,
19+ 'installed_tests_execdir': installed_tests_execdir,
20 }
21 configure_file(configuration: test_description_subst,
22 input: '../minijasmine.test.in',
23@@ -125,7 +125,7 @@ foreach test : dbus_tests
24
25 dbus_test_description_subst = {
26 'name': 'test@0@.js'.format(test),
27- 'installed_tests_execdir': prefix / installed_tests_execdir,
28+ 'installed_tests_execdir': installed_tests_execdir,
29 }
30 configure_file(
31 configuration: dbus_test_description_subst,
32@@ -163,7 +163,7 @@ foreach test : modules_tests
33
34 esm_test_description_subst = {
35 'name': 'test@0@.js'.format(test),
36- 'installed_tests_execdir': prefix / installed_tests_execdir,
37+ 'installed_tests_execdir': installed_tests_execdir,
38 }
39 configure_file(configuration: esm_test_description_subst,
40 input: '../minijasmine-module.test.in',
41diff --git a/installed-tests/meson.build b/installed-tests/meson.build
42index 7a7c48ab..52508c2c 100644
43--- a/installed-tests/meson.build
44+++ b/installed-tests/meson.build
45@@ -30,7 +30,7 @@ foreach test : simple_tests
46
47 test_description_subst = {
48 'name': 'test@0@.sh'.format(test),
49- 'installed_tests_execdir': prefix / installed_tests_execdir,
50+ 'installed_tests_execdir': installed_tests_execdir,
51 }
52 configure_file(configuration: test_description_subst,
53 input: 'script.test.in', output: 'test@0@.sh.test'.format(test),
54@@ -85,7 +85,7 @@ foreach test : debugger_tests
55
56 test_description_subst = {
57 'name': '@0@.debugger'.format(test),
58- 'installed_tests_execdir': prefix / installed_tests_execdir,
59+ 'installed_tests_execdir': installed_tests_execdir,
60 }
61 configure_file(configuration: test_description_subst,
62 input: 'debugger.test.in',
63diff --git a/installed-tests/script.test.in b/installed-tests/script.test.in
64index debefc4c..96a91b88 100644
65--- a/installed-tests/script.test.in
66+++ b/installed-tests/script.test.in
67@@ -3,5 +3,5 @@
68
69 [Test]
70 Type=session
71-Exec=sh @prefix@/@installed_tests_execdir@/scripts/@name@
72+Exec=sh @installed_tests_execdir@/scripts/@name@
73 Output=TAP
74diff --git a/meson.build b/meson.build
75index bbfe8bc8..e6f87dc3 100644
76--- a/meson.build
77+++ b/meson.build
78@@ -25,8 +25,8 @@ datadir = get_option('datadir')
79 libexecdir = get_option('libexecdir')
80 gjsjsdir = datadir / api_name
81 pkglibdir = libdir / meson.project_name()
82-installed_tests_execdir = libexecdir / 'installed-tests' / meson.project_name()
83-installed_tests_metadir = datadir / 'installed-tests' / meson.project_name()
84+installed_tests_execdir = get_option('installed_test_prefix') / libexecdir / 'installed-tests' / meson.project_name()
85+installed_tests_metadir = get_option('installed_test_prefix') / datadir / 'installed-tests' / meson.project_name()
86
87 ### Check for conflicting build options ########################################
88
89@@ -577,9 +577,9 @@ install_data('installed-tests/extra/gjs.supp', install_dir: gjsjsdir / 'valgrind
90 install_data('installed-tests/extra/lsan.supp', install_dir: gjsjsdir / 'lsan')
91
92 if get_option('installed_tests')
93- schemadir = datadir / 'glib-2.0' / 'schemas'
94+ schemadir = get_option('installed_test_prefix') / datadir / 'glib-2.0' / 'schemas'
95 install_data('installed-tests/js/org.gnome.GjsTest.gschema.xml', install_dir: schemadir)
96- meson.add_install_script(glib_compile_schemas, prefix / schemadir, skip_if_destdir: true)
97+ meson.add_install_script(glib_compile_schemas, schemadir, skip_if_destdir: true)
98 endif
99
100 ### Generate pkg-config file ###################################################
101diff --git a/meson_options.txt b/meson_options.txt
102index fe425efd..29325756 100644
103--- a/meson_options.txt
104+++ b/meson_options.txt
105@@ -24,3 +24,5 @@ option('skip_gtk_tests', type: 'boolean', value: false,
106 description: 'Skip tests that need a display connection')
107 option('verbose_logs', type: 'boolean', value: false,
108 description: 'Enable extra log messages that may decrease performance (not allowed in release builds)')
109+option('installed_test_prefix', type: 'string', value: '',
110+ description: 'Prefix for installed tests')