summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--Makefile4
-rw-r--r--examples/GNUmakefile19
-rw-r--r--examples/Makefile194
-rw-r--r--tests/GNUmakefile31
-rw-r--r--tests/Makefile199
-rw-r--r--tests/array/main.cpp (renamed from tests/array.cpp)0
-rw-r--r--tests/circular_buffer/main.cpp (renamed from tests/circular_buffer.cpp)0
-rw-r--r--tests/functional/main.cpp (renamed from tests/functional.cpp)0
-rw-r--r--tests/matrix/main.cpp (renamed from tests/matrix.cpp)0
-rw-r--r--tests/meta/main.cpp (renamed from tests/meta.cpp)0
m---------tools/mgm0
12 files changed, 57 insertions, 393 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..e5ed9e2
--- a/dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
1[submodule "tools/mgm"]
2 path = tools/mgm
3 url = git://julien.isonoe.net/perso/mgm
diff --git a/Makefile b/Makefile
index b435ef6..c95d798 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,11 @@ all:
15 @echo 'Type “make install” to install at the default location (“$(prefix)”).' 15 @echo 'Type “make install” to install at the default location (“$(prefix)”).'
16 @echo 'Type “make prefix=/some/directory install” to install somewhere else.' 16 @echo 'Type “make prefix=/some/directory install” to install somewhere else.'
17 @echo 17 @echo
18 @echo 'There are some examples available in the “examples/” directory.'
18 @echo 'Type “make test” to compile and execute the available tests.' 19 @echo 'Type “make test” to compile and execute the available tests.'
20 @echo
21 @echo 'Before running the examples or the tests, be sure to run'
22 @echo '“git submodule update --init”.'
19 23
20install: 24install:
21 $(MKDIR) -- '$(includedir)' 25 $(MKDIR) -- '$(includedir)'
diff --git a/examples/GNUmakefile b/examples/GNUmakefile
new file mode 100644
index 0000000..5501684
--- a/dev/null
+++ b/examples/GNUmakefile
@@ -0,0 +1,19 @@
1PROJECTS := \
2 array\
3 array_view\
4 expression\
5 functional\
6 interpolation\
7 math\
8 matrix\
9 meta\
10 numerical_derivate\
11 quaternion\
12 rational\
13 ref
14
15# Default compilation flags.
16CXXFLAGS := -std=c++98 -I ../include/ -I ~/usr/include/
17
18# Includes MyGreatMakefile
19include ../tools/mgm/mgm.mk
diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644
index db4750e..0000000
--- a/examples/Makefile
+++ b/dev/null
@@ -1,194 +0,0 @@
1##
2# My Great Makefile v0.4.2
3#
4# Julien Fontanet <julien.fontanet@isonoe.net>
5#
6# Copyleft 2010
7##
8
9##
10# This Makefile works only with gcc/g++ (g++ is used for linking).
11# The C prefix is ".c".
12# The C++ prefix is ".cpp".
13##
14
15########################
16# Global configuration #
17########################
18
19# Enables colored messages during compilation.
20COLORS := 1
21
22# Compiles in debug mode. (Necessary for the tests.)
23DEBUG := 1
24
25# Compiles with OpenMP.
26OPENMP := 1
27
28# Enables profiling.
29PROFILING := 0
30
31# Strips the binary from all its debug information (reduce the binary size).
32STRIP_BIN := 0
33
34# Displays which commands are executed during compilation.
35VERBOSE := 0
36
37# Projects list.
38PROJECTS := \
39 array\
40 array_view\
41 expression\
42 functional\
43 interpolation\
44 math\
45 matrix\
46 meta\
47 numerical_derivate\
48 quaternion\
49 rational\
50 ref
51
52PREFIX := /usr/local
53
54CXXFLAGS += -std=c++98 -pedantic -Wall -ggdb3
55CXXFLAGS += -Wextra -Winline -Wconversion -ggdb3
56CXXFLAGS += -I ../include/
57
58LDFLAGS +=
59
60
61#############################
62# Per project configuration #
63#############################
64
65
66
67###########################################
68# DO NOT MODIFY ANYTHING AFTER THIS LINE. #
69###########################################
70
71.DEFAULT_GOAL := all
72CC := gcc
73CFLAGS += -MMD
74CXX := g++
75CXXFLAGS += -MMD
76COMMON_OBJECTS := $(addsuffix .o,$(COMMON_SRCS))
77COMMON_DEPS := $(addsuffix .d,$(COMMON_SRCS))
78
79ifneq ($(DEBUG),1)
80CFLAGS += -DNDEBUG -fno-strict-aliasing -funroll-loops -O3 -g0
81CXXFLAGS += -DNDEBUG -fno-strict-aliasing -funroll-loops -O3 -g0
82endif
83
84ifeq ($(OPENMP),1)
85CFLAGS += -fopenmp
86CXXFLAGS += -fopenmp
87LDFLAGS += -fopenmp
88endif
89
90ifeq ($(PROFILING),1)
91CFLAGS += -pg
92CXXFLAGS += -pg
93LDFLAGS += -pg
94endif
95
96ifneq ($(VERBOSE),1)
97.SILENT:
98endif
99
100ifeq ($(COLORS),1)
101COLOR_RED := \033[0;22;31m
102COLOR_GREEN := \033[0;22;32m
103COLOR_YELLOW := \033[33m
104COLOR_BLUE := \033[0;22;34m
105COLOR_PURPLE := \033[0;22;35m
106COLOR_CYAN := \033[0;22;36m
107
108COLOR_RED_BOLD := \033[0;1;31m
109COLOR_GREEN_BOLD := \033[0;1;32m
110COLOR_YELLOW_BOLD := \033[0;1;33m
111COLOR_BLUE_BOLD := \033[0;1;34m
112COLOR_PURPLE_BOLD := \033[0;1;35m
113COLOR_CYAN_BOLD := \033[0;1;36m
114
115COLOR_NONE := \033[0m
116COLOR_NONE_BOLD := \033[1m
117endif
118
119# Rules to always execute.
120.PHONY: all clean distclean install uninstall
121
122# Generic rule definition.
123define PROJECT_TPL
124# The default target is "bin/PROJECT_NAME".
125$(1)_TARGET ?= bin/$(1)
126
127# The default source is "PROJECT_NAME/main.cpp".
128$(1)_SRCS ?= $(1)/main.cpp
129
130# The default install directory is "PREFIX/bin".
131$(1)_INSTALL_DIR ?= $(PREFIX)/bin
132$(1)_INSTALL ?= $$($(1)_INSTALL_DIR)/$$(notdir $$($(1)_TARGET))
133
134$(1)_OBJECTS := $$(addsuffix .o,$$($(1)_SRCS))
135$(1)_DEPS := $$(addsuffix .d,$$($(1)_SRCS))
136
137$$($(1)_OBJECTS): CFLAGS := $(CFLAGS) $$($(1)_CFLAGS)
138$$($(1)_OBJECTS): CXXFLAGS := $(CXXFLAGS) $$($(1)_CXXFLAGS)
139$$($(1)_OBJECTS): Makefile
140
141-include $$($(1)_DEPS)
142
143all: $$($(1)_TARGET)
144$$($(1)_TARGET): $$($(1)_OBJECTS) $(COMMON_OBJECTS)
145 mkdir -p -- '$$(@D)'
146 @printf ' $(COLOR_PURPLE_BOLD)L %s$(COLOR_NONE)\n' '$$@'
147 $(CXX) $(LDFLAGS) $$($(1)_LDFLAGS) -o '$$@' $$^
148ifeq ($(STRIP_BIN),1)
149 strip '$$@'
150endif
151
152$$($(1)_INSTALL): $$($(1)_TARGET)
153 @printf ' $(COLOR_YELLOW_BOLD)I %s$(COLOR_NONE)\n' '$$($(1)_INSTALL)'
154 mkdir -p -- '$$($(1)_INSTALL_DIR)'
155 cp -f $$^ '$$($(1)_INSTALL)'
156
157.PHONY: install-$(1) uninstall-$(1) clean-$(1) distclean-$(1)
158
159install: install-$(1)
160install-$(1): $$($(1)_INSTALL)
161
162uninstall: uninstall-$(1)
163uninstall-$(1):
164 @printf ' $(COLOR_YELLOW_BOLD)U %s$(COLOR_NONE)\n' '$$($(1)_INSTALL)'
165 $(RM) -v '$$($(1)_INSTALL)'
166
167clean: clean-$(1)
168clean-$(1):
169 $(RM) -v $$($(1)_DEPS) $$($(1)_OBJECTS)
170
171distclean: distclean-$(1)
172distclean-$(1): clean-$(1)
173 $(RM) -v $$($(1)_TARGET)
174 rmdir --parents --ignore-fail-on-non-empty -- '$$(dir $$($(1)_TARGET))'
175endef
176
177# Creates rules for each project.
178$(foreach project,$(PROJECTS),$(eval $(call PROJECT_TPL,$(project))))
179
180distclean: clean-COMMON
181clean: clean-COMMON
182clean-COMMON:
183 $(RM) -v $(COMMON_DEPS) $(COMMON_OBJECTS)
184
185# Generic rules
186.SUFFIXES: # Disable auto rules
187
188%.c.o: %.c
189 @printf ' $(COLOR_BLUE_BOLD)CC %s$(COLOR_NONE)\n' '$@'
190 $(CC) $(CFLAGS) -c -o '$@' '$<'
191
192%.cpp.o: %.cpp
193 @printf ' $(COLOR_BLUE_BOLD)CC %s$(COLOR_NONE)\n' '$@'
194 $(CXX) $(CXXFLAGS) -c -o '$@' '$<'
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
new file mode 100644
index 0000000..df85065
--- a/dev/null
+++ b/tests/GNUmakefile
@@ -0,0 +1,31 @@
1PROJECTS := \
2 array \
3 circular_buffer \
4 functional \
5 matrix \
6 meta
7
8# Default compilation flags.
9CXXFLAGS := -std=c++98 -I ../include/
10
11# Because these are unit tests (see contracts.h).
12DEBUG := 1
13CXXFLAGS += -DEXDEBUG
14
15# Includes MyGreatMakefile
16include ../tools/mgm/mgm.mk
17
18all:
19 @for f in bin/*; do \
20 [ -x "$$f" ] || continue; \
21 basename="$${f#*/}"; \
22 printf '%s\033[72G' "$$basename"; \
23 "$$f" 2> "$$basename".log >&2 && { \
24 rm -f "$$basename.log"; \
25 printf '$(COLOR_GREEN_BOLD)[passed]$(COLOR_NONE)\n'; \
26 } || { \
27 printf '$(COLOR_RED_BOLD)[failed]$(COLOR_NONE)\n\n$(COLOR_YELLOW_BOLD)%s$(COLOR_NONE)\n' "$$basename".log; \
28 cat "$$basename".log; \
29 printf '\n'; \
30 } \
31 done
diff --git a/tests/Makefile b/tests/Makefile
deleted file mode 100644
index 0f354ba..0000000
--- a/tests/Makefile
+++ b/dev/null
@@ -1,199 +0,0 @@
1##
2# My Great Makefile v0.4.2
3#
4# Julien Fontanet <julien.fontanet@isonoe.net>
5#
6# Copyleft 2010
7##
8
9##
10# This Makefile works only with gcc/g++ (g++ is used for linking).
11# The C prefix is ".c".
12# The C++ prefix is ".cpp".
13##
14
15########################
16# Global configuration #
17########################
18
19# Enables colored messages during compilation.
20COLORS := 1
21
22# Compiles in debug mode. (Necessary for the tests.)
23DEBUG := 1
24
25# Compiles with OpenMP.
26OPENMP := 1
27
28# Enables profiling.
29PROFILING := 0
30
31# Strips the binary from all its debug information (reduce the binary size).
32STRIP_BIN := 0
33
34# Displays which commands are executed during compilation.
35VERBOSE := 0
36
37# Projects list.
38PROJECTS := $(basename $(wildcard *.cpp))
39
40PREFIX := /usr/local
41
42CXXFLAGS += -DEXDEBUG
43CXXFLAGS += -std=c++98 -pedantic -Wall -ggdb3
44CXXFLAGS += -Wextra -Winline -Wconversion -ggdb3
45CXXFLAGS += -I ../include/
46
47LDFLAGS +=
48
49
50#############################
51# Per project configuration #
52#############################
53
54
55
56###########################################
57# DO NOT MODIFY ANYTHING AFTER THIS LINE. #
58###########################################
59
60.DEFAULT_GOAL := all
61CC := gcc
62CFLAGS += -MMD
63CXX := g++
64CXXFLAGS += -MMD
65COMMON_OBJECTS := $(addsuffix .o,$(COMMON_SRCS))
66COMMON_DEPS := $(addsuffix .d,$(COMMON_SRCS))
67
68ifneq ($(DEBUG),1)
69CFLAGS += -DNDEBUG -fno-strict-aliasing -funroll-loops -O3 -g0
70CXXFLAGS += -DNDEBUG -fno-strict-aliasing -funroll-loops -O3 -g0
71endif
72
73ifeq ($(OPENMP),1)
74CFLAGS += -fopenmp
75CXXFLAGS += -fopenmp
76LDFLAGS += -fopenmp
77endif
78
79ifeq ($(PROFILING),1)
80CFLAGS += -pg
81CXXFLAGS += -pg
82LDFLAGS += -pg
83endif
84
85ifneq ($(VERBOSE),1)
86.SILENT:
87endif
88
89ifeq ($(COLORS),1)
90COLOR_RED := \033[0;22;31m
91COLOR_GREEN := \033[0;22;32m
92COLOR_YELLOW := \033[33m
93COLOR_BLUE := \033[0;22;34m
94COLOR_PURPLE := \033[0;22;35m
95COLOR_CYAN := \033[0;22;36m
96
97COLOR_RED_BOLD := \033[0;1;31m
98COLOR_GREEN_BOLD := \033[0;1;32m
99COLOR_YELLOW_BOLD := \033[0;1;33m
100COLOR_BLUE_BOLD := \033[0;1;34m
101COLOR_PURPLE_BOLD := \033[0;1;35m
102COLOR_CYAN_BOLD := \033[0;1;36m
103
104COLOR_NONE := \033[0m
105COLOR_NONE_BOLD := \033[1m
106endif
107
108# Rules to always execute.
109.PHONY: all clean distclean install uninstall
110
111# Generic rule definition.
112define PROJECT_TPL
113# The default target is "bin/PROJECT_NAME".
114$(1)_TARGET ?= bin/$(1)
115
116# The default source is "PROJECT_NAME.cpp".
117$(1)_SRCS ?= $(1).cpp
118
119# The default install directory is "PREFIX/bin".
120$(1)_INSTALL_DIR ?= $(PREFIX)/bin
121$(1)_INSTALL ?= $$($(1)_INSTALL_DIR)/$$(notdir $$($(1)_TARGET))
122
123$(1)_OBJECTS := $$(addsuffix .o,$$($(1)_SRCS))
124$(1)_DEPS := $$(addsuffix .d,$$($(1)_SRCS))
125
126$$($(1)_OBJECTS): CFLAGS := $(CFLAGS) $$($(1)_CFLAGS)
127$$($(1)_OBJECTS): CXXFLAGS := $(CXXFLAGS) $$($(1)_CXXFLAGS)
128$$($(1)_OBJECTS): Makefile
129
130-include $$($(1)_DEPS)
131
132all: $$($(1)_TARGET)
133$$($(1)_TARGET): $$($(1)_OBJECTS) $(COMMON_OBJECTS)
134 mkdir -p -- '$$(@D)'
135 @printf ' $(COLOR_PURPLE_BOLD)L %s$(COLOR_NONE)\n' '$$@'
136 $(CXX) $(LDFLAGS) $$($(1)_LDFLAGS) -o '$$@' $$^
137ifeq ($(STRIP_BIN),1)
138 strip '$$@'
139endif
140
141$$($(1)_INSTALL): $$($(1)_TARGET)
142 @printf ' $(COLOR_YELLOW_BOLD)I %s$(COLOR_NONE)\n' '$$($(1)_INSTALL)'
143 mkdir -p -- '$$($(1)_INSTALL_DIR)'
144 cp -f $$^ '$$($(1)_INSTALL)'
145
146.PHONY: install-$(1) uninstall-$(1) clean-$(1) distclean-$(1)
147
148install: install-$(1)
149install-$(1): $$($(1)_INSTALL)
150
151uninstall: uninstall-$(1)
152uninstall-$(1):
153 @printf ' $(COLOR_YELLOW_BOLD)U %s$(COLOR_NONE)\n' '$$($(1)_INSTALL)'
154 $(RM) -v '$$($(1)_INSTALL)'
155
156clean: clean-$(1)
157clean-$(1):
158 $(RM) -v $$($(1)_DEPS) $$($(1)_OBJECTS)
159
160distclean: distclean-$(1)
161distclean-$(1): clean-$(1)
162 $(RM) -v $$($(1)_TARGET)
163 rmdir --parents --ignore-fail-on-non-empty -- '$$(dir $$($(1)_TARGET))'
164endef
165
166# Creates rules for each project.
167$(foreach project,$(PROJECTS),$(eval $(call PROJECT_TPL,$(project))))
168
169distclean: clean-COMMON
170clean: clean-COMMON
171clean-COMMON:
172 $(RM) -v $(COMMON_DEPS) $(COMMON_OBJECTS)
173
174# Generic rules
175.SUFFIXES: # Disable auto rules
176
177%.c.o: %.c
178 @printf ' $(COLOR_BLUE_BOLD)CC %s$(COLOR_NONE)\n' '$@'
179 $(CC) $(CFLAGS) -c -o '$@' '$<'
180
181%.cpp.o: %.cpp
182 @printf ' $(COLOR_BLUE_BOLD)CC %s$(COLOR_NONE)\n' '$@'
183 $(CXX) $(CXXFLAGS) -c -o '$@' '$<'
184
185# Run each test.
186all:
187 @for f in bin/*; do \
188 [ -x "$$f" ] || continue; \
189 basename="$${f#*/}"; \
190 printf '%s\033[72G' "$$basename"; \
191 "$$f" 2> "$$basename".log >&2 && { \
192 rm -f "$$basename.log"; \
193 printf '$(COLOR_GREEN_BOLD)[passed]$(COLOR_NONE)\n'; \
194 } || { \
195 printf '$(COLOR_RED_BOLD)[failed]$(COLOR_NONE)\n\n$(COLOR_YELLOW_BOLD)%s$(COLOR_NONE)\n' "$$basename".log; \
196 cat "$$basename".log; \
197 printf '\n'; \
198 } \
199 done
diff --git a/tests/array.cpp b/tests/array/main.cpp
index cb07ce1..cb07ce1 100644
--- a/tests/array.cpp
+++ b/tests/array/main.cpp
diff --git a/tests/circular_buffer.cpp b/tests/circular_buffer/main.cpp
index 37ebdfb..37ebdfb 100644
--- a/tests/circular_buffer.cpp
+++ b/tests/circular_buffer/main.cpp
diff --git a/tests/functional.cpp b/tests/functional/main.cpp
index fc9d801..fc9d801 100644
--- a/tests/functional.cpp
+++ b/tests/functional/main.cpp
diff --git a/tests/matrix.cpp b/tests/matrix/main.cpp
index b89d971..b89d971 100644
--- a/tests/matrix.cpp
+++ b/tests/matrix/main.cpp
diff --git a/tests/meta.cpp b/tests/meta/main.cpp
index a6188a0..a6188a0 100644
--- a/tests/meta.cpp
+++ b/tests/meta/main.cpp
diff --git a/tools/mgm b/tools/mgm
new file mode 160000
Subproject 9b6b172cdd1dd5d13a9e3d9d837cccd13732897