|
root / base / usr / src / cmd / reefc / Makefile
Makefile Makefile 62 lines 1.8 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#
# 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