commit c863d4ab7302ed21212644902be0caa12e2aa689
parent b4b5838b56003120560615c6580620fe6031bc27
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Mon, 17 Jun 2024 19:57:59 -0300
compile each object file separately
this allows us to compile the program using multiple threads for example
with `make -j <number of threads>`
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,7 +1,7 @@
CC := g++
CFLAGS := -Wall -pedantic -ansi -std=c++98 -O3
SRCS := $(wildcard *.cpp)
-LIBS := $(wildcard *.h)
+OBJS := $(SRCS:.cpp=.o)
TARGET := main
@@ -9,8 +9,12 @@ TARGET := main
all: $(TARGET)
-$(TARGET): $(SRCS) $(LIBS)
+$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
+ rm -f $(OBJS)
+
+%.o: %.cpp
+ g++ $(CFLAGS) -c $< -o $@
clean:
rm -f $(TARGET)