Skip to content

Commit a337614

Browse files
committed
Modified Makefile
1 parent 7112423 commit a337614

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

Makefile

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
# Compiler and flags
22
CC := gcc
3-
CFLAGS := -Wall -Wextra -Werror -pedantic -std=gnu11 -O2 -Wno-format
3+
CFLAGS := -Wall -Wextra -Werror -pedantic -std:=gnu11 -O2 -Wno-format
44
DEBUGFLAGS := -g -O0
55

66
# Directories
7-
SRCDIR := src
87
TESTDIR := 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)
1528
TEST_SRC := $(TESTDIR)/main.c
16-
TEST_OBJ := $(OBJDIR)/main.o
29+
TEST_OBJ := $(TESTDIR)/main.o
1730
TARGET := printf
1831

1932
INCLUDES := -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)
3848
clean:
39-
rm -rf $(OBJDIR) $(TARGET)
49+
rm -rf $(OBJS) $(TEST_OBJ) $(TARGET)
4050

4151
# Debug mode: build with -g and run gdb
4252
debug: CFLAGS := $(CFLAGS) $(DEBUGFLAGS)
@@ -53,7 +63,7 @@ re: clean all
5363

5464
# Format code with clang-format
5565
format:
56-
clang-format -i src/*.c include/*.h
66+
clang-format -i *.c include/*.h
5767

5868
# Show help
5969
help:

0 commit comments

Comments
 (0)