# HelloNervous — native build Makefile (run this ON a Nervous system).
#
# Nervous installs the desktop developer headers under /usr/include (DGrid/, LibCore/,
# SYSTEM_LIB/, DGrid/Gfx/, LibMain/ ...) and dev symlinks libnervous*.so under /usr/lib, so a
# plain clang++ compile "just works" — no cross-compile, no build tree needed.
#
# Usage:   make            # builds ./HelloNervous
#          ./HelloNervous  # run it on the desktop
#          make clean
#
# This is a normal GNU/BSD-agnostic Makefile; use `make` (Nervous ships bmake as `make`).

# NOTE: use plain '=' (NOT '?='). FreeBSD's make (bmake) PRE-DEFINES CXX=c++ and CXXFLAGS=-O2 -pipe,
# and '?=' only assigns when a variable is UNSET -- so with '?=' our std/flags were ignored and the
# build ran as `c++ -O2 -pipe` (no -std=c++23), which fails: SYSTEM_LIB needs C++23 (it uses `auto`
# params, char8_t, consteval, requires-clauses...). Plain '=' forces our values to win.
CXX = clang++
CXXFLAGS = -std=c++23 -O2 -g -fno-exceptions -Wall -Wextra

# The Nervous GUI libraries this program links against, in dependency order. A minimal DGrid
# app needs the GUI + graphics + core + IPC + base libraries and their transitive deps.
LIBS = \
	-lnervousmain \
	-ldgrid \
	-lgfx \
	-lnervousfilesystem \
	-lnervousconfig \
	-lnervousipc \
	-lnervousthreading \
	-lnervouscore \
	-lnervousurl \
	-lnervousunicode \
	-lnervoustextcodec \
	-lnervoustimezone \
	-lnervouscorebasic \
	-lnervouscoreminimal \
	-lnervoussystem \
	-lpthread

PROG = HelloNervous

$(PROG): main.cpp
	$(CXX) $(CXXFLAGS) -o $@ main.cpp -L/usr/lib $(LIBS)

clean:
	rm -f $(PROG)

.PHONY: clean
