-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
103 lines (89 loc) · 3.4 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
91
92
93
94
95
96
97
98
99
100
101
102
103
VER_MAJOR=3
VER_MINOR=2
VER_RELEASE=1
VERSION=$(VER_MAJOR).$(VER_MINOR).$(VER_RELEASE)
BUILD_DIR=.build
BUILD_DIR_RELEASE=$(BUILD_DIR)_release
BUILD_DIR_DEBUG=$(BUILD_DIR)_debug
BUNDLE_NAME=sviewgl
OUT_NAME=sviewgl
COMPILE_COMMANDS_DIR=.compile_commands
PREFIX?=/usr/local
UNAME=$(shell uname -s)
ifeq ($(UNAME), Darwin)
BUNDLE_NAME=sviewgl.app
OUT_NAME="Simple Viewer GL.app"
endif
all:
@echo "Usage:"
@echo " make <release | debug> - make release or debug application"
@echo " make install - install application"
@echo " make <cppcheck> - do static code verification"
@echo " make <make_tar> - make tar.gz source package"
@echo " make <make_deb> - make DEB package"
@echo " make <make_rpm> - make RPM package"
@echo " make <clean> - cleanup directory"
release:
$(shell if [ ! -d $(BUILD_DIR_RELEASE) ]; then mkdir $(BUILD_DIR_RELEASE); fi)
cd $(BUILD_DIR_RELEASE) && \
cmake .. \
-Wno-dev \
-DCMAKE_BUILD_TYPE=Release \
-DAPP_VERSION_MAJOR:STRING=$(VER_MAJOR) \
-DAPP_VERSION_MINOR:STRING=$(VER_MINOR) \
-DAPP_VERSION_RELEASE:STRING=$(VER_RELEASE) && \
make -j
rm -fr $(OUT_NAME) && cp -r $(BUILD_DIR_RELEASE)/$(BUNDLE_NAME) $(OUT_NAME)
debug:
$(shell if [ ! -d $(BUILD_DIR_DEBUG) ]; then mkdir $(BUILD_DIR_DEBUG); fi)
cd $(BUILD_DIR_DEBUG) && \
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DAPP_VERSION_MAJOR:STRING=$(VER_MAJOR) \
-DAPP_VERSION_MINOR:STRING=$(VER_MINOR) \
-DAPP_VERSION_RELEASE:STRING=$(VER_RELEASE) && \
make -j
rm -fr $(OUT_NAME) && cp -r $(BUILD_DIR_DEBUG)/$(BUNDLE_NAME) $(OUT_NAME)
build_compile_commands:
$(shell if [ ! -d $(COMPILE_COMMANDS_DIR) ]; then mkdir $(COMPILE_COMMANDS_DIR); fi )
cd $(COMPILE_COMMANDS_DIR) && \
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DAPP_VERSION_MAJOR:STRING=$(VER_MAJOR) \
-DAPP_VERSION_MINOR:STRING=$(VER_MINOR) \
-DAPP_VERSION_RELEASE:STRING=$(VER_RELEASE)
rm -f compile_commands.json ; \
ln -s $(COMPILE_COMMANDS_DIR)/compile_commands.json compile_commands.json
cppcheck:
cppcheck \
-DEXIF_SUPPORT=1 \
-DLCMS2_SUPPORT=1 \
-DJPEG2000_SUPPORT=1 \
-DGIF_SUPPORT=1 \
-DTIFF_SUPPORT=1 \
-DWEBP_SUPPORT=1 \
-DOPENEXR_SUPPORT=1 \
-DIMLIB2_SUPPORT=1 \
-j 1 \
--std=c++14 \
--enable=all \
-f -I src src/ 2> cppcheck-output
clean:
rm -fr $(BUILD_DIR)* $(OUT_NAME) $(BUNDLE_NAME) $(COMPILE_COMMANDS_DIR) \
$(BUNDLE_NAME)-$(VERSION)* $(BUNDLE_NAME)_$(VERSION)* \
*.log *.tasks *.sh *.xz *.list *.deb \
cppcheck-output strace_out cov-int
install:
install -m 755 -d $(DESTDIR)$(PREFIX)/bin
install -m 755 $(BUNDLE_NAME) $(DESTDIR)$(PREFIX)/bin
make_tar: clean
install -d $(BUNDLE_NAME)-$(VERSION)
cp -R cmake src res dist/debian INSTALL README.md CMakeLists.txt Makefile sviewgl.desktop res/Icon-1024.png dist/fedora/* dist/gentoo/* $(BUNDLE_NAME)-$(VERSION)
mv $(BUNDLE_NAME)-$(VERSION)/simpleviewer-gl-_VERSION_.ebuild $(BUNDLE_NAME)-$(VERSION)/simpleviewer-gl-$(VERSION).ebuild
sed "s/_VERSION_/$(VERSION)/" -i $(BUNDLE_NAME)-$(VERSION)/$(BUNDLE_NAME).spec
sed "s/_VERSION_/$(VERSION)/" -i $(BUNDLE_NAME)-$(VERSION)/debian/changelog
tar -zf $(BUNDLE_NAME)-$(VERSION).tar.gz -c $(BUNDLE_NAME)-$(VERSION)
make_deb: make_tar
mv $(BUNDLE_NAME)-$(VERSION).tar.gz $(BUNDLE_NAME)_$(VERSION).orig.tar.gz
cd $(BUNDLE_NAME)-$(VERSION) ; PREFIX=/usr dpkg-buildpackage -F -tc
make_rpm: make_tar
rpmbuild -ta $(BUNDLE_NAME)-$(VERSION).tar.gz