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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
From 18af66624114a213b033bc5e5e42154c48e404ae Mon Sep 17 00:00:00 2001
From: fu_changjie <fu_changjie@qq.com>
Date: Thu, 10 Dec 2020 15:29:20 +0800
Subject: [PATCH] add option out-dir on configure and use different Makefile
---
configure | 86 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 47 insertions(+), 39 deletions(-)
diff --git a/configure b/configure
index d461294..cad4913 100755
--- a/configure
+++ b/configure
@@ -127,6 +127,7 @@ my $prefix = '/usr/local/openresty';
my $ngx_sbin;
my %resty_opts;
my $dry_run;
+my $out_dir = 'build';
my @ngx_rpaths;
my $cc;
my $cores;
@@ -160,6 +161,11 @@ for my $opt (@ARGV) {
$dry_run = 1;
next;
}
+
+ if ($opt =~ /^--out-dir=(.+)/) {
+ $out_dir = $1;
+ next;
+ }
if ($opt =~ /^--with-make=(.*)/) {
$resty_opts{make} = $1;
@@ -422,10 +428,10 @@ my $cmd = "sh ./configure --prefix=$ngx_prefix"
shell $cmd, $dry_run;
-push @make_cmds, "cd $root_dir/build/$ngx_dir && "
+push @make_cmds, "cd $root_dir/$out_dir/$ngx_dir && "
. "\$(MAKE)";
-push @make_install_cmds, "cd $root_dir/build/$ngx_dir && "
+push @make_install_cmds, "cd $root_dir/$out_dir/$ngx_dir && "
. "\$(MAKE) install DESTDIR=\$(DESTDIR)";
push @make_install_cmds,
@@ -620,18 +626,18 @@ _END_
#unshift @ngx_cc_opts, '-O2';
}
- if (-d 'build') {
- system("rm -rf build") == 0 or
- die "failed to remove directory build/.\n";
+ if (-d "$out_dir") {
+ system("rm -rf $out_dir") == 0 or
+ die "failed to remove directory $out_dir/.\n";
}
- if (-e 'build') {
- die "file or directory \"build\" already exists. please remove it ",
+ if (-e "$out_dir") {
+ die "file or directory \"$out_dir\" already exists. please remove it ",
"first.\n";
}
- shell "cp -rp bundle/ build";
+ shell "cp -rp bundle/ $out_dir";
- cd 'build';
+ cd "$out_dir";
push @make_install_cmds, "mkdir -p \$(DESTDIR)$prefix/",
"-cp $root_dir/COPYRIGHT \$(DESTDIR)$prefix/";
@@ -776,8 +782,8 @@ _END_
}
if ($on_solaris) {
- $extra_opts .= " INSTALL_X='$root_dir/build/install -m 0755' " .
- "INSTALL_F='$root_dir/build/install -m 0644'";
+ $extra_opts .= " INSTALL_X='$root_dir/$out_dir/install -m 0755' " .
+ "INSTALL_F='$root_dir/$out_dir/install -m 0644'";
}
if (defined $cc) {
@@ -837,11 +843,11 @@ _END_
"include", "luajit-2.1");
}
- push @make_cmds, "cd $root_dir/build/$luajit_src && "
+ push @make_cmds, "cd $root_dir/$out_dir/$luajit_src && "
. "\$(MAKE)$extra_opts PREFIX=$luajit_prefix";
my $abs_luajit_src =
- File::Spec->rel2abs(File::Spec->catfile($root_dir, "build",
+ File::Spec->rel2abs(File::Spec->catfile($root_dir, "$out_dir",
$luajit_src),
$root_dir);
@@ -979,10 +985,10 @@ _EOC_
$extra_opts .= " CC=cc";
}
- push @make_cmds, "cd $root_dir/build/$dir && ".
+ push @make_cmds, "cd $root_dir/$out_dir/$dir && ".
"\$(MAKE)$extra_opts";
- push @make_install_cmds, "cd $root_dir/build/$dir && " .
+ push @make_install_cmds, "cd $root_dir/$out_dir/$dir && " .
"\$(MAKE) install$extra_opts";
}
@@ -994,7 +1000,7 @@ _EOC_
"LUA_LIB_DIR=$lualib_prefix";
if ($on_solaris) {
- $extra_opts .= " INSTALL=$root_dir/build/install";
+ $extra_opts .= " INSTALL=$root_dir/$out_dir/install";
}
if ($opts->{debug}) {
@@ -1017,10 +1023,10 @@ _EOC_
$extra_opts .= " CC=cc";
}
- push @make_cmds, "cd $root_dir/build/$dir && " .
+ push @make_cmds, "cd $root_dir/$out_dir/$dir && " .
"\$(MAKE)$extra_opts";
- push @make_install_cmds, "cd $root_dir/build/$dir && " .
+ push @make_install_cmds, "cd $root_dir/$out_dir/$dir && " .
"\$(MAKE) install$extra_opts";
}
@@ -1047,7 +1053,7 @@ _EOC_
}
if ($on_solaris) {
- $extra_opts .= " INSTALL=$root_dir/build/install";
+ $extra_opts .= " INSTALL=$root_dir/$out_dir/install";
if ($opts->{debug}) {
$extra_opts .= " CFLAGS=\"-g -O -Wall\"";
}
@@ -1068,10 +1074,10 @@ _EOC_
$extra_opts .= " CC=cc";
}
- push @make_cmds, "cd $root_dir/build/$dir && ".
+ push @make_cmds, "cd $root_dir/$out_dir/$dir && ".
"\$(MAKE)$extra_opts";
- push @make_install_cmds, "cd $root_dir/build/$dir && " .
+ push @make_install_cmds, "cd $root_dir/$out_dir/$dir && " .
"\$(MAKE) install$extra_opts";
}
@@ -1098,7 +1104,7 @@ _EOC_
}
if ($on_solaris) {
- $extra_opts .= " INSTALL=$root_dir/build/install";
+ $extra_opts .= " INSTALL=$root_dir/$out_dir/install";
if ($opts->{debug}) {
$extra_opts .= " CFLAGS=\"-g -O -Wall\"";
@@ -1120,10 +1126,10 @@ _EOC_
$extra_opts .= " CC=cc";
}
- push @make_cmds, "cd $root_dir/build/$dir && ".
+ push @make_cmds, "cd $root_dir/$out_dir/$dir && ".
"\$(MAKE)$extra_opts";
- push @make_install_cmds, "cd $root_dir/build/$dir && " .
+ push @make_install_cmds, "cd $root_dir/$out_dir/$dir && " .
"\$(MAKE) install$extra_opts";
}
@@ -1146,8 +1152,8 @@ _EOC_
} else {
$target_dir = "\$(DESTDIR)$prefix/bin/";
}
- push @make_install_cmds, "cd $root_dir/build/$opm_dir && "
- . "$root_dir/build/install bin/* $target_dir";
+ push @make_install_cmds, "cd $root_dir/$out_dir/$opm_dir && "
+ . "$root_dir/$out_dir/install bin/* $target_dir";
}
# configure resty-cli:
@@ -1160,8 +1166,8 @@ _EOC_
} else {
$target_dir = "\$(DESTDIR)$prefix/bin/";
}
- push @make_install_cmds, "cd $root_dir/build/$resty_cli_dir && "
- . "$root_dir/build/install bin/* $target_dir";
+ push @make_install_cmds, "cd $root_dir/$out_dir/$resty_cli_dir && "
+ . "$root_dir/$out_dir/install bin/* $target_dir";
if ($platform ne 'msys') {
# patch the resty script:
@@ -1169,7 +1175,7 @@ _EOC_
print "patching the resty script with hard-coded nginx binary ",
"path...\n";
- my $resty_bin = "$root_dir/build/$resty_cli_dir/bin/resty";
+ my $resty_bin = "$root_dir/$out_dir/$resty_cli_dir/bin/resty";
open my $in, $resty_bin
or die "Cannot open $resty_bin for reading: $!\n";
my ($new, $found);
@@ -1199,8 +1205,8 @@ _EOC_
# configure restydoc indexes
push @make_install_cmds,
- "cp $root_dir/build/resty.index \$(DESTDIR)$prefix/",
- "cp -r $root_dir/build/pod \$(DESTDIR)$prefix/";
+ "cp $root_dir/$out_dir/resty.index \$(DESTDIR)$prefix/",
+ "cp -r $root_dir/$out_dir/pod \$(DESTDIR)$prefix/";
# prepare nginx configure line
@@ -1244,9 +1250,9 @@ sub add_lua_lib ($$$) {
my $extra_opts =
" DESTDIR=\$(DESTDIR) LUA_LIB_DIR=$lualib_prefix"
- ." INSTALL=$root_dir/build/install";
+ ." INSTALL=$root_dir/$out_dir/install";
- push @make_install_cmds, "cd $root_dir/build/$dir && " .
+ push @make_install_cmds, "cd $root_dir/$out_dir/$dir && " .
"\$(MAKE) install$extra_opts";
}
}
@@ -1256,6 +1262,8 @@ sub usage ($) {
my $msg = <<'_EOC_';
--help this message
+ --out-dir=DIR set the make output dir
+
--prefix=PATH set the installation prefix (default to /usr/local/openresty)
--with-debug enable debug logging
@@ -1538,13 +1546,13 @@ _EOC_
}
sub gen_makefile {
- if (-f 'Makefile') {
- unlink 'Makefile' or
- die "ERROR: failed to remove existing Makefile: $!\n";
+ if (-f "Makefile-$out_dir") {
+ unlink "Makefile-$out_dir" or
+ die "ERROR: failed to remove existing Makefile-$out_dir: $!\n";
}
- open my $out, ">Makefile" or
- die "Cannot open Makefile for writing: $!\n";
+ open my $out, ">Makefile-$out_dir" or
+ die "Cannot open Makefile-$out_dir for writing: $!\n";
for my $line (@extra_make_env) {
print $out "export $line\n";
@@ -1561,7 +1569,7 @@ sub gen_makefile {
print $out "install: all\n\t" . join("\n\t", @make_install_cmds) . "\n\n";
- print $out "clean:\n\trm -rf build *.exe *.dll openresty-*\n";
+ print $out "clean:\n\trm -rf $out_dir *.exe *.dll openresty-*\n";
close $out;
}
--
2.27.0
|