-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (61 loc) · 1.78 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
ifeq ($(OS),Windows_NT)
# is Windows_NT on XP, 2000, 7, Vista, 10...
detected_OS := Windows
else
detected_OS := $(shell uname -s)
# same as "uname -s"
endif
APP=rigid
ifeq ($(detected_OS), Windows)
target = build_$(detected_OS)/$(APP).exe
endif
ifeq ($(detected_OS), Linux)
target = build_$(detected_OS)/$(APP)
endif
LINKER_DEBUG:=
ifneq ($(V),)
LINKER_DEBUG = -Wl,--verbose
endif
ifneq ($(DEBUG),)
OPTIMIZE_FLAGS := -Og
DEBUG_FLAGS = -ggdb3 -DDEBUG
else
OPTIMIZE_FLAGS := -O2
ifeq ($(DEBUG),INFO)
DEBUG_FLAGS = -ggdb3
endif
endif
OBJECT_DIR = build_$(detected_OS)
DLL_DEPS :=
ifeq ($(detected_OS), Windows)
DLL_DEPS += $(OBJECT_DIR)/libgsl-25.dll $(OBJECT_DIR)/libgslcblas-0.dll
endif
all: $(target) $(DLL_DEPS)
@echo $(target)
@echo $(detected_OS)
@echo $(DLL_DEPS)
run: $(target)
$(target)
plot: $(target)
$(target) >result.txt
gnuplot draw.plt
animation: animations.json
result.txt: $(target)
$(target) >result.txt
animations.json: result.txt | convert_to_animation.py $(target)
python3 convert_to_animation.py $< > $@
$(OBJECT_DIR)/%.o: %.c | $(OBJECT_DIR)
gcc -c $< -I/usr/include -Wall -Wpedantic $(OPTIMIZE_FLAGS) $(DEBUG_FLAGS) -o $@
$(OBJECT_DIR):
mkdir -p $@
SRC := rigid.c van_der_pol_example.c rigid_body_motion.c free_fall.c pendulum.c wmq_debug.c wmq_error.c inverse_matrix.c gsl_utils.c
TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/,$(basename $(SRC))))
$(OBJECT_DIR)/libgsl-25.dll:
cp /mingw64/bin/libgsl-25.dll $(OBJECT_DIR)/
$(OBJECT_DIR)/libgslcblas-0.dll:
cp /mingw64/bin/libgslcblas-0.dll $(OBJECT_DIR)/
$(target): $(TARGET_OBJS)
gcc $^ -L/usr/lib $(OPTIMIZE_FLAGS) $(DEBUG_FLAGS) -lgsl -lgslcblas -llapack -lm $(LINKER_DEBUG) -o $@
clean:
rm -f $(APP) *.elf *.exe *.o
rm -rf build_*