Skip to content

Commit

Permalink
make: better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmavr committed Sep 27, 2024
1 parent 389ddd2 commit 153c21f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
CC = gcc
SRC_DIR = src
INC_DIR = include
# This is where the targets will be compiled from
TARGET_DIR = examples
TEST_DIR = test
CFLAGS = -g -I$(INC_DIR) -Wall
CFLAGS = -O3 -I$(INC_DIR) -Wall
LDFLAGS = -lm
TEST_SRC = $(wildcard $(TEST_DIR)/*.c)

ifeq ($(MAKECMDGOALS), test)
# If `test` is passed as a cmd argument, extend flags to handle unit tests
TARGET_SRC = $(wildcard $(TEST_DIR)/*.c)
TARGET_SRC = $(TEST_SRC)
TARGETS = $(patsubst $(TEST_DIR)/%.c,%,$(TEST_SRC))
TARGET_DIR = test
else
TARGET_SRC = $(wildcard $(TARGET_DIR)/*.c)
TARGET_DIR = examples
# Strip file path so each demo source gets a target,
# e.g. examples/01_demo.c -> 01_demo
TARGET_SRC = $(wildcard $(TARGET_DIR)/*.c)
TARGETS = $(patsubst $(TARGET_DIR)/%.c, %, $(TARGET_SRC))
TARGET_DIR = examples
endif

# What to do by default (no arguments)
Expand All @@ -36,4 +34,3 @@ $(TARGETS): %: $(TARGET_DIR)/%.o $(wildcard $(SRC_DIR)/*.o)
RM = rm -rf
clean:
$(RM) $(TARGETS) $(SRC_DIR)/*.o $(TARGET_DIR)/*.o tests

0 comments on commit 153c21f

Please sign in to comment.