#	$CPPCCHOME/scbcpp/makefile  --  step.144: standalone libscbcpp.a
#
# Builds ../lib/libscbcpp.a from the GENERATED clone under scbcpp/{src,include}
# (namespace ccsscb; produced by scripts/scbcpp_sync.sh -- never edit the clone
# by hand, C-144-C). Same .cc.a archive discipline + STDCPP knob as
# ../lib/makefile, which this makefile deliberately does NOT touch (C-144-A).
#
# A standalone SCB-processing C++ app compiles with -I$CPPCCHOME/scbcpp/include
# and links $CPPCCHOME/lib/libscbcpp.a ALONE (no libruntime.a / libgenerate.a).
# -O2+ consumers: add -fno-strict-aliasing (same overlay code as the original;
# see README.md "Building against the cppcc runtime").

STDCPP ?= c++17
cfl	= -std=$(STDCPP) -Wall -g

ifneq (,$(findstring clang,$(CXX)))
cfl	+= -Wno-unused-but-set-variable -Wno-unused-private-field -Wno-parentheses-equality
endif

CCFLAGS  = $(cfl) -Iinclude
ARFLAGS = rvU

LIBSCBCPP= ../lib/libscbcpp.a

LO_scb_binary= $(LIBSCBCPP)(src/SyntaxControlledBinary.o)
LO_scr_runtime= $(LIBSCBCPP)(src/SyntaxControlledRuntime.o)
LO_scr_converter= $(LIBSCBCPP)(src/SyntaxControlledConverter.o)
LO_tnm_tokennames= $(LIBSCBCPP)(src/TokenNames.o)
LO_com_routines= $(LIBSCBCPP)(src/CommonRoutines.o)
LO_sys_routines= $(LIBSCBCPP)(src/SystemRoutines.o)
LO_log_logger= $(LIBSCBCPP)(src/Logger.o)
LO_lex_stub= $(LIBSCBCPP)(src/TokenizerBoundaryStub.o)

INCL	= \
		include/CommonRoutines.h	\
		include/SystemRoutines.h \
		include/cppccstd.h

.cc.a	:
	cd $(<D); $(CXX) -c $(CCFLAGS:-Iinclude=-I../include) $(<F)
	$(AR) $(ARFLAGS) $@ $*.o
	rm -f $*.o

all : $(LIBSCBCPP)
	@echo  "/$(LIBSCBCPP)/ done !"
	ranlib $(LIBSCBCPP)

$(LIBSCBCPP) : \
	$(LO_sys_routines)	\
	$(LO_com_routines)	\
	$(LO_log_logger)	\
	$(LO_scr_runtime) \
	$(LO_scb_binary) \
	$(LO_tnm_tokennames) \
	$(LO_scr_converter) \
	$(LO_lex_stub)
		@echo "$@ changed"

$(LO_sys_routines)	\
$(LO_com_routines)	\
$(LO_log_logger)	\
$(LO_scr_runtime) \
$(LO_scb_binary) \
$(LO_tnm_tokennames) \
$(LO_scr_converter) \
$(LO_lex_stub)	:	\
		$(INCL)
