use .o instead of .c.o or .cpp.o + fix issue in makefile

This commit is contained in:
Mylloon 2024-02-28 14:57:14 +01:00
parent 5165d8f898
commit 8f0b120d19
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 10 additions and 10 deletions

View file

@ -2,7 +2,7 @@ CC = gcc
RM = rm
SOURCES = $(wildcard src/*.c)
OBJETS = $(patsubst %.c,%.c.o,$(notdir $(SOURCES)))
OBJETS = $(patsubst %.c,%.o,$(notdir $(SOURCES)))
CFLAGS = -std=c11 -pedantic
LDFLAGS =
@ -10,9 +10,12 @@ LDFLAGS =
EXE = example
EXE_EXT = out
%.c.o: src/%.c
%.o: src/%.c
$(CC) -c $< -o $@ $(CFLAGS)
compilation: $(OBJETS)
$(CC) -o $(EXE).$(EXE_EXT) $(OBJETS) $(LDFLAGS)
main: CFLAGS += -O3
main: compilation
@ -21,9 +24,6 @@ dev: CFLAGS += -fanalyzer -fsanitize=undefined -g -Og
dev: LDFLAGS += -fsanitize=undefined
dev: compilation
compilation: $(OBJETS)
$(CC) -o $(EXE).$(EXE_EXT) $(OBJETS) $(LDFLAGS)
all:
main

View file

@ -2,16 +2,19 @@ CXX = g++
RM = rm
SOURCES = $(wildcard src/*.cpp)
OBJETS = $(patsubst %.cpp,%.cpp.o,$(notdir $(SOURCES)))
OBJETS = $(patsubst %.cpp,%.o,$(notdir $(SOURCES)))
CXXFLAGS = --std=c++11
EXE = example
EXE_EXT = out
%.cpp.o: src/%.cpp
%.o: src/%.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS)
compilation: $(OBJETS)
$(CXX) -o $(EXE).$(EXE_EXT) $(OBJETS)
main: CXXFLAGS += -O3
main: compilation
@ -19,9 +22,6 @@ dev: CXXFLAGS += -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -g
dev: CXXFLAGS += -Wold-style-cast -Wsign-conversion
dev: compilation
compilation: $(OBJETS)
$(CXX) -o $(EXE).$(EXE_EXT) $(OBJETS)
all:
main