# makefile — builds the obfuscator executable against the SCB C++
# library delivered in any b3u.dev bundles zip (see the accompanying
# compendium: docs/CCS_Obfuscator_Compendium_Draft_0.2.pdf, section 1.2).
#
# Source: authored in b3u_use_cases (ships in ccs_obfuscator-platform.zip
# beside obfuscator.cc, cipher.h and xtea.h).
#
# The obfuscator is a PURE SCB PROCESSOR — it loads a grammar binary,
# builds the runtime, transforms it, and re-serializes. It is therefore
# GRAMMAR-AGNOSTIC: it needs no generated KeyWordDefinition header, and
# links libscbcpp.a ALONE — no libruntime.a, no libgenerate.a, no
# compiler front-half. Whichever unit you compiled on b3u.dev, its
# bundles zip carries the same scbcpp package, so any of them will do.
#
# Layout assumed (the delivery layout, unzipped):
#   ~/ccsUseCases/<unit>/scbcpp   the SCB C++ library
#                                 (include/ + lib/libscbcpp.a)
#
# Override on the command line if your unit is named differently:
#   make SCBCPP=$HOME/ccsUseCases/metta/scbcpp

SCBCPP ?= $(HOME)/ccsUseCases/ccs_json/scbcpp

CXX      ?= g++
# -fno-strict-aliasing is recommended for anything linking the cppcc
# runtime at -O2 or above (see the cppcc README, "Building against the
# cppcc runtime"): the SCB packs a (type,data) pair into one word and
# reads it back through a bitfield overlay.
CXXFLAGS ?= -std=c++17 -O2 -Wall -fno-strict-aliasing

obfuscator: obfuscator.cc cipher.h xtea.h
	$(CXX) $(CXXFLAGS) -I$(SCBCPP)/include -I. \
	  obfuscator.cc $(SCBCPP)/lib/libscbcpp.a -lm -o obfuscator

clean:
	rm -f obfuscator

.PHONY: clean
