-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
90 lines (75 loc) · 2.57 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
87
88
89
90
# hiptext - Image to Text Converter
# Copyright (c) 2013 Justine Tunney
# Example invocations:
# - make # Bring hiptext to life.
# - make check # Run unit tests.
# - sudo make install # Allow hiptext to stay forever :)
# - sudo make uninstall # Kick hiptext out of your house :(
# - make clean # Delete all generated files.
# - make lint # Check for C++ style errors.
# - make -pn | less # View implicit make rules and variables.
#
# Create an optimized build:
# CXXFLAGS="-O3 -flto -DNDEBUG" make
LINK.o = $(LINK.cc)
PREFIX ?= /usr/local
TARGET_ARCH ?= -march=native
CXXFLAGS ?= -g -O3
CXXFLAGS += -std=c++11 -Wall -Wextra
CXXFLAGS += -fno-exceptions -fno-rtti
LDLIBS += -lm -lglog -lgflags -lpng -ljpeg
LDLIBS += -lavcodec -lavformat -lavutil -lswscale
LDLIBS += $(shell freetype-config --libs)
SOURCES = \
artiste.o \
charquantizer.o \
font.o \
graphic.o \
jpeg.o \
macterm.o \
movie.o \
pixel.o \
pixel_parse.o \
png.o \
termprinter.o \
sixelprinter.o \
unicode.o \
xterm256.o
all: hiptext
hiptext: hiptext.o $(SOURCES)
.PHONY: check clean install uninstall lint
check: test
./test --alsologtostderr --gtest_color=yes
clean:
$(RM) test hiptext $(wildcard *.o *.d *.S $(GTEST_DIR)/*.o) cpplint.py
install: hiptext
install --mode=0755 hiptext $(PREFIX)/bin
uninstall:
$(RM) $(PREFIX)/bin/hiptext
cpplint.py:
wget -O $@ https://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py
lint: cpplint.py
python cpplint.py $(wildcard *.cc hiptext/*.h) \
2>&1 | grep -v 'termprinter\.cc:.*non-const' \
| grep -v 'readability/streams' \
| grep -v 'build/include' \
| grep -v 'build/header_guard' \
| grep -v 'legal/copyright' \
| grep -v 'Found C system header after' \
| grep -v 'runtime/references' \
| grep -v 'whitespace/parens'
%.cc: %.rl
ragel -o $@ $<
# Flag overrides for individual targets.
pixel_parse.o: CXXFLAGS := $(filter-out -MD,$(CXXFLAGS))
font.%: CXXFLAGS += $(shell freetype-config --cflags)
# google-test integration magic.
GTEST_DIR ?= gtest
TESTS = $(GTEST_DIR)/src/gtest-all.o $(GTEST_DIR)/src/gtest_main.o \
$(patsubst %.cc,%.o,$(wildcard *_test.cc))
$(TESTS): CXXFLAGS += -I$(GTEST_DIR)/include -I$(GTEST_DIR) -pthread
$(filter gtest%,$(TESTS)): CXXFLAGS := $(filter-out -MD -Wall,$(CXXFLAGS))
test: $(TESTS) $(SOURCES) ; $(LINK.cc) $^ $(LDLIBS) -lpthread -o $@
# Recompile sources when headers change.
CXXFLAGS += -MD
-include $(wildcard *.d)