27
27
28
28
echo "configure.php on PHP " . phpversion () . "\n\n" ;
29
29
30
+ // init_argv()
31
+ // init_checks()
32
+ // init_clean()
33
+ // xml_configure()
34
+ // xml_parse()
35
+ // xml_xinclude()
36
+ // xml_validate()
37
+ // phd_sources()
38
+ // phd_version()
39
+ // php_history()
40
+
30
41
const RNG_SCHEMA_DIR = __DIR__ . DIRECTORY_SEPARATOR . 'docbook ' . DIRECTORY_SEPARATOR . 'docbook-v5.2-os ' . DIRECTORY_SEPARATOR . 'rng ' . DIRECTORY_SEPARATOR ;
31
42
const RNG_SCHEMA_FILE = RNG_SCHEMA_DIR . 'docbook.rng ' ;
32
43
const RNG_SCHEMA_XINCLUDE_FILE = RNG_SCHEMA_DIR . 'docbookxi.rng ' ;
@@ -81,6 +92,29 @@ function usage() // {{{
81
92
HELPCHUNK ;
82
93
} // }}}
83
94
95
+ function realpain ( string $ path , bool $ touch = false , bool $ mkdir = false ) : string
96
+ {
97
+ // pain is real
98
+
99
+ // care for external XML tools (realpath() everywhere)
100
+ // care for Windows builds (foward slashes everywhere)
101
+ // avoid `cd` and chdir() like the plague
102
+
103
+ $ path = str_replace ( "\\" , '/ ' , $ path );
104
+
105
+ if ( $ mkdir && ! file_exists ( $ path ) )
106
+ mkdir ( $ path , recursive: true );
107
+
108
+ if ( $ touch && ! file_exists ( $ path ) )
109
+ touch ( $ path );
110
+
111
+ $ res = realpath ( $ path );
112
+ if ( is_string ( $ res ) )
113
+ $ path = $ res ;
114
+
115
+ return $ path ;
116
+ }
117
+
84
118
function errbox ($ msg ) {
85
119
$ len = strlen ($ msg )+4 ;
86
120
$ line = "+ " . str_repeat ("- " , $ len ) . "+ " ;
@@ -251,7 +285,7 @@ function generate_sources_file() // {{{
251
285
echo 'Iterating over files for sources info... ' ;
252
286
$ en_dir = "{$ ac ['rootdir ' ]}/ {$ ac ['EN_DIR ' ]}" ;
253
287
$ source_langs = array (
254
- array ('base ' , $ ac ['srcdir ' ], array ('manual.xml.in ' , 'funcindex.xml ' )),
288
+ array ('base ' , $ ac ['srcdir ' ], array ('manual.xml ' , 'funcindex.xml ' )),
255
289
array ('en ' , $ en_dir , find_xml_files ($ en_dir )),
256
290
);
257
291
if ($ ac ['LANG ' ] !== 'en ' ) {
@@ -630,12 +664,6 @@ function getFileModificationHistory(): array {
630
664
}
631
665
632
666
633
- // We shouldn't be globbing for this. autoconf requires you to tell it which files to use, we should do the same
634
- // Notice how doing it this way results in generating less than half as many files.
635
- $ infiles = array (
636
- 'manual.xml.in ' ,
637
- );
638
-
639
667
// Show local repository status to facilitate debug
640
668
641
669
$ repos = array ();
@@ -659,19 +687,45 @@ function getFileModificationHistory(): array {
659
687
$ output = str_replace ( "\n\n" , "\n" , $ output );
660
688
echo "\n" , trim ( $ output ) . "\n\n" ;
661
689
662
- foreach ($ infiles as $ in ) {
663
- $ in = chop ("{$ ac ['basedir ' ]}/ {$ in }" );
664
690
665
- $ out = substr ($ in , 0 , -3 );
666
- echo "Generating {$ out }... " ;
667
- if (generate_output_file ($ in , $ out , $ ac )) {
668
- echo "done \n" ;
669
- } else {
670
- echo "fail \n" ;
671
- errors_are_bad (117 );
691
+ xml_configure ();
692
+ function xml_configure ()
693
+ {
694
+ global $ ac ;
695
+ $ lang = $ ac ["LANG " ];
696
+ $ conf = [];
697
+
698
+ $ conf [] = "<!ENTITY LANG ' $ lang'> " ;
699
+
700
+ if ( $ lang == 'en ' )
701
+ {
702
+ realpain ( __DIR__ . "/temp/empty " , touch: true );
703
+ $ trans1 = realpain ( __DIR__ . "/temp/empty " );
704
+ $ trans2 = realpain ( __DIR__ . "/temp/empty " );
705
+ $ trans3 = realpain ( __DIR__ . "/temp/empty " );
706
+ }
707
+ else
708
+ {
709
+ $ trans1 = realpain ( __DIR__ . "/../ $ lang/language-defs.ent " );
710
+ $ trans2 = realpain ( __DIR__ . "/../ $ lang/language-snippets.ent " );
711
+ $ trans3 = realpain ( __DIR__ . "/../ $ lang/extensions.ent " );
672
712
}
713
+ $ conf [] = "<!ENTITY % translation-defs SYSTEM ' $ trans1'> " ;
714
+ $ conf [] = "<!ENTITY % translation-snippets SYSTEM ' $ trans2'> " ;
715
+ $ conf [] = "<!ENTITY % translation-extensions SYSTEM ' $ trans3'> " ;
716
+
717
+ if ( $ ac ['CHMENABLED ' ] == 'yes ' )
718
+ {
719
+ $ chmpath = realpain ( __DIR__ . "/chm/manual.chm.xml " );
720
+ $ conf [] = "<!ENTITY manual.chmonly SYSTEM ' $ chmpath'> " ;
721
+ }
722
+ else
723
+ $ conf [] = "<!ENTITY manual.chmonly ''> " ;
724
+
725
+ file_put_contents ( __DIR__ . "/temp/manual.conf " , implode ( "\n" , $ conf ) );
673
726
}
674
727
728
+
675
729
if ($ ac ['SEGFAULT_ERROR ' ] === 'yes ' ) {
676
730
libxml_use_internal_errors (true );
677
731
}
0 commit comments