diff --git a/utils/check-package b/utils/check-package
index f64daed84c..6bd0c0b31f 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -61,6 +61,7 @@ DO_CHECK_INTREE = re.compile(r"|".join([
 DO_NOT_CHECK_INTREE = re.compile(r"|".join([
     r"boot/barebox/barebox\.mk$",
     r"fs/common\.mk$",
+    r"package/alchemy/atom.mk.in$",
     r"package/doc-asciidoc\.mk$",
     r"package/pkg-\S*\.mk$",
     r"toolchain/helpers\.mk$",
@@ -84,7 +85,7 @@ def get_lib_from_filename(fname):
         return checkpackagelib.lib_config
     if fname.endswith(".hash"):
         return checkpackagelib.lib_hash
-    if fname.endswith(".mk"):
+    if fname.endswith(".mk") or fname.endswith(".mk.in"):
         return checkpackagelib.lib_mk
     if fname.endswith(".patch"):
         return checkpackagelib.lib_patch
diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py
index b0bd52bdf6..931fa39dda 100644
--- a/utils/checkpackagelib/lib_mk.py
+++ b/utils/checkpackagelib/lib_mk.py
@@ -21,6 +21,16 @@ continue_conditional = ["elif", "else"]
 end_conditional = ["endif"]
 
 
+def get_package_prefix_from_filename(filename):
+    package = os.path.splitext(os.path.splitext(os.path.basename(filename))[0])[0]
+    # linux tools do not use LINUX_TOOL_ prefix for variables
+    package = package.replace("linux-tool-", "")
+    # linux extensions do not use LINUX_EXT_ prefix for variables
+    package = package.replace("linux-ext-", "")
+    package_upper = package.replace("-", "_").upper()
+    return package, package_upper
+
+
 class Indent(_CheckFunction):
     COMMENT = re.compile(r"^\s*#")
     CONDITIONAL = re.compile(r"^\s*({})\s".format("|".join(start_conditional + end_conditional + continue_conditional)))
@@ -179,12 +189,10 @@ class RemoveDefaultPackageSourceVariable(_CheckFunction):
     packages_that_may_contain_default_source = ["binutils", "gcc", "gdb"]
 
     def before(self):
-        package, _ = os.path.splitext(os.path.basename(self.filename))
-        package_upper = package.replace("-", "_").upper()
-        self.package = package
+        self.package, package_upper = get_package_prefix_from_filename(self.filename)
         self.FIND_SOURCE = re.compile(
             r"^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
-            .format(package_upper, package, package_upper))
+            .format(package_upper, self.package, package_upper))
 
     def check_line(self, lineno, text):
         if self.FIND_SOURCE.search(text):
@@ -254,16 +262,10 @@ class TypoInPackageVariable(_CheckFunction):
     VARIABLE = re.compile(r"^(define\s+)?([A-Z0-9_]+_[A-Z0-9_]+)")
 
     def before(self):
-        package, _ = os.path.splitext(os.path.basename(self.filename))
-        package = package.replace("-", "_").upper()
-        # linux tools do not use LINUX_TOOL_ prefix for variables
-        package = package.replace("LINUX_TOOL_", "")
-        # linux extensions do not use LINUX_EXT_ prefix for variables
-        package = package.replace("LINUX_EXT_", "")
-        self.package = package
-        self.REGEX = re.compile(r"(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(package))
+        _, self.package = get_package_prefix_from_filename(self.filename)
+        self.REGEX = re.compile(r"(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(self.package))
         self.FIND_VIRTUAL = re.compile(
-            r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
+            r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(self.package))
         self.virtual = []
 
     def check_line(self, lineno, text):
diff --git a/utils/checkpackagelib/test_lib_mk.py b/utils/checkpackagelib/test_lib_mk.py
index 5f5663377b..d817cdece0 100644
--- a/utils/checkpackagelib/test_lib_mk.py
+++ b/utils/checkpackagelib/test_lib_mk.py
@@ -3,6 +3,40 @@ import checkpackagelib.test_util as util
 import checkpackagelib.lib_mk as m
 
 
+get_package_prefix_from_filename = [
+    ('linux extension',
+     'linux/linux-ext-aufs.mk',
+     ['aufs', 'AUFS']),
+    ('linux tool',
+     'package/linux-tools/linux-tool-gpio.mk.in',
+     ['gpio', 'GPIO']),
+    ('boot',
+     'boot/binaries-marvell/binaries-marvell.mk',
+     ['binaries-marvell', 'BINARIES_MARVELL']),
+    ('toolchain',
+     'toolchain/toolchain-external/toolchain-external-bootlin/toolchain-external-bootlin.mk',
+     ['toolchain-external-bootlin', 'TOOLCHAIN_EXTERNAL_BOOTLIN']),
+    ('package, underscore, subfolder',
+     'package/x11r7/xapp_bitmap/xapp_bitmap.mk',
+     ['xapp_bitmap', 'XAPP_BITMAP']),
+    ('package, starting with number',
+     'package/4th/4th.mk',
+     ['4th', '4TH']),
+    ('package, long name',
+     'package/perl-mojolicious-plugin-authentication/perl-mojolicious-plugin-authentication.mk',
+     ['perl-mojolicious-plugin-authentication', 'PERL_MOJOLICIOUS_PLUGIN_AUTHENTICATION']),
+    ('package, case sensitive',
+     'package/libeXosip2/libeXosip2.mk',
+     ['libeXosip2', 'LIBEXOSIP2']),
+    ]
+
+
+@pytest.mark.parametrize('testname,filename,expected', get_package_prefix_from_filename)
+def test_get_package_prefix_from_filename(testname, filename, expected):
+    prefix_lower, prefix_upper = m.get_package_prefix_from_filename(filename)
+    assert [prefix_lower, prefix_upper] == expected
+
+
 Indent = [
     ('ignore comment at beginning of line',
      'any',
@@ -496,6 +530,12 @@ TypoInPackageVariable = [
      'OTHERS_VAR = \n',
      [['any.mk:2: possible typo: OTHERS_VAR -> *ANY*',
        'OTHERS_VAR = \n']]),
+    ('linux tool',
+     'package/linux-tools/linux-tool-cpupower.mk.in',
+     'CPUPOWER_DEPENDENCIES =\n'
+     'POWER_DEPENDENCIES +=\n',
+     [['package/linux-tools/linux-tool-cpupower.mk.in:2: possible typo: POWER_DEPENDENCIES -> *CPUPOWER*',
+       'POWER_DEPENDENCIES +=\n']]),
     ]
 
 
