{
  "$defs": {
    "accessPath": {
      "additionalProperties": false,
      "description": "One project, SDK, or explicit CodeWarrior-style include root.",
      "properties": {
        "anchor": {
          "default": "project",
          "enum": [
            "project",
            "project-relative",
            "sdk"
          ]
        },
        "class": {
          "enum": [
            "user",
            "system"
          ]
        },
        "path": {
          "$ref": "#/$defs/projectPath"
        },
        "recursive": {
          "default": false,
          "type": "boolean"
        }
      },
      "required": [
        "class",
        "path"
      ],
      "type": "object"
    },
    "application": {
      "additionalProperties": false,
      "description": "Classic application Finder metadata and memory settings.",
      "properties": {
        "creator": {
          "$ref": "#/$defs/fourcc"
        },
        "file_type": {
          "$ref": "#/$defs/fourcc"
        },
        "memory": {
          "$ref": "#/$defs/applicationMemory"
        },
        "output_name": {
          "type": "string"
        }
      },
      "required": [
        "creator",
        "file_type"
      ],
      "type": "object"
    },
    "applicationMemory": {
      "additionalProperties": false,
      "properties": {
        "application_stack_bytes": {
          "maximum": 4294967295,
          "minimum": 1,
          "type": "integer"
        },
        "minimum_heap_bytes": {
          "maximum": 4294967295,
          "minimum": 1,
          "type": "integer"
        },
        "preferred_heap_bytes": {
          "maximum": 4294967295,
          "minimum": 1,
          "type": "integer"
        },
        "size_flags": {
          "maximum": 65535,
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "preferred_heap_bytes",
        "minimum_heap_bytes"
      ],
      "type": "object"
    },
    "compiler": {
      "additionalProperties": false,
      "description": "Semantic compiler settings accepted by the manifest loader.",
      "properties": {
        "char_signedness": {
          "enum": [
            "signed",
            "unsigned"
          ]
        },
        "codewarrior_ansi_strict": {
          "type": "boolean"
        },
        "codewarrior_dont_inline": {
          "type": "boolean"
        },
        "codewarrior_enums_always_int": {
          "type": "boolean"
        },
        "codewarrior_force_cxx": {
          "type": "boolean"
        },
        "cxx_bool_keywords": {
          "type": "boolean"
        },
        "cxx_exceptions": {
          "type": "boolean"
        },
        "cxx_rtti": {
          "type": "boolean"
        },
        "cxx_wchar_type": {
          "type": "boolean"
        },
        "defines": {
          "default": [],
          "items": {
            "$ref": "#/$defs/define"
          },
          "type": "array"
        },
        "include_search": {
          "$ref": "#/$defs/includeSearch"
        },
        "optimization_level": {
          "maximum": 3,
          "minimum": 0,
          "type": "integer"
        },
        "prefix_header": {
          "$ref": "#/$defs/projectPath"
        },
        "source_compatibility": {
          "default": "native",
          "enum": [
            "native",
            "codewarrior-classic"
          ]
        },
        "standard": {
          "default": "c89",
          "enum": [
            "c89",
            "c99"
          ]
        },
        "structure_alignment": {
          "enum": [
            "power",
            "mac68k"
          ]
        }
      },
      "type": "object"
    },
    "customRuntime": {
      "additionalProperties": false,
      "description": "Explicit startup/runtime inputs for project-custom targets.",
      "properties": {
        "defines": {
          "default": [],
          "items": {
            "$ref": "#/$defs/define"
          },
          "type": "array"
        },
        "header_paths": {
          "default": [],
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "type": "array"
        },
        "runtime_libraries": {
          "default": [],
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "type": "array"
        },
        "startup_objects": {
          "default": [],
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "define": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "fourcc": {
      "description": "Exactly four printable ASCII characters.",
      "maxLength": 4,
      "minLength": 4,
      "pattern": "^[\\x20-\\x7E]{4}$",
      "type": "string"
    },
    "includeSearch": {
      "additionalProperties": false,
      "description": "Include search policy; user paths precede system paths.",
      "properties": {
        "access_path_order": {
          "default": "user-first",
          "enum": [
            "user-first"
          ]
        },
        "always_search_user_paths": {
          "default": true,
          "type": "boolean"
        },
        "source_directory_first": {
          "default": false,
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "library": {
      "additionalProperties": false,
      "allOf": [
        {
          "else": {
            "required": [
              "path"
            ]
          },
          "if": {
            "properties": {
              "kind": {
                "enum": [
                  "system-import",
                  "runtime"
                ]
              }
            }
          },
          "then": {
            "not": {
              "required": [
                "path"
              ]
            }
          }
        },
        {
          "else": {
            "properties": {
              "pef_fragments": {
                "maxItems": 0
              }
            }
          },
          "if": {
            "properties": {
              "kind": {
                "const": "system-import"
              }
            }
          }
        }
      ],
      "description": "One logical or physical library input in link order.",
      "properties": {
        "kind": {
          "default": "system-import",
          "enum": [
            "system-import",
            "runtime",
            "vendor",
            "object",
            "archive",
            "cfm-merge"
          ]
        },
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "path": {
          "$ref": "#/$defs/projectPath"
        },
        "pef_fragments": {
          "default": [],
          "items": {
            "$ref": "#/$defs/pefFragment"
          },
          "type": "array"
        },
        "weak_import": {
          "default": false,
          "type": "boolean"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "linkOrder": {
      "additionalProperties": false,
      "description": "The kind selects exactly one associated field: path for source, index for library, or target for subtarget.",
      "oneOf": [
        {
          "not": {
            "anyOf": [
              {
                "required": [
                  "index"
                ]
              },
              {
                "required": [
                  "target"
                ]
              }
            ]
          },
          "properties": {
            "kind": {
              "const": "source"
            }
          },
          "required": [
            "kind",
            "path"
          ]
        },
        {
          "not": {
            "anyOf": [
              {
                "required": [
                  "path"
                ]
              },
              {
                "required": [
                  "target"
                ]
              }
            ]
          },
          "properties": {
            "kind": {
              "const": "library"
            }
          },
          "required": [
            "kind",
            "index"
          ]
        },
        {
          "not": {
            "anyOf": [
              {
                "required": [
                  "path"
                ]
              },
              {
                "required": [
                  "index"
                ]
              }
            ]
          },
          "properties": {
            "kind": {
              "const": "subtarget"
            }
          },
          "required": [
            "kind",
            "target"
          ]
        }
      ],
      "properties": {
        "index": {
          "maximum": 18446744073709551615,
          "minimum": 0,
          "type": "integer"
        },
        "kind": {
          "enum": [
            "source",
            "library",
            "subtarget"
          ]
        },
        "path": {
          "$ref": "#/$defs/projectPath"
        },
        "target": {
          "type": "string"
        }
      },
      "required": [
        "kind"
      ],
      "type": "object"
    },
    "linker": {
      "additionalProperties": false,
      "properties": {
        "exports": {
          "default": [],
          "items": {
            "pattern": "^[A-Za-z0-9_.$]+$",
            "type": "string"
          },
          "type": "array"
        },
        "permit_multiple_definitions": {
          "default": false,
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "pefFragment": {
      "additionalProperties": false,
      "properties": {
        "fragment_name": {
          "minLength": 1,
          "type": "string"
        },
        "length": {
          "maximum": 4294967295,
          "minimum": 1,
          "type": "integer"
        },
        "offset": {
          "maximum": 4294967295,
          "minimum": 0,
          "type": "integer"
        },
        "weak_import": {
          "default": false,
          "type": "boolean"
        }
      },
      "required": [
        "fragment_name",
        "offset",
        "length"
      ],
      "type": "object"
    },
    "project": {
      "additionalProperties": false,
      "description": "Project identity and optional default target.",
      "properties": {
        "default_target": {
          "type": "string"
        },
        "name": {
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "projectPath": {
      "description": "Normalized anchor-relative path. Absolute paths and backslashes are rejected. Parent components are preserved; project/SDK anchors reject escape, while explicit project-relative anchors allow intentional parent traversal.",
      "minLength": 1,
      "type": "string"
    },
    "resource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "default": "rez-source",
          "enum": [
            "rez-source",
            "precompiled-fork"
          ]
        },
        "path": {
          "$ref": "#/$defs/projectPath"
        }
      },
      "required": [
        "path"
      ],
      "type": "object"
    },
    "resourceOutput": {
      "additionalProperties": false,
      "properties": {
        "copy_fragments": {
          "type": "boolean"
        },
        "creator": {
          "$ref": "#/$defs/fourcc"
        },
        "file_type": {
          "$ref": "#/$defs/fourcc"
        },
        "output_name": {
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "output_name",
        "creator",
        "file_type",
        "copy_fragments"
      ],
      "type": "object"
    },
    "sdk": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "deprecated": true,
          "description": "Compatibility form; prefer packages. When packages is empty, name becomes the requested package ID.",
          "type": "string"
        },
        "packages": {
          "default": [],
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "type": "array"
        },
        "requires": {
          "default": [],
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "sharedLibrary": {
      "additionalProperties": false,
      "properties": {
        "creator": {
          "$ref": "#/$defs/fourcc"
        },
        "current_version": {
          "default": 0,
          "minimum": 0,
          "type": "integer"
        },
        "exports": {
          "enum": [
            "none",
            "pragma",
            "explicit-list",
            "all"
          ]
        },
        "file_type": {
          "$ref": "#/$defs/fourcc"
        },
        "fragment_name": {
          "type": "string"
        },
        "initializer": {
          "type": "string"
        },
        "main": {
          "type": "string"
        },
        "old_definition_version": {
          "default": 0,
          "minimum": 0,
          "type": "integer"
        },
        "old_import_version": {
          "default": 0,
          "minimum": 0,
          "type": "integer"
        },
        "output_name": {
          "minLength": 1,
          "type": "string"
        },
        "share_data": {
          "default": false,
          "type": "boolean"
        },
        "terminator": {
          "type": "string"
        }
      },
      "required": [
        "output_name",
        "creator",
        "file_type",
        "exports"
      ],
      "type": "object"
    },
    "sourceCompilerSettings": {
      "additionalProperties": false,
      "properties": {
        "defines": {
          "default": [],
          "items": {
            "$ref": "#/$defs/define"
          },
          "type": "array"
        },
        "prefix_headers": {
          "default": [],
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "type": "array"
        },
        "source": {
          "$ref": "#/$defs/projectPath"
        }
      },
      "required": [
        "source"
      ],
      "type": "object"
    },
    "subtarget": {
      "additionalProperties": false,
      "properties": {
        "link_against_output": {
          "default": true,
          "type": "boolean"
        },
        "target": {
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "target"
      ],
      "type": "object"
    },
    "target": {
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "compiler_target": {
                "const": "classic-68k-segmented-app-c-v1"
              }
            },
            "required": [
              "compiler_target"
            ]
          },
          "then": {
            "properties": {
              "api": {
                "const": "classic"
              },
              "architecture": {
                "const": "m68k"
              },
              "backend": {
                "const": "macmake-classic"
              },
              "executable": {
                "const": "code-resources"
              },
              "kind": {
                "const": "application"
              },
              "language": {
                "const": "c"
              },
              "platform": {
                "const": "classic-mac-os"
              },
              "runtime": {
                "const": "classic-segmented"
              },
              "runtime_profile": {
                "const": "macmake-classic-m68k-c-v1"
              }
            },
            "required": [
              "kind",
              "platform",
              "architecture",
              "api",
              "runtime",
              "runtime_profile",
              "executable",
              "language",
              "backend"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "runtime_profile": {
                "const": "macmake-classic-m68k-c-v1"
              }
            },
            "required": [
              "runtime_profile"
            ]
          },
          "then": {
            "properties": {
              "api": {
                "const": "classic"
              },
              "architecture": {
                "const": "m68k"
              },
              "backend": {
                "const": "macmake-classic"
              },
              "compiler_target": {
                "const": "classic-68k-segmented-app-c-v1"
              },
              "executable": {
                "const": "code-resources"
              },
              "kind": {
                "const": "application"
              },
              "language": {
                "const": "c"
              },
              "platform": {
                "const": "classic-mac-os"
              },
              "runtime": {
                "const": "classic-segmented"
              }
            },
            "required": [
              "kind",
              "platform",
              "architecture",
              "api",
              "runtime",
              "compiler_target",
              "executable",
              "language",
              "backend"
            ]
          }
        }
      ],
      "properties": {
        "access_paths": {
          "default": [],
          "description": "Ordered header search roots used for this target.",
          "items": {
            "$ref": "#/$defs/accessPath"
          },
          "type": "array"
        },
        "api": {
          "description": "API environment; values are not interchangeable across OS families.",
          "enum": [
            "classic",
            "carbon-lib",
            "carbon-framework"
          ]
        },
        "application": {
          "$ref": "#/$defs/application",
          "description": "Finder metadata, output name, and application memory settings."
        },
        "architecture": {
          "description": "Target instruction-set architecture.",
          "enum": [
            "powerpc",
            "m68k"
          ]
        },
        "backend": {
          "default": "retro68",
          "description": "Build provider; omission selects the legacy Retro68 parser default.",
          "enum": [
            "retro68",
            "reference-cw8",
            "macmake-classic"
          ]
        },
        "cfm_fragment": {
          "$ref": "#/$defs/sharedLibrary"
        },
        "compiler": {
          "$ref": "#/$defs/compiler",
          "default": {},
          "description": "Target-wide compiler settings; omitted fields use provider defaults."
        },
        "compiler_target": {
          "description": "Versioned compiler target contract; required by supported native profiles.",
          "enum": [
            "classic-ppc-xcoff-c-v1",
            "classic-68k-code-resource-c-v1",
            "classic-68k-segmented-app-c-v1",
            "classic-ppc-xcoff-cxx-preview-v1",
            "cw8-os9-carbon-ppc-c-v1-preview"
          ]
        },
        "custom_runtime": {
          "$ref": "#/$defs/customRuntime"
        },
        "executable": {
          "description": "Output executable container format.",
          "enum": [
            "pef",
            "mach-o",
            "code-resources"
          ]
        },
        "kind": {
          "default": "application",
          "description": "Target output kind; application is the default.",
          "enum": [
            "application",
            "resource-collection",
            "code-resource",
            "static-library",
            "shared-library"
          ]
        },
        "language": {
          "default": "c",
          "description": "Declared translation-unit language family; defaults to C.",
          "enum": [
            "c",
            "c++",
            "mixed"
          ]
        },
        "libraries": {
          "default": [],
          "description": "Ordered logical libraries and project-owned link inputs.",
          "items": {
            "$ref": "#/$defs/library"
          },
          "type": "array"
        },
        "link_order": {
          "default": [],
          "items": {
            "$ref": "#/$defs/linkOrder"
          },
          "type": "array"
        },
        "linker": {
          "$ref": "#/$defs/linker",
          "default": {},
          "description": "Semantic exports and duplicate-definition policy."
        },
        "name": {
          "description": "Target name used in diagnostics and output selection.",
          "minLength": 1,
          "type": "string"
        },
        "platform": {
          "description": "Classic Mac OS or Mac OS X target family.",
          "enum": [
            "classic-mac-os",
            "macos-x"
          ]
        },
        "resource_output": {
          "$ref": "#/$defs/resourceOutput"
        },
        "resources": {
          "default": [],
          "description": "Ordered Rez source or precompiled resource-fork inputs.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/projectPath"
              },
              {
                "$ref": "#/$defs/resource"
              }
            ]
          },
          "type": "array"
        },
        "runtime": {
          "description": "CFM or dyld linkage model.",
          "enum": [
            "cfm",
            "dyld",
            "classic-segmented"
          ]
        },
        "runtime_profile": {
          "default": "retro68-newlib",
          "description": "Runtime contract. Probe profiles are experimental; see macmake help targets.",
          "enum": [
            "retro68-newlib",
            "codewarrior-msl-compatible",
            "project-custom",
            "macmake-classic-c-v1",
            "macmake-classic-m68k-c-v1",
            "macmake-classic-entry-probe-v1",
            "macmake-classic-direct-entry-probe-v1",
            "macmake-classic-raw-entry-probe-v1",
            "macmake-classic-raw-entry-probe-no-empty-data-v1",
            "macmake-classic-startup-probe-v1"
          ]
        },
        "sdk": {
          "$ref": "#/$defs/sdk",
          "description": "Registered SDK package identities and required capabilities."
        },
        "shared_library": {
          "$ref": "#/$defs/sharedLibrary"
        },
        "source_compiler_settings": {
          "default": [],
          "items": {
            "$ref": "#/$defs/sourceCompilerSettings"
          },
          "type": "array"
        },
        "sources": {
          "description": "Explicit, ordered project-relative translation-unit membership.",
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "type": "array"
        },
        "subtargets": {
          "default": [],
          "items": {
            "$ref": "#/$defs/subtarget"
          },
          "type": "array"
        }
      },
      "required": [
        "name",
        "platform",
        "architecture",
        "api",
        "runtime",
        "executable",
        "sources"
      ],
      "type": "object"
    }
  },
  "$id": "urn:macmake:manifest:0.1.1",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "JSON Schema view of the TOML structures accepted by this macMAKE build. TOML is the input format; the exact native M68000 profile pairing is encoded here, and macmake help manifest documents additional semantic rules.",
  "examples": [
    {
      "project": {
        "default_target": "Classic PPC C",
        "name": "HelloPPC"
      },
      "target": [
        {
          "api": "carbon-lib",
          "application": {
            "creator": "HmPP",
            "file_type": "APPL",
            "memory": {
              "application_stack_bytes": 32768,
              "minimum_heap_bytes": 2097152,
              "preferred_heap_bytes": 4194304,
              "size_flags": 22720
            },
            "output_name": "HelloPPC"
          },
          "architecture": "powerpc",
          "backend": "macmake-classic",
          "cfm_fragment": {
            "creator": "HmPP",
            "current_version": 0,
            "exports": "pragma",
            "file_type": "APPL",
            "fragment_name": "HelloPPC",
            "main": "__start",
            "old_definition_version": 0,
            "old_import_version": 0,
            "output_name": "HelloPPC",
            "share_data": false
          },
          "compiler": {
            "standard": "c89"
          },
          "compiler_target": "classic-ppc-xcoff-c-v1",
          "executable": "pef",
          "kind": "application",
          "language": "c",
          "libraries": [
            {
              "kind": "archive",
              "name": "MSL_C_Carbon",
              "path": "sdk/MSL_C_Carbon.Lib"
            },
            {
              "kind": "archive",
              "name": "MSL_Runtime_PPC_D",
              "path": "sdk/MSL_Runtime_PPC_D.Lib"
            },
            {
              "kind": "archive",
              "name": "MSL_Extras_Carbon",
              "path": "sdk/MSL_Extras_Carbon.Lib"
            },
            {
              "kind": "system-import",
              "name": "MathLib"
            },
            {
              "kind": "system-import",
              "name": "CarbonLib",
              "pef_fragments": [
                {
                  "fragment_name": "CarbonLib",
                  "length": 80688,
                  "offset": 0,
                  "weak_import": false
                },
                {
                  "fragment_name": "CarbonLib",
                  "length": 91808,
                  "offset": 80688,
                  "weak_import": true
                },
                {
                  "fragment_name": "Apple;Carbon;Multimedia",
                  "length": 74960,
                  "offset": 172496,
                  "weak_import": true
                },
                {
                  "fragment_name": "Apple;Carbon;Networking",
                  "length": 5464,
                  "offset": 247456,
                  "weak_import": true
                }
              ]
            }
          ],
          "name": "Classic PPC C",
          "platform": "classic-mac-os",
          "runtime": "cfm",
          "runtime_profile": "codewarrior-msl-compatible",
          "sdk": {
            "packages": [
              "macos9-sdk"
            ],
            "requires": [
              "classic.universal-interfaces.headers",
              "classic.carbon.headers",
              "classic.carbon.imports",
              "classic.math.imports"
            ]
          },
          "sources": [
            "src/main.c",
            "src/value.c"
          ]
        }
      ]
    }
  ],
  "properties": {
    "project": {
      "$ref": "#/$defs/project"
    },
    "target": {
      "description": "TOML [[target]] tables, kept in declaration order.",
      "items": {
        "$ref": "#/$defs/target"
      },
      "minItems": 1,
      "type": "array"
    }
  },
  "required": [
    "project",
    "target"
  ],
  "title": "macMAKE project manifest",
  "type": "object",
  "x-macmake-help-schema-version": "1.0.0",
  "x-macmake-manifest-schema-version": "0.1.1",
  "x-macmake-semantic-constraints": [
    "This schema describes object shape; manifest loading performs additional cross-field validation.",
    "backend=macmake-classic requires an allowed compiler_target/runtime_profile combination for the selected kind; see help targets. The bounded experimental M68000 application pair is classic-68k-segmented-app-c-v1 with macmake-classic-m68k-c-v1.",
    "runtime_profile=project-custom requires custom_runtime; custom_runtime is rejected for other runtime profiles.",
    "resource_output is valid only for resource-collection or static-library; resource-collection requires it.",
    "shared_library and cfm_fragment are mutually exclusive; shared_library requires kind=shared-library; cfm_fragment may also describe an application fragment.",
    "system-import and runtime libraries omit path; vendor, object, archive, and cfm-merge libraries require a project-relative path.",
    "PEF fragment extents are permitted only on system-import libraries; lengths must be positive and extents must be valid for their data fork.",
    "All source, resource, library, include, runtime, and output paths must satisfy their field-specific project-relative or filename rules.",
    "Application preferred_heap_bytes must be at least minimum_heap_bytes; heap sizes are nonzero.",
    "link_order requires path for source, index for library, or target for subtarget; fields for other kinds are rejected and references must match declared membership.",
    "SDK package names and packages must agree when both are supplied; package IDs and required capabilities are resolved against the local catalog.",
    "Project target names must be unique; the default target and each subtarget dependency must refer to a declared target, and dependency cycles are rejected.",
    "Source compiler settings must reference a declared source at most once; compiler defines need a non-empty name.",
    "Target combinations must be coherent: Classic Mac OS requires CFM/PEF and Classic or CarbonLib API; Mac OS X requires dyld/Mach-O and Carbon.framework.",
    "backend accepts retro68, reference-cw8, or macmake-classic; compiler_target is valid only with macmake-classic, which has target-kind/profile pairing rules."
  ]
}
