-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
247 lines (221 loc) · 5.75 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
ITERATION=1.lru
PREFIX=/usr/local
LICENSE=GPL-3.0
VENDOR="Free Software Foundation"
MAINTAINER="Ryan Parman"
DESCRIPTION="The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, and Go, as well as libraries for these languages."
URL=https://gcc.gnu.org
ACTUALOS=$(shell osqueryi "select * from os_version;" --json | jq -r ".[].name")
EL=$(shell if [[ "$(ACTUALOS)" == "Amazon Linux AMI" ]]; then echo alami; else echo el; fi)
RHEL=$(shell [[ -f /etc/centos-release ]] && rpm -q --queryformat '%{VERSION}' centos-release)
#-------------------------------------------------------------------------------
all:
@echo "Run 'make gcc6' or 'make gcc7'."
#-------------------------------------------------------------------------------
.PHONY: gcc6
gcc6: gcc6-vars info clean install-deps gcc-compile install-tmp package move
.PHONY: gcc7
gcc7: gcc7-vars info clean install-deps gcc-compile install-tmp package move
#-------------------------------------------------------------------------------
.PHONY: gcc6-vars
gcc6-vars:
$(eval NAME=gcc6)
$(eval VERSION=6.4.0)
.PHONY: gcc7-vars
gcc7-vars:
$(eval NAME=gcc7)
$(eval VERSION=7.2.0)
#-------------------------------------------------------------------------------
.PHONY: info
info:
@ echo "NAME: $(NAME)"
@ echo "VERSION: $(VERSION)"
@ echo "ITERATION: $(ITERATION)"
@ echo "PREFIX: $(PREFIX)"
@ echo "LICENSE: $(LICENSE)"
@ echo "VENDOR: $(VENDOR)"
@ echo "MAINTAINER: $(MAINTAINER)"
@ echo "DESCRIPTION: $(DESCRIPTION)"
@ echo "URL: $(URL)"
@ echo "OS: $(ACTUALOS)"
@ echo "EL: $(EL)"
@ echo "RHEL: $(RHEL)"
@ echo " "
#-------------------------------------------------------------------------------
.PHONY: clean
clean:
rm -Rf /tmp/installdir* gcc* gmon.out
#-------------------------------------------------------------------------------
.PHONY: install-deps
install-deps:
yum -y install \
autoconf \
autogen \
automake \
binutils \
bzip2-devel \
dejagnu \
diffutils \
flex-devel \
gawk \
gcc \
gcc-c++ \
gcc-gnat \
gettext-devel \
gmp-devel \
gperf \
guile-devel \
gzip \
libmpc-devel \
m4 \
make \
mpfr \
patch \
perl \
python27 \
tar \
tcl-devel \
texinfo-tex \
;
#-------------------------------------------------------------------------------
.PHONY: gcc-compile
gcc-compile:
wget http://www.netgull.com/gcc/releases/gcc-$(VERSION)/gcc-$(VERSION).tar.gz;
tar zxvf gcc-$(VERSION).tar.gz;
cd ./gcc-$(VERSION) && \
contrib/download_prerequisites && \
cd .. && \
mkdir -p gcc-build && cd gcc-build && \
../gcc-$(VERSION)/configure \
--prefix=$(PREFIX) \
--enable-host-shared \
--disable-multilib \
--enable-threads \
--enable-tls \
--enable-bootstrap \
--enable-gold=yes \
--enable-ld=yes \
--enable-compressed-debug-sections=all \
--enable-libada \
--enable-libssp \
--enable-lto \
--enable-objc-gc \
--enable-vtable-verify \
--enable-generated-files-in-srcdir \
--enable-targets=all \
&& \
make -j$$(nproc);
#-------------------------------------------------------------------------------
.PHONY: install-tmp
install-tmp:
mkdir -p /tmp/installdir-$(NAME)-$(VERSION);
cd ./gcc-build && \
make install DESTDIR=/tmp/installdir-$(NAME)-$(VERSION);
#-------------------------------------------------------------------------------
.PHONY: package
package:
# Main package
fpm \
-f \
-d "$(NAME)-libs = $(VERSION)-$(ITERATION).$(EL)$(RHEL)" \
-s dir \
-t rpm \
-n $(NAME) \
-v $(VERSION) \
-C /tmp/installdir-$(NAME)-$(VERSION) \
-m $(MAINTAINER) \
--iteration $(ITERATION) \
--license $(LICENSE) \
--vendor $(VENDOR) \
--prefix / \
--url $(URL) \
--description $(DESCRIPTION) \
--rpm-defattrdir 0755 \
--rpm-digest md5 \
--rpm-compression gzip \
--rpm-os linux \
--rpm-changelog CHANGELOG-$(NAME).txt \
--rpm-dist $(EL)$(RHEL) \
--rpm-auto-add-directories \
usr/local/bin \
;
# Libs package
fpm \
-f \
-s dir \
-t rpm \
-n $(NAME)-libs \
-v $(VERSION) \
-C /tmp/installdir-$(NAME)-$(VERSION) \
-m $(MAINTAINER) \
--iteration $(ITERATION) \
--license $(LICENSE) \
--vendor $(VENDOR) \
--prefix / \
--url $(URL) \
--description $(DESCRIPTION) \
--rpm-defattrdir 0755 \
--rpm-digest md5 \
--rpm-compression gzip \
--rpm-os linux \
--rpm-changelog CHANGELOG-$(NAME).txt \
--rpm-dist $(EL)$(RHEL) \
--rpm-auto-add-directories \
usr/local/lib \
usr/local/lib64 \
usr/local/libexec \
;
# Development package
fpm \
-f \
-d "$(NAME) = $(VERSION)-$(ITERATION).$(EL)$(RHEL)" \
-s dir \
-t rpm \
-n $(NAME)-devel \
-v $(VERSION) \
-C /tmp/installdir-$(NAME)-$(VERSION) \
-m $(MAINTAINER) \
--iteration $(ITERATION) \
--license $(LICENSE) \
--vendor $(VENDOR) \
--prefix / \
--url $(URL) \
--description $(DESCRIPTION) \
--rpm-defattrdir 0755 \
--rpm-digest md5 \
--rpm-compression gzip \
--rpm-os linux \
--rpm-changelog CHANGELOG-$(NAME).txt \
--rpm-dist $(EL)$(RHEL) \
--rpm-auto-add-directories \
usr/local/include \
;
# Documentation package
fpm \
-f \
-d "$(NAME) = $(VERSION)-$(ITERATION).$(EL)$(RHEL)" \
-s dir \
-t rpm \
-n $(NAME)-doc \
-v $(VERSION) \
-C /tmp/installdir-$(NAME)-$(VERSION) \
-m $(MAINTAINER) \
--iteration $(ITERATION) \
--license $(LICENSE) \
--vendor $(VENDOR) \
--prefix / \
--url $(URL) \
--description $(DESCRIPTION) \
--rpm-defattrdir 0755 \
--rpm-digest md5 \
--rpm-compression gzip \
--rpm-os linux \
--rpm-changelog CHANGELOG-$(NAME).txt \
--rpm-dist $(EL)$(RHEL) \
--rpm-auto-add-directories \
usr/local/share \
;
#-------------------------------------------------------------------------------
.PHONY: move
move:
[[ -d /vagrant/repo ]] && mv *.rpm /vagrant/repo/