]> git.sesse.net Git - movit/blob - Makefile
Add some missing tests to .gitignore.
[movit] / Makefile
1 GTEST_DIR ?= /usr/src/gtest
2
3 EIGEN_CXXFLAGS := $(shell pkg-config --cflags eigen3)
4 ifeq ($(EIGEN_CXXFLAGS),)
5 $(error Empty EIGEN_CXXFLAGS. You probably need to install Eigen3)
6 endif
7
8 GLEW_CXXFLAGS := $(shell pkg-config --cflags glew)
9 ifeq ($(GLEW_CXXFLAGS),)
10 $(error Empty GLEW_CXXFLAGS. You probably need to install GLEW)
11 endif
12
13 GLEW_LIBS := $(shell pkg-config --libs glew)
14 ifeq ($(GLEW_LIBS),)
15 $(error Empty GLEW_LIBS. You probably need to install GLEW)
16 endif
17
18 SDL_CXXFLAGS := $(shell sdl-config --cflags)
19 ifeq ($(SDL_CXXFLAGS),)
20 $(error Empty SDL_CXXFLAGS. You probably need to install SDL)
21 endif
22
23 SDL_LIBS := $(shell sdl-config --libs)
24 ifeq ($(SDL_LIBS),)
25 $(error Empty SDL_LIBS. You probably need to install SDL)
26 endif
27
28 CC=gcc
29 CXX=g++
30 CXXFLAGS=-Wall -g -I$(GTEST_DIR)/include $(EIGEN_CXXFLAGS) $(GLEW_CXXFLAGS)
31 LDFLAGS=$(GLEW_LIBS) $(SDL_LIBS)
32 DEMO_LDFLAGS=-lSDL_image -lrt -lpthread -lpng
33 RANLIB=ranlib
34
35 ifeq ($(COVERAGE),1)
36 CXXFLAGS += -fprofile-arcs -ftest-coverage
37 LDFLAGS += -fprofile-arcs -ftest-coverage
38 endif
39
40 DEMO_OBJS=demo.o
41
42 # Unit tests.
43 TESTS=effect_chain_test
44 TESTS += mix_effect_test
45 TESTS += overlay_effect_test
46 TESTS += gamma_expansion_effect_test
47 TESTS += gamma_compression_effect_test
48 TESTS += colorspace_conversion_effect_test
49 TESTS += alpha_multiplication_effect_test
50 TESTS += alpha_division_effect_test
51 TESTS += saturation_effect_test
52 TESTS += deconvolution_sharpen_effect_test
53 TESTS += blur_effect_test
54 TESTS += unsharp_mask_effect_test
55 TESTS += glow_effect_test
56 TESTS += diffusion_effect_test
57 TESTS += white_balance_effect_test
58 TESTS += lift_gamma_gain_effect_test
59 TESTS += resample_effect_test
60 TESTS += padding_effect_test
61 TESTS += dither_effect_test
62 TESTS += flat_input_test
63 TESTS += ycbcr_input_test
64
65 # Core.
66 LIB_OBJS=effect_util.o util.o widgets.o effect.o effect_chain.o init.o
67
68 # Inputs.
69 LIB_OBJS += flat_input.o
70 LIB_OBJS += ycbcr_input.o
71
72 # Effects.
73 LIB_OBJS += lift_gamma_gain_effect.o
74 LIB_OBJS += white_balance_effect.o
75 LIB_OBJS += gamma_expansion_effect.o
76 LIB_OBJS += gamma_compression_effect.o
77 LIB_OBJS += colorspace_conversion_effect.o
78 LIB_OBJS += alpha_multiplication_effect.o
79 LIB_OBJS += alpha_division_effect.o
80 LIB_OBJS += saturation_effect.o
81 LIB_OBJS += vignette_effect.o
82 LIB_OBJS += mirror_effect.o
83 LIB_OBJS += blur_effect.o
84 LIB_OBJS += diffusion_effect.o
85 LIB_OBJS += glow_effect.o
86 LIB_OBJS += unsharp_mask_effect.o
87 LIB_OBJS += mix_effect.o
88 LIB_OBJS += overlay_effect.o
89 LIB_OBJS += resize_effect.o
90 LIB_OBJS += padding_effect.o
91 LIB_OBJS += resample_effect.o
92 LIB_OBJS += dither_effect.o
93 LIB_OBJS += deconvolution_sharpen_effect.o
94 LIB_OBJS += sandbox_effect.o
95
96 # Default target:
97 all: $(TESTS) demo
98
99 # Google Test and other test library functions.
100 TEST_OBJS = gtest-all.o gtest_sdl_main.o test_util.o
101
102 gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc
103         $(CXX) -MMD $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c $< -o $@
104 gtest_sdl_main.o: gtest_sdl_main.cpp
105         $(CXX) -MMD $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c $< -o $@
106
107 # Unit tests.
108 $(TESTS): %: %.o $(TEST_OBJS) libmovit.a
109         $(CXX) -o $@ $^ $(LDFLAGS)
110
111 OBJS=$(DEMO_OBJS) $(LIB_OBJS) $(TEST_OBJS) $(TESTS:=.o)
112
113 # A small demo program.
114 demo: libmovit.a $(DEMO_OBJS)
115         $(CXX) -o demo $(DEMO_OBJS) libmovit.a $(LDFLAGS) $(DEMO_LDFLAGS)
116
117 # The library itself.
118 libmovit.a: $(LIB_OBJS)
119         $(AR) rc $@ $(LIB_OBJS)
120         $(RANLIB) $@
121
122 %.o: %.cpp
123         $(CXX) -MMD -MP $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
124
125 DEPS=$(OBJS:.o=.d)
126 -include $(DEPS)
127
128 clean:
129         $(RM) demo $(TESTS) libmovit.a $(OBJS) $(OBJS:.o=.gcno) $(OBJS:.o=.gcda) $(DEPS) step-*.dot
130         $(RM) -r movit.info coverage/
131
132 check: $(TESTS)
133         FAILED_TESTS=""; \
134         for TEST in $(TESTS); do \
135             ./$$TEST || FAILED_TESTS="$$TEST $$FAILED_TESTS"; \
136         done; \
137         if [ "$$FAILED_TESTS" ]; then \
138                 echo Failed tests: $$FAILED_TESTS; \
139                 exit 1; \
140         fi
141
142 # You need to build with COVERAGE=1 to use this target.
143 coverage: check
144         lcov -d . -c -o movit.info
145         lcov --remove movit.info '*_test.cpp' '*/test_util.{cpp,h}' -o movit.info
146         genhtml -o coverage movit.info
147
148 .PHONY: coverage clean check all