|
root / base / usr / src / lib / libreef / Makefile
Makefile Makefile 58 lines 1.5 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
#
# Copyright 2026 Zygaena Project
#
# Hammerhead: Reef runtime library (CMake wrapper)
#
# Builds libreef (the Reef language runtime) from contrib/reef source.
# The runtime is a C library built with CMake, following the libressl pattern.
#
# Source: contrib/reef/ (extracted from reef-lang tarball, gitignored)
# Installs: /usr/lib/libreef.so, /usr/lib/reef/runtime/*, /usr/include/reef/
#

include ../../Makefile.master

unexport LD_ALTEXEC

CONTRIBDIR = $(CONTRIB)/reef
BUILDDIR = $(CURDIR)/build

CMAKE = cmake
CMAKE_FLAGS = \
	-DCMAKE_C_COMPILER=$(GNUC_ROOT)/bin/gcc \
	-DCMAKE_C_FLAGS="-m64 -Wno-error=format-zero-length" \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DCMAKE_INSTALL_LIBDIR=lib

# Hammerhead: skip libreef if contrib/reef source is not available
# (e.g., self-hosted builds without the reef-lang tarball)
REEF_AVAILABLE := $(wildcard $(CONTRIBDIR)/reef-runtime/CMakeLists.txt)

all: $(if $(REEF_AVAILABLE),_build_reef)

_build_reef: $(BUILDDIR)/Makefile
	$(MAKE) -C $(BUILDDIR) -j2

$(BUILDDIR)/Makefile: $(CONTRIBDIR)/reef-runtime/CMakeLists.txt
	mkdir -p $(BUILDDIR)
	cd $(BUILDDIR) && $(CMAKE) $(CONTRIBDIR)/reef-runtime $(CMAKE_FLAGS)

install: $(if $(REEF_AVAILABLE),_install_reef)

_install_reef: _build_reef
	DESTDIR=$(ROOT) $(CMAKE) --install $(BUILDDIR)
	# Install reefc.conf template if present
	if [ -f $(CONTRIBDIR)/etc/reefc.conf ]; then \
		$(INS) -s -m 644 -f $(ROOT)/etc/reef $(CONTRIBDIR)/etc/reefc.conf; \
	fi

clean:
	$(RM) -r $(BUILDDIR)

clobber: clean

install_h:

.PHONY: all install clean clobber install_h