# # Copyright 2026 Zygaena Project # # Hammerhead: reefc (Reef compiler) build wrapper # # Builds the reefc compiler from contrib/reef source using dune (OCaml). # Requires OCaml toolchain (ocaml, dune) to be installed on the build host. # # Source: contrib/reef/ (extracted from reef-lang tarball, gitignored) # Installs: /usr/bin/reefc, /usr/lib/reef/*, /etc/reef/reefc.conf # include ../Makefile.cmd unexport LD_ALTEXEC unexport VERSION CONTRIBDIR = $(CONTRIB)/reef BUILDDIR = $(CONTRIBDIR) # OCaml/dune environment OCAMLLIB ?= /usr/local/lib/ocaml OCAMLFIND_DESTDIR ?= $(OCAMLLIB) # The Reef top-level Makefile builds both runtime and compiler. # Since libreef (lib/) builds the runtime separately via CMake, # we only need to build the compiler here via dune. BUILD_ENV = \ OCAMLLIB=$(OCAMLLIB) \ OCAMLFIND_DESTDIR=$(OCAMLFIND_DESTDIR) \ PATH="$(GNUC_ROOT)/bin:/usr/local/bin:$(PATH)" # Hammerhead: skip reefc if contrib/reef source is not available REEF_AVAILABLE := $(wildcard $(CONTRIBDIR)/dune-project) all: $(if $(REEF_AVAILABLE),cd $(CONTRIBDIR) && $(BUILD_ENV) dune build,@echo "Skipping reefc: contrib/reef not available") install: $(if $(REEF_AVAILABLE),_install_reefc) _install_reefc: all # Install reefc binary mkdir -p $(ROOT)/usr/bin cp $(CONTRIBDIR)/_build/default/reefc/reefc.exe $(ROOT)/usr/bin/reefc 2>/dev/null || \ cp $(CONTRIBDIR)/_build/install/default/bin/reefc $(ROOT)/usr/bin/reefc chmod 755 $(ROOT)/usr/bin/reefc # Install reefc.conf mkdir -p $(ROOT)/etc/reef if [ -f $(CONTRIBDIR)/etc/reefc.conf ]; then \ cp $(CONTRIBDIR)/etc/reefc.conf $(ROOT)/etc/reef/reefc.conf; \ chmod 644 $(ROOT)/etc/reef/reefc.conf; \ fi clean: cd $(CONTRIBDIR) && dune clean 2>/dev/null || true clobber: clean _msg: .PHONY: all install clean clobber _msg