Fix check-* scripts when harfbuzz is a subproject

When harfbuzz is a subproject paths are in the form
"subprojects/harfbuzz/src/...". Instead of removing "src/" prefix, take
the absolute path and make it relative to current source dir.

This fix regression introduced in
https://github.com/harfbuzz/harfbuzz/pull/3394.
diff --git a/src/Makefile.am b/src/Makefile.am
index 81eb4c9..e1b56a5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -437,6 +437,7 @@
 
 TESTS_ENVIRONMENT = \
 	srcdir="$(srcdir)" \
+	base_srcdir="$(srcdir)" \
 	builddir="$(builddir)" \
 	MAKE="$(MAKE) $(AM_MAKEFLAGS)" \
 	HBSOURCES="$(HBSOURCES)" \
diff --git a/src/check-c-linkage-decls.py b/src/check-c-linkage-decls.py
index 49cd296..fe18eda 100755
--- a/src/check-c-linkage-decls.py
+++ b/src/check-c-linkage-decls.py
@@ -2,18 +2,20 @@
 
 import sys, os
 
-os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
+srcdir = os.getenv ('srcdir', os.path.dirname (__file__))
+base_srcdir = os.getenv ('base_srcdir', srcdir)
 
-def removeprefix(s, prefix):
-    if s.startswith(prefix):
-        return s[len(prefix):]
-    else:
-        return s[:]
+os.chdir (srcdir)
+
+def removeprefix(s):
+	abs_path = os.path.join(base_srcdir, s)
+	return os.path.relpath(abs_path, srcdir)
+
 
 HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
 	[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
 HBSOURCES = [
-    removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split ()
+    removeprefix(x) for x in os.getenv ('HBSOURCES', '').split ()
 ] or [
     x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))
 ]
diff --git a/src/check-header-guards.py b/src/check-header-guards.py
index b45ffe1..35ae6be 100755
--- a/src/check-header-guards.py
+++ b/src/check-header-guards.py
@@ -2,19 +2,20 @@
 
 import sys, os, re
 
-os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
+srcdir = os.getenv ('srcdir', os.path.dirname (__file__))
+base_srcdir = os.getenv ('base_srcdir', srcdir)
 
-def removeprefix(s, prefix):
-    if s.startswith(prefix):
-        return s[len(prefix):]
-    else:
-        return s[:]
+os.chdir (srcdir)
+
+def removeprefix(s):
+	abs_path = os.path.join(base_srcdir, s)
+	return os.path.relpath(abs_path, srcdir)
 
 
 HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
 	[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
 HBSOURCES = [
-    removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split ()
+    removeprefix(x) for x in os.getenv ('HBSOURCES', '').split ()
 ] or [
     x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))
 ]
diff --git a/src/check-includes.py b/src/check-includes.py
index ed201aa..fc95874 100755
--- a/src/check-includes.py
+++ b/src/check-includes.py
@@ -2,19 +2,20 @@
 
 import sys, os, re
 
-os.chdir (os.getenv ('srcdir', os.path.dirname (__file__)))
+srcdir = os.getenv ('srcdir', os.path.dirname (__file__))
+base_srcdir = os.getenv ('base_srcdir', srcdir)
 
-def removeprefix(s, prefix):
-    if s.startswith(prefix):
-        return s[len(prefix):]
-    else:
-        return s[:]
+os.chdir (srcdir)
+
+def removeprefix(s):
+	abs_path = os.path.join(base_srcdir, s)
+	return os.path.relpath(abs_path, srcdir)
 
 HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \
 	[x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')]
 
 HBSOURCES = [
-    removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split ()
+    removeprefix(x) for x in os.getenv ('HBSOURCES', '').split ()
 ] or [
     x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh'))
 ]
diff --git a/src/meson.build b/src/meson.build
index 41102bc..e814965 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -718,6 +718,7 @@
 
   env = environment()
   env.set('srcdir', meson.current_source_dir())
+  env.set('base_srcdir', meson.source_root())
   env.set('builddir', meson.current_build_dir())
   env.set('libs', meson.current_build_dir()) # TODO: Merge this with builddir after autotools removal
   HBSOURCES = []