# hoardom makefile # supports: make, make install, make deb, make pkg, make clean NAME := hoardom VERSION := $(shell grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') DESCRIPTION := Domain hoarding made less painful MAINTAINER := crt PREFIX ?= /usr/local BINDIR := $(PREFIX)/bin DATADIR := $(PREFIX)/share APPDIR := $(DATADIR)/applications ICONDIR := $(DATADIR)/icons/hicolor/256x256/apps ICON_FILE := dist/AppIcon.ico CARGO ?= cargo CARGO_FLAGS ?= BUILDDIR := target/release BINARY := $(BUILDDIR)/$(NAME) GUI_BINARY := $(BUILDDIR)/$(NAME)-app # packaging scratch dirs PKG_ROOT := target/pkg-root DEB_ROOT := target/deb-root MAC_ROOT := target/mac-root MAC_APP := target/mac-root/$(NAME).app # ---- build ---- .PHONY: all build release debug clean install uninstall deb pkg app all: release release: $(CARGO) build --release $(CARGO_FLAGS) debug: $(CARGO) build $(CARGO_FLAGS) # build the gui wrapper (requires gui feature) app: release $(CARGO) build --release --features gui $(CARGO_FLAGS) # ---- install (linux / mac) ---- install: release @echo "installing $(NAME) to $(DESTDIR)$(BINDIR)" install -d $(DESTDIR)$(BINDIR) install -m 755 $(BINARY) $(DESTDIR)$(BINDIR)/$(NAME) @# install gui wrapper too if it was built @if [ -f $(GUI_BINARY) ]; then \ install -m 755 $(GUI_BINARY) $(DESTDIR)$(BINDIR)/$(NAME)-app; \ fi ifeq ($(shell uname), Darwin) @echo "installing macOS app bundle" install -d $(DESTDIR)/Applications $(MAKE) _mac_app APP_DEST=$(DESTDIR)/Applications else @echo "installing desktop file" install -d $(DESTDIR)$(APPDIR) install -m 644 dist/$(NAME).desktop $(DESTDIR)$(APPDIR)/$(NAME).desktop install -d $(DESTDIR)$(ICONDIR) install -m 644 $(ICON_FILE) $(DESTDIR)$(ICONDIR)/$(NAME).ico endif @echo "done, $(NAME) is ready to go" uninstall: rm -f $(DESTDIR)$(BINDIR)/$(NAME) rm -f $(DESTDIR)$(BINDIR)/$(NAME)-app rm -f $(DESTDIR)$(APPDIR)/$(NAME).desktop rm -f $(DESTDIR)$(ICONDIR)/$(NAME).ico ifeq ($(shell uname), Darwin) rm -rf $(DESTDIR)/Applications/$(NAME).app endif @echo "uninstalled" # ---- debian .deb package ---- deb: app @echo "building deb package v$(VERSION)" rm -rf $(DEB_ROOT) # binaries install -d $(DEB_ROOT)/usr/bin install -m 755 $(BINARY) $(DEB_ROOT)/usr/bin/$(NAME) @if [ -f $(GUI_BINARY) ]; then \ install -m 755 $(GUI_BINARY) $(DEB_ROOT)/usr/bin/$(NAME)-app; \ fi # desktop file + icon install -d $(DEB_ROOT)/usr/share/applications install -m 644 dist/$(NAME).desktop $(DEB_ROOT)/usr/share/applications/$(NAME).desktop install -d $(DEB_ROOT)/usr/share/icons/hicolor/256x256/apps install -m 644 $(ICON_FILE) $(DEB_ROOT)/usr/share/icons/hicolor/256x256/apps/$(NAME).ico # control file install -d $(DEB_ROOT)/DEBIAN printf 'Package: $(NAME)\n\ Version: $(VERSION)\n\ Section: utils\n\ Priority: optional\n\ Architecture: $(shell dpkg --print-architecture 2>/dev/null || echo amd64)\n\ Maintainer: $(MAINTAINER)\n\ Description: $(DESCRIPTION)\n\ TUI and CLI tool for searching domain availability across TLD lists.\n\ Includes favorites, scratchpad, export, and custom list support.\n' > $(DEB_ROOT)/DEBIAN/control dpkg-deb --build --root-owner-group $(DEB_ROOT) target/$(NAME)_$(VERSION)_$(shell dpkg --print-architecture 2>/dev/null || echo amd64).deb @echo "deb built: target/$(NAME)_$(VERSION)_*.deb" # ---- macOS .pkg package ---- pkg: app @echo "building macOS pkg v$(VERSION)" rm -rf $(PKG_ROOT) $(MAC_ROOT) # cli binary package install -d $(PKG_ROOT)/cli$(PREFIX)/bin install -m 755 $(BINARY) $(PKG_ROOT)/cli$(PREFIX)/bin/$(NAME) pkgbuild \ --root $(PKG_ROOT)/cli \ --identifier ch.teleco.$(NAME).cli \ --version $(VERSION) \ --install-location / \ target/$(NAME)-cli.pkg # app bundle package install -d $(PKG_ROOT)/app $(MAKE) _mac_app APP_DEST=$(PKG_ROOT)/app pkgbuild \ --component $(PKG_ROOT)/app/$(NAME).app \ --identifier ch.teleco.$(NAME).app \ --version $(VERSION) \ --install-location /Applications \ target/$(NAME)-app.pkg # distribution xml so the installer actually has permission to write to /Applications printf '\n\ \n\ $(NAME) $(VERSION)\n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ \n\ #$(NAME)-cli.pkg\n\ #$(NAME)-app.pkg\n\ \n' > $(PKG_ROOT)/distribution.xml productbuild \ --distribution $(PKG_ROOT)/distribution.xml \ --package-path target \ target/$(NAME)-$(VERSION).pkg rm -f target/$(NAME)-cli.pkg target/$(NAME)-app.pkg rm -rf $(PKG_ROOT) @echo "pkg built: target/$(NAME)-$(VERSION).pkg" # ---- internal: macOS .app bundle ---- _mac_app: @test -n "$(APP_DEST)" || (echo "APP_DEST not set" && exit 1) install -d $(APP_DEST)/$(NAME).app/Contents/MacOS install -d $(APP_DEST)/$(NAME).app/Contents/Resources # gui wrapper as the executable (or shell launcher as fallback) @if [ -f $(GUI_BINARY) ]; then \ echo "using native gui wrapper"; \ install -m 755 $(GUI_BINARY) $(APP_DEST)/$(NAME).app/Contents/MacOS/$(NAME)-app; \ else \ echo "gui wrapper not built, using shell launcher fallback"; \ install -m 755 dist/mac-launcher.sh $(APP_DEST)/$(NAME).app/Contents/MacOS/$(NAME)-app; \ fi # the actual tui binary (gui wrapper spawns this, shell launcher also needs it) install -m 755 $(BINARY) $(APP_DEST)/$(NAME).app/Contents/MacOS/$(NAME) # Info.plist printf '\n\ \n\ \n\ \n\ CFBundleExecutable\n\ $(NAME)-app\n\ CFBundleIdentifier\n\ ch.teleco.$(NAME)\n\ CFBundleName\n\ $(NAME)\n\ CFBundleDisplayName\n\ hoardom\n\ CFBundleVersion\n\ $(VERSION)\n\ CFBundleShortVersionString\n\ $(VERSION)\n\ CFBundlePackageType\n\ APPL\n\ CFBundleIconFile\n\ icon.icns\n\ LSMinimumSystemVersion\n\ 10.12\n\ NSHighResolutionCapable\n\ \n\ \n\ \n' > $(APP_DEST)/$(NAME).app/Contents/Info.plist # app icon cp dist/AppIcon.icns $(APP_DEST)/$(NAME).app/Contents/Resources/icon.icns # ---- clean ---- clean: $(CARGO) clean rm -rf $(PKG_ROOT) $(DEB_ROOT) $(MAC_ROOT) rm -f target/$(NAME)_*.deb target/$(NAME)-*.pkg