# Makefile — unit tests for mux_table_* (#1667 Phase 3).
#
# Needs a built tree: make install from repo root (libmux.so in mux/lib).

CXX      = g++
# -MMD -MP: emit header prerequisites next to each object (#1952).  Without
# them the .o depends only on the .cpp, so editing a header this harness
# compiles against rebuilds nothing and the suite reports green against the
# previous header.
CXXFLAGS = -std=c++17 -g -O2 -Wall -Wextra -fPIC -MMD -MP
INCDIR   = ../../mux/include
LIBDIR   = ../../mux/lib

TARGET   = test_table

all: $(TARGET)

test_table.o: test_table.cpp
	$(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -I$(INCDIR) -c -o $@ $<

$(TARGET): test_table.o
	$(CXX) $(CXXFLAGS) -o $@ $^ -L$(LIBDIR) -lmux -Wl,-rpath,$(LIBDIR)

test: $(TARGET)
	LD_LIBRARY_PATH=$(LIBDIR):$$LD_LIBRARY_PATH ./$(TARGET)

clean:
	rm -f $(TARGET) test_table.o test_table.d

# Generated by -MMD; absent on the first build, hence the leading '-'.
-include $(wildcard *.d)

.PHONY: all test clean
