File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Compiler and flags
22CC := gcc
3- CFLAGS := -Wall -Wextra -Werror -pedantic -std=gnu11 -O2 -Wno-format
3+ CFLAGS := -Wall -Wextra -Werror -pedantic -std: =gnu11 -O2 -Wno-format
44DEBUGFLAGS := -g -O0
55
66# Directories
7- SRCDIR := src
87TESTDIR := tests
9- OBJDIR := build
108
119# Sources and Object files
12- SRCS := $(wildcard $(SRCDIR ) /* .c)
13- OBJS := $(SRCS:$(SRCDIR ) /%.c=$(OBJDIR ) /%.o )
14-
10+ SRCS := \
11+ dispatcher.c \
12+ handle_binary.c \
13+ handle_char.c \
14+ handle_decimal.c \
15+ handle_hexadecimal.c \
16+ handle_octal.c \
17+ handle_percent.c \
18+ handle_pointer.c \
19+ handle_reverse.c \
20+ handle_rot13.c \
21+ handle_string.c \
22+ handle_unprintable.c \
23+ handle_unsigned.c \
24+ parser.c \
25+ printf.c \
26+ utils.c
27+ OBJS := $(SRCS:.c=.o )
1528TEST_SRC := $(TESTDIR ) /main.c
16- TEST_OBJ := $(OBJDIR ) /main.o
29+ TEST_OBJ := $(TESTDIR ) /main.o
1730TARGET := printf
1831
1932INCLUDES := -Iinclude
@@ -26,17 +39,14 @@ $(TARGET): $(OBJS) $(TEST_OBJ)
2639 $(CC ) $(CFLAGS ) $(INCLUDES ) $^ -o $@
2740
2841# Produce object files
29- $( OBJDIR ) / % .o : $( SRCDIR ) / % .c | $( OBJDIR )
42+ % .o : % .c
3043 $(CC ) $(CFLAGS ) $(INCLUDES ) -c $< -o $@
3144
32- $(OBJDIR ) /main.o : $(TEST_SRC ) | $( OBJDIR )
45+ $(TEST_OBJ ) : $(TEST_SRC )
3346 $(CC ) $(CFLAGS ) $(INCLUDES ) -c $< -o $@
3447
35- # Create build directory if needed
36- $(OBJDIR ) :
37- mkdir -p $(OBJDIR )
3848clean :
39- rm -rf $(OBJDIR ) $(TARGET )
49+ rm -rf $(OBJS ) $( TEST_OBJ ) $(TARGET )
4050
4151# Debug mode: build with -g and run gdb
4252debug : CFLAGS := $(CFLAGS ) $(DEBUGFLAGS )
@@ -53,7 +63,7 @@ re: clean all
5363
5464# Format code with clang-format
5565format :
56- clang-format -i src/ * .c include/* .h
66+ clang-format -i * .c include/* .h
5767
5868# Show help
5969help :
You can’t perform that action at this time.
0 commit comments