Skip to content
Snippets Groups Projects
Commit 6bfcfb78 authored by ERKEN EFE's avatar ERKEN EFE
Browse files

:hammer: CONFIG: Update makefile for new structure

Reworked makefile with new paths, variables for project structure.
parent e8a05416
Branches
Tags
No related merge requests found
CC = gcc
CFLAGS = -Wall -Wextra -g # L'option de debug -g à enlever
CPPFLAGS = -I include
# L'option de debug -g à enlever
CFLAGS = -Wall -Wextra -g
LDFLAGS =
LDLIBS = -lncurses
ALL_SOURCES = $(wildcard *.c)
TEST_SOURCES = $(filter-out main.c, $(ALL_SOURCES))
SOURCES = $(filter-out test.c, $(ALL_SOURCES))
HEADERS = $(wildcard *.h)
ALL_OBJECTS = $(ALL_SOURCES:.c=.o)
TEST_OBJECTS = $(TEST_SOURCES:.c=.o)
OBJECTS = $(SOURCES:.c=.o)
LEVELS = $(wildcard level*.txt)
SPATH = src/
HPATH = include/
OPATH = obj/
LEVELPATH = levels/
ALL_SOURCES = $(wildcard $(SPATH)*.c)
TEST_SOURCES = $(filter-out $(SPATH)main.c, $(ALL_SOURCES))
SOURCES = $(filter-out $(SPATH)test.c, $(ALL_SOURCES))
HEADERS = $(wildcard $(HPATH)*.h)
ALL_OBJECTS = $(addprefix $(OPATH),$(patsubst %.c,%.o,$(notdir $(ALL_SOURCES))))
TEST_OBJECTS = $(addprefix $(OPATH),$(patsubst %.c,%.o,$(notdir $(TEST_SOURCES))))
OBJECTS = $(addprefix $(OPATH),$(patsubst %.c,%.o,$(notdir $(SOURCES))))
LEVELS = $(wildcard $(LEVELPATH)level*.txt)
DOCGEN = doxygen
DOXYFILE = doc/Doxyfile
ARCHIVE_NAME = ERKEN_Efe.tar.gz
ARCHIVE_SOURCES = $(SOURCES) $(HEADERS) makefile $(LEVELS) README.md Doxyfile
ARCHIVE_SOURCES = $(SOURCES) $(HEADERS) makefile $(LEVELS) README.md $(DOXYFILE)
ARCHIVER = tar
ARCHIVE_FLAGS = -cvzf
TEST_EXEC = sokoban_test
......@@ -29,16 +37,30 @@ $(EXEC) : $(OBJECTS)
$(TEST_EXEC) : $(TEST_OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
%.o : %.c %.h
$(CC) $(CFLAGS) -c $<
$(OPATH)%.o : $(SPATH)%.c $(HPATH)%.h | $(OPATH)
@echo "-o $@ -c $^"
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
$(OPATH) :
mkdir -p $@
clean :
rm -f $(EXEC) $(TEST_EXEC) $(ALL_OBJECTS)
doc :
doxygen Doxyfile
$(DOCGEN) $(DOXYFILE)
archive : $(ARCHIVE_NAME)
$(ARCHIVE_NAME) : $(ARCHIVE_SOURCES)
$(ARCHIVER) $(ARCHIVE_FLAGS) $@ $^
echo :
@echo "All_SOURCES = $(ALL_SOURCES)"
@echo "TEST_SOURCES = $(TEST_SOURCES)"
@echo "SOURCES = $(SOURCES)"
@echo "HEADERS = $(HEADERS)"
@echo "All_OBJECTS = $(ALL_OBJECTS)"
@echo "TEST_OBJECTS = $(TEST_OBJECTS)"
@echo "OBJECTS = $(OBJECTS)"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment