Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
BelaBartok39 committed Aug 12, 2024
2 parents 1c47071 + b876df4 commit a306948
Show file tree
Hide file tree
Showing 13 changed files with 1,051 additions and 153 deletions.
Empty file added .gitignore
Empty file.
31 changes: 25 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
CC = gcc
CFLAGS = -Wall -Wextra -O2
LIBS = -lm -lcjson
INCLUDES = $(shell pkg-config --cflags cjson) -Isrc

CFLAGS = -Wall -Wextra -g -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L
LIBS = -lcjson
INCLUDES = $(shell pkg-config --cflags cjson 2>/dev/null || echo "") -Isrc
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin

TEST_DIR = tests
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
DEPS = $(wildcard $(SRC_DIR)/*.h)
TARGET = $(BIN_DIR)/fancyD

.PHONY: all clean install uninstall
# Test-specific variables
TEST_SRCS = $(wildcard $(TEST_DIR)/*.c)
TEST_OBJS = $(TEST_SRCS:$(TEST_DIR)/%.c=$(OBJ_DIR)/%.o)
MAIN_OBJ = $(OBJ_DIR)/main.o
TEST_TARGET = $(BIN_DIR)/run_tests
TEST_LIBS = $(LIBS) -lcjson -lcheck -lsubunit -lpthread -lrt -lm

.PHONY: all clean install uninstall test

all: $(TARGET)

Expand Down Expand Up @@ -50,3 +56,16 @@ debug:
@echo "cJSON flags: $(INCLUDES)"
@echo "Libraries: $(LIBS)"
@ls -l $(SRC_DIR)

# Test targets
test: $(TEST_TARGET)
@echo "Running tests"
./$(TEST_TARGET)

$(TEST_TARGET): $(filter-out $(MAIN_OBJ), $(OBJS)) $(TEST_OBJS) | $(BIN_DIR)
@echo "Building test executable"
$(CC) $(CFLAGS) -o $@ $^ $(TEST_LIBS)

$(OBJ_DIR)/%.o: $(TEST_DIR)/%.c | $(OBJ_DIR)
@echo "Compiling test file $<"
$(CC) $(CFLAGS) $(INCLUDES) -I$(SRC_DIR) -c $< -o $@
Binary file added bin/fancyD
Binary file not shown.
Binary file added bin/run_tests
Binary file not shown.
Binary file added obj/fancy.o
Binary file not shown.
Binary file added obj/main.o
Binary file not shown.
Binary file added obj/test_fancy.o
Binary file not shown.
Loading

0 comments on commit a306948

Please sign in to comment.