# Build the C++ linker + OMF emitter.  Produces tools/link816 and
# tools/omfEmit (self-contained binaries).
#
# Usage:
#   make           build both
#   make clean     remove build artefacts

CXX      ?= g++
CXXFLAGS ?= -std=c++17 -O2 -Wall -Wextra -Wno-unused-parameter

PROJECT_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../..)
OUT_LINKER   := $(PROJECT_ROOT)/tools/link816
OUT_OMF      := $(PROJECT_ROOT)/tools/omfEmit

all: $(OUT_LINKER) $(OUT_OMF)

$(OUT_LINKER): link816.cpp
	@mkdir -p $(dir $@)
	$(CXX) $(CXXFLAGS) -o $@ $<

$(OUT_OMF): omfEmit.cpp
	@mkdir -p $(dir $@)
	$(CXX) $(CXXFLAGS) -o $@ $<

clean:
	rm -f $(OUT_LINKER) $(OUT_OMF)
