mirror of
https://github.com/tbamud/tbamud.git
synced 2026-03-21 19:56:33 +01:00
Update Makefile.in to include unit tests
This commit is contained in:
parent
fbbc63b02b
commit
e0bfb2bc64
1 changed files with 52 additions and 0 deletions
|
|
@ -46,6 +46,7 @@ $%.o: %.c
|
|||
|
||||
clean:
|
||||
rm -f *.o depend
|
||||
rm -f ./tests/*.o depend
|
||||
|
||||
# Dependencies for the object files (automagically generated with
|
||||
# gcc -MM)
|
||||
|
|
@ -54,3 +55,54 @@ depend:
|
|||
$(CC) -MM *.c > depend
|
||||
|
||||
-include depend
|
||||
|
||||
# ---- Unit tests (5e-like rules) ----
|
||||
.PHONY: tests check
|
||||
|
||||
BINDIR ?= ../bin
|
||||
TESTS_DIR := tests
|
||||
TESTS_SRC := $(TESTS_DIR)/tests_5e.c
|
||||
TESTS_BIN := $(BINDIR)/tests_5e
|
||||
TESTS_OBJS := $(TESTS_DIR)/tests_5e.o $(TESTS_DIR)/stubs_unit.o
|
||||
|
||||
# Only what we need; add more .o if the linker asks
|
||||
TEST_LINK_OBJS := utils.o constants.o random.o
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $(BINDIR)
|
||||
|
||||
tests: $(TESTS_BIN)
|
||||
|
||||
check: $(TESTS_BIN)
|
||||
@echo "Running tests_5e..."
|
||||
@$(TESTS_BIN)
|
||||
|
||||
$(TESTS_BIN): $(TESTS_OBJS) $(TEST_LINK_OBJS) | $(BINDIR)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LIBS) -lm
|
||||
|
||||
$(TESTS_DIR)/tests_5e.o: $(TESTS_SRC)
|
||||
$(CC) $(CFLAGS) -I. -c -o $@ $<
|
||||
|
||||
$(TESTS_DIR)/stubs_unit.o: $(TESTS_DIR)/stubs_unit.c
|
||||
$(CC) $(CFLAGS) -I. -c -o $@ $<
|
||||
|
||||
# ---- Simulations (5e-like rules) ----
|
||||
.PHONY: sims run_sims
|
||||
|
||||
SIMS_DIR := tests
|
||||
SIMS_SRC := $(SIMS_DIR)/sim_5e.c
|
||||
SIMS_BIN := $(BINDIR)/sim_5e
|
||||
SIMS_OBJS := $(SIMS_DIR)/sim_5e.o $(SIMS_DIR)/stubs_unit.o
|
||||
SIM_LINK_OBJS := utils.o constants.o random.o
|
||||
|
||||
sims: $(SIMS_BIN)
|
||||
|
||||
run_sims: $(SIMS_BIN)
|
||||
@echo "Running sim_5e..."
|
||||
@$(SIMS_BIN)
|
||||
|
||||
$(SIMS_BIN): $(SIMS_OBJS) $(SIM_LINK_OBJS) | $(BINDIR)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LIBS) -lm
|
||||
|
||||
$(SIMS_DIR)/sim_5e.o: $(SIMS_SRC)
|
||||
$(CC) $(CFLAGS) -I. -c -o $@ $<
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue