@@ -14,17 +14,69 @@ all_from 'lib/Zonemaster/LDNS.pm';
1414repository ' https://github.com/zonemaster/zonemaster-ldns' ;
1515bugtracker ' https://github.com/zonemaster/zonemaster-ldns/issues' ;
1616
17+ =head1 Optional features
18+
19+ =over
20+
21+ =item --[no-]ed25519
22+
23+ Enable (or disable) support for Ed25519 in both openssl and ldns.
24+ Enabled by default.
25+
26+ =item --[no-]idn
27+
28+ Enable (or disable) support for converting IDN labels in U-label format (with
29+ non-ASCII Unicode characters) to the same IDN labels in A-label format (encoded
30+ in ASCII).
31+ Enabled by default.
32+
33+ =item --[no-]internal-ldns
34+
35+ When enabled, an included version of ldns is statically linked into
36+ Zonemaster::LDNS.
37+ When disabled, libldns is dynamically linked just like other dependencies.
38+ Enabled by default.
39+
40+ =item --[no-]randomize
41+
42+ Experimental.
43+ Randomizes the capitalization of returned domain names.
44+ Disabled by default.
45+
46+ =item --prefix-openssl=PATH
47+
48+ Search for OpenSSL headers and libraries in PATH.
49+ The LDNS script will look for an "include" and a "lib" folder.
50+
51+ =item --openssl-inc=PATH
52+
53+ Search for OpenSSL include in PATH.
54+ The PATH is passed to the LDNS compiler via the CFLAGS variable.
55+
56+ =item --openssl-lib=PATH
57+
58+ Search for OpenSSL library in PATH.
59+ The PATH is passed to the LDNS compiler via the LDFLAGS variable.
60+
61+ =back
62+
63+ =cut
64+
1765my $opt_ed25519 = 1;
1866my $opt_idn = 1;
1967my $opt_internal_ldns = 1;
2068my $opt_randomize = 0;
2169my $opt_prefix_openssl = " " ;
70+ my $opt_openssl_inc = " " ;
71+ my $opt_openssl_lib = " " ;
2272GetOptions(
2373 ' ed25519!' => \$opt_ed25519 ,
2474 ' idn!' => \$opt_idn ,
2575 ' internal-ldns!' => \$opt_internal_ldns ,
2676 ' randomize!' => \$opt_randomize ,
2777 ' prefix-openssl=s' => \$opt_prefix_openssl ,
78+ ' openssl-inc=s' => \$opt_openssl_inc ,
79+ ' openssl-lib=s' => \$opt_openssl_lib ,
2880);
2981
3082configure_requires ' Devel::CheckLib' ;
@@ -42,12 +94,31 @@ cc_src_paths 'src';
4294# OpenSSL
4395
4496my %assert_lib_args_openssl ;
45- if ( $opt_prefix_openssl ) {
46- print " Custom prefix for OpenSSL: $opt_prefix_openssl \n " ;
47- cc_include_paths " $opt_prefix_openssl /include" ;
48- cc_libs " -L$opt_prefix_openssl /lib" , " crypto" ;
49- $assert_lib_args_openssl {incpath } = " $opt_prefix_openssl /include" ;
50- $assert_lib_args_openssl {libpath } = " $opt_prefix_openssl /lib" ;
97+ my $custom_openssl = ( $opt_prefix_openssl or $opt_openssl_inc or $opt_openssl_lib );
98+ if ( $custom_openssl ) {
99+ my $openssl_incpath = " " ;
100+ my $openssl_libpath = " " ;
101+
102+ if ( $opt_prefix_openssl ) {
103+ print " Custom prefix for OpenSSL: $opt_prefix_openssl \n " ;
104+ $openssl_incpath = " $opt_prefix_openssl /include" ;
105+ $openssl_libpath = " $opt_prefix_openssl /lib" ;
106+ }
107+
108+ if ( $opt_openssl_inc ) {
109+ print " Custom include directory for OpenSSL: $opt_openssl_inc \n " ;
110+ $openssl_incpath = " $opt_openssl_inc " ;
111+ }
112+
113+ if ( $opt_openssl_lib ) {
114+ print " Custom library directory for OpenSSL: $opt_openssl_lib \n " ;
115+ $openssl_libpath = " $opt_openssl_lib " ;
116+ }
117+
118+ cc_include_paths " $openssl_incpath " ;
119+ cc_libs " -L$openssl_libpath " , " crypto" ;
120+ $assert_lib_args_openssl {incpath } = " $openssl_incpath " ;
121+ $assert_lib_args_openssl {libpath } = " $openssl_libpath " ;
51122}
52123else {
53124 cc_libs ' crypto' ;
@@ -99,12 +170,11 @@ else {
99170if ( $opt_idn ) {
100171 print " Feature idn enabled\n " ;
101172 check_lib_or_exit(
102- lib => ' idn ' ,
103- header => ' idna .h' ,
173+ lib => ' idn2 ' ,
174+ header => ' idn2 .h' ,
104175 function =>
105- ' if(strcmp(IDNA_ACE_PREFIX,"xn--")==0) return 0; else return 1;'
106- );
107- cc_libs ' idn' ;
176+ ' return IDN2_OK;' );
177+ cc_libs ' idn2' ;
108178 cc_define ' -DWE_CAN_HAZ_IDN' ;
109179}
110180else {
@@ -156,11 +226,18 @@ CONFIGURE_FLAGS += --disable-ldns-config --disable-dane
156226
157227END_CONFIGURE_FLAGS
158228
159- my $openssl_make = <<END_ED25519 ;
229+ my $openssl_make = <<END_OPENSSL_MAKE ;
160230
161231CONFIGURE_FLAGS += --with-ssl=$opt_prefix_openssl
162232
163- END_ED25519
233+ END_OPENSSL_MAKE
234+
235+ my $openssl_flags = <<END_OPENSSL_FLAGS ;
236+
237+ CFLAGS += -I$opt_openssl_inc
238+ LDFLAGS += -L$opt_openssl_lib
239+
240+ END_OPENSSL_FLAGS
164241
165242 my $ed25519_make = <<'END_ED25519' ;
166243
@@ -176,13 +253,14 @@ END_NO_ED25519
176253
177254 my $internal_ldns_make = <<'END_INTERNAL_LDNS' ;
178255
256+ CFLAGS += -fPIC
179257LDFROM += ldns/.libs/libldns.a
180258
181259config :: ldns/.libs/libldns.a
182260
183261ldns/.libs/libldns.a: ldns/configure
184262 cd ldns ;\
185- ./configure CFLAGS=-fPIC $(CONFIGURE_FLAGS) ;\
263+ ./configure CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" $(CONFIGURE_FLAGS) ;\
186264 make lib
187265
188266ldns/configure:
@@ -203,6 +281,7 @@ END_INTERNAL_LDNS
203281 $postamble .= $openssl_make if $opt_prefix_openssl ;
204282 $postamble .= $ed25519_make if $opt_ed25519 ;
205283 $postamble .= $no_ed25519_make if !$opt_ed25519 ;
284+ $postamble .= $openssl_flags if ( $opt_openssl_inc or $opt_openssl_lib );
206285 $postamble .= $internal_ldns_make ;
207286 }
208287
0 commit comments