# Main Makefile - Platform detection and delegation
# This file is invoked by codermake CLI tool

# Detect platform
OS := $(shell uname -s)

# Include base configuration
include $(CODERMAKE_PACKAGE_DIR)/makefiles/base.mk

# Include platform-specific rules
ifeq ($(OS),OS400)
    # IBM i platform
    include $(CODERMAKE_PACKAGE_DIR)/makefiles/ibmi.mk
else
    # Unix-like platforms (Linux, macOS, FreeBSD, etc.)
    include $(CODERMAKE_PACKAGE_DIR)/makefiles/unix.mk
endif

# Initialize log directory (shared across platforms)
$(shell rm -rf tmp/logs && $(MKDIR) -p tmp/logs)

# Include preprocessed rules from system temp directory
# CODERMAKE_RULES_DIR is set by the codermake CLI to point to /tmp/codermake-<uuid>/
-include $(CODERMAKE_RULES_DIR)/rules.mk
-include $(CODERMAKE_RULES_DIR)/targets.mk

# Default target
.DEFAULT_GOAL := all
.PHONY: all
all: $(TARGETS)

# Clean target
.PHONY: clean
clean: platform-clean
	@rm -rf tmp/logs
