-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
86 lines (67 loc) · 2.35 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
84
85
86
# expect iRRAM installation root directory to be $(IRRAM)
# settings, individual section
#IRRAM = /home/info04/brausse/IVP-tests/iRRAM_2013_01/installed
#PKG_CONFIG_PATH = ~/bin/installed/lib64/pkgconfig
include Makefile.paths
# g++ <= 4.7 cannot handle the syntax properly
#CXX = clang++
PKG_CONFIG = PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config
override CFLAGS += -O2 -Wall -DNDEBUG #--coverage #-Wextra -pedantic
override CFLAGS += -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-switch
override CXXFLAGS := $(CXXFLAGS) -std=c++11 $(CFLAGS) -Wno-tautological-compare
override CFLAGS := -std=c11 $(CFLAGS)
EXES = \
ivp \
pendulum \
nbody \
iRRAM_LDFLAGS = -L $(IRRAM)/lib -Wl,-rpath -Wl,$(IRRAM)/lib
iRRAM_LDLIBS = -lstdc++ -lm -lmpfr -lgmp -liRRAM
iRRAM_CXXFLAGS = -I $(IRRAM)/include
ivp_OBJS = ivp.o
ivp_LDFLAGS = $(iRRAM_LDFLAGS) -pg
ivp_LDLIBS = $(iRRAM_LDLIBS) # -lgcov
ivp_CXXFLAGS = $(iRRAM_CXXFLAGS) #-pg
ifneq ($(PICARD),)
ivp_CXXFLAGS += -DMETHOD_PICARD=$(PICARD)
endif
pendulum_OBJS = pendulum-vis.o
pendulum_PKGS = cairo sdl
pendulum_CFLAGS =
pendulum_LDFLAGS =
pendulum_LDLIBS = -lm
nbody_OBJS = nbody-vis.o ring-buf.o
nbody_PKGS = cairo sdl
nbody_CFLAGS = #-pg
nbody_LDFLAGS = #-pg
nbody_LDLIBS = -lm
# rules, generic section
define EXE_template
ifneq "$$($(1)_PKGS)" ""
$(1)_PKG_CONFIG := $$(PKG_CONFIG) $$($(1)_PKGS)
else
$(1)_PKG_CONFIG := \#
endif
$$($(1)_OBJS): override CFLAGS += $$($(1)_CFLAGS) `$$($(1)_PKG_CONFIG) --cflags`
$$($(1)_OBJS): override CXXFLAGS += $$($(1)_CXXFLAGS) `$$($(1)_PKG_CONFIG) --cflags`
$(1): override LDFLAGS += $$($(1)_LDFLAGS) `$$($(1)_PKG_CONFIG) --libs-only-L --libs-only-other`
$(1): override LDLIBS += $$($(1)_LDLIBS) `$$($(1)_PKG_CONFIG) --libs-only-l`
$(1): $$($(1)_OBJS)
$$(CC) $$(LDFLAGS) $$^ $$(LDLIBS) $$(OUTPUT_OPTION)
.PHONY: $(1)-clean $(1)-prof
$(1)-clean:
$(RM) $(1) $$($(1)_OBJS)
$(1)-prof: override $(1)_CFLAGS += -pg
$(1)-prof: override $(1)_CXXFLAGS += -pg
$(1)-prof: override $(1)_LDFLAGS += -pg
$(1)-prof: $(1)
OBJS += $$($(1)_OBJS)
endef
.PHONY: all clean
all: ivp $(EXES)
$(foreach exe,$(EXES),$(eval $(call EXE_template,$(exe))))
$(OBJS): %.o: $(wildcard *.h)
#override CXXFLAGS := $(CXXFLAGS) $(iRRAM_CXXFLAGS)
#override LDFLAGS := $(LDFLAGS) $(iRRAM_LDFLAGS)
#override LDLIBS := $(LDLIBS) $(iRRAM_LDLIBS)
clean:
$(RM) $(OBJS) $(EXES)