# Makefile for ZTools FreeCAD Workbench # Installs to local flatpak FreeCAD instance WORKBENCH_NAME := ZTools FLATPAK_APP := org.freecad.FreeCAD # FreeCAD Mod directory for flatpak FLATPAK_MOD_DIR := $(HOME)/.var/app/$(FLATPAK_APP)/data/FreeCAD/Mod INSTALL_DIR := $(FLATPAK_MOD_DIR)/$(WORKBENCH_NAME) .PHONY: all install uninstall clean check-flatpak list dev-install dev-uninstall run help all: install # Check if flatpak FreeCAD is installed check-flatpak: @if ! flatpak list | grep -q $(FLATPAK_APP); then \ echo "Error: FreeCAD flatpak ($(FLATPAK_APP)) is not installed"; \ exit 1; \ fi # Install the workbench install: check-flatpak @echo "Installing $(WORKBENCH_NAME) workbench to flatpak FreeCAD..." @mkdir -p $(INSTALL_DIR)/ztools/commands @mkdir -p $(INSTALL_DIR)/ztools/datums @mkdir -p $(INSTALL_DIR)/ztools/resources/icons @cp -v package.xml $(INSTALL_DIR)/ @cp -v ztools/InitGui.py $(INSTALL_DIR)/ @cp -v ztools/ztools/*.py $(INSTALL_DIR)/ztools/ @cp -v ztools/ztools/commands/*.py $(INSTALL_DIR)/ztools/commands/ @cp -v ztools/ztools/datums/*.py $(INSTALL_DIR)/ztools/datums/ @cp -v ztools/ztools/resources/*.py $(INSTALL_DIR)/ztools/resources/ @cp -v ztools/ztools/resources/icons/*.svg $(INSTALL_DIR)/ztools/resources/icons/ @echo "Installation complete!" @echo "Restart FreeCAD to load the workbench." # Uninstall the workbench uninstall: @echo "Uninstalling $(WORKBENCH_NAME) workbench..." @rm -rf $(INSTALL_DIR) @echo "Uninstallation complete!" # Clean build artifacts (if any) clean: @find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true @find . -type f -name "*.pyc" -delete 2>/dev/null || true @echo "Cleaned build artifacts." # List installed files list: @echo "Installed files in $(INSTALL_DIR):" @find $(INSTALL_DIR) -type f 2>/dev/null || echo "Workbench not installed." # Development: install with symlink for live editing dev-install: check-flatpak @echo "Installing $(WORKBENCH_NAME) workbench (dev mode with symlink)..." @mkdir -p $(FLATPAK_MOD_DIR) @rm -rf $(INSTALL_DIR) @ln -sfv $(CURDIR) $(INSTALL_DIR) @echo "Dev installation complete (symlinked)!" @echo "Changes to source files will be reflected immediately (restart FreeCAD to reload)." # Remove dev symlink dev-uninstall: @echo "Removing dev symlink..." @rm -f $(INSTALL_DIR) @echo "Dev uninstallation complete!" # Run FreeCAD flatpak run: @echo "Starting FreeCAD flatpak..." @flatpak run $(FLATPAK_APP) # Show help help: @echo "ZTools Workbench Makefile" @echo "" @echo "Targets:" @echo " install - Install workbench to flatpak FreeCAD" @echo " uninstall - Remove workbench from flatpak FreeCAD" @echo " dev-install - Install as symlink for development" @echo " dev-uninstall- Remove development symlink" @echo " clean - Remove Python cache files" @echo " list - List installed files" @echo " run - Start FreeCAD flatpak" @echo " help - Show this help message" @echo "" @echo "Install directory: $(INSTALL_DIR)"