-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
45 lines (34 loc) · 1.11 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
CC=g++
STD=c++11
CFLAGS=-Wall -Wextra -std=$(STD)
TARGET_NAME=./tp2
TMPOUT_NAME=tp2.out
BUILD_PATH=./build
SOURCE_PATH=./src
LIB_PATH=./include
INPUT_PATH=./input
OUTPUT_PATH=./output
INPUT_GENERATOR_TARGET=./generator
RUN_TEST=03
SOURCE_EXT := cpp
SOURCES := $(shell find $(SOURCE_PATH) -path '*.$(SOURCE_EXT)')
OBJECTS := $(patsubst $(SOURCE_PATH)/%,$(BUILD_PATH)/%,$(SOURCES:.$(SOURCE_EXT)=.o))
all: $(TARGET_NAME)
$(BUILD_PATH)/%.o: $(SOURCE_PATH)/%.cpp $(LIB_PATH)/%.hpp
mkdir -p $(BUILD_PATH)
$(CC) -c $(CFLAGS) -o $@ $<
$(TARGET_NAME): $(OBJECTS) ./main.cpp
$(CC) $(CFLAGS) -o $(TARGET_NAME) ./main.cpp $(OBJECTS)
clean:
rm -rf $(BUILD_PATH)/*
rm $(TARGET_NAME)
run:
$(TARGET_NAME) $(INPUT_PATH)/$(RUN_TEST).in
mem:
valgrind --leak-check=full --show-leak-kinds=all $(TARGET_NAME) $(INPUT_PATH)/$(RUN_TEST).in > ./output/mem.log
$(INPUT_GENERATOR_TARGET): generate_in.cpp
$(CC) $(CFLAGS) -o $(INPUT_GENERATOR_TARGET) generate_in.cpp
time: $(INPUT_GENERATOR_TARGET) $(TARGET_NAME)
@bash time.sh $(TARGET_NAME) $(TMPOUT_NAME) $(INPUT_GENERATOR_TARGET)
tests:
@bash run_tests.sh $(TARGET_NAME) $(TMPOUT_NAME)