@@ -25,12 +25,20 @@ import nodedownload
2525# parse our options
2626parser = optparse .OptionParser ()
2727
28+ valid_os = ('win' , 'mac' , 'solaris' , 'freebsd' , 'openbsd' , 'linux' , 'android' )
29+ valid_arch = ('arm' , 'arm64' , 'ia32' , 'mips' , 'mipsel' , 'x32' , 'x64' )
30+ valid_arm_float_abi = ('soft' , 'softfp' , 'hard' )
31+ valid_mips_arch = ('loongson' , 'r1' , 'r2' , 'r6' , 'rx' )
32+ valid_mips_fpu = ('fp32' , 'fp64' , 'fpxx' )
33+ valid_mips_float_abi = ('soft' , 'hard' )
34+
2835# Options should be in alphabetical order but keep --prefix at the top,
2936# that's arguably the one people will be looking for most.
3037parser .add_option ('--prefix' ,
3138 action = 'store' ,
3239 dest = 'prefix' ,
33- help = 'select the install prefix (defaults to /usr/local)' )
40+ default = '/usr/local' ,
41+ help = 'select the install prefix [default: %default]' )
3442
3543parser .add_option ('--debug' ,
3644 action = 'store_true' ,
@@ -40,14 +48,14 @@ parser.add_option('--debug',
4048parser .add_option ('--dest-cpu' ,
4149 action = 'store' ,
4250 dest = 'dest_cpu' ,
43- help = 'CPU architecture to build for. '
44- 'Valid values are: arm, arm64, ia32, mips, mipsel, x32, x64' )
51+ choices = valid_arch ,
52+ help = 'CPU architecture to build for ({0})' . format ( ', ' . join ( valid_arch )) )
4553
4654parser .add_option ('--dest-os' ,
4755 action = 'store' ,
4856 dest = 'dest_os' ,
49- help = 'operating system to build for. Valid values are: '
50- 'win, mac, solaris, freebsd, openbsd, linux, android' )
57+ choices = valid_os ,
58+ help = 'operating system to build for ({0})' . format ( ', ' . join ( valid_os )) )
5159
5260parser .add_option ('--gdb' ,
5361 action = 'store_true' ,
@@ -83,7 +91,8 @@ parser.add_option('--shared-http-parser-includes',
8391parser .add_option ('--shared-http-parser-libname' ,
8492 action = 'store' ,
8593 dest = 'shared_http_parser_libname' ,
86- help = 'alternative lib name to link to (default: \' http_parser\' )' )
94+ default = 'http_parser' ,
95+ help = 'alternative lib name to link to [default: %default]' )
8796
8897parser .add_option ('--shared-http-parser-libpath' ,
8998 action = 'store' ,
@@ -103,7 +112,8 @@ parser.add_option('--shared-libuv-includes',
103112parser .add_option ('--shared-libuv-libname' ,
104113 action = 'store' ,
105114 dest = 'shared_libuv_libname' ,
106- help = 'alternative lib name to link to (default: \' uv\' )' )
115+ default = 'uv' ,
116+ help = 'alternative lib name to link to [default: %default]' )
107117
108118parser .add_option ('--shared-libuv-libpath' ,
109119 action = 'store' ,
@@ -123,7 +133,8 @@ parser.add_option('--shared-openssl-includes',
123133parser .add_option ('--shared-openssl-libname' ,
124134 action = 'store' ,
125135 dest = 'shared_openssl_libname' ,
126- help = 'alternative lib name to link to (default: \' crypto,ssl\' )' )
136+ default = 'crypto,ssl' ,
137+ help = 'alternative lib name to link to [default: %default]' )
127138
128139parser .add_option ('--shared-openssl-libpath' ,
129140 action = 'store' ,
@@ -143,7 +154,8 @@ parser.add_option('--shared-zlib-includes',
143154parser .add_option ('--shared-zlib-libname' ,
144155 action = 'store' ,
145156 dest = 'shared_zlib_libname' ,
146- help = 'alternative lib name to link to (default: \' z\' )' )
157+ default = 'z' ,
158+ help = 'alternative lib name to link to [default: %default]' )
147159
148160parser .add_option ('--shared-zlib-libpath' ,
149161 action = 'store' ,
@@ -170,26 +182,33 @@ parser.add_option('--v8-options',
170182parser .add_option ('--with-arm-float-abi' ,
171183 action = 'store' ,
172184 dest = 'arm_float_abi' ,
173- help = 'specifies which floating-point ABI to use. Valid values are: '
174- 'soft, softfp, hard' )
185+ choices = valid_arm_float_abi ,
186+ help = 'specifies which floating-point ABI to use ({0}).' .format (
187+ ', ' .join (valid_arm_float_abi )))
175188
176189parser .add_option ('--with-mips-arch-variant' ,
177190 action = 'store' ,
178191 dest = 'mips_arch_variant' ,
179192 default = 'r2' ,
180- help = 'MIPS arch variant: loongson, r1, r2, r6, rx' )
193+ choices = valid_mips_arch ,
194+ help = 'MIPS arch variant ({0}) [default: %default]' .format (
195+ ', ' .join (valid_mips_arch )))
181196
182197parser .add_option ('--with-mips-fpu-mode' ,
183198 action = 'store' ,
184199 dest = 'mips_fpu_mode' ,
185200 default = 'fp32' ,
186- help = 'MIPS FPU mode: fp32, fp64, fpxx' )
201+ choices = valid_mips_fpu ,
202+ help = 'MIPS FPU mode ({0}) [default: %default]' .format (
203+ ', ' .join (valid_mips_fpu )))
187204
188205parser .add_option ('--with-mips-float-abi' ,
189206 action = 'store' ,
190207 dest = 'mips_float_abi' ,
191208 default = 'hard' ,
192- help = 'MIPS floating-point ABI: soft, hard' )
209+ choices = valid_mips_float_abi ,
210+ help = 'MIPS floating-point ABI ({0}) [default: %default]' .format (
211+ ', ' .join (valid_mips_float_abi )))
193212
194213parser .add_option ('--with-dtrace' ,
195214 action = 'store_true' ,
@@ -219,12 +238,14 @@ parser.add_option('--with-icu-path',
219238parser .add_option ('--with-icu-locales' ,
220239 action = 'store' ,
221240 dest = 'with_icu_locales' ,
222- help = 'Comma-separated list of locales for "small-icu". Default: "root,en". "root" is assumed.' )
241+ default = 'root,en' ,
242+ help = 'Comma-separated list of locales for "small-icu". "root" is assumed. '
243+ '[default: %default]' )
223244
224245parser .add_option ('--with-intl' ,
225246 action = 'store' ,
226247 dest = 'with_intl' ,
227- help = 'Intl mode: none, full-icu, small-icu ( default is none) ' )
248+ help = 'Intl mode: none, full-icu, small-icu [ default: none] ' )
228249
229250parser .add_option ('--with-icu-source' ,
230251 action = 'store' ,
@@ -583,44 +604,35 @@ def configure_node(o):
583604def configure_libz (o ):
584605 o ['variables' ]['node_shared_zlib' ] = b (options .shared_zlib )
585606
586- # assume shared_zlib if one of these is set?
607+ if b (options .shared_zlib ) == True :
608+ o ['libraries' ] += ['-l%s' % options .shared_zlib_libname ]
587609 if options .shared_zlib_libpath :
588610 o ['libraries' ] += ['-L%s' % options .shared_zlib_libpath ]
589- if options .shared_zlib_libname :
590- o ['libraries' ] += ['-l%s' % options .shared_zlib_libname ]
591- elif options .shared_zlib :
592- o ['libraries' ] += ['-lz' ]
593611 if options .shared_zlib_includes :
594612 o ['include_dirs' ] += [options .shared_zlib_includes ]
595613
596614
597615def configure_http_parser (o ):
598616 o ['variables' ]['node_shared_http_parser' ] = b (options .shared_http_parser )
599-
600- # assume shared http_parser if one of these is set?
617+
618+ if b (options .shared_http_parser ) == True :
619+ o ['libraries' ] += ['-l%s' % options .shared_http_parser_libname ]
601620 if options .shared_http_parser_libpath :
602621 o ['libraries' ] += ['-L%s' % options .shared_http_parser_libpath ]
603- if options .shared_http_parser_libname :
604- o ['libraries' ] += ['-l%s' % options .shared_http_parser_libname ]
605- elif options .shared_http_parser :
606- o ['libraries' ] += ['-lhttp_parser' ]
607622 if options .shared_http_parser_includes :
608623 o ['include_dirs' ] += [options .shared_http_parser_includes ]
609624
610625
611626def configure_libuv (o ):
612627 o ['variables' ]['node_shared_libuv' ] = b (options .shared_libuv )
613628
614- # assume shared libuv if one of these is set?
629+ if b (options .shared_libuv ) == True :
630+ o ['libraries' ] += ['-l%s' % options .shared_libuv_libname ]
615631 if options .shared_libuv_libpath :
616632 o ['libraries' ] += ['-L%s' % options .shared_libuv_libpath ]
617633 else :
618634 o ['variables' ]['uv_library' ] = 'static_library'
619635
620- if options .shared_libuv_libname :
621- o ['libraries' ] += ['-l%s' % options .shared_libuv_libname ]
622- elif options .shared_libuv :
623- o ['libraries' ] += ['-luv' ]
624636 if options .shared_libuv_includes :
625637 o ['include_dirs' ] += [options .shared_libuv_includes ]
626638
@@ -644,15 +656,12 @@ def configure_openssl(o):
644656 if options .shared_openssl :
645657 (libs , cflags ) = pkg_config ('openssl' ) or ('-lssl -lcrypto' , '' )
646658
659+ libnames = options .shared_openssl_libname .split (',' )
660+ o ['libraries' ] += ['-l%s' % s for s in libnames ]
661+
647662 if options .shared_openssl_libpath :
648663 o ['libraries' ] += ['-L%s' % options .shared_openssl_libpath ]
649664
650- if options .shared_openssl_libname :
651- libnames = options .shared_openssl_libname .split (',' )
652- o ['libraries' ] += ['-l%s' % s for s in libnames ]
653- else :
654- o ['libraries' ] += libs .split ()
655-
656665 if options .shared_openssl_includes :
657666 o ['include_dirs' ] += [options .shared_openssl_includes ]
658667 else :
@@ -760,23 +769,14 @@ def configure_intl(o):
760769 return
761770 # --with-intl=<with_intl>
762771 # set the default
763- if with_intl is None :
764- with_intl = 'none' # The default mode of Intl
765- # sanity check localelist
766- if options .with_icu_locales and (with_intl != 'small-icu' ):
767- print 'Error: --with-icu-locales only makes sense with --with-intl=small-icu'
768- sys .exit (1 )
769- if with_intl == 'none' or with_intl is None :
772+ if with_intl in (None , 'none' ):
770773 o ['variables' ]['v8_enable_i18n_support' ] = 0
771774 return # no Intl
772775 elif with_intl == 'small-icu' :
773776 # small ICU (English only)
774777 o ['variables' ]['v8_enable_i18n_support' ] = 1
775778 o ['variables' ]['icu_small' ] = b (True )
776- with_icu_locales = options .with_icu_locales
777- if not with_icu_locales :
778- with_icu_locales = 'root,en'
779- locs = set (with_icu_locales .split (',' ))
779+ locs = set (options .with_icu_locales .split (',' ))
780780 locs .add ('root' ) # must have root
781781 o ['variables' ]['icu_locales' ] = string .join (locs ,',' )
782782 elif with_intl == 'full-icu' :
0 commit comments