forked from sysown/proxysql
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile.BSD
116 lines (97 loc) · 3.49 KB
/
Makefile.BSD
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
104
105
106
107
108
109
110
111
112
113
114
115
116
O0=-O0
O2=-O2
O1=-O1
O3=-O3 -mtune=native
#OPTZ=$(O2)
EXTRALINK=#-pg
ALL_DEBUG=-ggdb -DDEBUG
NO_DEBUG=
DEBUG=${ALL_DEBUG}
#export DEBUG
#export OPTZ
#export EXTRALINK
MAKEFILE?=Makefile.BSD
CC?=gcc
CXX?=g++
.PHONY: default
default: build_deps build_lib build_src
.PHONY: debug
debug: build_deps_debug build_lib_debug build_src_debug
.PHONY: build_deps
build_deps:
cd deps && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE}
.PHONY: build_lib
build_lib:
cd lib && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} -f Makefile.BSD
.PHONY: build_src
build_src:
cd src && OPTZ="${O2} -ggdb" CC=${CC} CXX=${CXX} ${MAKE} -f Makefile.BSD
.PHONY: build_deps_debug
build_deps_debug:
cd deps && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE}
.PHONY: build_lib_debug
build_lib_debug:
cd lib && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} -f Makefile.BSD
.PHONY: build_src_debug
build_src_debug:
cd src && OPTZ="${O0} -ggdb -DDEBUG" CC=${CC} CXX=${CXX} ${MAKE} -f Makefile.BSD
.PHONY: clean
clean:
cd lib && ${MAKE} clean
cd src && ${MAKE} clean
packages: centos7 ubuntu12 ubuntu14
.PHONY: packages
centos7: binaries/proxysql-1.0.1-1.x86_64.rpm
.PHONY: centos
ubuntu12: binaries/proxysql_1.0.1-ubuntu12_amd64.deb
.PHONY: ubuntu12
ubuntu14: binaries/proxysql_1.0.1-ubuntu14_amd64.deb
.PHONY: ubuntu14
binaries/proxysql-1.0.1-1.x86_64.rpm:
# Create CentOS 7 rpm file by creating docker image, running a container and extracting the RPM from the temp container
docker build -t centos7_proxysql --no-cache=true ./docker/images/proxysql/centos7-build
docker run -i --name=centos7_build centos7_proxysql bash &
sleep 5
docker cp centos7_build:/root/rpmbuild/RPMS/x86_64/proxysql-1.0.1-1.x86_64.rpm ./binaries
# docker kill centos7_build
docker rm centos7_build
binaries/proxysql_1.0.1-ubuntu12_amd64.deb:
docker build -t ubuntu12_proxysql --no-cache=true ./docker/images/proxysql/ubuntu-12.04-build
docker run -i --name=ubuntu12_build ubuntu12_proxysql bash &
sleep 5
docker cp ubuntu12_build:/opt/proxysql/proxysql_1.0.1_amd64.deb ./binaries/proxysql_1.0.1-ubuntu12_amd64.deb
# docker kill ubuntu12_build
docker rm ubuntu12_build
binaries/proxysql_1.0.1-ubuntu14_amd64.deb:
docker stop ubuntu14_build || true
docker rm ubuntu14_build || true
docker create --name ubuntu14_build renecannao/proxysql:build-ubuntu14 bash -c "while : ; do sleep 10 ; done"
docker start ubuntu14_build
docker exec ubuntu14_build bash -c "cd /opt; git clone https://github.com/sysown/proxysql.git proxysql"
docker exec ubuntu14_build bash -c "cd /opt/proxysql; ${MAKE} clean && ${MAKE} -j"
docker cp docker/images/proxysql/ubuntu-14.04-build/proxysql.ctl ubuntu14_build:/opt/proxysql/
docker exec ubuntu14_build bash -c "cd /opt/proxysql; cp src/proxysql . ; equivs-build proxysql.ctl"
docker cp ubuntu14_build:/opt/proxysql/proxysql_1.0.1_amd64.deb ./binaries/proxysql_1.0.1-ubuntu14_amd64.deb
docker stop ubuntu14_build
docker rm ubuntu14_build
.PHONY: cleanall
cleanall:
cd deps && ${MAKE} cleanall
cd lib && ${MAKE} clean
cd src && ${MAKE} clean
rm binaries/*deb || true
rm binaries/*rpm || true
install: src/proxysql
install -m 0755 src/proxysql /usr/local/bin
install -m 0600 etc/proxysql.cnf /etc
install -m 0755 etc/init.d/proxysql /etc/init.d
if [ ! -d /var/run/proxysql ]; then mkdir /var/run/proxysql ; fi
update-rc.d proxysql defaults
.PHONY: install
uninstall:
rm /etc/init.d/proxysql
rm /etc/proxysql.cnf
rm /usr/local/bin/proxysql
rmdir /var/run/proxysql 2>/dev/null || true
update-rc.d proxysql remove
.PHONY: uninstall