    def makefile_normalizer(
        self, path, memoize_replacements=True, debug=False
    ) -> Optional[bytes]:
        """
        Normalizes the content of the makefile for hashing purposes (nothing else!),
        so that it can be compared to other Makefiles
        generated by different users on different systems.
        """
        p = Path(path)
        if not p.name.lower().startswith("makefile"):
            return None
        makefile_content_orig = p.read_bytes()
        target: Target = None
        try:
            target = Target.current()
        except RuntimeError:
            # No current target, returning Makefile content unchanged
            return makefile_content_orig
        if target is None:
            return makefile_content_orig
        if not hasattr(target, "_compile_options"):  #
            return makefile_content_orig
        if not hasattr(self, "_include_path_hash_cache"):
            self._include_path_hash_cache = {}
        makefile_content = makefile_content_orig.decode("utf-8")
        compile_options = list(shlex.split(target._compile_options))
        tmpdir = tempfile.gettempdir()
        replacements = {}
        for i in range(len(compile_options)):
            if compile_options[i] == "-I":
                if i < len(compile_options) - 1:
                    inc_path = compile_options[i + 1]

            elif compile_options[i].startswith("-I"):
                inc_path = compile_options[i][2:]
            else:
                continue
            # We are creating hashes of all include directories in a temp dir
            if inc_path.startswith(tmpdir):
                if memoize_replacements and inc_path in self._include_path_hash_cache:
                    inc_path_hash = self._include_path_hash_cache[inc_path]
                else:
                    inc_path_hash = create_dir_hash([], inc_path, is_source)
                    if memoize_replacements:
                        self._include_path_hash_cache[inc_path] = inc_path_hash
                replacements[inc_path] = inc_path_hash

        for search, replace in replacements.items():
            makefile_content = makefile_content.replace(search, replace)
        makefile_content = re.sub(
            r"[^/\\]+[/\\]fb_include", "fb_include", makefile_content
        )
        makefile_bytes = makefile_content.encode("utf-8")
        if debug:
            (p.parent / (p.name + ".normalized")).write_bytes(makefile_bytes)
        return makefile_bytes
Normalizes the content of the makefile for hashing purposes (nothing else!),
so that it can be compared to other Makefiles
generated by different users on different systems.
python/aitemplate/backend/build_cache_base.py