Skip to content

Commit

Permalink
WIP: try to fix Makefile to compile both examples and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmavr committed Sep 26, 2024
1 parent ae2bc06 commit 8314d58
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ EXAMPLES = $(patsubst $(EXAMPLES_DIR)/%.c,%,$(EXAMPLES_SRC))
# If `test` is passed as a cmd argument, extend flags to handle unit tests
ifeq ($(MAKECMDGOALS), test)
CFLAGS += -DRUN_UNIT_TESTS
TARGET = test/test
SRC = $(wildcard $(SRC_DIR)/*.c) $(TEST_SRC)
SRC = $(wildcard $(SRC_DIR)/*.c)
EXAMPLES = $(patsubst $(TEST_DIR)/%.c,%,$(TEST_SRC))
EXAMPLES_DIR = test
TARGET = $(EXAMPLES)
OBJECTS = $(SRC:%.c=%.o) $(TEST_SRC)
else
TARGET = $(EXAMPLES)
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJECTS = $(SRC:%.c=%.o)
endif

OBJECTS = $(SRC:%.c=%.o)

# What to do by default (no arguments)
all: $(EXAMPLES)
Expand All @@ -32,11 +35,8 @@ $(EXAMPLES): %: $(EXAMPLES_DIR)/%.c $(wildcard $(SRC_DIR)/*.c)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

# Phony to always rerun it

test: $(TARGET)
./$(TARGET)

test: all
.PHONY: clean

RM = rm -rf
Expand Down

0 comments on commit 8314d58

Please sign in to comment.