diff options
author | carlosg <carlosg> | 2006-05-16 15:03:57 +0000 |
---|---|---|
committer | carlosg <carlosg> | 2006-05-16 15:03:57 +0000 |
commit | d2aa1ae17071ea6289bead36e7a27613e535545c (patch) | |
tree | fb89b28bf5ee31c4d38691815facc8788629f5c9 | |
parent | e9b940071d7c926a6be6bb2aca0e38b2bddadbb2 (diff) |
2006-05-15 Carlos Garnacho Parro <carlosg@gnome.org>
* Merged the waiting-the-dbus branch into HEAD
* configure.in, Makefile.am, autogen.sh: bump to 1.9.0, do not use
translations (no longer needed) and fix references to the new .pc file
* GroupsConfig.pm, HostsConfig.pm, IfacesConfig.pm, NFSConfig.pm,
NTPConfig.pm, SMBConfig.pm, ServicesConfig.pm, ServicesList.pm,
SharesList.pm, SystemToolsBackends.pl.in, TimeConfig.pm,
UsersConfig.pm, org.freedesktop.SystemToolsBackends.service.in,
system-tools-backends-2.0.pc.in, test-backends, Init/Services.pm,
Init/ServicesList.pm, Network/Hosts.pm, Network/Ifaces.pm,
Shares/Exports.pm, Shares/NFS.pm, Shares/SMB.pm, Time/NTP.pm,
Time/TimeDate.pm, Users/Groups.pm, Users/Shells.pm, Users/Users.pm,
Utils/Backend.pm, Utils/File.pm, Utils/Monitor.pm, Utils/Parse.pm,
Utils/Platform.pm, Utils/Replace.pm, Utils/Report.pm, Utils/Util.pm,
Utils/XML.pm: Added/refactored files, replace the functionality in
the older *.pl.in files
* boot-conf.in, boot-grub.pl.in, boot-lilo.pl.in, boot-yaboot.pl.in,
boot.pl.in, file.pl.in, general.pl.in, network-conf.in, network.pl.in,
parse.pl.in, platform.pl.in, replace.pl.in, report.pl.in,
service-list.pl.in, service.pl.in, services-conf.in, share.pl.in,
shares-conf.in, system-tools-backends.pc.in, time-conf.in,
users-conf.in, util.pl.in, xml.pl.in: Functional removed files,
they've been replaced with the files above.
* add_amp.sh, debug.pl.in, dhcpd-conf.in, dhcpd.pl.in, disks-conf.in,
display-conf.in, filesys.pl.in, font-conf.in, font.pl.in,
gen-reportcode-list.sh, guess_system.sh, hardware-conf.in,
internetsharing-conf.in, ishare.pl.in, media.pl.in, memory-conf.in,
mouse-conf.in, option.pl, package-conf.in, partition.pl.in,
perldoc.pl, print-conf.in, print.pl.in, process.pl.in,
removable-media.pl.in, rhprinterdb2gstxml.pl, test.pl,
tokenizer.pl.in, type1inst, x.pl.in: Bunch of unused files (or used in
unstable tools), if/when they prove their usefulness, they'll be added
back, but for now they'd better be in the Attic.
-rw-r--r-- | .cvsignore | 8 | ||||
-rw-r--r-- | ChangeLog | 406 | ||||
-rw-r--r-- | GroupsConfig.pm | 69 | ||||
-rw-r--r-- | HostsConfig.pm | 80 | ||||
-rw-r--r-- | IfacesConfig.pm | 79 | ||||
-rw-r--r-- | Init/.cvsignore | 2 | ||||
-rw-r--r-- | Init/Makefile.am | 5 | ||||
-rw-r--r-- | Init/Services.pm | 1170 | ||||
-rw-r--r-- | Init/ServicesList.pm (renamed from service-list.pl.in) | 31 | ||||
-rw-r--r-- | Makefile.am | 75 | ||||
-rw-r--r-- | NFSConfig.pm | 66 | ||||
-rw-r--r-- | NTPConfig.pm (renamed from process.pl.in) | 63 | ||||
-rw-r--r-- | Network/.cvsignore | 2 | ||||
-rw-r--r-- | Network/Hosts.pm | 306 | ||||
-rw-r--r-- | Network/Ifaces.pm | 3372 | ||||
-rw-r--r-- | Network/Makefile.am | 5 | ||||
-rw-r--r-- | SMBConfig.pm | 65 | ||||
-rw-r--r-- | ServicesConfig.pm | 71 | ||||
-rw-r--r-- | ServicesList.pm | 60 | ||||
-rw-r--r-- | Shares/.cvsignore | 2 | ||||
-rw-r--r-- | Shares/Exports.pm (renamed from share.pl.in) | 214 | ||||
-rw-r--r-- | Shares/Makefile.am | 5 | ||||
-rw-r--r-- | Shares/NFS.pm | 212 | ||||
-rw-r--r-- | Shares/SMB.pm | 319 | ||||
-rw-r--r-- | SharesList.pm | 67 | ||||
-rwxr-xr-x | SystemToolsBackends.pl.in | 69 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | Time/.cvsignore | 2 | ||||
-rw-r--r-- | Time/Makefile.am | 5 | ||||
-rw-r--r-- | Time/NTP.pm | 190 | ||||
-rw-r--r-- | Time/TimeDate.pm | 432 | ||||
-rw-r--r-- | TimeConfig.pm | 66 | ||||
-rw-r--r-- | Users/.cvsignore | 2 | ||||
-rw-r--r-- | Users/Groups.pm | 243 | ||||
-rw-r--r-- | Users/Makefile.am | 6 | ||||
-rw-r--r-- | Users/Shells.pm | 99 | ||||
-rw-r--r-- | Users/Users.pm | 707 | ||||
-rw-r--r-- | UsersConfig.pm | 82 | ||||
-rw-r--r-- | Utils/.cvsignore | 2 | ||||
-rw-r--r-- | Utils/Backend.pm (renamed from general.pl.in) | 248 | ||||
-rw-r--r-- | Utils/File.pm (renamed from file.pl.in) | 320 | ||||
-rw-r--r-- | Utils/Makefile.am | 12 | ||||
-rw-r--r-- | Utils/Monitor.pm | 93 | ||||
-rw-r--r-- | Utils/Parse.pm (renamed from parse.pl.in) | 891 | ||||
-rw-r--r-- | Utils/Platform.pm (renamed from platform.pl.in) | 328 | ||||
-rw-r--r-- | Utils/Replace.pm (renamed from replace.pl.in) | 904 | ||||
-rw-r--r-- | Utils/Report.pm (renamed from report.pl.in) | 134 | ||||
-rw-r--r-- | Utils/Util.pm (renamed from util.pl.in) | 67 | ||||
-rw-r--r-- | Utils/XML.pm (renamed from xml.pl.in) | 275 | ||||
-rw-r--r-- | add_amp.sh | 16 | ||||
-rwxr-xr-x | autogen.sh | 2 | ||||
-rw-r--r-- | boot-conf.in | 270 | ||||
-rw-r--r-- | boot-grub.pl.in | 1067 | ||||
-rw-r--r-- | boot-lilo.pl.in | 597 | ||||
-rw-r--r-- | boot-yaboot.pl.in | 349 | ||||
-rw-r--r-- | boot.pl.in | 506 | ||||
-rwxr-xr-x | configure | 20743 | ||||
-rw-r--r-- | configure.in | 82 | ||||
-rw-r--r-- | debug.pl.in | 222 | ||||
-rwxr-xr-x | dhcpd-conf.in | 196 | ||||
-rw-r--r-- | dhcpd.pl.in | 819 | ||||
-rwxr-xr-x | disks-conf.in | 1827 | ||||
-rw-r--r-- | display-conf.in | 229 | ||||
-rw-r--r-- | filesys.pl.in | 1115 | ||||
-rw-r--r-- | font-conf.in | 124 | ||||
-rw-r--r-- | font.pl.in | 1299 | ||||
-rwxr-xr-x | gen-reportcode-list.sh | 84 | ||||
-rwxr-xr-x | guess_system.sh | 1121 | ||||
-rwxr-xr-x | hardware-conf.in | 880 | ||||
-rwxr-xr-x | internetsharing-conf.in | 235 | ||||
-rw-r--r-- | ishare.pl.in | 526 | ||||
-rw-r--r-- | m4macros/.cvsignore | 2 | ||||
-rw-r--r-- | media.pl.in | 204 | ||||
-rwxr-xr-x | memory-conf.in | 588 | ||||
-rw-r--r-- | mouse-conf.in | 173 | ||||
-rwxr-xr-x | network-conf.in | 638 | ||||
-rw-r--r-- | network.pl.in | 6535 | ||||
-rw-r--r-- | option.pl | 175 | ||||
-rw-r--r-- | org.freedesktop.SystemToolsBackends.service.in | 4 | ||||
-rw-r--r-- | package-conf.in | 193 | ||||
-rw-r--r-- | partition.pl.in | 781 | ||||
-rwxr-xr-x | perldoc.pl | 176 | ||||
-rw-r--r-- | po/.cvsignore | 1 | ||||
-rwxr-xr-x | print-conf.in | 261 | ||||
-rw-r--r-- | print.pl.in | 335 | ||||
-rw-r--r-- | removable-media.pl.in | 69 | ||||
-rwxr-xr-x | rhprinterdb2gstxml.pl | 119 | ||||
-rw-r--r-- | service.pl.in | 2082 | ||||
-rwxr-xr-x | services-conf.in | 383 | ||||
-rwxr-xr-x | shares-conf.in | 807 | ||||
-rw-r--r-- | system-tools-backends-2.0.pc.in (renamed from system-tools-backends.pc.in) | 0 | ||||
-rwxr-xr-x | test-backends | 87 | ||||
-rwxr-xr-x | test.pl | 56 | ||||
-rwxr-xr-x | time-conf.in | 1028 | ||||
-rwxr-xr-x | tokenizer.pl.in | 368 | ||||
-rwxr-xr-x | type1inst | 1387 | ||||
-rw-r--r-- | users-conf.in | 1633 | ||||
-rw-r--r-- | x.pl.in | 2209 |
98 files changed, 27329 insertions, 37208 deletions
@@ -7,8 +7,7 @@ boot-grub.pl boot-lilo.pl boot-yaboot.pl boot.pl -config.log -config.status +config.* configure debug.pl dhcpd-conf @@ -54,3 +53,8 @@ users-conf util.pl x.pl xml.pl +Loader.pl +ltmain.sh +*.service +*.pc +stamp-h1 @@ -1,3 +1,409 @@ +2006-05-15 Carlos Garnacho Parro <carlosg@gnome.org> + + * Merged the waiting-the-dbus branch into HEAD + + * configure.in, Makefile.am, autogen.sh: bump to 1.9.0, do not use + translations (no longer needed) and fix references to the new .pc file + + * GroupsConfig.pm, HostsConfig.pm, IfacesConfig.pm, NFSConfig.pm, + NTPConfig.pm, SMBConfig.pm, ServicesConfig.pm, ServicesList.pm, + SharesList.pm, SystemToolsBackends.pl.in, TimeConfig.pm, + UsersConfig.pm, org.freedesktop.SystemToolsBackends.service.in, + system-tools-backends-2.0.pc.in, test-backends, Init/Services.pm, + Init/ServicesList.pm, Network/Hosts.pm, Network/Ifaces.pm, + Shares/Exports.pm, Shares/NFS.pm, Shares/SMB.pm, Time/NTP.pm, + Time/TimeDate.pm, Users/Groups.pm, Users/Shells.pm, Users/Users.pm, + Utils/Backend.pm, Utils/File.pm, Utils/Monitor.pm, Utils/Parse.pm, + Utils/Platform.pm, Utils/Replace.pm, Utils/Report.pm, Utils/Util.pm, + Utils/XML.pm: Added/refactored files, replace the functionality in + the older *.pl.in files + + * boot-conf.in, boot-grub.pl.in, boot-lilo.pl.in, boot-yaboot.pl.in, + boot.pl.in, file.pl.in, general.pl.in, network-conf.in, network.pl.in, + parse.pl.in, platform.pl.in, replace.pl.in, report.pl.in, + service-list.pl.in, service.pl.in, services-conf.in, share.pl.in, + shares-conf.in, system-tools-backends.pc.in, time-conf.in, + users-conf.in, util.pl.in, xml.pl.in: Functional removed files, + they've been replaced with the files above. + + * add_amp.sh, debug.pl.in, dhcpd-conf.in, dhcpd.pl.in, disks-conf.in, + display-conf.in, filesys.pl.in, font-conf.in, font.pl.in, + gen-reportcode-list.sh, guess_system.sh, hardware-conf.in, + internetsharing-conf.in, ishare.pl.in, media.pl.in, memory-conf.in, + mouse-conf.in, option.pl, package-conf.in, partition.pl.in, + perldoc.pl, print-conf.in, print.pl.in, process.pl.in, + removable-media.pl.in, rhprinterdb2gstxml.pl, test.pl, + tokenizer.pl.in, type1inst, x.pl.in: Bunch of unused files (or used in + unstable tools), if/when they prove their usefulness, they'll be added + back, but for now they'd better be in the Attic. + +2006-05-15 Carlos Garnacho Parro <carlosg@gnome.org> + + * Utils/Replace.pm: added functions for replacing in gentoo's + /etc/conf.d/net like files + * Utils/Parse.pm: ditto for parsing + * Utils/File.pm (copy): do not fail miserably if the original copy + doesn't exist + * Utils/Platform.pm: add support for Ubuntus, Mandrivas, Yoper, VLOS, + Archlinux and Ark in this branch, rename Specifix to rPath + * Users/Users.pm, Time/TimeDate.pm, Time/NTP.pm, Network/Ifaces.pm, + Network/Hosts.pm, Init/Services.pm: add changes related to these + distros in this branch + * Shares/SMB.pm: add mapping function to know the distro config file + +2006-05-14 Carlos Garnacho Parro <carlosg@gnome.org> + + * HostsConfig.pm, Network/Hosts.pm: added hability to get/set hostname + and domainname + * NFSConfig.pm: fix a typo + * Shares/NFS.pm: fix another typo, make a variable local to a function + * SMBConfig.pm, Shares/SMB.pm: add hability to get/set general SMB + properties + * Utils/Backend.pm: use system bus by default, remove some ancient + code + * Utils/File.pm (remove): use $gst_prefix + * Utils/Monitor.pm: remove some silly c&p in the license banner + * Utils/Parse.pm: fix typo + * Init/Services.pm (set_gentoo_services): refactor it a bit to allow + individual services to be started/stopped from other parts of the code + (say interfaces auto) + * Init/ServicesList.pm: make a difference between SMB and NFS + * Utils/Replace.pm (set_join_hash): renamed to join_hash. + (set_ppp_options_re) (set_ppp_options_connect): added + * IfacesConfig.pm, Network/Ifaces.pm: add set() functionality, minor + changes to get() + * Utils/Platform.pm: added methods for getting the detected platform, + setting a custom platform and getting the list of supported platforms. + Other misc fixes to detect properly the platform + * Loader.pl.in: remove unused variable, add Platform object + * test-backend: use system bus + +2006-03-17 Carlos Garnacho Parro <carlosg@gnome.org> + + * GroupsConfig.pm: add maximum and minimum GID + * UsersConfig.pm: add default shell + * Time/TimeDate.pm: fixed a couple of typos + * Users/Users.pm: put default home_prefix to the home dirname (i.e.: + /home/) + +2005-12-12 Carlos Garnacho Parro <carlosg@gnome.org> + + * org.freedesktop.SystemToolsBackends.service.in, Init/Makefile.am, + Network/Makefile.am: added files + * configure.in, Makefile.am: fixed build, added .service file + +2005-12-09 Carlos Garnacho Parro <carlosg@gnome.org> + + * Time/TimeDate.pm (get_local_time) (set_local_time): modified to deal + with UTC time, renamed accordingly. Modified months to be between 0 + and 11, in the localtime() fashion. + +2005-12-05 Carlos Garnacho Parro <carlosg@gnome.org> + + * Loader.pl.in, Utils/Backend.pm: add --system parameter, to run the + backends in the system bus + * Users/Users.pm: fix the code for the root case (number of parameters + mismatch) + * test-backends: cosmetic fix + +2005-11-20 Carlos Garnacho Parro <carlosg@gnome.org> + + * GroupsConfig.pm, Users/Groups.pm: removed id from the group struct + * ShellsConfig.pm: removed, has been moved to UsersConfig, didn't have + much sense as a separate object. + * Loader.pl.in: removed ShellsConfig.pm + * UsersConfig.pm, Users/Users.pm: removed id from the user struct, + added shells array here + * Users/Groups.pm, Users/Users.pm: made the code for + adding/deleting/modifying users/groups a bit more readable + * Utils/Monitor.pm: initilize correctly the file monitor if Gamin is + present + +2005-11-17 Carlos Garnacho Parro <carlosg@gnome.org> + + * HostsConfig.pm: really add a "set" dbus method + +2005-11-14 Carlos Garnacho Parro <carlosg@gnome.org> + + * Utils/Monitor.pm: make use of gamin optional, thus not spreading the + "changed" signals if it isn't installed + +2005-11-11 Carlos Garnacho Parro <carlosg@gnome.org> + + * IfacesConfig.pm: added, DBus object to handle network ifaces config + * Network/Ifaces.pm: added again, at the moment there's only + get() support + * Loader.pl.in: added the IfacesConfig object + * Shares/SMB.pm (get): fixed a typo with $smb_conf_file + * Utils/Monitor.pm: use the recently uploaded Sys::Gamin CPAN perl + module + * Utils/Parse.pm (expand): allow expanding of several keywords. + (get_ppp_options_re): added. + +2005-11-05 Carlos Garnacho Parro <carlosg@gnome.org> + + * Init/Services.pm: added missing set() support for the rest of the + init systems + +2005-11-04 Carlos Garnacho Parro <carlosg@gnome.org> + + * ServicesConfig.pm, Init/Services.pm: began to add set() support, at + the moment it's working for sysV, the rest is to come. + * Init/Services.pm: fixed get() for systems distinct to sysV, should + work fine now. + +2005-10-30 Carlos Garnacho Parro <carlosg@gnome.org> + + * NFSConfig.pm, Shares/NFS.pm: added set() methods. + * SMBConfig.pm, Shares/SMB.pm: ditto + * Utils/File.pm (open_filter_write_from_names): small fix when the + output stream can't be opened + * TODO: updated + +2005-10-27 Carlos Garnacho Parro <carlosg@gnome.org> + + * GroupsConfig.pm, Users/Groups.pm: added set() methods + * UsersConfig.pm, Users/Users.pm: ditto + * Users/Users.pm: removed lots of dead and unused code + +2005-10-24 Carlos Garnacho Parro <carlosg@gnome.org> + + * Utils/Backend.pm, Report.pm: fix args parsing and verbose reports + +2005-10-21 Carlos Garnacho Parro <carlosg@gnome.org> + + * HostsConfig.pm, Network/Hosts.pm: Implemented set() methods + * NTPConfig.pm, Time/NTP.pm: ditto + * TimeConfig.pm, Time/TimeDate.pm: ditto + * SMBConfig.pm: monitor SMB config files + * ServicesConfig.pm, Init/Services.pm: added runlevel roles, plus + default runlevel + * TODO: updated + +2005-10-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * SMBConfig.pm, Shares/SMB.pm: include share name in the provided + information + +2005-10-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * GroupsConfig.pm, HostsConfig.pm, NFSConfig.pm, NTPConfig.pm, + SMBConfig.pm, ServicesConfig.pm, ShellsConfig.pm, TimeConfig.pm, + UsersConfig.pm: fixed objects paths + * test-backends: ditto + * Shares/NFS.pm: fixed and simplified things for retrieving + information + +2005-10-11 Carlos Garnacho Parro <carlosg@gnome.org> + + * TimeConfig.pm: return the correct number of parameters + * Time/TimeDate.pm: return correctly all needed parameters + +2005-10-08 Carlos Garnacho Parro <carlosg@gnome.org> + + * GroupsConfig.pm, HostsConfig.pm, Loader.pl.in, NFSConfig.pm, + NTPConfig.pm, SMBConfig.pm, ServicesConfig.pm, ShellsConfig.pm, + TimeConfig.pm, UsersConfig.pm, test-backends: updated everything to + latest perl DBus bindings API + +2005-10-06 Carlos Garnacho Parro <carlosg@gnome.org> + + * configure.in: changed installation path + +2005-10-04 Carlos Garnacho Parro <carlosg@gnome.org> + + * Network/Hosts.pm: added + * HostsConfig.pm: ditto + * ServicesConfig.pm: ditto + * Init/ServicesList.pm: ditto + * Init/Services.pm: added code, need to review to see if it works on + non system V distros + * Loader.pl.in: added new services + +2005-09-17 Carlos Garnacho Parro <carlosg@gnome.org> + + * Loader.pl.in: add some code to check whether the backends are + installed and add the install path to @INC in such case. Use + objects for SMB, NFS and time/date + * Makefile.am, autogen.sh, configure.in: modified to make the + thing actually compile + * Shares/Makefile.am, Time/Makefile.am, Users/Makefile.am, + Utils/Makefile.am: added + * NFSConfig.pm, Shares/NFS.pm: added + * SMBConfig.pm, Shares/SMB.pm: added + * TimeConfig.pm, Time/TimeDate.pm: added + * UsersConfig.pm: fixed a typo + * Utils/Parse.pm (get_from_ini_bool): return 0 (not undef) if it + couldn't find the value + +2005-08-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * Loader.pl.in: use the new objects + +2005-08-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * Time/NTP.pm: module for handling NTP servers configuration + * NTPConfig.pm: toplevel object for dealing with NTP config + +2005-08-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * test-backends: improved a bit, removed unused code + +2005-08-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * Users/Groups.pm: module for managing group settings + * GroupsConfig.pm: toplevel object for dealing with groups + +2005-08-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * ShellsConfig.pm: ShellsList object renamed, all exported objects + will be called *Config + +2005-08-13 Carlos Garnacho Parro <carlosg@gnome.org> + + * Users/Shells.pm: small indenting fix + * Users/Users.pm: modify to get data from login.defs and some pam + info (whether to use MD5 to crypt passwords) + * UsersConfig.pm: new toplevel object, contains the users list, and + logindefs info relevant to users. Deprecates UserList + * UsersList.pm: deleted + +2005-06-12 Carlos Garnacho Parro <carlosg@gnome.org> + + * time-conf.in: applied patch to update /etc/timezone in debian based + systems. Fixes #167035 + +2005-06-12 Carlos Garnacho Parro <carlosg@gnome.org> + + * network.pl.in: added support for WEP key type (ASCII or hexa) + +2005-05-08 Carlos Garnacho Parro <carlosg@gnome.org> + + * UsersList.pm: added + * Loader.pl.in: use UsersList + * Users/Users.pm: made passwd/shadow parameters a bit more generic, + but still needs some love. Removed unused bits from the get() + function, implemented get_files() + +2005-05-04 Carlos Garnacho Parro <carlosg@gnome.org> + + * SharesList.pm: adapted signal emitting to new Dbus bindings API + * Users/Shells.pm: separated shells handling from Users/Users.pm, + implemented set() + * ShellsList.pm: use new .pm for shells, monitor /etc/shells + * Utils/Monitor.pm: accept both arrays and single file names + +2005-05-02 Carlos Garnacho Parro <carlosg@gnome.org> + + * Users/Users.pm: moved from users-conf.in, removed some code that + should not be used now + * users-conf.in: removed + * ShellsList.pm: object for gettings the available shells + * Loader.pl.in: add ShellsList to the init code + * ServicesList.pm: put object path correctly + * test-backends: put object paths correctly + * Init/Services.pm: forgot to rename namespace to Init::Services + +2005-04-29 Carlos Garnacho Parro <carlosg@gnome.org> + + * SharesList.pm: put object path correctly + * configure.in: use the 2.0 .pc file, bumped version to 1.9.x + * system-tools-backends.pc.in: removed + * system-tools-backends-2.0.pc.in: added + +2005-04-27 Carlos Garnacho Parro <carlosg@gnome.org> + + * Init/Services.pm: added, previously known as service.pl.in + * service.pl.in: removed + * ServicesList.pm: added, DBus object for accessing services at init + * Loader.pl.in: added ServicesList + * SharesList.pm: updated to latest DBus bindings api + * network.pl.in: use Init::Services + * test-backends: don't recurse infinitely with arrays, other + improvements + +2005-04-21 Carlos Garnacho Parro <carlosg@gnome.org> + + * test-backends: Added simple perl script for querying the backends + data + +2005-04-20 Carlos Garnacho Parro <carlosg@gnome.org> + + * Utils/Monitor.pm: New file for monitoring file changes and emitting + DBus signals according to this + * Loader.pl.in: added function for monitoring files in a timeout + * SharesList.pm: monitor SMB and NFS files and emit "changed" signal + * Shares/Exports.pm: misc changes + +2005-04-20 Carlos Garnacho Parro <carlosg@gnome.org> + + * Loader.pl.in: Added, this will be the application that will load all + the backend objects, instead of being each backend an executable + * SharesList.pm: Added, this is the DBus object for the shared folders + list, at the moment it only does SMB (First DBus object here, wooo) + * network.pl.in: misc changes for making object work, it will be + eventually moved to Network/*.pm + * Shares/Exports.pm: new place for share.pl.in + * Utils/Backend.pm: added vars for the DBus path and so + * TODO: Added + * shares.pl.in: to the attic with you + +2005-04-19 Carlos Garnacho Parro <carlosg@gnome.org> + + * Third round of huge commits + * parse.pl.in: removed + * Utils/Parse.pm: new place for the file above, plus function renaming + * boot-conf.in, boot-grub.pl.in, boot-lilo.pl.in, boot-yaboot.pl.in, + boot-pl.in, dhcpd.pl.in, disks-conf.in, filesys.pl.in, ishare.pl.in, + media.pl.in, network.pl.in, print.pl.in, service.pl.in, share.pl.in, + shares-conf.in, time-conf.in, users-conf.in, Utils/Backend.pm, + Utils/Platform.pm, Utils/Replace.pm, Utils/Report.pm, Utils/XML.pm: + Use new module, other misc fixes + * xml.pl.in, replace.pl.in, platform.pl.in, general.pl.in: Forgot to + remove these + +2005-04-18 Carlos Garnacho Parro <carlosg@gnome.org> + + * Second round in huge commits + * general.pl.in, platform.pl.in, replace.pl.in, xml.pl.in: Second + step in modularization + * Utils/Backend.pm, Platform.pm, Replace.pm, XML.pm: new place/name + for the files above, plus function renaming and so + * boot-conf.in, boot-grub.pl.in, boot-lilo.pl.in, boot-yaboot.pl.in, + boot.pl.in, dhcpd-conf.in, dhcpd.pl.in, disks-conf.in, + display-conf.in, filesys.pl.in, font-conf.in, font.pl.in, + hardware-conf.in, internetsharing-conf.in, ishare.pl.in, media.pl.in, + memory-conf.in, mouse-conf.in, network-conf.in, network.pl.in, + package-conf.in, partition.pl.in, print-conf.in, print.pl.in, + process.pl.in, removable-media.pl.in, service.pl.in, services-conf.in, + share.pl.in, shares-conf.in, time-conf.in, users-conf.in, x.pl.in, + Utils/File.pm, Utils/Report.pm: + Use new modules and function names + * replace-func: improved + +2005-04-14 Carlos Garnacho Parro <carlosg@gnome.org> + + * created the experimental DBus branch + * file.pl.in, report.pl.in, util.pl.in: First step in modulization, + they've been converted to perl modules and put in Utils/* + * Utils/File.pm, Report.pm, Util.pm: these are the previous files with + some function renaming, due to the fact that modules are already + namespaced + * debug.pl.in: deleted, was barely used, and things have been quite + stable for a good time + * boot-conf.in, boot-grub.pl.in, boot-lilo.pl.in, boot-yaboot.pl.in, + boot.pl.in, dhcpd-conf.in, dhcpd.pl.in, disks-conf, display-conf, + filesys.pl.in, font-conf.in, font.pl.in, general.pl.in, + hardware-conf.in, internetshareing-conf.in, ishare.pl.in, + memory-conf.in, mouse-conf.in, network-conf.in, network.pl.in, + package-conf.in, parse.pl.in, partition.pl.in, platform.pl.in, + print-conf.in, print.pl.in, process.pl.in, replace.pl.in, + service.pl.in, services-conf.in, share.pl.in, shares-conf.in, + time-conf.in, tokenizer.pl.in, users-conf.in, x.pl.in, xml.pl.in: + Use these modules instead of the old files + * replace-func: silly shellscript for renaming function names in perl + files, is helping a lot in the backends modulization task + 2006-04-18 Carlos Garnacho Parro <carlosg@gnome.org> * po/no.po, configure.in: nuke no.po under request from Kjartan Maraas diff --git a/GroupsConfig.pm b/GroupsConfig.pm new file mode 100644 index 0000000..1eb9f79 --- /dev/null +++ b/GroupsConfig.pm @@ -0,0 +1,69 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Groups list +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package GroupsConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Utils::Backend; +use Users::Groups; +use Users::Users; + +my $OBJECT_NAME = "GroupsConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + + Utils::Monitor::monitor_files (&Users::Groups::get_files (), + $self, $OBJECT_NAME, "changed"); + return $self; +} + +dbus_method ("get", [], [[ "array", [ "struct", "string", "string", "int32", [ "array", "string" ]]], "int32", "int32" ]); +dbus_method ("set", [[ "array", [ "struct", "string", "string", "int32", [ "array", "string" ]]], "int32", "int32" ], []); +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + my $groups, $logindefs; + + $groups = Users::Groups::get (); + $logindefs = &Users::Users::get_logindefs (); + + return ($groups, $$logindefs{"gmin"}, $$logindefs{"gmax"}); +} + +sub set +{ + my ($self, $config) = @_; + + Users::Groups::set ($config); +} + +1; diff --git a/HostsConfig.pm b/HostsConfig.pm new file mode 100644 index 0000000..304aebf --- /dev/null +++ b/HostsConfig.pm @@ -0,0 +1,80 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Hosts location config +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package HostsConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Network::Hosts; + +my $OBJECT_NAME = "HostsConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + +# Utils::Monitor::monitor_files (&Users::Groups::get_files (), +# $self, $OBJECT_NAME, "changed"); + + return $self; +} + +dbus_method ("get", [], + [ "string", "string", + [ "array", [ "struct", "string", [ "array", "string" ]]], + ["array", "string" ], + ["array", "string" ]]); +dbus_method ("set", + [[ "array", [ "struct", "string", [ "array", "string" ]]], + ["array", "string" ], + ["array", "string" ]], []); + +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + my ($hostname, $domainname); + + ($hostname, $domainname) = Network::Hosts::get_fqdn (); + + return ($hostname, $domainname, + Network::Hosts::get (), + Network::Hosts::get_dns (), + Network::Hosts::get_search_domains ()); +} + +sub set +{ + my ($self, @config) = @_; + + Network::Hosts::set ($config[0]); + Network::Hosts::set_dns ($config[1]); + Network::Hosts::set_search_domains ($config[2]); +} + +1; diff --git a/IfacesConfig.pm b/IfacesConfig.pm new file mode 100644 index 0000000..c1dcc58 --- /dev/null +++ b/IfacesConfig.pm @@ -0,0 +1,79 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the network interfaces config +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package IfacesConfig; + +use Network::Ifaces; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); + +my $OBJECT_NAME = "IfacesConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + +# Utils::Monitor::monitor_files (&Users::Groups::get_files (), +# $self, $OBJECT_NAME, "changed"); + + return $self; +} + +dbus_method ("get", [], + [[ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string", "string", "int32", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "int32", "int32", "string", "string", "int32", "int32", "int32", "int32" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "string", "int32", "int32", "int32", "int32" ]]]); +dbus_method ("set", + [[ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string", "string", "int32", "string" ]], + [ "array", [ "struct", "string", "int32", "int32", "string", "string", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "int32", "int32", "string", "string", "int32", "int32", "int32", "int32" ]], + [ "array", [ "struct", "string", "int32", "string", "string", "string", "string", "int32", "int32", "int32", "int32" ]]], []); + +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + + return &Network::Ifaces::get (); +} + +sub set +{ + my ($self, @config) = @_; + + &Network::Ifaces::set ($config[0], $config[1], $config[2], + $config[3], $config[4], $config[5]); +} + +1; diff --git a/Init/.cvsignore b/Init/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/Init/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/Init/Makefile.am b/Init/Makefile.am new file mode 100644 index 0000000..7bb5391 --- /dev/null +++ b/Init/Makefile.am @@ -0,0 +1,5 @@ +sharesdir = $(scriptsdir)/Init + +shares_SCRIPTS = \ + Services.pm \ + ServicesList.pm diff --git a/Init/Services.pm b/Init/Services.pm new file mode 100644 index 0000000..0136e87 --- /dev/null +++ b/Init/Services.pm @@ -0,0 +1,1170 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# Functions for manipulating system services, like daemons and network. +# +# Copyright (C) 2002 Ximian, Inc. +# +# Authors: Carlos Garnacho Parro <garparr@teleline.es>, +# Hans Petter Jansson <hpj@ximian.com>, +# Arturo Espinosa <arturo@ximian.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Init::Services; + +use Init::ServicesList; + +sub get_runlevel_roles +{ + my (%dist_map, %runlevels); + my ($desc, $distro); + + %dist_map = + ( + "redhat-5.2" => "redhat-5.2", + "redhat-6.0" => "redhat-5.2", + "redhat-6.1" => "redhat-5.2", + "redhat-6.2" => "redhat-5.2", + "redhat-7.0" => "redhat-5.2", + "redhat-7.1" => "redhat-5.2", + "redhat-7.2" => "redhat-5.2", + "redhat-7.3" => "redhat-5.2", + "redhat-8.0" => "redhat-5.2", + "redhat-9" => "redhat-5.2", + "openna-1.0" => "redhat-5.2", + + "mandrake-7.1" => "redhat-5.2", + "mandrake-7.2" => "redhat-5.2", + "mandrake-9.0" => "redhat-5.2", + "mandrake-9.1" => "redhat-5.2", + "mandrake-9.2" => "redhat-5.2", + "mandrake-10.0" => "redhat-5.2", + "mandrake-10.1" => "redhat-5.2", + + "blackpanther-4.0" => "redhat-5.2", + + "conectiva-9" => "redhat-5.2", + "conectiva-10" => "redhat-5.2", + + "debian-2.2" => "debian-2.2", + "debian-3.0" => "debian-2.2", + "debian-sarge" => "debian-2.2", + "ubuntu-5.04" => "debian-2.2", + + "suse-7.0" => "redhat-5.2", + "suse-9.0" => "redhat-5.2", + "suse-9.1" => "redhat-5.2", + + "turbolinux-7.0" => "redhat-5.2", + "pld-1.0" => "redhat-5.2", + "pld-1.1" => "redhat-5.2", + "pld-1.99" => "redhat-5.2", + "fedora-1" => "redhat-5.2", + "fedora-2" => "redhat-5.2", + "fedora-3" => "redhat-5.2", + + "rpath" => "redhat-5.2", + + "vine-3.0" => "redhat-5.2", + "vine-3.1" => "redhat-5.2", + + "slackware-9.1.0" => "slackware-9.1.0", + "slackware-10.0.0" => "slackware-9.1.0", + "slackware-10.1.0" => "slackware-9.1.0", + + "gentoo" => "gentoo", + "vlos-1.2" => "gentoo", + + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + %runlevels= + ( + "redhat-5.2" => [["0", "HALT" ], + ["1", "RECOVER" ], + ["2", "NONE" ], + ["3", "TEXT" ], + ["4", "NONE" ], + ["5", "GRAPHICAL" ], + ["6", "REBOOT" ]], + + "debian-2.2" => [["0", "HALT" ], + ["1", "RECOVER" ], + ["2", "NONE" ], + ["3", "NONE" ], + ["4", "NONE" ], + ["5", "NONE" ], + ["6", "REBOOT" ]], + + "gentoo" => [["boot", "BOOT" ], + ["default", "GRAPHICAL" ], + ["nonetwork", "RECOVER" ]], + + "freebsd-5" => [["default", "GRAPHICAL" ]], + + "slackware-9.1.0" => [["default", "GRAPHICAL" ]] + ); + + $distro = $dist_map{$Utils::Backend::tool{"platform"}}; + $desc = $runlevels{$distro}; + + return $desc; +} + +# This function gets the runlevel that is in use +sub get_sysv_default_runlevel +{ + my (@arr); + @arr = split / /, `/sbin/runlevel` ; + chomp $arr[1]; + + return $arr[1]; +} + +sub get_default_runlevel +{ + my $type = &get_init_type (); + + return "default" if ($type eq "gentoo" || $type eq "rcng" || $type eq "bsd"); + return &get_sysv_default_runlevel (); +} + +sub get_sysv_paths +{ + my %dist_map = + ( + # gst_dist => [rc.X dirs location, init.d scripts location, relative path location] + "redhat-5.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-6.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-6.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-6.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-7.3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-8.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "redhat-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "openna-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "mandrake-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-9.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-9.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-9.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-10.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-10.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandrake-10.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandriva-2006.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "mandriva-2006.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "yoper-2.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "blackpanther-4.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "conectiva-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "conectiva-10" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "debian-2.2" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + "debian-3.0" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + "debian-sarge" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + "ubuntu-5.04" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + "ubuntu-5.10" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + "ubuntu-6.04" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], + + "suse-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d", "../"], + "suse-9.0" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], + "suse-9.1" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], + + "turbolinux-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "pld-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "pld-1.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "pld-1.99" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "fedora-1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "fedora-2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "fedora-3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "fedora-4" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "rpath" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + + "vine-3.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "vine-3.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + "ark" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], + ); + my $res; + + $res = $dist_map{$Utils::Backend::tool{"platform"}}; + &Utils::Report::do_report ("service_sysv_unsupported", $Utils::Backend::tool{"platform"}) if ($res eq undef); + return @$res; +} + +# we are going to extract the name of the script +sub get_sysv_service_name +{ + my ($service) = @_; + + $service =~ s/$initd_path\///; + + return $service; +} + +# This function gets the state of the service along the runlevels, +# it also returns the average priority +sub get_sysv_runlevels_status +{ + my ($service) = @_; + my ($link); + my ($runlevel, $action, $priority); + my (@arr, @ret); + + foreach $link (<$rcd_path/rc[0-6].d/[SK][0-9][0-9]$service>) + { + $link =~ s/$rcd_path\///; + $link =~ /rc([0-6])\.d\/([SK])([0-9][0-9]).*/; + ($runlevel,$action,$priority)=($1,$2,$3); + + if ($action eq "S") + { + push @arr, [ $runlevel, "start", $priority ]; + } + elsif ($action eq "K") + { + push @arr, [ $runlevel, "stop", $priority ]; + } + } + + return \@arr; +} + +# We are going to extract the information of the service +sub get_sysv_service_info +{ + my ($service) = @_; + my ($script, @actions, @runlevels, $role); + + # Return if it's a directory + return if (-d $service); + + # We have to check if the service is executable + return unless (-x $service); + + $script = &get_sysv_service_name ($service); + + # We have to check out if the service is in the "forbidden" list + return if (&Init::ServicesList::is_forbidden ($script)); + + $runlevels = &get_sysv_runlevels_status($script); + $role = &Init::ServicesList::get_role ($script); + + return ($script, $role, $runlevels); +} + +# This function gets an ordered array of the available services from a SysV system +sub get_sysv_services +{ + my ($service); + my (@arr); + + ($rcd_path, $initd_path) = &get_sysv_paths (); + + return undef unless ($rcd_path && $initd_path); + + foreach $service (<$initd_path/*>) + { + my (@info); + + @info = &get_sysv_service_info ($service); + push @arr, \@info if (scalar (@info)); + } + + return \@arr; +} + +# These are the functions for storing the service settings in SysV +sub remove_sysv_link +{ + my ($rcd_path, $runlevel, $script) = @_; + + foreach $link (<$rcd_path/rc$runlevel.d/[SK][0-9][0-9]$script>) + { + &Utils::Report::enter (); + &Utils::Report::do_report ("service_sysv_remove_link", "$link"); + unlink ($link); + &Utils::Report::leave (); + } +} + +sub add_sysv_link +{ + my ($rcd_path, $relative_path, $runlevel, $action, $priority, $service) = @_; + my ($prio) = sprintf ("%0.2d",$priority); + + symlink ("$relative_path/$service", "$rcd_path/rc$runlevel.d/$action$prio$service"); + + &Utils::Report::enter (); + &Utils::Report::do_report ("service_sysv_add_link", "$rcd_path/rc$runlevel.d/$action$prio$service"); + &Utils::Report::leave (); +} + +sub set_sysv_service +{ + my ($service) = @_; + my ($script, $priority, $runlevels); + my ($action); + + ($rcd_path, $initd_path, $relative_path) = &get_sysv_paths (); + + $script = $$service[0]; + $runlevels = $$service[2]; + + foreach $r (@$runlevels) + { + $runlevel = $$r[0]; + $action = ($$r[1] eq "start") ? "S" : "K"; + $priority = $$r[2]; + + if (!-f "$rcd_path/rc$runlevel.d/$action$priority$script") + { + &remove_sysv_link ($rcd_path, $runlevel, $script); + &add_sysv_link ($rcd_path, $relative_path, $runlevel, $action, $priority, $script); + } + } +} + +sub set_sysv_services +{ + my ($services) = @_; + + foreach $i (@$services) + { + &set_sysv_service($i); + } +} + +# This functions get an ordered array of the available services from a file-rc system +sub get_filerc_runlevels_status +{ + my ($start_service, $stop_service, $priority) = @_; + my (@arr, @ret); + + # we start with the runlevels in which the service starts + if ($start_service !~ /-/) { + my (@runlevels); + + @runlevels = split /,/, $start_service; + + foreach $runlevel (@runlevels) + { + push @arr, { "name" => $runlevel, + "action" => "start", + "priority" => $priority}; + } + } + + # now let's go with the runlevels in which the service stops + if ($stop_service !~ /-/) { + my (@runlevels); + + @runlevels = split /,/, $stop_service; + + foreach $runlevel (@runlevels) + { + push @arr, { "name" => $runlevel, + "action" => "stop", + "priority" => $priority}; + } + } + + push @ret, {"runlevel" => \@arr}; + return \@ret; +} + +sub get_filerc_service_info +{ + my ($line, %ret) = @_; + my %hash; + my @runlevels; + + if ($line =~ /^([0-9][0-9])[\t ]+([0-9\-S,]+)[\t ]+([0-9\-S,]+)[\t ]+\/etc\/init\.d\/(.*)/) + { + $priority = $1; + $stop_service = $2; + $start_service = $3; + $script = $4; + + return undef if (&Init::ServicesList::is_forbidden ($script)); + + $hash{"script"} = $script; + + $hash{"runlevels"} = &get_filerc_runlevels_status ($start_service, $stop_service, $priority); + $hash{"role"} = &Init::ServicesList::get_role ($script); + + return (\%hash); + } + + return undef; +} + +sub get_filerc_services +{ + my ($script); + my (%ret); + + open FILE, "$gst_prefix/etc/runlevel.conf" or return undef; + while ($line = <FILE>) + { + if ($line !~ /^#.*/) + { + my (%hash); + my ($start_service, $stop_service); + $hash = &get_filerc_service_info ($line); + + if ($hash ne undef) + { + $script = $$hash{"script"}; + + if ($ret{$script} eq undef) + { + $ret{$script} = $hash; + } + else + { + my (@runlevels); + + # We need to mix the runlevels + @runlevels = $$hash{"runlevels"}[0]{"runlevel"}; + foreach $runlevel (@runlevels) + { + push @{$ret{$script}{"runlevels"}[0]{"runlevel"}}, $runlevel; + } + } + } + } + } + + return \%ret; +} + +# These are the functions for storing the service settings in file-rc +sub concat_filerc_runlevels +{ + my (@runlevels) = @_; + + $str = join (",", sort (@runlevels)); + return ($str) ? $str : "-"; +} + +sub set_filerc_service +{ + my ($buff, $initd_path, $service) = @_; + my (%hash, $priority, $line, $str); + + $runlevels = $$service[2]; + + foreach $i (@$runlevels) + { + $priority = 0 + $$i[2]; + $priority = 50 if ($priority == 0); #very rough guess + + if ($$i[1] eq "start") + { + $hash{$priority}{"start"} = [] if (!$hash{$priority}{"start"}); + push @{$hash{$priority}{"start"}}, $$i[0]; + } + else + { + $hash{$priority}{"stop"} = [] if (!$hash{$priority}{"stop"}); + push @{$hash{$priority}{"stop"}}, $$i[0]; + } + } + + foreach $priority (keys %hash) + { + $line = sprintf ("%0.2d", $priority) . "\t"; + $line .= &concat_filerc_runlevels (@{$hash{$priority}{"stop"}}) . "\t"; + $line .= &concat_filerc_runlevels (@{$hash{$priority}{"start"}}) . "\t"; + $line .= $initd_path . "/" . $$service{"script"} . "\n"; + + push @$buff, $line; + } +} + +sub set_filerc_services +{ + my ($services) = @_; + my ($buff, $lineno, $line, $file); + my ($rcd_path, $initd_path, $relative_path) = &sysv_get_paths (); + + $file = "/etc/runlevel.conf"; + + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); + + $lineno = 0; + + # We prepare the file for storing the configuration, save the initial comments + # and delete the rest + while ($$buff[$lineno] =~ /^#.*/) + { + $lineno++; + } + + for ($i = $lineno; $i < scalar (@$buff); $i++) + { + $$buff[$i] =~ /.*\/etc\/init\.d\/(.*)/; + + # we need to keep the forbidden services and the services that only start in rcS.d + if (!&Init::ServicesList::is_forbidden ($1)) + { + delete $$buff[$i]; + } + } + + # Now we append the services + foreach $service (@$services) + { + &set_filerc_service ($buff, $initd_path, $service); + } + + @$buff = sort @$buff; + + push @$buff, "\n"; + &Utils::File::clean_buffer ($buff); + &Utils::File::save_buffer ($buff, $file); +} + +# this functions get a list of the services that run on a bsd init +sub get_bsd_service_info +{ + my ($service) = @_; + my ($script); + my (%hash); + my (@arr, @rl); + + $script = $service; + $script =~ s/^.*\///; + $script =~ s/^rc\.//; + + return undef if (! Utils::File::exists ($service)); + + return undef if (&Init::ServicesList::is_forbidden ($script)); + + $hash {"script"} = $service; + + # we hardcode the fourth runlevel, it's the graphical one + if ( -x $service) + { + push @arr, { "name" => 4, + "action" => "start" }; + } + else + { + push @arr, { "name" => 4, + "action" => "stop" }; + } + + push @rl, { "runlevel" => \@arr }; + + $hash{"runlevels"} = \@rl; + $hash{"role"} = &Init::ServicesList::get_role ($script); + + return \%hash; +} + +sub get_bsd_services +{ + my (%ret); + my ($files) = [ "rc.M", "rc.inet2", "rc.4" ]; + my ($file); + + foreach $i (@$files) + { + $file = "/etc/rc.d/" . $i; + $fd = &Utils::File::open_read_from_names ($file); + + if (!$fd) { + &Utils::Report::do_report ("rc_file_read_failed", $file); + return undef; + } + + while (<$fd>) + { + $line = $_; + + if ($line =~ /^if[ \t]+\[[ \t]+\-x[ \t]([0-9a-zA-Z\/\.\-_]+) .*\]/) + { + my (%hash); + $service = $1; + + $hash = &get_bsd_service_info ($service); + + if ($hash ne undef) + { + $ret{$service} = $hash; + } + } + } + + Utils::File::close_file ($fd); + } + + return \%ret; +} + +# This function stores the configuration in a bsd init +sub set_bsd_services +{ + my ($services) = @_; + my ($script, $runlevels); + + foreach $service (@$services) + { + $script = $$service[0]; + $runlevels = $$service[2]; + $runlevel = $$runlevels[0]; + + $action = $$runlevel[1]; + + if ($action eq "start") + { + &Utils::File::run ("chmod ugo+x $script"); + } + else + { + &Utils::File::run ("chmod ugo-x $script"); + } + } +} + +# these functions get a list of the services that run on a gentoo init +sub get_gentoo_service_status +{ + my ($script, $runlevel) = @_; + my ($services) = &get_gentoo_services_by_runlevel ($runlevel); + + foreach $i (@$services) + { + return 1 if ($i eq $script); + } + + return 0; +} + +sub get_gentoo_runlevels +{ + my($raw_output) = Utils::File::run_backtick("rc-status -l"); + my(@runlevels) = split(/\n/,$raw_output); + + return @runlevels; +} + +sub get_gentoo_services_by_runlevel +{ + my($runlevel) = @_; + my($raw_output) = Utils::File::run_backtick("rc-status $runlevel"); + my(@raw_lines) = split(/\n/,$raw_output); + my(@services); + my($line); + + foreach $line (@raw_lines) + { + if ($line !~ /^Runlevel/) + { + $line=(split(" ",$line))[0]; + push(@services,$line); + } + } + + return \@services +} + +sub get_gentoo_services_list +{ + my ($service, @services); + + foreach $service (<$gst_prefix/etc/init.d/*>) + { + if (-x $service) + { + $service =~ s/.*\///; + push @services, $service; + } + } + + return \@services; +} + +sub gentoo_service_exists +{ + my($service) = @_; + my($services) = &get_gentoo_services_list(); + + foreach $i (@$services) + { + return 1 if ($i =~ /$service/); + } + + return 0; +} + +sub get_gentoo_runlevels_by_service +{ + my ($service) = @_; + my(@runlevels,@services_in_runlevel,@contain_runlevels, $runlevel); + my ($elem); + + # let's do some caching to improve performance + if ($gentoo_services_hash eq undef) + { + @runlevels = &get_gentoo_runlevels (); + + foreach $runlevel (@runlevels) + { + $$gentoo_services_hash{$runlevel} = &get_gentoo_services_by_runlevel ($runlevel); + } + } + + if (&gentoo_service_exists($service)) + { + foreach $runlevel (keys %$gentoo_services_hash) + { + $services_in_runlevel = $$gentoo_services_hash {$runlevel}; + + foreach $elem (@$services_in_runlevel) + { + push (@contain_runlevels, $runlevel) if ($elem eq $service); + } + } + } + + return @contain_runlevels; +} + +sub get_gentoo_runlevel_status_by_service +{ + my ($service) = @_; + my (@arr, @ret); + my (@runlevels) = &get_gentoo_runlevels(); + my (@started) = &get_gentoo_runlevels_by_service($service); + my (%start_runlevels) = map { $started[$_], 1 } 0 .. $#started; + + foreach $runlevel (@runlevels) + { + if (defined $start_runlevels{$runlevel}) + { + push @arr, { "name" => $runlevel, + "action" => "start" }; + } + else + { + push @arr, { "name" => $runlevel, + "action" => "stop" }; + } + } + + push @ret, { "runlevel" => \@arr }; + return @ret; +} + +sub get_gentoo_service_info +{ + my ($service) = @_; + my ($script, @actions, @runlevels); + my %hash; + + # We have to check out if the service is in the "forbidden" list + return undef if (&Init::ServicesList::is_forbidden ($service)); + + my($runlevels) = &get_gentoo_runlevel_status_by_service ($service); + + $hash{"script"} = $service; + $hash{"runlevels"} = $runlevels unless ($runlevels eq undef); + $hash{"role"} = &Init::ServicesList::get_role ($service); + + return \%hash; +} + +sub get_gentoo_services +{ + my ($service); + my (%ret); + my ($service_list) = &get_gentoo_services_list (); + + foreach $service (@$service_list) + { + my (%hash); + + $hash = &get_gentoo_service_info ($service); + $ret{$service} = $hash if ($hash ne undef); + } + + return \%ret; +} + +sub set_gentoo_service_status +{ + my ($script, $rl, $action) = @_; + + if ($action eq "start") + { + &Utils::File::run ("rc-update add $script $rl"); + } + elsif ($action eq "stop") + { + &Utils::File::run ("rc-update del $script $rl"); + } +} + +# This function stores the configuration in gentoo init +sub set_gentoo_services +{ + my ($services) = @_; + my ($action, $rl, $script, $arr); + + foreach $service (@$services) + { + $script = $$service[0]; + $arr = $$service[2]; + + foreach $i (@$arr) + { + $action = $$i[1]; + $rl = $$i[0]; + &set_gentoo_service_status ($script, $rl, $action); + } + } +} + +# rcNG functions, mostly for FreeBSD +sub get_rcng_status_by_service +{ + my ($service) = @_; + my ($fd, $line, $active); + + # This is the only difference between rcNG and archlinux + if ($gst_dist eq "archlinux") + { + return &Utils::File::exists ("/var/run/daemons/$service"); + } + else + { + $fd = &Utils::File::run_pipe_read ("/etc/rc.d/$service rcvar"); + + while (<$fd>) + { + $line = $_; + + if ($line =~ /^\$.*=YES$/) + { + $active = 1; + last; + } + } + + Utils::File::close_file ($fd); + return $active; + } +} + +sub get_rcng_service_info +{ + my ($service) = @_; + my ($script, @actions, @runlevels); + my (%hash, @arr, @rl); + + # We have to check if the service is in the "forbidden" list + return undef if (&Init::ServicesList::is_forbidden ($service)); + + $hash{"script"} = $service; + + if (get_rcng_status_by_service ($service)) + { + push @arr, { "name" => "default", + "action" => "start" }; + } + else + { + push @arr, { "name" => "default", + "action" => "stop" }; + } + + push @rl, { "runlevel", \@arr }; + + $hash {"runlevels"} = \@rl; + $hash {"role"} = &Init::ServicesList::get_role ($service); + + return \%hash; +} + +sub get_rcng_services +{ + my ($service); + my (%ret); + + foreach $service (<$gst_prefix/etc/rc.d/*>) + { + my (%hash); + + $service =~ s/.*\///; + $hash = &get_rcng_service_info ($service); + + $ret{$service} = $hash if ($hash ne undef); + } + + return \%ret; +} + +# These functions store the configuration of a rcng init +sub set_rcng_service_status +{ + my ($service, $action) = @_; + my ($fd, $key, $res); + my ($default_rcconf) = "/etc/defaults/rc.conf"; + my ($rcconf) = "/etc/rc.conf"; + + if (&Utils::File::exists ("/etc/rc.d/$service")) + { + $fd = &Utils::File::run_pipe_read ("/etc/rc.d/$service rcvar"); + + while (<$fd>) + { + if (/^\$(.*)=.*$/) + { + # to avoid cluttering rc.conf with duplicated data, + # we first look in the defaults/rc.conf for the key + $key = $1; + $res = &Utils::Parse::get_sh_bool ($default_rcconf, $key); + + if ($res == $action) + { + &Utils::Replace::set_sh ($rcconf, $key); + } + else + { + &Utils::Replace::set_sh_bool ($rcconf, $key, "YES", "NO", $action); + } + } + } + + &Utils::File::close_file ($fd); + } + elsif (&Utils::File::exists ("/usr/local/etc/rc.d/$service.sh")) + { + if ($action) + { + Utils::File::copy_file ("/usr/local/etc/rc.d/$service.sh.sample", + "/usr/local/etc/rc.d/$service.sh"); + } + else + { + Utils::File::remove ("/usr/local/etc/rc.d/$service.sh"); + } + } +} + +sub set_archlinux_service_status +{ + my ($script, $active) = @_; + my $rcconf = '/etc/rc.conf'; + my ($daemons); + + $daemons = &Utils::Parse::get_sh ($rcconf, "DAEMONS"); + + if (($daemons =~ m/$script/) && !$active) + { + $daemons =~ s/$script[ \t]*//; + } + elsif (($daemons !~ m/$script/) && $active) + { + $daemons =~ s/network/network $script/g; + } + + &Utils::Replace::set_sh ($rcconf, "DAEMONS", $daemons); +} + +sub set_rcng_services +{ + my ($services) = @_; + my ($action, $runlevels, $script, $func); + + # archlinux stores services differently + if ($gst_dist eq "archlinux") + { + $func = \&set_archlinux_service_status; + } + else + { + $func = \&set_rcng_service_status; + } + + foreach $service (@$services) + { + $script = $$service[0]; + $runlevels = $$service[2]; + $runlevel = $$runlevels[0]; + $action = ($$runlevel[1] eq "start")? 1 : 0; + + &$func ($script, $action); + } +} + +# SuSE functions, quite similar to SysV, but not equal... +sub get_suse_service_info ($service) +{ + my ($service) = @_; + my (%hash, @arr, @ret); + + # We have to check if the service is in the "forbidden" list + return undef if (&Init::ServicesList::is_forbidden ($service)); + + $hash{"script"} = $service; + + foreach $link (<$rcd_path/rc[0-9S].d/S[0-9][0-9]$service>) + { + $link =~ s/$rcd_path\///; + $link =~ /rc([0-6])\.d\/S[0-9][0-9].*/; + $runlevel = $1; + + push @arr, { "name" => $runlevel, + "action" => "start" }; + } + + foreach $link (<$rcd_path/boot.d/S[0-9][0-9]$service>) + { + push @arr, {"name" => "B", + "action" => "start" }; + } + + if (scalar @arr > 0) + { + push @ret, { "runlevel" => \@arr }; + $hash{"runlevels"} = \@ret; + $hash{"role"} = &Init::ServicesList::get_role ($service); + } + + return \%hash; +} + +sub get_suse_services +{ + my ($service, %ret); + + ($rcd_path, $initd_path) = &get_sysv_paths (); + + foreach $service (<$gst_prefix/etc/init.d/*>) + { + my (%hash); + + next if (-d $service || ! -x $service); + + $service =~ s/.*\///; + $hash = &get_suse_service_info ($service); + + $ret{$service} = $hash if ($hash ne undef); + } + + return \%ret; +} + +# This function stores the configuration in suse init +sub set_suse_services +{ + my ($services) = @_; + my ($action, $runlevels, $script, $rllist); + + foreach $service (@$services) + { + $script = $$service[0]; + $runlevels = $$service[2]; + $rllist = ""; + + &Utils::File::run ("insserv -r $script"); + + foreach $rl (@$runlevels) + { + if ($$rl[1] eq "start") + { + $rllist .= $$rl[0] . ","; + } + } + + if ($rllist ne "") + { + $rllist =~ s/,$//; + + &Utils::File::run ("insserv $script,start=$rllist"); + } + } +} + +# generic functions to get the available services +sub get_init_type +{ + if (($gst_dist =~ /debian/) && (Utils::File::exists ("/etc/runlevel.conf"))) + { + return "file-rc"; + } + elsif ($gst_dist =~ /slackware/) + { + return "bsd"; + } + elsif (($gst_dist =~ /freebsd/) || ($gst_dist =~ /archlinux/)) + { + return "rcng"; + } + elsif (($gst_dist =~ /gentoo/) || ($gst_dist =~ /^vlos/)) + { + return "gentoo"; + } + elsif ($gst_dist =~ /suse/) + { + return "suse"; + } + else + { + return "sysv"; + } +} + +sub get +{ + $type = &get_init_type (); + + return &get_sysv_services () if ($type eq "sysv"); + return &get_filerc_services () if ($type eq "file-rc"); + return &get_bsd_services () if ($type eq "bsd"); + return &get_gentoo_services () if ($type eq "gentoo"); + return &get_rcng_services () if ($type eq "rcng"); + return &get_suse_services () if ($type eq "suse"); + + return undef; +} + +sub set +{ + my ($services) = @_; + + $type = &get_init_type (); + + &set_sysv_services ($services) if ($type eq "sysv"); + &set_filerc_services ($services) if ($type eq "file-rc"); + &set_bsd_services ($services) if ($type eq "bsd"); + &set_gentoo_services ($services) if ($type eq "gentoo"); + &set_rcng_services ($services) if ($type eq "rcng"); + &set_suse_services ($services) if ($type eq "suse"); +} + +1; diff --git a/service-list.pl.in b/Init/ServicesList.pm index 460c4ea..9f93ae9 100644 --- a/service-list.pl.in +++ b/Init/ServicesList.pm @@ -1,11 +1,8 @@ -#!/usr/bin/env perl #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- -# Functions for getting service descriptions. +# Copyright (C) 2005 Carlos Garnacho # -# Copyright (C) 2002 Ximian, Inc. -# -# Authors: Carlos Garnacho Parro <garnacho@tuxerver.net> +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Library General Public License as published @@ -21,12 +18,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Init::ServicesList; + # This function determines if a service is "forbidden" or not (if runlevel-admin must show it or not) -sub gst_service_list_service_is_forbidden +sub is_forbidden { - my ($service) = @_; - my ($ret); + my ($service) = @_; + my ($ret); my ($service_forbidden_list) = [ @@ -151,8 +150,8 @@ sub gst_service_list_service_is_forbidden { return 1 if ($service =~ "^$i\$"); } - - return undef; + + return 0; } @@ -183,7 +182,7 @@ sub gst_service_list_service_is_forbidden # If you feel that there are more important/necessary roles, # mail me at carlosg@gnome.org -sub gst_service_get_role +sub get_role { my ($script) = @_; @@ -216,7 +215,6 @@ sub gst_service_get_role "cron" => "COMMAND_SCHEDULER", "crond" => "COMMAND_SCHEDULER", "cupsd" => "PRINTER_SERVICE", - "cups" => "PRINTER_SERVICE", "cupsys" => "PRINTER_SERVICE", "daytime" => "NETWORK", "daytime-udp" => "NETWORK", @@ -266,14 +264,15 @@ sub gst_service_get_role "named" => "NETWORK", "netfs" => "SYSTEM", "network" => "SYSTEM", - "nfs" => "FILE_SERVER", - "nfs-user-server" => "FILE_SERVER", - "nfs-kernel-server" => "FILE_SERVER", + "nfs" => "FILE_SERVER_NFS", + "nfs-user-server" => "FILE_SERVER_NFS", + "nfs-kernel-server" => "FILE_SERVER_NFS", "nfslock" => "SYSTEM", "nscd" => "NETWORK", "ntpd" => "NTP_SERVER", "ntpdate" => "NTP_SERVER", "ntp-client" => "NTP_CLIENT", + "ntp-server" => "NTP_SERVER", "ntp-simple" => "NTP_SERVER", "oftpd" => "FTP_SERVER", "oops" => "NETWORK", @@ -295,7 +294,7 @@ sub gst_service_get_role "rhnsd" => "SYSTEM", "rsync" => "NETWORK", "rsyncd" => "NETWORK", - "samba" => "FILE_SERVER", + "samba" => "FILE_SERVER_SMB", "saslauthd" => "SYSTEM", # FIXME: maybe a SECURITY role makes sense? "sendmail" => "MTA", "servers" => "NETWORK", diff --git a/Makefile.am b/Makefile.am index bb49856..367bd8a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,70 +1,39 @@ -SUBDIRS = m4macros files po +SUBDIRS = m4macros files Init Network Shares Time Users Utils -backends = \ - dhcpd-conf \ - disks-conf \ - memory-conf \ - network-conf \ - services-conf \ - shares-conf \ - time-conf \ - users-conf \ - boot-conf \ - print-conf \ - mouse-conf \ - internetsharing-conf \ - package-conf \ - display-conf \ - font-conf +scripts = \ + SystemToolsBackends.pl \ + GroupsConfig.pm \ + HostsConfig.pm \ + IfacesConfig.pm \ + NFSConfig.pm \ + NTPConfig.pm \ + ServicesConfig.pm \ + SMBConfig.pm \ + TimeConfig.pm \ + UsersConfig.pm -perl_libs = \ - boot.pl \ - boot-grub.pl \ - boot-lilo.pl \ - boot-yaboot.pl \ - dhcpd.pl \ - debug.pl \ - file.pl \ - filesys.pl \ - font.pl \ - general.pl \ - ishare.pl \ - media.pl \ - network.pl \ - parse.pl \ - partition.pl \ - platform.pl \ - print.pl \ - process.pl \ - replace.pl \ - report.pl \ - service.pl \ - service-list.pl \ - share.pl \ - tokenizer.pl \ - util.pl \ - x.pl \ - xml.pl - -scripts_SCRIPTS = $(backends) $(perl_libs) guess_system.sh type1inst +scripts_SCRIPTS = $(scripts) EXTRA_DIST = \ intltool-extract.in \ intltool-merge.in \ intltool-update.in \ - system-tools-backends.pc.in \ - guess_system.sh \ - type1inst \ + system-tools-backends-2.0.pc.in \ README \ AUTHORS \ NEWS -CLEANFILES = $(backends) $(perl_libs) +CLEANFILES = $(scripts) -DISTCLEANFILES = \ +DISTCLEANFILES = \ intltool-extract \ intltool-merge \ intltool-update pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = system-tools-backends.pc +pkgconfig_DATA = system-tools-backends-2.0.pc + +# Dbus service file +servicedir = $(DBUS_SERVICES_DIR) +service_DATA = org.freedesktop.SystemToolsBackends.service + diff --git a/NFSConfig.pm b/NFSConfig.pm new file mode 100644 index 0000000..583e92f --- /dev/null +++ b/NFSConfig.pm @@ -0,0 +1,66 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the NFS Configuration +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package NFSConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Shares::NFS; + +my $OBJECT_NAME = "NFSConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + + Utils::Monitor::monitor_files (&Shares::NFS::get_distro_nfs_file (), + $self, $OBJECT_NAME, "changed"); + return $self; +} + +dbus_method ("get", [], [[ "array", [ "struct", "string", [ "array", [ "struct", "string", "int32" ]]]]]); +dbus_method ("set", [[ "array", [ "struct", "string", [ "array", [ "struct", "string", "int32" ]]]]], []); +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + my ($shares); + + $shares = &Shares::NFS::get (); + + return $shares; +} + +sub set +{ + my ($self, @config) = @_; + + &Shares::NFS::set (@config); +} + +1; diff --git a/process.pl.in b/NTPConfig.pm index c1047d6..ba9ec57 100644 --- a/process.pl.in +++ b/NTPConfig.pm @@ -1,9 +1,8 @@ -#!/usr/bin/env perl #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- -# Common process stuff for the setup tools backends. +# DBus object for the NTP config # -# Copyright (C) 2000-2001 Ximian, Inc. +# Copyright (C) 2005 Carlos Garnacho # # Authors: Carlos Garnacho Parro <carlosg@gnome.org> # @@ -21,34 +20,46 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) +package NTPConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Utils::Backend; +use Time::NTP; + +my $OBJECT_NAME = "NTPConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + +# Utils::Monitor::monitor_files (&Users::Groups::get_files (), +# $self, $OBJECT_NAME, "changed"); + + return $self; } -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; +dbus_method ("get", [], [[ "array", "string" ]]); +dbus_method ("set", [[ "array", "string" ]], []); +dbus_signal ("changed", []); -sub gst_process_kill_by_pidfile +sub get { - my ($pidfile) = @_; - my ($buf, $pid); - - if ($pidfile !~ /^\//) - { - # add default pidfiles path if it isn't full path - $pidfile = "/var/run/" . $pidfile; - } - - if (&gst_file_exists ($pidfile)) - { - $buf = &gst_file_buffer_load ($pidfile); - $pid = $$buf[0]; - - &gst_file_run ("kill -9 $pid"); - } + my ($self) = @_; + + return &Time::NTP::get (); +} + +sub set +{ + my ($self, @config) = @_; + + &Time::NTP::set (@config); } 1; diff --git a/Network/.cvsignore b/Network/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/Network/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/Network/Hosts.pm b/Network/Hosts.pm new file mode 100644 index 0000000..899245e --- /dev/null +++ b/Network/Hosts.pm @@ -0,0 +1,306 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# Hosts Configuration handling +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# Carlos Garnacho <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Network::Hosts; + +sub get_fqdn_parse_table +{ + my %dist_map = + ( + "redhat-5.2" => "redhat-6.2", + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-7.2", + "redhat-9" => "redhat-7.2", + "openna-1.0" => "redhat-6.2", + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "redhat-6.2", + "mandrake-9.1" => "redhat-6.2", + "mandrake-9.2" => "redhat-6.2", + "mandrake-10.0" => "redhat-6.2", + "mandrake-10.1" => "redhat-6.2", + "mandrake-10.2" => "redhat-6.2", + "mandriva-2006.0" => "redhat-6.2", + "mandriva-2006.1" => "redhat-6.2", + "yoper-2.2" => "redhat-6.2", + "blackpanther-4.0" => "redhat-6.2", + "conectiva-9" => "redhat-6.2", + "conectiva-10" => "redhat-6.2", + "debian-2.2" => "debian-2.2", + "debian-3.0" => "debian-2.2", + "debian-sarge" => "debian-2.2", + "ubuntu-5.04" => "debian-2.2", + "ubuntu-5.10" => "debian-2.2", + "ubuntu-6.04" => "debian-2.2", + "suse-9.0" => "suse-9.0", + "suse-9.1" => "suse-9.0", + "turbolinux-7.0" => "redhat-7.0", + "pld-1.0" => "redhat-6.2", + "pld-1.1" => "redhat-6.2", + "pld-1.99" => "redhat-6.2", + "fedora-1" => "redhat-7.2", + "fedora-2" => "redhat-7.2", + "fedora-3" => "redhat-7.2", + "fedora-4" => "redhat-7.2", + "rpath" => "redhat-7.2", + "vine-3.0" => "redhat-6.2", + "vine-3.1" => "redhat-6.2", + "ark" => "redhat-6.2", + "slackware-9.1.0" => "suse-9.0", + "slackware-10.0.0" => "suse-9.0", + "slackware-10.1.0" => "suse-9.0", + "slackware-10.2.0" => "suse-9.0", + "gentoo" => "gentoo", + "vlos-1.2" => "gentoo", + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + fn => + { + SYSCONFIG_NW => "/etc/sysconfig/network", + RESOLV_CONF => "/etc/resolv.conf" + }, + table => + [ + [ "hostname", \&Utils::Parse::get_sh, SYSCONFIG_NW, HOSTNAME ], + [ "domain", \&Utils::Parse::split_first_str, RESOLV_CONF, "domain", "[ \t]+" ] + ] + }, + + "redhat-7.2" => + { + fn => + { + SYSCONFIG_NW => ["/etc/sysconfig/networking/profiles/default/network", + "/etc/sysconfig/networking/network", + "/etc/sysconfig/network"], + RESOLV_CONF => ["/etc/sysconfig/networking/profiles/default/resolv.conf", + "/etc/resolv.conf"], + }, + table => + [ + [ "hostname", \&Utils::Parse::get_sh, SYSCONFIG_NW, HOSTNAME ], + [ "domain", \&Utils::Parse::split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], + ] + }, + + "debian-2.2" => + { + fn => + { + RESOLV_CONF => "/etc/resolv.conf", + HOSTNAME => "/etc/hostname", + }, + table => + [ + [ "hostname", \&Utils::Parse::get_first_line, HOSTNAME ], + [ "domain", \&Utils::Parse::split_first_str, RESOLV_CONF, "domain", "[ \t]+" ] + ] + }, + + "suse-9.0" => + { + fn => + { + RESOLV_CONF => "/etc/resolv.conf", + HOSTNAME => "/etc/HOSTNAME", + }, + table => + [ + [ "hostname", \&Utils::Parse::get_fq_hostname, HOSTNAME ], + [ "domain", \&Utils::Parse::get_fq_domain, HOSTNAME ], + [ "domain", \&Utils::Parse::split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], + ] + }, + + "gentoo" => + { + fn => + { + HOSTNAME => "/etc/conf.d/hostname", + DOMAINNAME => "/etc/conf.d/domainname", + RESOLV_CONF => "/etc/resolv.conf", + }, + table => + [ + [ "hostname", \&Utils::Parse::get_sh, HOSTNAME, HOSTNAME ], + [ "domain", \&Utils::Parse::get_sh, DOMAINNAME, DNSDOMAIN ], + [ "domain", \&Utils::Parse::split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], + ] + }, + + "freebsd-5" => + { + fn => + { + RC_CONF => "/etc/rc.conf", + RESOLV_CONF => "/etc/resolv.conf", + }, + table => + [ + [ "hostname", \&Utils::Parse::get_sh_re, RC_CONF, hostname, "^([^\.]*)\." ], + [ "domain", \&Utils::Parse::split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], + ] + }, + ); + + my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + return %{$dist_tables{$dist}} if $dist; + + &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); + return undef; +} + +sub add_statichost_alias +{ + my ($localhost, $alias) = @_; + my $i; + + foreach $i (@$localhost) + { + return if ($i eq $alias); + } + + push @$localhost, $alias; +} + +sub remove_statichost_alias +{ + my ($localhost, $alias) = @_; + my $i; + + for ($i = 0; $i < @$localhost; $i++) { + if ($$localhost[$i] eq $alias) + { + delete $$localhost[$i]; + return; + } + } +} + +sub ensure_loopback_statichost +{ + my ($statichost, $hostname, $old_hostname, $lo_ip) = @_; + my $i; + + if (exists $$statichost{$lo_ip}) + { + my $localhost = $$statichost{$lo_ip}; + &remove_statichost_alias ($localhost, $old_hostname) if ($old_hostname); + &add_statichost_alias ($localhost, $hostname); + } + else + { + $$statichost{$lo_ip} = [ ("localhost", "localhost.localdomain", $hostname) ]; + } +} + +sub get_fqdn +{ + my %dist_attrib; + my $hash; + + %dist_attrib = &get_fqdn_parse_table (); + + $hash = &Utils::Parse::get_from_table ($dist_attrib{"fn"}, + $dist_attrib{"table"}); + + return ($$hash {"hostname"}, $$hash{"domain"}); +} + +sub get +{ + my ($statichosts, @arr); + + $statichosts = &Utils::Parse::split_hash ("/etc/hosts", "[ \t]+", "[ \t]+"); + + foreach $i (sort keys %$statichosts) + { + push @arr, [$i, $$statichosts{$i}]; + } + + return \@arr; +} + +sub get_dns +{ + my (@dns); + + @dns = &Utils::Parse::split_all_unique_hash_comment ("/etc/resolv.conf", "nameserver", "[ \t]+"); + + return @dns; +} + +sub get_search_domains +{ + my (@search_domains); + + @search_domains = &Utils::Parse::split_first_array_unique ("/etc/resolv.conf", "search", "[ \t]+", "[ \t]+"); + + return @search_domains; +} + +sub set_fqdn +{ + # FIXME: implement, add a call to &ensure_loopback_statichost() +} + +sub set +{ + my (@config) = @_; + my ($i, %hash); + + foreach $i (@config) + { + $hash{$i[0]} = $i[1]; + } + + &Utils::Replace::join_hash ("/etc/hosts", "[ \t]+", "[ \t]+", %hash); +} + +sub set_dns +{ + my (@dns) = @_; + + &Utils::Replace::join_all ("/etc/resolv.conf", "nameserver", "[ \t]+", @dns); +} + +sub set_search_domains +{ + my (@search_domains) = @_; + + &Utils::Replace::join_first_array ("/etc/resolv.conf", "search", + "[ \t]+", "[ \t]+", @search_domains); +} + +1; diff --git a/Network/Ifaces.pm b/Network/Ifaces.pm new file mode 100644 index 0000000..1a9cc9e --- /dev/null +++ b/Network/Ifaces.pm @@ -0,0 +1,3372 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# Network Interfaces Configuration handling +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# Arturo Espinosa <arturo@ximian.com> +# Michael Vogt <mvo@debian.org> - Debian 2.[2|3] support. +# David Lee Ludwig <davidl@wpi.edu> - Debian 2.[2|3] support. +# Grzegorz Golawski <grzegol@pld-linux.org> - PLD support +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Network::Ifaces; + +use Utils::Util; +use Init::Services; + +# FIXME: this function isn't IPv6-aware +# it checks if a IP address is in the same network than another +sub is_ip_in_same_network +{ + my ($address1, $address2, $netmask) = @_; + my (@add1, @add2, @mask); + my ($i); + + return 0 if (!$address1 || !$address2 || !$netmask); + + @add1 = split (/\./, $address1); + @add2 = split (/\./, $address2); + @mask = split (/\./, $netmask); + + for ($i = 0; $i < 4; $i++) + { + $add1[$i] += 0; + $add2[$i] += 0; + $mask[$i] += 0; + + return 0 if (($add1[$i] & $mask[$i]) != ($add2[$i] & $mask[$i])); + } + + return 1; +} + +sub ensure_iface_broadcast_and_network +{ + my ($iface) = @_; + + if (exists $$iface{"netmask"} && + exists $$iface{"address"}) + { + if (! exists $$iface{"broadcast"}) + { + $$iface{"broadcast"} = &Utils::Util::ip_calc_broadcast ($$iface{"address"}, $$iface{"netmask"}); + } + + if (! exists $$iface{"network"}) + { + $$iface{"network"} = &Utils::Util::ip_calc_network ($$iface{"address"}, $$iface{"netmask"}); + } + } +} + +sub check_pppd_plugin +{ + my ($plugin) = @_; + my ($version, $output); + + $version = &Utils::File::run_backtick ("pppd --version", 1); + $version =~ s/.*version[ \t]+//; + chomp $version; + + return 0 if !version; + return &Utils::File::exists ("/usr/lib/pppd/$version/$plugin.so"); +} + +sub get_linux_wireless_ifaces +{ + my ($fd, $line); + my (@ifaces, $command); + + $command = &Utils::File::get_cmd_path ("iwconfig"); + open $fd, "$command |"; + return @ifaces if $fd eq undef; + + while (<$fd>) + { + if (/^([a-zA-Z0-9]+)[\t ].*$/) + { + push @ifaces, $1; + } + } + + &Utils::File::close_file ($fd); + + &Utils::Report::leave (); + return \@ifaces; +} + +sub get_freebsd_wireless_ifaces +{ + my ($fd, $line, $iface); + my (@ifaces, $command); + + $command = &Utils::File::get_cmd_path ("iwconfig"); + open $fd, "$command |"; + return @ifaces if $fd eq undef; + + while (<$fd>) + { + if (/^([a-zA-Z]+[0-9]+):/) + { + $iface = $1; + } + + if (/media:.*wireless.*/i) + { + push @ifaces, $iface; + } + } + + &Utils::File::close_file ($fd); + &Utils::Report::leave (); + + return \@ifaces; +} + +# Returns an array with the wireless devices found +sub get_wireless_ifaces +{ + my ($plat) = $Utils::Backend::tool{"system"}; + + return &get_linux_wireless_ifaces if ($plat eq "Linux"); + return &get_freebsd_wireless_ifaces if ($plat eq "FreeBSD"); +} + +# returns interface type depending on it's interface name +# types_cache is a global var for caching interface types +sub get_interface_type +{ + my ($dev) = @_; + my (@wireless_ifaces, $wi, $type); + + return $types_cache{$dev} if (exists $types_cache{$dev}); + + #check whether interface is wireless + $wireless_ifaces = &get_wireless_ifaces (); + foreach $wi (@$wireless_ifaces) + { + if ($dev eq $wi) + { + $types_cache{$dev} = "wireless"; + return $types_cache{$dev}; + } + } + + if ($dev =~ /^(ppp|tun)/) + { + # check whether the proper plugin exists + if (&check_pppd_plugin ("capiplugin")) + { + $types_cache{$dev} = "isdn"; + } + else + { + $types_cache{$dev} = "modem"; + } + } + elsif ($dev =~ /^(eth|dc|ed|bfe|em|fxp|bge|de|xl|ixgb|txp|vx|lge|nge|pcn|re|rl|sf|sis|sk|ste|ti|tl|tx|vge|vr|wb|cs|ex|ep|fe|ie|lnc|sn|xe|le|an|awi|wi|ndis|wlaue|axe|cue|kue|rue|fwe|nve)[0-9]/) + { + $types_cache{$dev} = "ethernet"; + } + elsif ($dev =~ /irlan[0-9]/) + { + $types_cache{$dev} = "irlan"; + } + elsif ($dev =~ /plip[0-9]/) + { + $types_cache{$dev} = "plip"; + } + elsif ($dev =~ /lo[0-9]?/) + { + $types_cache{$dev} = "loopback"; + } + + return $types_cache{$dev}; +} + +sub get_freebsd_interfaces_info +{ + my ($dev, %ifaces, $fd); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_iface_active_get"); + + $fd = &Utils::File::run_pipe_read ("ifconfig"); + return {} if $fd eq undef; + + while (<$fd>) + { + chomp; + if (/^([^ \t:]+):.*(<.*>)/) + { + $dev = $1; + $ifaces{$dev}{"dev"} = $dev; + $ifaces{$dev}{"enabled"} = 1 if ($2 =~ /[<,]UP[,>]/); + } + + s/^[ \t]+//; + if ($dev) + { + $ifaces{$dev}{"hwaddr"} = $1 if /ether[ \t]+([^ \t]+)/i; + $ifaces{$dev}{"addr"} = $1 if /inet[ \t]+([^ \t]+)/i; + $ifaces{$dev}{"mask"} = $1 if /netmask[ \t]+([^ \t]+)/i; + $ifaces{$dev}{"bcast"} = $1 if /broadcast[ \t]+([^ \t]+)/i; + } + } + + &Utils::File::close_file ($fd); + &Utils::Report::leave (); + return %ifaces; +} + +sub get_linux_interfaces_info +{ + my ($dev, %ifaces, $fd); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_iface_active_get"); + + $fd = &Utils::File::run_pipe_read ("ifconfig -a"); + return {} if $fd eq undef; + + while (<$fd>) + { + chomp; + if (/^([^ \t:]+)/) + { + $dev = $1; + $ifaces{$dev}{"enabled"} = 0; + $ifaces{$dev}{"dev"} = $dev; + } + + s/^[ \t]+//; + if ($dev) + { + $ifaces{$dev}{"hwaddr"} = $1 if /HWaddr[ \t]+([^ \t]+)/i; + $ifaces{$dev}{"addr"} = $1 if /addr:([^ \t]+)/i; + $ifaces{$dev}{"mask"} = $1 if /mask:([^ \t]+)/i; + $ifaces{$dev}{"bcast"} = $1 if /bcast:([^ \t]+)/i; + $ifaces{$dev}{"enabled"} = 1 if /^UP[ \t]/i; + } + } + + &Utils::File::close_file ($fd); + &Utils::Report::leave (); + return %ifaces; +} + +sub get_interfaces_info +{ + my (%ifaces, $type); + + return &get_linux_interfaces_info if ($Utils::Backend::tool{"system"} eq "Linux"); + return &get_freebsd_interfaces_info if ($Utils::Backend::tool{"system"} eq "FreeBSD"); + return undef; +} + +# boot method parsing/replacing +sub get_rh_bootproto +{ + my ($file, $key) = @_; + my %rh_to_proto_name = + ( + "bootp" => "bootp", + "dhcp" => "dhcp", + "pump" => "pump", + "none" => "none" + ); + my $ret; + + $ret = &Utils::Parse::get_sh ($file, $key); + + if (!exists $rh_to_proto_name{$ret}) + { + &Utils::Report::do_report ("network_bootproto_unsup", $file, $ret); + $ret = "none"; + } + return $rh_to_proto_name{$ret}; +} + +sub set_rh_bootproto +{ + my ($file, $key, $value) = @_; + my %proto_name_to_rh = + ( + "bootp" => "bootp", + "dhcp" => "dhcp", + "pump" => "pump", + "none" => "none" + ); + + return &Utils::Replace::set_sh ($file, $key, $proto_name_to_rh{$value}); +} + +sub get_debian_bootproto +{ + my ($file, $iface) = @_; + my (@stanzas, $stanza, $method, $bootproto); + my %debian_to_proto_name = + ( + "bootp" => "bootp", + "dhcp" => "dhcp", + "loopback" => "none", + "ppp" => "none", + "static" => "none" + ); + + &Utils::Report::enter (); + @stanzas = &Utils::Parse::get_interfaces_stanzas ($file, "iface"); + + foreach $stanza (@stanzas) + { + if (($$stanza[0] eq $iface) && ($$stanza[1] eq "inet")) + { + $method = $$stanza[2]; + last; + } + } + + if (exists $debian_to_proto_name {$method}) + { + $bootproto = $debian_to_proto_name {$method}; + } + else + { + $bootproto = "none"; + &Utils::Report::do_report ("network_bootproto_unsup", $method, $iface); + } + + &Utils::Report::leave (); + return $bootproto; +} + +sub set_debian_bootproto +{ + my ($file, $iface, $value) = @_; + my (@stanzas, $stanza, $method, $bootproto); + my %proto_name_to_debian = + ( + "bootp" => "bootp", + "dhcp" => "dhcp", + "loopback" => "loopback", + "ppp" => "ppp", + "none" => "static" + ); + + my %dev_to_method = + ( + "lo" => "loopback", + "ppp" => "ppp", + "ippp" => "ppp" + ); + + foreach $i (keys %dev_to_method) + { + $value = $dev_to_method{$i} if $iface =~ /^$i/; + } + + return &Utils::Replace::set_interfaces_stanza_value ($file, $iface, 2, $proto_name_to_debian{$value}); +} + +sub get_slackware_bootproto +{ + my ($file, $iface) = @_; + + if (&Utils::Parse::get_rcinet1conf_bool ($file, $iface, USE_DHCP)) + { + return "dhcp" + } + else + { + return "none"; + } +} + +sub set_slackware_bootproto +{ + my ($file, $iface, $value) = @_; + + if ($value eq "dhcp") + { + &Utils::Replace::set_rcinet1conf ($file, $iface, USE_DHCP, "yes"); + } + else + { + &Utils::Replace::set_rcinet1conf ($file, $iface, USE_DHCP); + } +} + +sub get_bootproto +{ + my ($file, $key) = @_; + my ($str); + + $str = &Utils::Parse::get_sh ($file, $key); + + return "dhcp" if ($key =~ /dhcp/i); + return "bootp" if ($key =~ /bootp/i); + return "none"; +} + +sub set_suse_bootproto +{ + my ($file, $key, $value) = @_; + my %proto_name_to_suse90 = + ( + "dhcp" => "dhcp", + "bootp" => "bootp", + "static" => "none", + ); + + return &Utils::Replace::set_sh ($file, $key, $proto_name_to_suse90{$value}); +} + +sub get_gentoo_bootproto +{ + my ($file, $dev) = @_; + + return "dhcp" if (&Utils::Parse::get_confd_net ($file, "config_$dev") =~ /dhcp/i); + return "none"; +} + +sub set_gentoo_bootproto +{ + my ($file, $dev, $value) = @_; + + return if ($dev =~ /^ppp/); + + return &Utils::Replace::set_confd_net ($file, "config_$dev", "dhcp") if ($value ne "none"); + + # replace with a fake IP address, it will be replaced + # later with the correct one, I know it's a hack + return &Utils::Replace::set_confd_net ($file, "config_$dev", "0.0.0.0"); +} + +sub set_freebsd_bootproto +{ + my ($file, $dev, $value) = @_; + + return &Utils::Replace::set_sh ($file, "ifconfig_$dev", "dhcp") if ($value ne "none"); + return &Utils::Replace::set_sh ($file, "ifconfig_$dev", ""); +} + +# Functions to get the system interfaces, these are distro dependent +sub sysconfig_dir_get_existing_ifaces +{ + my ($dir) = @_; + my (@ret, $i, $name); + local *IFACE_DIR; + + if (opendir IFACE_DIR, "$gst_prefix/$dir") + { + foreach $i (readdir (IFACE_DIR)) + { + push @ret, $1 if ($i =~ /^ifcfg-(.+)$/); + } + + closedir (IFACE_DIR); + } + + return \@ret; +} + +sub get_existing_rh62_ifaces +{ + return @{&sysconfig_dir_get_existing_ifaces ("/etc/sysconfig/network-scripts")}; +} + +sub get_existing_rh72_ifaces +{ + my ($ret, $arr); + + # This syncs /etc/sysconfig/network-scripts and /etc/sysconfig/networking + &Utils::File::run ("redhat-config-network-cmd"); + + $ret = &sysconfig_dir_get_existing_ifaces + ("/etc/sysconfig/networking/profiles/default"); + $arr = &sysconfig_dir_get_existing_ifaces + ("/etc/sysconfig/networking/devices"); + + &Utils::Util::arr_merge ($ret, $arr); + return @$ret; +} + +sub get_existing_suse_ifaces +{ + return @{&sysconfig_dir_get_existing_ifaces ("/etc/sysconfig/network")}; +} + +sub get_existing_pld_ifaces +{ + return @{&sysconfig_dir_get_existing_ifaces ("/etc/sysconfig/interfaces")}; +} + +sub get_pap_passwd +{ + my ($file, $login) = @_; + my (@arr, $passwd); + + $login = '"?' . $login . '"?'; + &Utils::Report::enter (); + &Utils::Report::do_report ("network_get_pap_passwd", $login, $file); + $arr = &Utils::Parse::split_first_array ($file, $login, "[ \t]+", "[ \t]+"); + + $passwd = $$arr[1]; + &Utils::Report::leave (); + + $passwd =~ s/^\"([^\"]*)\"$/$1/; + + return $passwd; +} + +sub set_pap_passwd +{ + my ($file, $login, $passwd) = @_; + my ($line); + + $login = '"' . $login . '"'; + $passwd = '"'. $passwd . '"'; + $line = "* $passwd"; + + return &Utils::Replace::split ($file, $login, "[ \t]+", $line); +} + +sub get_wep_key_type +{ + my ($func) = shift @_; + my ($val); + + $val = &$func (@_); + + return undef if (!$val); + return "ascii" if ($val =~ /^s\:/); + return "hexadecimal"; +} + +sub get_wep_key +{ + my ($func) = shift @_; + my ($val); + + $val = &$func (@_); + $val =~ s/^s\://; + + return $val; +} + +sub set_wep_key_full +{ + my ($key, $key_type, $func); + + # seems kind of hackish, but we want to use distro + # specific saving functions, so we need to leave + # the args as variable as possible + $func = shift @_; + $key_type = pop @_; + $key = pop @_; + + if ($key_type eq "ascii") + { + $key = "s:" . $key; + } + + push @_, $key; + &$func (@_); +} + +sub get_modem_volume +{ + my ($file) = @_; + my ($volume); + + $volume = &Utils::Parse::get_from_chatfile ($file, "AT.*(M0|L[1-3])"); + + return 3 if ($volume eq undef); + + $volume =~ s/^[ml]//i; + return $volume; +} + +sub check_type +{ + my ($type) = shift @_; + my ($expected_type) = shift @_; + my ($func) = shift @_; + + if ($type =~ "^$expected_type") + { + &$func (@_); + } +} + +# Distro specific helper functions +sub get_debian_auto_by_stanza +{ + my ($file, $iface) = @_; + my (@stanzas, $stanza, $i); + + @stanzas = &Utils::Parse::get_interfaces_stanzas ($file, "auto"); + + foreach $stanza (@stanzas) + { + foreach $i (@$stanza) + { + return $stanza if $i eq $iface; + } + } + + return undef; +} + +sub get_debian_auto +{ + my ($file, $iface) = @_; + + return (&get_debian_auto_by_stanza ($file, $iface) ne undef)? 1 : 0; +} + +sub set_debian_auto +{ + my ($file, $iface, $value) = @_; + my ($buff, $line_no, $found); + + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); + $line_no = 0; + + while (($found = &Utils::Replace::interfaces_get_next_stanza ($buff, \$line_no, "auto")) >= 0) + { + if ($value) + { + if ($$buff[$line_no] =~ /[ \t]$iface([\# \t\n])/) + { + return &Utils::File::save_buffer ($buff, $file); + } + } + else + { + # I'm including the hash here, although the man page says it's not supported. + last if $$buff[$line_no] =~ s/[ \t]$iface([\# \t\n])/$1/; + } + + $line_no ++; + } + + if ($found < 0 && $value) + { + &Utils::Replace::interfaces_auto_stanza_create ($buff, $iface); + } + else + { + if ($value) + { + chomp $$buff[$line_no]; + $$buff[$line_no] .= " $iface\n"; + } + $$buff[$line_no] =~ s/auto[ \t]*$//; + } + + return &Utils::File::save_buffer ($buff, $file); +} + +sub get_debian_remote_address +{ + my ($file, $iface) = @_; + my ($str, @tuples, $tuple, @res); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_get_remote", $iface); + + @tuples = &Utils::Parse::get_interfaces_option_tuple ($file, $iface, "up", 1); + + &Utils::Report::leave (); + + foreach $tuple (@tuples) + { + @res = $$tuple[1] =~ /[ \t]+pointopoint[ \t]+([^ \t]+)/; + return $res[0] if $res[0]; + } + + return undef; +} + +sub set_debian_remote_address +{ + my ($file, $iface, $value) = @_; + my ($ifconfig, $ret); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_set_remote", $iface); + + $ifconfig = &Utils::File::locate_tool ("ifconfig"); + + $ret = &Utils::Replace::set_interfaces_option_str ($file, $iface, "up", + "$ifconfig $iface pointopoint $value"); + &Utils::Report::leave (); + return $ret; +} + +sub get_suse_dev_name +{ + my ($iface) = @_; + my ($ifaces, $dev, $hwaddr); + my ($dev); + + $dev = &Utils::Parse::get_sh ("/var/run/sysconfig/if-$iface", "interface"); + + if ($dev eq undef) + { + $dev = &Utils::File::run_backtick ("getcfg-interface $iface"); + } + + # FIXME: is all this necessary? getcfg-interface should give us what we want + if ($dev eq undef) + { + # Those are the last cases, we make rough guesses + if ($iface =~ /-pcmcia-/) + { + # it's something like wlan-pcmcia-0 + $dev =~ s/-pcmcia-//; + } + elsif ($iface =~ /-id-([a-fA-F0-9\:]*)/) + { + # it's something like eth-id-xx:xx:xx:xx:xx:xx, which is the NIC MAC + $hwaddr = $1; + $ifaces = &get_interfaces_info (); + + foreach $d (keys %$ifaces) + { + if ($hwaddr eq $$ifaces{$d}{"hwaddr"}) + { + $dev = $d; + last; + } + } + } + } + + if ($dev eq undef) + { + # We give up, take $iface as $dev + $dev = $iface; + } + + return $dev; +} + +sub get_suse_auto +{ + my ($file, $key) = @_; + my ($ret); + + $ret = &Utils::Parse::get_sh ($file, $key); + + return 1 if ($ret =~ /^onboot$/i); + return 0; +} + +sub set_suse_auto +{ + my ($file, $key, $enabled) = @_; + my ($ret); + + return &Utils::Replace::set_sh($file, $key, + ($enabled) ? "onboot" : "manual"); +} + +sub get_suse_gateway +{ + my ($file, $address, $netmask) = @_; + my ($gateway) = &Utils::Parse::split_first_array_pos ($file, "default", 0, "[ \t]+", "[ \t]+"); + + return $gateway if &is_ip_in_same_network ($address, $gateway, $netmask); + return undef; +} + +# Return IP address or netmask, depending on $what +# FIXME: This function could be used in other places than PLD, +# calculates netmask given format 1.1.1.1/128 +sub get_pld_ipaddr +{ + my ($file, $key, $what) = @_; + my ($ipaddr, $netmask, $ret, $i); + my @netmask_prefixes = (0, 128, 192, 224, 240, 248, 252, 254, 255); + + $ipaddr = &Utils::Parse::get_sh($file, $key); + return undef if $ipaddr eq ""; + + if($ipaddr =~ /([^\/]*)\/([[:digit:]]*)/) + { + $netmask = $2; + return undef if $netmask eq ""; + + if($what eq "address") + { + return $1; + } + + for($i = 0; $i < int($netmask/8); $i++) + { + $ret .= "255."; + } + + $ret .= "$netmask_prefixes[$b%8]." if $netmask < 32; + + for($i = int($netmask/8) + 1; $i < 4; $i++) + { + $ret .= "0."; + } + + chop($ret); + return $ret; + } + return undef; +} + +sub set_pld_ipaddr +{ + my ($file, $key, $what, $value) = @_; + my %prefixes = + ( + "0" => 0, + "128" => 1, + "192" => 2, + "224" => 3, + "240" => 4, + "248" => 5, + "252" => 6, + "254" => 7, + "255" => 8 + ); + my ($ipaddr, $netmask); + + $ipaddr = &Utils::Parse::get_sh($file, $key); + return undef if $ipaddr eq ""; + + if($what eq "address") + { + $ipaddr =~ s/.*\//$value\//; + } + else + { + if($value =~ /([[:digit:]]*).([[:digit:]]*).([[:digit:]]*).([[:digit:]]*)/) + { + $netmask = $prefixes{$1} + $prefixes{$2} + $prefixes{$3} + $prefixes{$4}; + $ipaddr =~ s/\/[[:digit:]]*/\/$netmask/; + } + } + + return &Utils::Replace::set_sh($file, $key, $ipaddr); +} + +sub get_gateway +{ + my ($file, $key, $address, $netmask) = @_; + my ($gateway); + + return undef if ($address eq undef); + + $gateway = &Utils::Parse::get_sh ($file, $key); + + return $gateway if &is_ip_in_same_network ($address, $gateway, $netmask); + return undef; +} + +# looks for eth_up $eth_iface_number +sub get_slackware_auto +{ + my ($file, $rclocal, $iface) = @_; + my ($search) = 0; + my ($buff); + + if ($iface =~ /^eth/) + { + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); + + $iface =~ s/eth//; + + foreach $i (@$buff) + { + if ($i =~ /^[ \t]*'start'\)/) + { + $search = 1; + } + elsif (($i =~ /^[ \t]*;;/) && ($search == 1)) + { + return 0; + } + elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1)) + { + return 1 if ($1 == $iface); + } + } + + return 0; + } + elsif ($iface =~ /^ppp/) + { + return &Utils::Parse::get_kw ($rclocal, "ppp-go"); + } +} + +# adds or deletes eth_up $eth_iface_number +sub set_slackware_auto +{ + my ($file, $rclocal, $iface, $active) = @_; + my ($search) = 0; + my ($nline) = 0; + my ($buff, $sline); + + if ($iface =~ /^eth/) + { + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); + + $iface =~ s/eth//; + + foreach $i (@$buff) + { + if ($i =~ /^[ \t]*('start'\)|\*\))/) + { + # if the line is 'start') or *), begin the search + $search = 1; + } + elsif (($i =~ /^[ \t]*gateway_up/) && ($search == 1)) + { + # save the line in which we're going to save the eth_up stuff + $sline = $nline; + } + elsif (($i =~ /^[ \t]*(;;|esac)/) && ($search == 1)) + { + # we've arrived to the end of the case, if we wanted to + # add the iface, now it's the moment + $$buff[$sline] = "\teth_up $iface\n" . $$buff[$sline] if ($active == 1); + $search = 0; + } + elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1)) + { + if ($1 == $iface) + { + delete $$buff[$nline] if ($active == 0); + $search = 0; + } + } + + $nline++; + } + + return &Utils::File::save_buffer ($buff, $file); + } + elsif ($iface =~ /^ppp/) + { + return &Utils::Replace::set_kw ($rclocal, "ppp-go", $active); + } +} + +sub get_freebsd_auto +{ + my ($file, $defaults_file, $iface) = @_; + my ($val); + + $val = &Utils::Parse::get_sh ($file, "network_interfaces"); + $val = &Utils::Parse::get_sh ($defaults_file, "network_interfaces") if ($val eq undef); + + return 1 if ($val eq "auto"); + return 1 if ($val =~ /$iface/); + return 0; +} + +sub set_freebsd_auto +{ + my ($file, $iface, $active) = @_; + my ($val); + + $val = &Utils::Parse::get_sh ($file, "network_interfaces"); + $val = &Utils::File::run_backtick ("ifconfig -l") if ($val =~ /auto/); + $val .= " "; + + if ($active && ($val !~ /$iface /)) + { + $val .= $iface; + } + elsif (!$active && ($val =~ /$iface /)) + { + $val =~ s/$iface //; + } + + # Trim the string + $val =~ s/^[ \t]*//; + $val =~ s/[ \t]*$//; + + &Utils::Replace::set_sh ($file, "network_interfaces", $val); +} + +sub get_freebsd_ppp_persist +{ + my ($startif, $iface) = @_; + my ($val); + + if ($iface =~ /^tun[0-9]+/) + { + $val = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-(auto|ddial)[ \t]+"); + + return 1 if ($val eq "ddial"); + return 0; + } + + return undef; +} + +# we need this function because essid can be +# multiword, and thus it can't be in rc.conf +sub set_freebsd_essid +{ + my ($file, $startif, $iface, $essid) = @_; + + if ($essid =~ /[ \t]/) + { + # It's multiword + &Utils::File::save_buffer ("ifconfig $iface ssid \"$essid\"", $startif); + &Utils::Replace::set_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", ""); + } + else + { + &Utils::Replace::set_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", " ssid $essid"); + } +} + +sub interface_changed +{ + my ($iface, $old_iface) = @_; + my ($key); + + foreach $key (keys %$iface) + { + next if ($key eq "enabled"); + return 1 if ($$iface{$key} ne $$old_iface{$key}); + } + + return 0; +} + +sub activate_interface_by_dev +{ + my ($dev, $enabled) = @_; + + &Utils::Report::enter (); + + if ($enabled) + { + &Utils::Report::do_report ("network_iface_activate", $dev); + return -1 if &Utils::File::run ("ifup $dev"); + } + else + { + &Utils::Report::do_report ("network_iface_deactivate", $dev); + return -1 if &Utils::File::run ("ifdown $dev"); + } + + &Utils::Report::leave (); + + return 0; +} + +# This works for all systems that have ifup/ifdown scripts. +sub activate_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my ($dev); + + if ($force || &interface_changed ($hash, $old_hash)) + { + $dev = ($$hash{"file"}) ? $$hash{"file"} : $$hash{"dev"}; + &activate_interface_by_dev ($dev, $enabled); + } +} + +# FIXME: can this function be mixed with the above? +sub activate_suse_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my ($iface, $dev); + + if ($force || &interface_changed ($hash, $old_hash)) + { + $dev = ($$hash{"file"}) ? &get_suse_dev_name ($$hash{"file"}) : $$hash{"dev"}; + &activate_interface_by_dev ($dev, $enabled); + } +} + +sub activate_slackware_interface_by_dev +{ + my ($dev, $enabled) = @_; + my ($address, $netmask, $gateway); + my ($file) = "/etc/rc.d/rc.inet1.conf"; + my ($ret) = 0; + + &Utils::Report::enter (); + + if ($enabled) + { + &Utils::Report::do_report ("network_iface_activate", $dev); + + if ($dev =~ /^ppp/) + { + $ret = &Utils::File::run ("ppp-go"); + } + else + { + if (&Utils::Parse::get_rcinet1conf_bool ($file, $dev, USE_DHCP)) + { + # Use DHCP + $ret = &Utils::File::run ("dhclient $dev"); + } + else + { + $address = &Utils::Parse::get_rcinet1conf ($file, $dev, "IPADDR"); + $netmask = &Utils::Parse::get_rcinet1conf ($file, $dev, "NETMASK"); + $gateway = &get_gateway ($file, "GATEWAY", $address, $netmask); + + $ret = &Utils::File::run ("ifconfig $dev $address netmask $netmask up"); + + # Add the gateway if necessary + if ($gateway ne undef) + { + &Utils::File::run ("route add default gw $gateway"); + } + } + } + } + else + { + &Utils::Report::do_report ("network_iface_deactivate", $dev); + + $ret = &Utils::File::run ("ifconfig $dev down") if ($dev =~ /^eth/); + $ret = &Utils::File::run ("ppp-off") if ($dev =~ /^ppp/); + } + + &Utils::Report::leave (); + return -1 if ($ret != 0); + return 0; +} + +sub activate_slackware_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my $dev = $$hash{"file"}; + + if ($force || &interface_changed ($hash, $old_hash)) + { + &activate_slackware_interface_by_dev ($dev, $enabled); + } +} + +sub activate_gentoo_interface_by_dev +{ + my ($dev, $enabled) = @_; + my $file = "/etc/init.d/net.$dev"; + my $action = ($enabled == 1)? "start" : "stop"; + + return &Utils::File::run ("$file $action"); +} + +sub activate_gentoo_interface +{ + my ($hash, $old_hash, $enabled, $force) = @_; + my $dev = $$hash{"file"}; + + if ($force || &interface_changed ($hash, $old_hash)) + { + &activate_gentoo_interface_by_dev ($dev, $enabled); + } +} + +sub activate_freebsd_interface_by_dev +{ + my ($hash, $enabled) = @_; + my ($dev) = $$hash{"file"}; + my ($startif) = "/etc/start_if.$dev"; + my ($file) = "/etc/rc.conf"; + my ($command, $dhcp_flags, $defaultroute, $fd); + + if ($enabled) + { + # Run the /etc/start_if.$dev commands + $fd = &Utils::File::open_read_from_names ($startif); + + while (<$fd>) + { + `$_`; + } + + &Utils::File::close_file ($fd); + $command = &Utils::Parse::get_sh ($file, "ifconfig_$dev"); + + # Bring up the interface + if ($command =~ /DHCP/i) + { + $dhcp_flags = &Utils::Parse::get_sh ($file, "dhcp_flags"); + &Utils::File::run ("dhclient $dhcp_flags $dev"); + } + else + { + &Utils::File::run ("ifconfig $dev $command"); + } + + # Add the default route + $default_route = &Utils::Parse::get_sh ($file, "defaultrouter"); + &Utils::File::run ("route add default $default_route") if ($default_route !~ /^no$/i); + } + else + { + &Utils::File::run ("ifconfig $dev down"); + } +} + +sub activate_freebsd_interface +{ + my ($hash, $old_hash, $enabled, $force) =@_; + + if ($force || &interface_changed ($hash, $old_hash)) + { + &activate_freebsd_interface_by_dev ($hash, $enabled); + } +} + +sub remove_pap_entry +{ + my ($file, $login) = @_; + my ($i, $buff); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_remove_pap", $file, $login); + + $buff = &Utils::File::load_buffer ($file); + + foreach $i (@$buff) + { + $i = "" if ($i =~ /^[ \t]*$login[ \t]/); + } + + &Utils::File::clean_buffer ($buff); + &Utils::Report::leave (); + return &Utils::File::save_buffer ($buff, $file); +} + +sub delete_rh62_interface +{ + my ($old_hash) = @_; + my ($dev, $login); + + $dev = $$old_hash{"file"}; + $login = $old_hash{"login"}; + &activate_interface_by_dev ($dev, 0); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } + + &Utils::File::remove ("/etc/sysconfig/network-scripts/ifcfg-$dev"); +} + +sub delete_rh72_interface +{ + my ($old_hash) = @_; + my ($filedev, $dev, $login); + + $filedev = $$old_hash{"file"}; + $dev = $$old_hash{"dev"}; + $login = $$old_hash{"login"}; + + &activate_interface_by_dev ($filedev, 0); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } + + &Utils::File::remove ("/etc/sysconfig/networking/devices/ifcfg-$filedev"); + &Utils::File::remove ("/etc/sysconfig/networking/profiles/default/ifcfg-$filedev"); + &Utils::File::remove ("/etc/sysconfig/network-scripts/ifcfg-$dev"); + + &Utils::File::run ("redhat-config-network-cmd"); +} + +sub delete_debian_interface +{ + my ($old_hash) = @_; + my ($dev, $login); + + $dev = $$old_hash{"dev"}; + $login = $old_hash{"login"}; + + &activate_interface_by_dev ($dev, 0); + &Utils::Replace::interfaces_iface_stanza_delete ("/etc/network/interfaces", $dev); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } +} + +sub delete_suse_interface +{ + my ($old_hash) = @_; + my ($file, $provider, $dev); + + $file = $$old_hash{"file"}; + $dev = &get_suse_dev_name ($file); + $provider = &Utils::Parse::get_sh ("/etc/sysconfig/network/ifcfg-$file", PROVIDER); + + activate_interface_by_dev ($dev, 0); + + &Utils::File::remove ("/etc/sysconfig/network/ifroute-$file"); + &Utils::File::remove ("/etc/sysconfig/network/ifcfg-$file"); + &Utils::File::remove ("/etc/sysconfig/network/providers/$provider"); +} + +sub delete_pld_interface +{ + my ($old_hash) = @_; + my ($dev, $login); + + my $dev = $$old_hash{"file"}; + my $login = $$old_hash{"login"}; + &activate_interface_by_dev ($dev, 0); + + if ($login) + { + &remove_pap_entry ("/etc/ppp/pap-secrets", $login); + &remove_pap_entry ("/etc/ppp/chap-secrets", $login); + } + + &Utils::File::remove ("/etc/sysconfig/interfaces/ifcfg-$dev"); +} + +sub delete_slackware_interface +{ + my ($old_hash) = @_; + my ($rcinetconf, $rcinet, $rclocal, $pppscript, $dev); + + $rcinetconf = "/etc/rc.d/rc.inet1.conf"; + $rcinet = "/etc/rc.d/rc.inet1"; + $rclocal = "/etc/rc.d/rc.local"; + $pppscript = "/etc/ppp/pppscript"; + $dev = $$old_hash {"dev"}; + + # remove ifup/ppp-go at startup if existing + &set_slackware_auto ($rcinet, $rclocal, $dev, 0); + + if ($dev =~ /^ppp/) + { + &Utils::File::remove ($pppscript); + } + else + { + # empty the values + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "IPADDR", ""); + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "NETMASK", ""); + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "USE_DHCP", ""); + &Utils::Replace::set_rcinet1conf ($rcinetconf, $dev, "DHCP_HOSTNAME", ""); + } +} + +sub delete_gentoo_interface +{ + my ($old_hash) = @_; + my ($dev, $gateway); + + $dev = $$old_hash {"dev"}; + $gateway = $$old_hash {"gateway"}; + + # bring down the interface and remove from init + &Init::Services::set_gentoo_service_status ("/etc/init.d/net.$dev", "default", "stop"); + + if ($dev =~ /^ppp/) + { + &Utils::File::remove ("/etc/conf.d/net.$dev"); + } + else + { + &Utils::Replace::set_sh ("/etc/conf.d/net", "config_$dev", ""); + } +} + +sub delete_freebsd_interface +{ + my ($old_hash) = @_; + my ($dev, $startif, $pppconf); + my ($buff, $line_no, $end_line_no, $i); + + $dev = $$old_hash{"dev"}; + $startif = "/etc/start_if.$dev"; + $pppconf = "/etc/ppp/ppp.conf"; + + &Utils::File::run ("ifconfig $dev down"); + + if ($dev =~ /^tun[0-9]+/) + { + # Delete the ppp.conf section + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $buff = &Utils::File::load_buffer ($pppconf); + + $line_no = &Utils::Parse::pppconf_find_stanza ($buff, $section); + $end_line_no = &Utils::Parse::pppconf_find_next_stanza ($buff, $line_no + 1); + $end_line_no = scalar @$buff + 1 if ($end_line_no == -1); + $end_line_no--; + + for ($i = $line_no; $i <= $end_line_no; $i++) + { + delete $$buff[$i]; + } + + &Utils::File::clean_buffer ($buff); + &Utils::File::save_buffer ($buff, $pppconf); + } + + &Utils::Replace::set_sh ("/etc/rc.conf", "ifconfig_$dev", ""); + &Utils::File::remove ($startif); +} + +# FIXME: should move to external file!!! +sub create_pppscript +{ + my ($pppscript) = @_; + my ($contents); + + if (!&Utils::File::exists ($pppscript)) + { + # create a template file from scratch + $contents = 'TIMEOUT 60' . "\n"; + $contents .= 'ABORT ERROR' . "\n"; + $contents .= 'ABORT BUSY' . "\n"; + $contents .= 'ABORT VOICE' . "\n"; + $contents .= 'ABORT "NO CARRIER"' . "\n"; + $contents .= 'ABORT "NO DIALTONE"' . "\n"; + $contents .= 'ABORT "NO DIAL TONE"' . "\n"; + $contents .= 'ABORT "NO ANSWER"' . "\n"; + $contents .= '"" "ATZ"' . "\n"; + $contents .= '"" "AT&FH0"' . "\n"; + $contents .= 'OK-AT-OK "ATDT000000000"' . "\n"; + $contents .= 'TIMEOUT 75' . "\n"; + $contents .= 'CONNECT' . "\n"; + + &Utils::File::save_buffer ($contents, $pppscript); + } +} + +#FIXME: should move to external file!!! +sub create_pppgo +{ + my ($pppgo) = "/usr/sbin/ppp-go"; + my ($contents, $pppd, $chat); + local *FILE; + + if (!&Utils::File::exists ($pppgo)) + { + $pppd = &Utils::File::locate_tool ("pppd"); + $chat = &Utils::File::locate_tool ("chat"); + + # create a simple ppp-go from scratch + # this script is based on the one that's created by pppsetup + $contents = "killall -INT pppd 2>/dev/null \n"; + $contents .= "rm -f /var/lock/LCK* /var/run/ppp*.pid \n"; + $contents .= "( $pppd connect \"$chat -v -f /etc/ppp/pppscript\") || exit 1 \n"; + $contents .= "exit 0 \n"; + + &Utils::File::save_buffer ($contents, $pppgo); + chmod 0777, "$gst_prefix/$pppgo"; + } +} + +# FIXME: should move to external file!!! +sub create_gentoo_files +{ + my ($dev) = @_; + my ($init) = "/etc/init.d/net.$dev"; + my ($conf) = "/etc/conf.d/net.$dev"; + my ($backup) = "/etc/conf.d/net.ppp0.gstbackup"; + + if ($dev =~ /ppp/) + { + &Utils::File::copy_file ("/etc/init.d/net.ppp0", $init) if (!&Utils::File::exists ($init)); + + # backup the ppp config file + &Utils::File::copy_file ("/etc/conf.d/net.ppp0", $backup) if (!&Utils::File::exists ($backup)); + &Utils::File::copy_file ($backup, $conf) if (!&Utils::File::exists ($conf)); + } + else + { + &Utils::File::copy_file ("/etc/init.d/net.eth0", $init) if (!&Utils::File::exists ($init)); + } + + chmod 0755, "$gst_prefix/$init"; +} + +# FIXME: should move to external file!!! +sub create_ppp_startif +{ + my ($startif, $iface, $dev, $persist) = @_; + my ($section); + + if ($dev =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $section = $dev if ($section eq undef); + + return &Utils::File::save_buffer ("ppp -ddial $section", $startif) if ($persist eq 1); + return &Utils::File::save_buffer ("ppp -auto $section", $startif); + } +} + +sub create_isdn_options +{ + my ($file) = @_; + + if (!&Utils::File::exists ($file)) + { + &Utils::File::copy_file_from_stock ("general_isdn_ppp_options", $file); + } +} + +sub set_modem_volume_sh +{ + my ($file, $key, $volume) = @_; + my ($vol); + + if ($volume == 0) { $vol = "ATM0" } + elsif ($volume == 1) { $vol = "ATL1" } + elsif ($volume == 2) { $vol = "ATL2" } + else { $vol = "ATL3" } + + return &Utils::Replace::set_sh ($file, $key, $vol); +} + +sub set_modem_volume +{ + my ($file, $volume) = @_; + my $line; + + $line = &Utils::Parse::get_from_chatfile ($file, "AT([^DZ][a-z0-9&]+)"); + $line =~ s/(M0|L[1-3])//g; + + if ($volume == 0) { $line .= "M0"; } + elsif ($volume == 1) { $line .= "L1"; } + elsif ($volume == 2) { $line .= "L2"; } + else { $line .= "L3"; } + + return &Utils::Replace::set_chat ($file, "AT([^DZ][a-z0-9&]+)", $line); +} + +sub set_pppconf_route +{ + my ($pppconf, $startif, $iface, $key, $val) = @_; + my ($section); + + if ($iface =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + &Utils::Replace::set_pppconf_common ($pppconf, $section, $key, + ($val == 1)? "add default HISADDR" : undef); + } +} + +sub set_pppconf_dial_command +{ + my ($pppconf, $startif, $iface, $val) = @_; + my ($section, $dial); + + if ($iface =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $dial = &Utils::Parse::get_pppconf ($pppconf, $section, "dial"); + $dial =~ s/ATD[TP]/$val/; + + &Utils::Replace::set_pppconf ($pppconf, $section, "dial", $dial); + } +} + +sub set_pppconf_volume +{ + my ($pppconf, $startif, $iface, $val) = @_; + my ($section, $dial, $vol, $pre, $post); + + if ($iface =~ /^tun[0-9]+/) + { + $section = &Utils::Parse::get_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); + $dial = &Utils::Parse::get_pppconf ($pppconf, $section, "dial"); + + if ($dial =~ /(.*AT[^ \t]*)([ML][0-3])(.* OK .*)/i) + { + $pre = $1; + $post = $3; + } + elsif ($dial =~ /(.*AT[^ \t]*)( OK .*)/i) + { + $pre = $1; + $post = $2; + } + + if ($val == 0) + { + $vol = "M0"; + } + else + { + $vol = "L$val"; + } + + $dial = $pre . $vol . $post; + &Utils::Replace::set_pppconf ($pppconf, $section, "dial", $dial); + } +} + +sub get_interface_parse_table +{ + my %dist_map = + ( + "redhat-5.2" => "redhat-6.2", + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-8.0", + "redhat-9" => "redhat-8.0", + "openna-1.0" => "redhat-6.2", + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "mandrake-9.0", + "mandrake-9.1" => "mandrake-9.0", + "mandrake-9.2" => "mandrake-9.0", + "mandrake-10.0" => "mandrake-9.0", + "mandrake-10.1" => "mandrake-9.0", + "mandrake-10.2" => "mandrake-9.0", + "mandriva-2006.0" => "mandrake-9.0", + "mandriva-2006.1" => "mandrake-9.0", + "yoper-2.2" => "redhat-6.2", + "blackpanther-4.0" => "mandrake-9.0", + "conectiva-9" => "conectiva-9", + "conectiva-10" => "conectiva-9", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + "ubuntu-5.04" => "debian-3.0", + "ubuntu-5.10" => "debian-3.0", + "ubuntu-6.04" => "debian-3.0", + "suse-9.0" => "suse-9.0", + "suse-9.1" => "suse-9.0", + "turbolinux-7.0" => "redhat-6.2", + "pld-1.0" => "pld-1.0", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "fedora-1" => "redhat-7.2", + "fedora-2" => "redhat-7.2", + "fedora-3" => "redhat-7.2", + "fedora-4" => "redhat-7.2", + "rpath" => "redhat-7.2", + "vine-3.0" => "vine-3.0", + "vine-3.1" => "vine-3.0", + "ark" => "vine-3.0", + "slackware-9.1.0" => "slackware-9.1.0", + "slackware-10.0.0" => "slackware-9.1.0", + "slackware-10.1.0" => "slackware-9.1.0", + "slackware-10.2.0" => "slackware-9.1.0", + "gentoo" => "gentoo", + "vlos-1.2" => "gentoo", + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + ifaces_get => \&get_existing_rh62_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + TYPE => "#type#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], + ] + }, + + "redhat-7.2" => + { + ifaces_get => \&get_existing_rh72_ifaces, + fn => + { + IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#", + "/etc/sysconfig/network-scripts/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + TYPE => "#type#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Parse::get_sh, IFCFG, ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "name", \&Utils::Parse::get_trivial, IFACE ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], + # wvdial settings + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "redhat-8.0" => + { + ifaces_get => \&get_existing_rh72_ifaces, + fn => + { + IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#", + "/etc/sysconfig/network-scripts/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + TYPE => "#type#", + IFACE => "#iface#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "name", \&Utils::Parse::get_trivial, IFACE ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], + # wvdial settings + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "vine-3.0" => + { + ifaces_get => \&get_existing_rh62_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + TYPE => "#type#", + IFACE => "#iface#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Parse::get_sh, IFCFG, ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, KEY ]], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], + # wvdial settings + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "mandrake-9.0" => + { + ifaces_get => \&get_existing_rh62_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + TYPE => "#type#", + IFACE => "#iface#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], + # wvdial settings + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "conectiva-9" => + { + ifaces_get => \&get_existing_rh62_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + TYPE => "#type#", + IFACE => "#iface#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf", + WVDIAL => "/etc/wvdial.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "section", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MTU ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MRU ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PAPNAME ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, LINESPEED ]], + [ "ppp_options", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], +# [ "name", \&Utils::Parse::get_sh, IFCFG, NAME ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], + # wvdial settings + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "debian-3.0" => + { + fn => + { + INTERFACES => "/etc/network/interfaces", + IFACE => "#iface#", + TYPE => "#type#", + CHAT => "/etc/chatscripts/%section%", + PPP_OPTIONS => "/etc/ppp/peers/%section%", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + }, + table => + [ + [ "dev", \&Utils::Parse::get_trivial, IFACE ], + [ "bootproto", \&get_debian_bootproto, [INTERFACES, IFACE]], + [ "auto", \&get_debian_auto, [INTERFACES, IFACE]], + [ "address", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "address" ], + [ "netmask", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], + [ "broadcast", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "broadcast" ], + [ "network", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "network" ], + [ "gateway", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], + [ "essid", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "wireless[_-]essid" ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]], + [ "remote_address", \&get_debian_remote_address, [INTERFACES, IFACE]], + [ "section", \&Utils::Parse::get_interfaces_option_str, [INTERFACES, IFACE], "provider" ], + [ "update_dns", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "usepeerdns" ]], + [ "noauth", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "noauth" ]], + [ "mtu", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], + [ "mru", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], + [ "login", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^user \"?([^\"]*)\"?" ]], + [ "password", \&check_type, [TYPE, "(modem|isdn)", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "(modem|isdn)", \&get_pap_passwd, CHAP, "%login%" ]], + [ "set_default_gw", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "defaultroute" ]], + [ "debug", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "debug" ]], + [ "persist", \&check_type, [TYPE, "(modem|isdn)", \&Utils::Parse::get_kw, PPP_OPTIONS, "persist" ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "crtscts" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd[^0-9]([0-9*#]*)[wW]" ]], + [ "external_line", \&check_type, [TYPE, "isdn", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^number[ \t]+(.+)[wW]" ]], + [ "phone_number", \&check_type, [TYPE, "isdn", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^number.*[wW \t](.*)" ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd.*[ptwW]([0-9, -]+)" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "(atd[tp])[0-9, -w]+" ]], + [ "volume", \&check_type, [TYPE, "modem", \&get_modem_volume, CHAT ]], +# [ "ppp_options", \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], + ] + }, + + "suse-9.0" => + { + ifaces_get => \&get_existing_suse_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/network/ifcfg-#iface#", + ROUTES_CONF => "/etc/sysconfig/network/routes", + PROVIDERS => "/etc/sysconfig/network/providers/%section%", + IFACE => "#iface#", + TYPE => "#type#", + }, + table => + [ + [ "dev", \&get_suse_dev_name, IFACE ], + [ "auto", \&get_suse_auto, IFCFG, STARTMODE ], + [ "bootproto", \&get_bootproto, IFCFG, BOOTPROTO ], + [ "address", \&Utils::Parse::get_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Parse::get_sh, IFCFG, NETMASK ], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMOTE_IPADDR ], + [ "essid", \&Utils::Parse::get_sh, IFCFG, WIRELESS_ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, IFCFG, WIRELESS_KEY ]], + [ "gateway", \&get_suse_gateway, ROUTES_CONF, "%address%", "%netmask%" ], + [ "gateway", \&get_suse_gateway, ROUTES_CONF, "%remote_address%", "255.255.255.255" ], + # Modem stuff goes here + [ "serial_port", \&Utils::Parse::get_sh, IFCFG, MODEM_DEVICE ], + [ "serial_speed", \&Utils::Parse::get_sh, IFCFG, SPEED ], + [ "mtu", \&Utils::Parse::get_sh, IFCFG, MTU ], + [ "mru", \&Utils::Parse::get_sh, IFCFG, MRU ], + [ "dial_command", \&Utils::Parse::get_sh, IFCFG, DIALCOMMAND ], + [ "external_line", \&Utils::Parse::get_sh, IFCFG, DIALPREFIX ], + [ "section", \&Utils::Parse::get_sh, IFCFG, PROVIDER ], + [ "volume", \&Utils::Parse::get_sh_re, IFCFG, INIT8, "AT.*[ml]([0-3])" ], + [ "login", \&Utils::Parse::get_sh, PROVIDERS, USERNAME ], + [ "password", \&Utils::Parse::get_sh, PROVIDERS, PASSWORD ], + [ "phone_number", \&Utils::Parse::get_sh, PROVIDERS, PHONE ], + [ "dns1", \&Utils::Parse::get_sh, PROVIDERS, DNS1 ], + [ "dns2", \&Utils::Parse::get_sh, PROVIDERS, DNS2 ], + [ "update_dns", \&Utils::Parse::get_sh_bool, PROVIDERS, MODIFYDNS ], + [ "persist", \&Utils::Parse::get_sh_bool, PROVIDERS, PERSIST ], + [ "stupid", \&Utils::Parse::get_sh_bool, PROVIDERS, STUPIDMODE ], + [ "set_default_gw", \&Utils::Parse::get_sh_bool, PROVIDERS, DEFAULTROUTE ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPD_OPTIONS ], + ] + }, + + "pld-1.0" => + { + ifaces_get => \&get_existing_pld_ifaces, + fn => + { + IFCFG => "/etc/sysconfig/interfaces/ifcfg-#iface#", + CHAT => "/etc/sysconfig/interfaces/data/chat-#iface#", + TYPE => "#type#", + IFACE => "#iface#", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&get_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Parse::get_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Parse::get_sh, IFCFG, DEVICE ], + [ "address", \&get_pld_ipaddr, IFCFG, IPADDR, "address" ], + [ "netmask", \&get_pld_ipaddr, IFCFG, IPADDR, "netmask" ], + [ "gateway", \&Utils::Parse::get_sh, IFCFG, GATEWAY ], + [ "remote_address", \&Utils::Parse::get_sh, IFCFG, REMIP ], + [ "update_dns", \&Utils::Parse::get_sh_bool, IFCFG, PEERDNS ], + [ "mtu", \&Utils::Parse::get_sh, IFCFG, MTU ], + [ "mru", \&Utils::Parse::get_sh, IFCFG, MRU ], + [ "login", \&Utils::Parse::get_sh, IFCFG, PAPNAME ], + [ "password", \&get_pap_passwd, PAP, "%login%" ], + [ "password", \&get_pap_passwd, CHAP, "%login%" ], + [ "serial_port", \&Utils::Parse::get_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Parse::get_sh, IFCFG, LINESPEED ], + [ "set_default_gw", \&Utils::Parse::get_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Parse::get_sh_bool, IFCFG, PERSIST ], + [ "serial_escapechars", \&Utils::Parse::get_sh_bool, IFCFG, ESCAPECHARS ], + [ "serial_hwctl", \&Utils::Parse::get_sh_bool, IFCFG, HARDFLOWCTL ], + [ "phone_number", \&Utils::Parse::get_from_chatfile, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "name", \&Utils::Parse::get_sh, IFCFG, DEVICE ], +# [ "broadcast", \&Utils::Parse::get_sh, IFCFG, BROADCAST ], +# [ "network", \&Utils::Parse::get_sh, IFCFG, NETWORK ], +# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Parse::get_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Parse::get_sh, IFCFG, DNS2 ], +# [ "ppp_options", \&Utils::Parse::get_sh, IFCFG, PPPOPTIONS ], +# [ "section", \&Utils::Parse::get_sh, IFCFG, WVDIALSECT ], +# [ "debug", \&Utils::Parse::get_sh_bool, IFCFG, DEBUG ], + ] + }, + + "slackware-9.1.0" => + { + fn => + { + RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", + RC_INET => "/etc/rc.d/rc.inet1", + RC_LOCAL => "/etc/rc.d/rc.local", + TYPE => "#type#", + IFACE => "#iface#", + WIRELESS => "/etc/pcmcia/wireless.opts", + PPP_OPTIONS => "/etc/ppp/options", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + CHAT => "/etc/ppp/pppscript", + }, + table => + [ + [ "dev", \&Utils::Parse::get_trivial, IFACE ], + [ "address", \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], IPADDR ], + [ "netmask", \&Utils::Parse::get_rcinet1conf, [RC_INET_CONF, IFACE], NETMASK ], + [ "gateway", \&get_gateway, RC_INET_CONF, GATEWAY, "%address%", "%netmask%" ], + [ "auto", \&get_slackware_auto, [RC_INET, RC_LOCAL, IFACE]], + [ "bootproto", \&get_slackware_bootproto, [RC_INET_CONF, IFACE]], + [ "essid", \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, ESSID ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_wireless_opts, [ WIRELESS, IFACE], \&get_wireless_ifaces, KEY ]], + # Modem stuff + [ "update_dns", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "usepeerdns" ]], + [ "noauth", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "noauth" ]], + [ "mtu", \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], + [ "mru", \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], + [ "serial_port", \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], + [ "serial_speed", \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], + [ "login", \&check_type, [TYPE, "modem", \&Utils::Parse::get_ppp_options_re, PPP_OPTIONS, "^name \"?([^\"]*)\"?" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [TYPE, "modem", \&get_pap_passwd, CHAP, "%login%" ]], + [ "set_default_gw", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "defaultroute" ]], + [ "debug", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "debug" ]], + [ "persist", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "persist" ]], + [ "serial_escapechars", \&check_type, [TYPE, "modem", \&Utils::Parse::split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], + [ "serial_hwctl", \&check_type, [TYPE, "modem", \&Utils::Parse::get_kw, PPP_OPTIONS, "crtscts" ]], + [ "external_line", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd[^0-9]*([0-9*#]*)[wW]" ]], + [ "phone_number", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "atd.*[ptw]([0-9, -]+)" ]], + [ "dial_command", \&check_type, [TYPE, "modem", \&Utils::Parse::get_from_chatfile, CHAT, "(atd[tp])[0-9, -w]+" ]], + [ "volume", \&check_type, [TYPE, "modem", \&get_modem_volume, CHAT ]], +# [ "ppp_options", \&check_type, [TYPE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], + ] + }, + + "gentoo" => + { + fn => + { + NET => "/etc/conf.d/net", + PPPNET => "/etc/conf.d/net.#iface#", + INIT => "net.#iface#", + TYPE => "#type#", + IFACE => "#iface#", + WIRELESS => "/etc/conf.d/wireless", + }, + table => + [ + [ "auto", \&Init::Services::get_gentoo_service_status, INIT, "default" ], + [ "dev", \&Utils::Parse::get_trivial, IFACE ], + [ "address", \&Utils::Parse::get_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ], + [ "netmask", \&Utils::Parse::get_confd_net_re, NET, "config_%dev%", "netmask[ \t]+([0-9\.]*)" ], + [ "remote_address", \&Utils::Parse::get_confd_net_re, NET, "config_%dev%", "dest_address[ \t]+([0-9\.]*)" ], + # [ "gateway", \&gst_network_gentoo_parse_gateway, [ NET, IFACE ]], + [ "bootproto", \&get_gentoo_bootproto, [ NET, IFACE ]], + [ "essid", \&Utils::Parse::get_sh, WIRELESS, "essid_%dev%" ], + [ "key_type", \&get_wep_key_type, [ \&Utils::Parse::get_sh, WIRELESS, "key_%essid%" ]], + [ "key", \&get_wep_key, [ \&Utils::Parse::get_sh, WIRELESS, "key_%essid%" ]], + # modem stuff + [ "update_dns", \&Utils::Parse::get_sh_bool, PPPNET, PEERDNS ], + [ "mtu", \&Utils::Parse::get_sh, PPPNET, MTU ], + [ "mru", \&Utils::Parse::get_sh, PPPNET, MRU ], + [ "serial_port", \&Utils::Parse::get_sh, PPPNET, MODEMPORT ], + [ "serial_speed", \&Utils::Parse::get_sh, PPPNET, LINESPEED ], + [ "login", \&Utils::Parse::get_sh, PPPNET, USERNAME ], + [ "password", \&Utils::Parse::get_sh, PPPNET, PASSWORD ], + [ "ppp_options", \&Utils::Parse::get_sh, PPPNET, PPPOPTIONS ], + [ "set_default_gw", \&Utils::Parse::get_sh_bool, PPPNET, DEFROUTE ], + [ "debug", \&Utils::Parse::get_sh_bool, PPPNET, DEBUG ], + [ "persist", \&Utils::Parse::get_sh_bool, PPPNET, PERSIST ], + [ "serial_escapechars", \&Utils::Parse::get_sh_bool, PPPNET, ESCAPECHARS ], + [ "serial_hwctl", \&Utils::Parse::get_sh_bool, PPPNET, HARDFLOWCTL ], + [ "external_line", \&Utils::Parse::get_sh_re, PPPNET, NUMBER, "^([0-9*#]*)wW" ], + [ "phone_number", \&Utils::Parse::get_sh_re, PPPNET, NUMBER, "w?([0-9]*)\$" ], + [ "volume", \&Utils::Parse::get_sh_re, PPPNET, INITSTRING, "^at.*[ml]([0-3])" ], + ] + }, + + "freebsd-5" => + { + fn => + { + RC_CONF => "/etc/rc.conf", + RC_CONF_DEFAULT => "/etc/defaults/rc.conf", + STARTIF => "/etc/start_if.#iface#", + PPPCONF => "/etc/ppp/ppp.conf", + TYPE => "#type#", + IFACE => "#iface#", + }, + table => + [ + [ "auto", \&get_freebsd_auto, [RC_CONF, RC_CONF_DEFAULT, IFACE ]], + [ "dev", \&Utils::Parse::get_trivial, IFACE ], + # we need to double check these values both in the start_if and in the rc.conf files, in this order + [ "address", \&Utils::Parse::get_startif, STARTIF, "inet[ \t]+([0-9\.]+)" ], + [ "address", \&Utils::Parse::get_sh_re, RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)" ], + [ "netmask", \&Utils::Parse::get_startif, STARTIF, "netmask[ \t]+([0-9\.]+)" ], + [ "netmask", \&Utils::Parse::get_sh_re, RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)" ], + [ "remote_address", \&Utils::Parse::get_startif, STARTIF, "dest_address[ \t]+([0-9\.]+)" ], + [ "remote_address", \&Utils::Parse::get_sh_re, RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)" ], + [ "essid", \&Utils::Parse::get_startif, STARTIF, "ssid[ \t]+(\".*\"|[^\"][^ ]+)" ], + [ "essid", \&Utils::Parse::get_sh_re, RC_CONF, "ifconfig_%dev%", "ssid[ \t]+([^ ]*)" ], + # this is for plip interfaces + [ "gateway", \&get_gateway, RC_CONF, "defaultrouter", "%remote_address%", "255.255.255.255" ], + [ "gateway", \&get_gateway, RC_CONF, "defaultrouter", "%address%", "%netmask%" ], + [ "bootproto", \&get_bootproto, RC_CONF, "ifconfig_%dev%" ], + # Modem stuff + [ "serial_port", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "device" ], + [ "serial_speed", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "speed" ], + [ "mtu", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "mtu" ], + [ "mru", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "mru" ], + [ "login", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "authname" ], + [ "password", \&Utils::Parse::get_pppconf, [ PPPCONF, STARTIF, IFACE ], "authkey" ], + [ "update_dns", \&Utils::Parse::get_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "dns" ], + [ "set_default_gw", \&Utils::Parse::get_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ], + [ "external_line", \&Utils::Parse::get_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "phone", "[ \t]+([0-9]+)[wW]" ], + [ "phone_number", \&Utils::Parse::get_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "phone", "[wW]?([0-9]+)[ \t]*\$" ], + [ "dial_command", \&Utils::Parse::get_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "dial", "(ATD[TP])" ], + [ "volume", \&Utils::Parse::get_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "dial", "AT.*[ml]([0-3]) OK " ], + [ "persist", \&get_freebsd_ppp_persist, [ STARTIF, IFACE ]], + ] + }, + ); + + my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + return %{$dist_tables{$dist}} if $dist; + + &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); + return undef; +} + +sub get_interface_replace_table +{ + my %dist_map = + ( + "redhat-5.2" => "redhat-6.2", + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-7.2", + "redhat-8.0" => "redhat-8.0", + "redhat-9" => "redhat-8.0", + "openna-1.0" => "redhat-6.2", + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "mandrake-9.0", + "mandrake-9.1" => "mandrake-9.0", + "mandrake-9.2" => "mandrake-9.0", + "mandrake-10.0" => "mandrake-9.0", + "mandrake-10.1" => "mandrake-9.0", + "mandrake-10.2" => "mandrake-9.0", + "mandriva-2006.0" => "mandrake-9.0", + "mandriva-2006.1" => "mandrake-9.0", + "yoper-2.2" => "redhat-6.2", + "blackpanther-4.0" => "mandrake-9.0", + "conectiva-9" => "conectiva-9", + "conectiva-10" => "conectiva-9", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + "ubuntu-5.04" => "debian-3.0", + "ubuntu-5.10" => "debian-3.0", + "ubuntu-6.04" => "debian-3.0", + "suse-9.0" => "suse-9.0", + "suse-9.1" => "suse-9.0", + "turbolinux-7.0" => "redhat-6.2", + "pld-1.0" => "pld-1.0", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "fedora-1" => "redhat-7.2", + "fedora-2" => "redhat-7.2", + "fedora-3" => "redhat-7.2", + "fedora-4" => "redhat-7.2", + "rpath" => "redhat-7.2", + "vine-3.0" => "vine-3.0", + "vine-3.1" => "vine-3.0", + "ark" => "vine-3.0", + "slackware-9.1.0" => "slackware-9.1.0", + "slackware-10.0.0" => "slackware-9.1.0", + "slackware-10.1.0" => "slackware-9.1.0", + "slackware-10.2.0" => "slackware-9.1.0", + "gentoo" => "gentoo", + "vlos-1.2" => "gentoo", + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], + [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "redhat-7.2" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh72_interface, + fn => + { + IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#", + "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "redhat-8.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh72_interface, + fn => + { + IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#", + "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", + "/etc/sysconfig/networking/devices/ifcfg-#iface#"], + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev" , \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "vine-3.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "mandrake-9.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "conectiva-9" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_rh62_interface, + fn => + { + IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", + CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev" , \&Utils::Replace::set_sh, IFCFG, NAME ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], + [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + # wvdial settings + [ "phone_number", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Phone" ]], + [ "update_dns", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], + [ "login", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Username" ]], + [ "password", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Password" ]], + [ "serial_port", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Modem" ]], + [ "serial_speed", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Baud" ]], + [ "set_default_gw", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], + [ "persist", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], + [ "dial_command", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], + [ "external_line", \&check_type, ["%dev%", "modem", \&Utils::Replace::set_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], + ] + }, + + "debian-3.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_debian_interface, + fn => + { + INTERFACES => "/etc/network/interfaces", + IFACE => "#iface#", + CHAT => "/etc/chatscripts/%section%", + PPP_OPTIONS => "/etc/ppp/peers/%section%", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + }, + table => + [ + [ "_always_", \&set_debian_bootproto, [INTERFACES, IFACE]], + [ "bootproto", \&set_debian_bootproto, [INTERFACES, IFACE]], + [ "auto", \&set_debian_auto, [INTERFACES, IFACE]], + [ "address", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "address" ], + [ "netmask", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], + [ "gateway", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], + [ "essid", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-essid" ], + [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless-key" ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_interfaces_option_str, INTERFACES, IFACE, "wireless-key", "%key%" ]], + # ugly hack for deleting undesired options (due to syntax duality) + [ "essid", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_essid", "" ], + [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_key", "" ], + [ "key", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "wireless_key1", "" ], + # End of hack + [ "section", \&Utils::Replace::set_interfaces_option_str, [INTERFACES, IFACE], "provider" ], + [ "remote_address", \&set_debian_remote_address, [INTERFACES, IFACE]], + # Modem stuff + [ "section", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_connect, PPP_OPTIONS ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&create_pppscript, CHAT ]], + [ "phone_number", \&check_type, [IFACE, "isdn", \&create_isdn_options, PPP_OPTIONS ]], + [ "update_dns", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "usepeerdns" ]], + [ "noauth", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "noauth" ]], + [ "set_default_gw", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "defaultroute" ]], + [ "persist", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "persist" ]], + [ "serial_port", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], + [ "login", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^user (.*)", "user \"%login%\"" ]], + [ "password", \&check_type, [IFACE, "(modem|isdn)", \&set_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [IFACE, "(modem|isdn)", \&set_pap_passwd, CHAP, "%login%" ]], + [ "dial_command", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "(atd[tp])[0-9w, -]+" ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w]+)" ]], + [ "external_line", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]], + [ "phone_number", \&check_type, [IFACE, "isdn", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %phone_number%" ]], + [ "external_line", \&check_type, [IFACE, "isdn", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %external_line%W%phone_number%" ]], + [ "volume", \&check_type, [IFACE, "modem", \&set_modem_volume, CHAT ]], +# [ "serial_escapechars", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], +# [ "debug", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::set_kw, PPP_OPTIONS, "debug" ]], +# [ "serial_hwctl", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "crtscts" ]], +# [ "mtu", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], +# [ "mru", \&check_type, [IFACE, "(modem|isdn)", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], +# [ "serial_speed", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], + ] + }, + + "suse-9.0" => + { + iface_set => \&activate_suse_interface, + iface_delete => \&delete_suse_interface, + fn => + { + IFCFG => "/etc/sysconfig/network/ifcfg-#iface#", + PROVIDERS => "/etc/sysconfig/network/providers/%section%", + ROUTE_CONF => "/etc/sysconfig/network/routes", + IFACE => "#iface#", + PPP_OPTIONS => "/etc/ppp/options" + }, + table => + [ + [ "auto", \&set_suse_auto, IFCFG, STARTMODE ], + [ "bootproto", \&set_suse_bootproto, IFCFG, BOOTPROTO ], + [ "address", \&Utils::Replace::set_sh, IFCFG, IPADDR ], + [ "netmask", \&Utils::Replace::set_sh, IFCFG, NETMASK ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMOTE_IPADDR ], + [ "essid", \&Utils::Replace::set_sh, IFCFG, WIRELESS_ESSID ], + [ "key", \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_sh, IFCFG, WIRELESS_KEY, "%key%" ]], + # Modem stuff goes here + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEM_DEVICE ], + [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPD_OPTIONS ], + [ "dial_command", \&Utils::Replace::set_sh, IFCFG, DIALCOMMAND], + [ "external_line", \&Utils::Replace::set_sh, IFCFG, DIALPREFIX], + [ "provider", \&Utils::Replace::set_sh, IFCFG, PROVIDER ], + [ "volume", \&check_type, [ IFACE, "modem", \&set_modem_volume_sh, IFCFG, INIT8 ]], + [ "login", \&Utils::Replace::set_sh, PROVIDERS, USERNAME ], + [ "password", \&Utils::Replace::set_sh, PROVIDERS, PASSWORD ], + [ "phone_number", \&Utils::Replace::set_sh, PROVIDERS, PHONE ], + [ "update_dns", \&Utils::Replace::set_sh_bool, PROVIDERS, MODIFYDNS ], + [ "persist", \&Utils::Replace::set_sh_bool, PROVIDERS, PERSIST ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, PROVIDERS, DEFAULTROUTE ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, SPEED ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "dns1", \&Utils::Replace::set_sh, PROVIDER, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, PROVIDER, DNS2 ], +# [ "stupid", \&Utils::Replace::set_sh_bool, PROVIDER, STUPIDMODE ], + ] + }, + + "pld-1.0" => + { + iface_set => \&activate_interface, + iface_delete => \&delete_pld_interface, + fn => + { + IFCFG => "/etc/sysconfig/interfaces/ifcfg-#iface#", + CHAT => "/etc/sysconfig/interfaces/data/chat-#iface#", + IFACE => "#iface#", + WVDIAL => "/etc/wvdial.conf", + PUMP => "/etc/pump.conf" + }, + table => + [ + [ "bootproto", \&set_rh_bootproto, IFCFG, BOOTPROTO ], + [ "auto", \&Utils::Replace::set_sh_bool, IFCFG, ONBOOT ], + [ "dev", \&Utils::Replace::set_sh, IFCFG, DEVICE ], + [ "address", \&set_pld_ipaddr, IFCFG, IPADDR, "address" ], + [ "netmask", \&set_pld_ipaddr, IFCFG, IPADDR, "netmask" ], + [ "gateway", \&Utils::Replace::set_sh, IFCFG, GATEWAY ], + [ "update_dns", \&Utils::Replace::set_sh_bool, IFCFG, PEERDNS ], + [ "remote_address", \&Utils::Replace::set_sh, IFCFG, REMIP ], + [ "login", \&Utils::Replace::set_sh, IFCFG, PAPNAME ], + [ "serial_port", \&Utils::Replace::set_sh, IFCFG, MODEMPORT ], + [ "ppp_options", \&Utils::Replace::set_sh, IFCFG, PPPOPTIONS ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, IFCFG, DEFROUTE ], + [ "persist", \&Utils::Replace::set_sh_bool, IFCFG, PERSIST ], + [ "phone_number", \&Utils::Replace::set_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ] +# [ "name", \&Utils::Replace::set_sh, IFCFG, NAME ], +# [ "broadcast", \&Utils::Replace::set_sh, IFCFG, BROADCAST ], +# [ "network", \&Utils::Replace::set_sh, IFCFG, NETWORK ], +# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], +# [ "dns1", \&Utils::Replace::set_sh, IFCFG, DNS1 ], +# [ "dns2", \&Utils::Replace::set_sh, IFCFG, DNS2 ], +# [ "mtu", \&Utils::Replace::set_sh, IFCFG, MTU ], +# [ "mru", \&Utils::Replace::set_sh, IFCFG, MRU ], +# [ "serial_speed", \&Utils::Replace::set_sh, IFCFG, LINESPEED ], +# [ "section", \&Utils::Replace::set_sh, IFCFG, WVDIALSECT ], +# [ "debug", \&Utils::Replace::set_sh_bool, IFCFG, DEBUG ], +# [ "serial_escapechars", \&Utils::Replace::set_sh_bool, IFCFG, ESCAPECHARS ], +# [ "serial_hwctl", \&Utils::Replace::set_sh_bool, IFCFG, HARDFLOWCTL ], + ] + }, + + "slackware-9.1.0" => + { + iface_set => \&activate_slackware_interface, + iface_delete => \&delete_slackware_interface, + fn => + { + RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", + RC_INET => "/etc/rc.d/rc.inet1", + RC_LOCAL => "/etc/rc.d/rc.local", + IFACE => "#iface#", + WIRELESS => "/etc/pcmcia/wireless.opts", + PPP_OPTIONS => "/etc/ppp/options", + PAP => "/etc/ppp/pap-secrets", + CHAP => "/etc/ppp/chap-secrets", + CHAT => "/etc/ppp/pppscript", + }, + table => + [ + [ "address", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], IPADDR ], + [ "netmask", \&Utils::Replace::set_rcinet1conf, [ RC_INET_CONF, IFACE ], NETMASK ], + [ "bootproto", \&set_slackware_bootproto, [ RC_INET_CONF, IFACE ] ], + [ "auto", \&set_slackware_auto, [ RC_INET, RC_LOCAL, IFACE ] ], + [ "essid", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, ESSID ], + [ "key", \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY ], + [ "key_type", \&set_wep_key_full, [ \&Utils::Replace::set_wireless_opts, [ WIRELESS, IFACE ], \&get_wireless_ifaces, KEY, "%key%" ]], + # Modem stuff + [ "phone_number", \&check_type, [IFACE, "modem", \&create_pppscript, CHAT ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&create_pppgo ]], + [ "update_dns", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "usepeerdns" ]], + [ "noauth", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "noauth" ]], + [ "set_default_gw", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "defaultroute" ]], + [ "debug", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "debug" ]], + [ "persist", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "persist" ]], + [ "serial_hwctl", \&check_type, [IFACE, "modem", \&Utils::Replace::set_kw, PPP_OPTIONS, "crtscts" ]], + [ "mtu", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], + [ "mru", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], + [ "serial_port", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], + [ "serial_speed", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], + [ "login", \&check_type, [IFACE, "modem", \&Utils::Replace::set_ppp_options_re, PPP_OPTIONS, "^name \"(.*)\"", "name \"%login%\"" ]], + [ "serial_escapechars", \&check_type, [IFACE, "modem", \&Utils::Replace::join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], + [ "password", \&check_type, [IFACE, "modem", \&set_pap_passwd, PAP, "%login%" ]], + [ "password", \&check_type, [IFACE, "modem", \&set_pap_passwd, CHAP, "%login%" ]], + [ "dial_command", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "(atd[tp])[0-9w, -]+" ]], + [ "phone_number", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w]+)" ]], + [ "external_line", \&check_type, [IFACE, "modem", \&Utils::Replace::set_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]], + [ "volume", \&check_type, [IFACE, "modem", \&set_modem_volume, CHAT ]], + #[ "ppp_options", \&check_type, [IFACE, "modem", \&gst_network_set_ppp_options_unsup, PPP_OPTIONS ]], + ] + }, + + "gentoo" => + { + iface_set => \&activate_gentoo_interface, + iface_delete => \&delete_gentoo_interface, + fn => + { + NET => "/etc/conf.d/net", + PPPNET => "/etc/conf.d/net.#iface#", + INIT => "net.#iface#", + IFACE => "#iface#", + WIRELESS => "/etc/conf.d/wireless", + }, + table => + [ + [ "dev", \&create_gentoo_files ], + [ "auto", \&set_gentoo_service_status, INIT, "default" ], + [ "bootproto", \&set_gentoo_bootproto, [ NET, IFACE ]], + [ "address", \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ], + [ "netmask", \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "[ \t]+netmask[ \t]+[0-9\.]*", " netmask %netmask%"], + [ "broadcast", \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "[ \t]+broadcast[ \t]+[0-9\.]*", " broadcast %broadcast%" ], + [ "remote_address", \&Utils::Replace::set_confd_net_re, NET, "config_%dev%", "[ \t]+dest_address[ \t]+[0-9\.]*", " dest_address %remote_address%" ], + # [ "gateway", \&Utils::Replace::set_confd_net_re, NET, "routes_%dev%", "[ \t]*default[ \t]+(via|gw)[ \t]+[0-9\.\:]*", "default via %gateway%" ], + [ "essid", \&Utils::Replace::set_sh, WIRELESS, "essid_%dev%" ], + [ "key", \&Utils::Replace::set_sh, WIRELESS, "key_%essid%" ], + [ "key_type", \&set_wep_key_type, [ \&Utils::Replace::set_sh, WIRELESS, "key_%essid%", "%key%" ]], + # modem stuff + [ "dev", \&check_type, [ IFACE, "modem", \&Utils::Replace::set_sh, PPPNET, PEER ]], + [ "update_dns", \&check_type, [ IFACE, "modem", \&Utils::Replace::set_sh_bool, PPPNET, PEERDNS ]], + [ "mtu", \&Utils::Replace::set_sh, PPPNET, MTU ], + [ "mru", \&Utils::Replace::set_sh, PPPNET, MRU ], + [ "serial_port", \&Utils::Replace::set_sh, PPPNET, MODEMPORT ], + [ "serial_speed", \&Utils::Replace::set_sh, PPPNET, LINESPEED ], + [ "login", \&Utils::Replace::set_sh, PPPNET, USERNAME ], + [ "password", \&Utils::Replace::set_sh, PPPNET, PASSWORD ], + [ "ppp_options", \&Utils::Replace::set_sh, PPPNET, PPPOPTIONS ], + [ "set_default_gw", \&Utils::Replace::set_sh_bool, PPPNET, DEFROUTE ], + [ "debug", \&Utils::Replace::set_sh_bool, PPPNET, DEBUG ], + [ "persist", \&Utils::Replace::set_sh_bool, PPPNET, PERSIST ], + [ "serial_escapechars", \&Utils::Replace::set_sh_bool, PPPNET, ESCAPECHARS ], + [ "serial_hwctl", \&Utils::Replace::set_sh_bool, PPPNET, HARDFLOWCTL ], + [ "phone_number", \&Utils::Replace::set_sh, PPPNET, NUMBER ], + [ "external_line", \&Utils::Replace::set_sh, PPPNET, NUMBER, "%external_line%W%phone_number%" ], + [ "volume", \&set_modem_volume_sh, PPPNET, INITSTRING ], + ] + }, + + "freebsd-5" => + { + iface_set => \&activate_freebsd_interface, + iface_delete => \&delete_freebsd_interface, + fn => + { + RC_CONF => "/etc/rc.conf", + STARTIF => "/etc/start_if.#iface#", + PPPCONF => "/etc/ppp/ppp.conf", + IFACE => "#iface#", + }, + table => + [ + [ "auto", \&set_freebsd_auto, [ RC_CONF, IFACE ]], + [ "bootproto", \&set_freebsd_bootproto, [ RC_CONF, IFACE ]], + [ "address", \&Utils::Replace::set_sh_re, RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)", "inet %address%" ], + [ "netmask", \&Utils::Replace::set_sh_re, RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)", " netmask %netmask%" ], + [ "remote_address", \&Utils::Replace::set_sh_re, RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)", " dest_address %remote_address%" ], + [ "essid", \&set_freebsd_essid, [ RC_CONF, STARTIF, IFACE ]], + # Modem stuff + # we need this for putting an empty ifconfig_tunX command in rc.conf + [ "phone_number", \&Utils::Replace::set_sh, RC_CONF, "ifconfig_%dev%", " " ], + [ "file", \&create_ppp_startif, [ STARTIF, IFACE ]], + [ "persist", \&create_ppp_startif, [ STARTIF, IFACE ], "%file%" ], + [ "serial_port", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "device" ], + [ "serial_speed", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "speed" ], + [ "mtu", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "mtu" ], + [ "mru", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "mru" ], + [ "login", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "authname" ], + [ "password", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "authkey" ], + [ "update_dns", \&Utils::Replace::set_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "dns" ], + [ "set_default_gw", \&set_pppconf_route, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ], + [ "phone_number", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "phone" ], + [ "external_line", \&Utils::Replace::set_pppconf, [ PPPCONF, STARTIF, IFACE ], "phone", "%external_line%W%phone_number%" ], + [ "dial_command", \&set_pppconf_dial_command, [ PPPCONF, STARTIF, IFACE ]], + [ "volume", \&set_pppconf_volume, [ PPPCONF, STARTIF, IFACE ]], + ] + } + ); + + my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + return %{$dist_tables{$dist}} if $dist; + + &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); + return undef; +} + +sub add_dialup_iface +{ + my ($ifaces) = @_; + my ($dev, $i); + + $dev = "ppp0" if ($Utils::Backend::tool{"system"} eq "Linux"); + $dev = "tun0" if ($Utils::Backend::tool{"system"} eq "FreeBSD"); + + foreach $i (@$ifaces) + { + return if ($i eq $dev); + } + + push @$ifaces, $dev if (&Utils::File::locate_tool ("pppd")); +} + +sub get_interfaces_config +{ + my (%dist_attrib, %config_hash, %hash, %fn); + my (@config_ifaces, @ifaces, $iface, $dev); + my ($dist, $value, $file, $proc); + my ($i, $j); + my ($modem_settings); + + %hash = &get_interfaces_info (); + %dist_attrib = &get_interface_parse_table (); + %fn = %{$dist_attrib{"fn"}}; + $proc = $dist_attrib{"ifaces_get"}; + + # FIXME: is proc necessary? why not using hash keys? + if ($proc) + { + @ifaces = &$proc (); + } + else + { + @ifaces = keys %hash; + } + + &add_dialup_iface (\@ifaces); + + # clear unneeded hash elements + foreach $i (@ifaces) + { + foreach $j (keys (%fn)) + { + ${$dist_attrib{"fn"}}{$j} = &Utils::Parse::expand ($fn{$j}, + "iface", $i, + "type", &get_interface_type ($i)); + } + + $iface = &Utils::Parse::get_from_table ($dist_attrib{"fn"}, + $dist_attrib{"table"}); + + &ensure_iface_broadcast_and_network ($iface); + $$iface{"file"} = $i if ($$iface{"file"} eq undef); + + if (exists $hash{$i}) + { + foreach $k (keys %$iface) + { + $hash{$i}{$k} = $$iface{$k}; + } + } + elsif (($i eq "ppp0") || ($dev eq "tun0")) + { + $hash{$i}{"dev"} = $i; + $hash{$i}{"enabled"} = 0; + + foreach $k (keys %$iface) + { + $hash{$i}{$k} = $$iface{$k}; + } + } + } + + return \%hash; +} + +sub interface_configured +{ + my ($iface) = @_; + my ($type); + + # FIXME: checking for "configuration" key is much better + $type = &get_interface_type ($$iface{"dev"}); + + if ($type eq "ethernet" || $type eq "irlan") + { + return 1 if ($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"netmask"})); + } + elsif ($type eq "wireless") + { + return 1 if (($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"netmask"})) && $$iface{"essid"}); + } + elsif ($type eq "plip") + { + return 1 if ($$iface{"bootproto"} eq "dhcp" || ($$iface{"address"} && $$iface{"remote_address"})); + } + elsif ($type eq "modem" || $type eq "isdn") + { + return 1 if ($$iface{"phone_number"} && $$iface{"login"}); + } + + return 0; +} + +sub set_interface_config +{ + my ($dev, $values_hash, $old_hash) = @_; + my (%dist_attrib, %fn); + my ($proc, $i, $res); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_iface_set", $dev); + + %dist_attrib = &get_interface_replace_table (); + $proc = $dist_attrib{"iface_set"}; + %fn = %{$dist_attrib{"fn"}}; + + foreach $i (keys (%fn)) + { + $ {$dist_attrib{"fn"}}{$i} = &Utils::Parse::expand ($fn{$i}, "iface", $dev); + } + + $res = &Utils::Replace::set_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, + $values_hash, $old_hash); + + # if success saving the settings for the interface, set up immediatly. + &$proc ($values_hash, $old_hash, $$values_hash{"enabled"}, 0) if !$res; + + &Utils::Report::leave (); + return $res; +} + +sub set_interfaces_config +{ + my ($values_hash) = @_; + my ($old_hash); + my (%dist_attrib); + my ($i); + my ($delete_proc, $set_proc); + my ($do_active); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_ifaces_set"); + + %dist_attrib = &get_interface_replace_table (); + $old_hash = &get_interfaces_config (); + + $delete_proc = $dist_attrib{"iface_delete"}; + $set_proc = $dist_attrib{"iface_set"}; + + foreach $i (keys %$values_hash) + { + $do_active = $$values_hash{$i}{"enabled"}; + + # delete it if it's no longer configured + if (&interface_configured ($$old_hash{$i}) && + !&interface_configured ($$values_hash{$i})) + { + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); + &$delete_proc ($$old_hash{$i}); + } + elsif (&interface_configured ($$values_hash{$i}) && + &interface_changed ($$values_hash{$i}, $$old_hash{$i})) + { + $$values_hash{$i}{"file"} = $$old_hash{$i}{"file"}; + + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); + &set_interface_config ($i, $$values_hash{$i}, $$old_hash{$i}); + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 1, 1) if ($do_active); + } + elsif ($$values_hash{$i}{"enabled"} != $$old_hash{$i}{"enabled"}) + { + # only state has changed + &$set_proc ($$values_hash{$i}, $$old_hash{$i}, $do_active, 1); + } + + } + + &Utils::Report::leave (); +} + +sub get +{ + my ($config, $iface, $type); + my ($ethernet, $wireless, $irlan); + my ($plip, $modem, $isdn); + + $config = &get_interfaces_config (); + + foreach $i (keys %$config) + { + $iface = $$config{$i}; + $type = &get_interface_type ($i); + + if ($type eq "ethernet") + { + push @$ethernet, [ $$iface{"dev"}, $$iface{"enabled"}, + ($$iface{"bootproto"} eq "dhcp") ? 1 : 0, + $$iface{"address"}, $$iface{"netmask"}, + $$iface{"network"}, $$iface{"broadcast"} ]; + } + elsif ($type eq "wireless") + { + push @$wireless, [ $$iface{"dev"}, $$iface{"enabled"}, + ($$iface{"bootproto"} eq "dhcp") ? 1 : 0, + $$iface{"address"}, $$iface{"netmask"}, + $$iface{"network"}, $$iface{"broadcast"}, + $$iface{"essid"}, + ($$iface{"key_type"} eq "ascii") ? 0 : 1, + $$iface{"key"} ]; + } + elsif ($type eq "irlan") + { + push @$irlan, [ $$iface{"dev"}, $$iface{"enabled"}, + ($$iface{"bootproto"} eq "dhcp") ? 1 : 0, + $$iface{"address"}, $$iface{"netmask"}, + $$iface{"network"}, $$iface{"broadcast"} ]; + } + elsif ($type eq "plip") + { + push @$plip, [ $$iface{"dev"}, $$iface{"enabled"}, + $$iface{"address"}, $$iface{"remote_address"} ]; + } + elsif ($type eq "modem") + { + push @$modem, [ $$iface{"dev"}, $$iface{"enabled"}, + $$iface{"phone_number"}, $$iface{"external_line"}, + $$iface{"serial_port"}, $$iface{"volume"}, + ($$iface{"dial_command"} eq "atdt") ? 0 : 1, + $$iface{"login"}, $$iface{"password"}, + $$iface{"set_default_gw"}, $$iface{"update_dns"}, + $$iface{"persist"}, $$iface{"noauth"} ]; + } + elsif ($type eq "isdn") + { + push @$isdn, [ $$iface{"dev"}, $$iface{"enabled"}, + $$iface{"phone_number"}, $$iface{"external_line"}, + $$iface{"login"}, $$iface{"password"}, + $$iface{"set_default_gw"}, $$iface{"update_dns"}, + $$iface{"persist"}, $$iface{"noauth"} ]; + } + } + + return ($ethernet, $wireless, $irlan, + $plip, $modem, $isdn); +} + +sub set +{ + my ($ethernet, $wireless, $irlan, $plip, $modem, $isdn) = @_; + my (%hash, $iface, $bootproto, $key_type); + + foreach $iface (@$ethernet) + { + $bootproto = ($$iface[2] == 1) ? "dhcp" : "none"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "bootproto" => $bootproto, + "address" => $$iface[3], "netmask" => $$iface[4] }; + } + + foreach $iface (@$wireless) + { + $bootproto = ($$iface[2] == 1) ? "dhcp" : "none"; + $key_type = ($$iface[8] == 1) ? "hexadecimal" : "ascii"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "bootproto" => $bootproto, + "address" => $$iface[3], "netmask" => $$iface[4], + "essid" => $$iface[7], "key_type" => $key_type, "key" => $$iface[9] }; + } + + foreach $iface (@$irlan) + { + $bootproto = ($$iface[2] == 1) ? "dhcp" : "none"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "bootproto" => $bootproto, + "address" => $$iface[3], "netmask" => $$iface[4] }; + } + + foreach $iface (@$plip) + { + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "address" => $$iface[2], "remote_address" => $$iface[3] }; + } + + foreach $iface (@$modem) + { + $dial_command = ($$iface[6] == 0) ? "ATDT" : "ATDP"; + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "phone_number" => $$iface[2], "external_line" => $$iface[3], + "serial_port" => $$iface[4], "volume" => $$iface[5], + "dial_command" => $dial_command, + "login" => $$iface[7], "password" => $$iface[8], + "set_default_gw" => $$iface[9], "update_dns"=> $$iface[10], + "persist" => $$iface[11], "noauth" => $$iface[12] }; + } + + foreach $iface (@$isdn) + { + $hash{$$iface[0]} = { "dev" => $$iface[0], "enabled" => $$iface[1], + "phone_number" => $$iface[2], "external_line" => $$iface[3], + "login" => $$iface[4], "password" => $$iface[5], + "set_default_gw" => $$iface[6], "update_dns"=> $$iface[7], + "persist" => $$iface[8], "noauth" => $$iface[9] }; + } + + &set_interfaces_config (\%hash); +} + +1; diff --git a/Network/Makefile.am b/Network/Makefile.am new file mode 100644 index 0000000..5f36923 --- /dev/null +++ b/Network/Makefile.am @@ -0,0 +1,5 @@ +sharesdir = $(scriptsdir)/Network + +shares_SCRIPTS = \ + Hosts.pm \ + Ifaces.pm diff --git a/SMBConfig.pm b/SMBConfig.pm new file mode 100644 index 0000000..743249c --- /dev/null +++ b/SMBConfig.pm @@ -0,0 +1,65 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the SMB Configuration +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package SMBConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Shares::SMB; + +my $OBJECT_NAME = "SMBConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + + Utils::Monitor::monitor_files (&Shares::SMB::get_distro_smb_file (), + $self, $OBJECT_NAME, "changed"); + return $self; +} + +dbus_method ("get", [], [[ "array", [ "struct", "string", "string", "string", "int32", "int32", "int32", "int32" ]], + "string", "string", "int32", "string" ]); +dbus_method ("set", [[ "array", [ "struct", "string", "string", "string", "int32", "int32", "int32", "int32" ]], + "string", "string", "int32", "string" ], []); +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + + return &Shares::SMB::get (); +} + +sub set +{ + my ($self, @config) = @_; + + &Shares::SMB::set (@config); +} + +1; diff --git a/ServicesConfig.pm b/ServicesConfig.pm new file mode 100644 index 0000000..bdbae76 --- /dev/null +++ b/ServicesConfig.pm @@ -0,0 +1,71 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Services config +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package ServicesConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Init::Services; + +my $OBJECT_NAME = "ServicesConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + +# Utils::Monitor::monitor_files (&Users::Groups::get_files (), +# $self, $OBJECT_NAME, "changed"); + + return $self; +} + +dbus_method ("get", [], + [[ "array", [ "struct", "string", "string" ]], + "string", + [ "array", [ "struct", "string", "string", [ "array", [ "struct", "string", "string", "int32" ]]]]]); +dbus_method ("set", [[ "array", [ "struct", "string", "string" ]], + "string", + [ "array", [ "struct", "string", "string", [ "array", [ "struct", "string", "string", "int32" ]]]]], []); +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + + return (&Init::Services::get_runlevel_roles (), + &Init::Services::get_default_runlevel (), + &Init::Services::get ()); +} + +sub set +{ + my ($self, @config) = @_; + + &Init::Services::set ($config[2]); +} + +1; diff --git a/ServicesList.pm b/ServicesList.pm new file mode 100644 index 0000000..dd11d53 --- /dev/null +++ b/ServicesList.pm @@ -0,0 +1,60 @@ +#!/usr/bin/env perl +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Services list +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package ServicesList; + +use base qw(Net::DBus::Object); +use Init::Services; + +my $OBJECT_NAME = "ServicesList"; +my $SERVICES_PATH = $Utils::Backend::DBUS_PATH . "/" . $OBJECT_NAME; + +sub new +{ + my $class = shift; + my $self = $class->SUPER::new ($SERVICES_PATH, + { + $OBJECT_NAME => { + methods => { + "get" => { + params => [], + returns => [[ "dict", "string", [ "dict", "string", "string" ]]], + }, + }, + }, + }, + @_); + bless $self, $class; + return $self; +} + +sub get +{ + my ($self) = @_; + my ($services); + + $services = Init::Services::gst_service_get_services (); + return $services; +} + +1; diff --git a/Shares/.cvsignore b/Shares/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/Shares/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/share.pl.in b/Shares/Exports.pm index 4c073b6..a26c77b 100644 --- a/share.pl.in +++ b/Shares/Exports.pm @@ -21,6 +21,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Shares::Exports; + +use Utils::File; +use Utils::Replace; +use Utils::Parse; + $SCRIPTSDIR = "@scriptsdir@"; if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) @@ -29,10 +35,6 @@ if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) $DOTIN = ".in"; } -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; require "$SCRIPTSDIR/network.pl$DOTIN"; @@ -363,25 +365,25 @@ sub gst_share_parse_smb_conf # Get the sections. - @sections = &gst_parse_ini_sections ($smb_conf_name); + @sections = &Utils::Parse::get_ini_sections ($smb_conf_name); for $section (@sections) { next if ($section =~ /^(global)|(homes)|(printers)|(print\$)$/); - next if (&gst_parse_ini_bool ($smb_conf_name, $section, "printable")); + next if (&Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "printable")); my $sesi = &gst_share_smb_info_new (); my $point, $comment, $enabled, $browseable, $public, $writable, $printable; - $point = &gst_parse_ini ($smb_conf_name, $section, "path"); - $comment = &gst_parse_ini ($smb_conf_name, $section, "comment"); - $enabled = &gst_parse_ini_bool ($smb_conf_name, $section, "available"); - $browseable = &gst_parse_ini_bool ($smb_conf_name, $section, "browsable") || - &gst_parse_ini_bool ($smb_conf_name, $section, "browseable"); - $public = &gst_parse_ini_bool ($smb_conf_name, $section, "public") || - &gst_parse_ini_bool ($smb_conf_name, $section, "guest"); - $writable = &gst_parse_ini_bool ($smb_conf_name, $section, "writable") || - &gst_parse_ini_bool ($smb_conf_name, $section, "writeable"); + $point = &Utils::Parse::get_from_ini ($smb_conf_name, $section, "path"); + $comment = &Utils::Parse::get_from_ini ($smb_conf_name, $section, "comment"); + $enabled = &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "available"); + $browseable = &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "browsable") || + &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "browseable"); + $public = &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "public") || + &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "guest"); + $writable = &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "writable") || + &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "writeable"); &gst_share_smb_info_set_name ($sesi, $section); &gst_share_smb_info_set_point ($sesi, $point); @@ -405,7 +407,7 @@ sub gst_share_parse_nfs_exports $table = &gst_share_nfs_table_new (); - $entries = &gst_parse_split_hash_with_continuation ($nfs_exports_name, "[ \t]+", "[ \t]+"); + $entries = &Utils::Parse::split_hash_with_continuation ($nfs_exports_name, "[ \t]+", "[ \t]+"); foreach $point (keys %$entries) { @@ -456,16 +458,16 @@ sub gst_share_replace_smb_conf # Get the sections. - @sections = &gst_parse_ini_sections ($file); + @sections = &Utils::Parse::get_ini_sections ($file); for $section (@sections) { next if ($section =~ /^(global)|(homes)|(printers)|(print\$)$/); - next if (&gst_parse_ini_bool ($file, $section, "printable")); + next if (&Utils::Parse::get_from_ini_bool ($file, $section, "printable")); if (!&gst_share_smb_table_find ($table, $section)) { - &gst_replace_remove_ini_section ($file, $section); + &Utils::Replace::remove_ini_section ($file, $section); } } @@ -474,20 +476,20 @@ sub gst_share_replace_smb_conf my $point, $comment, $enabled, $browseable, $public, $writable, $printable; my $name = &gst_share_smb_info_get_name ($export); - &gst_replace_ini ($file, $name, "path", &gst_share_smb_info_get_point ($export)); - &gst_replace_ini ($file, $name, "comment", &gst_share_smb_info_get_comment ($export)); - &gst_replace_ini_bool ($file, $name, "available", &gst_share_smb_info_get_enabled ($export)); - &gst_replace_ini_bool ($file, $name, "browseable", &gst_share_smb_info_get_browse ($export)); - &gst_replace_ini_bool ($file, $name, "public", &gst_share_smb_info_get_public ($export)); - &gst_replace_ini_bool ($file, $name, "writable", &gst_share_smb_info_get_write ($export)); + &Utils::Replace::set_ini ($file, $name, "path", &gst_share_smb_info_get_point ($export)); + &Utils::Replace::set_ini ($file, $name, "comment", &gst_share_smb_info_get_comment ($export)); + &Utils::Replace::set_ini_bool ($file, $name, "available", &gst_share_smb_info_get_enabled ($export)); + &Utils::Replace::set_ini_bool ($file, $name, "browseable", &gst_share_smb_info_get_browse ($export)); + &Utils::Replace::set_ini_bool ($file, $name, "public", &gst_share_smb_info_get_public ($export)); + &Utils::Replace::set_ini_bool ($file, $name, "writable", &gst_share_smb_info_get_write ($export)); - &gst_replace_remove_ini_var ($file, $name, "browsable"); - &gst_replace_remove_ini_var ($file, $name, "guest"); - &gst_replace_remove_ini_var ($file, $name, "writeable"); + &Utils::Replace::remove_ini_var ($file, $name, "browsable"); + &Utils::Replace::remove_ini_var ($file, $name, "guest"); + &Utils::Replace::remove_ini_var ($file, $name, "writeable"); } } -sub gst_share_nfs_exports_get_next_entry_line # $infd, $outfd +sub gst_share_nfs_exports_get_next_entry_line { my ($infd, $outfd) = @_; @@ -497,7 +499,7 @@ sub gst_share_nfs_exports_get_next_entry_line # $infd, $outfd # <point> <clients> my @line = split /[ \t]+/, $_; if ($line[0] eq "") { shift @line; } - if (@line < 1 || &gst_ignore_line (@line)) { print $outfd $_; next; } + if (@line < 1 || &Utils::Util::ignore_line (@line)) { print $outfd $_; next; } return $_; } @@ -652,14 +654,14 @@ sub gst_share_nfs_exports_add_entry my ($infd, $outfd); my ($line); - ($infd, $outfd) = &gst_file_open_filter_write_from_names ($file); + ($infd, $outfd) = &Utils::File::open_filter_write_from_names ($file); return undef if !$outfd; while (<$infd>) { print $outfd $_; } - &gst_file_close ($infd); + &Utils::File::close_file ($infd); print $outfd &gst_share_nfs_info_print_entry ($info) . "\n"; - &gst_file_close ($outfd); + &Utils::File::close_file ($outfd); } sub gst_share_nfs_exports_update_entry # filename, filesys_info @@ -669,7 +671,7 @@ sub gst_share_nfs_exports_update_entry # filename, filesys_info my ($line); my $replaced = 0; - ($infd, $outfd) = &gst_file_open_filter_write_from_names ($file); + ($infd, $outfd) = &Utils::File::open_filter_write_from_names ($file); return undef if !$outfd; while ($line = &gst_share_nfs_exports_get_next_entry_line ($infd, $outfd)) @@ -687,8 +689,8 @@ sub gst_share_nfs_exports_update_entry # filename, filesys_info } } - &gst_file_close ($infd); - &gst_file_close ($outfd); + &Utils::File::close_file ($infd); + &Utils::File::close_file ($outfd); } sub gst_share_nfs_exports_remove_entry @@ -697,7 +699,7 @@ sub gst_share_nfs_exports_remove_entry my ($infd, $outfd); my ($line); - ($infd, $outfd) = &gst_file_open_filter_write_from_names ($file); + ($infd, $outfd) = &Utils::File::open_filter_write_from_names ($file); return undef if !$outfd; while ($line = &gst_share_nfs_exports_get_next_entry_line ($infd, $outfd)) @@ -710,8 +712,8 @@ sub gst_share_nfs_exports_remove_entry } } - &gst_file_close ($infd); - &gst_file_close ($outfd); + &Utils::File::close_file ($infd); + &Utils::File::close_file ($outfd); } sub gst_share_nfs_exports_get_entry_line_point @@ -754,135 +756,31 @@ sub gst_share_replace_nfs_exports # filename, table } } - -sub gst_share_get_smbclient_list_cmd +sub get_files { - my ($host) = @_; - my ($tool_smbclient); - - $tool_smbclient = &gst_file_locate_tool ("smbclient"); - - return "$tool_smbclient -N -U % -L -I $host"; -} - + my ($smb_comb, $exports); + my (@arr); -sub gst_share_scan_smb_host_call -{ - my ($host) = @_; - my ($cmd, $dirs); - local *SMBCLIENT; + %dist_attrib = &gst_network_get_parse_table (); + push @arr, $dist_attrib{"fn"}{"SMB_CONF"}; - $cmd = &gst_share_get_smbclient_list_cmd ($host); - open (SMBCLIENT, "/bin/sh -c \"$cmd\" 2> /dev/null |"); + # This is pretty standard + push @arr, "/etc/exports"; - while (<SMBCLIENT>) - { - last if /^[ \t]+Sharename[ \t]+Type[ \t]+Comment/; - } - - while (<SMBCLIENT>) - { - chomp; - last if /^$/; - # Looking for sth like " fredsdir Disk Fred's Service" - if (/^[ \t]*([^ \t]+)[ \t]+Disk/) - { - $dirs .= ":" . $1; - } - } - close SMBCLIENT; - - return "$host:$dirs"; + return \@arr; } - -sub gst_share_scan_smb_start +sub get_list { - my (@hosts) = @_; - my ($host, @procs); - - foreach $host (@hosts) - { - push @procs, &gst_process_fork (\&gst_share_scan_smb_host_call, $host); - } - - return \@procs; -} - - -sub gst_share_scan_nfs_host_call -{ - my ($host) = @_; - my ($cmd, $dirs); - local *SHOWMOUNT; - - $cmd = &gst_share_get_showmount_cmd ($host); - open (SHOWMOUNT, "/bin/sh -c \"$cmd\" 2> /dev/null |"); - while (<SHOWMOUNT>) - { - chomp; - $dirs .= ":$_"; - } - close SHOWMOUNT; - - return "$host$dirs"; -} - - -sub gst_share_scan_nfs_start -{ - my (@hosts) = @_; - my ($host, @procs); - - foreach $host (@hosts) - { - push @procs, &gst_process_fork (\&gst_share_scan_nfs_host_call, $host); - } - - return \@procs; -} - - -sub gst_share_scan_share_collect -{ - my ($procs, $host2name) = @_; - my ($proc, $str, %hash, $host, @dirs); - - foreach $proc (@$procs) - { - if ($$proc{"ready"}) - { - sysread ($$proc{"fd"}, $str, 4096); - @dirs = split (':', $str); - $host = shift @dirs; - $hash{$$host2name{$host}} = [ @dirs ]; - } - &gst_process_kill ($proc); - } - - return \%hash; -} - - -sub gst_share_scan_network -{ - my ($host, @hosts); - my ($proc, @procs, $lookup_procs, $nfs_procs, $smb_procs); - my ($i, @names, %host2name, $nfs_table, $smb_table); - - @hosts = &gst_network_find_hosts (); - - $lookup_procs = &gst_network_lookup_address_start (@hosts); - $nfs_procs = &gst_share_scan_nfs_start (@hosts); - $smb_procs = &gst_share_scan_smb_start (@hosts); + my ($smb_exports, $nfs_exports); + my ($arr); - &gst_process_list_check_ready (10, [@$lookup_procs, @$nfs_procs, @$smb_procs]); + $arr = &get_files (); - @names = &gst_network_lookup_address_collect ($lookup_procs); - # http://tlc.perlarchive.com/articles/perl/ug0001.shtml - @host2name{@hosts} = @names; + $smb_exports = &gst_share_parse_smb_conf ($$arr[0]); + $nfs_exports = &gst_share_parse_nfs_exports ($$arr[1]); - return &gst_share_scan_collect ([@$nfs_procs, @$smb_procs], \%host2name); + return ($smb_exports, $nfs_exports); } 1; diff --git a/Shares/Makefile.am b/Shares/Makefile.am new file mode 100644 index 0000000..2653e07 --- /dev/null +++ b/Shares/Makefile.am @@ -0,0 +1,5 @@ +sharesdir = $(scriptsdir)/Shares + +shares_SCRIPTS = \ + NFS.pm \ + SMB.pm diff --git a/Shares/NFS.pm b/Shares/NFS.pm new file mode 100644 index 0000000..47f1d96 --- /dev/null +++ b/Shares/NFS.pm @@ -0,0 +1,212 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Shares::NFS; + +use Utils::Parse; + +sub get_distro_nfs_file +{ + # This is quite generic + return "/etc/exports"; +} + +sub get_share_client_info +{ + my ($client) = @_; + my ($pattern, $options_str, @options, $option); + my ($rw); + + $client =~ /^([a-zA-Z0-9.-_*?@\/]+)/; + $pattern = $1; + $pattern = "0.0.0.0/0" if $pattern eq ""; + $rw = 0; + + if ($client =~ /\((.+)\)/) + { + $option_str = $1; + @options = ($option_str =~ /([a-zA-Z0-9_=-]+),?/mg); + + for $option (@options) + { + $rw = ($option eq "rw") ? 1 : 0; + # Add supported NFS export options here. Some might have to be split on '='. + } + } + + return [ $pattern, $rw ]; +} + +sub get_share_info +{ + my ($clients) = @_; + my (@share_info, $client); + + foreach $client (@$clients) + { + push @share_info, &get_share_client_info ($client); + } + + return \@share_info; +} + +sub get_export_line +{ + my ($share) = @_; + my ($str); + + $str = sprintf ("%-15s ", $$share[0]); + + foreach $i (@{$$share[1]}) + { + $str .= $$i[0]; + $str .= "(rw)" if (!$$i[1]); + $str .= " "; + } + + $str .= "\n"; + return $str; +} + +sub add_entry +{ + my ($share, $file) = @_; + my ($buff); + + $buff = &Utils::File::load_buffer ($file); + push @$buff, &get_export_line ($share); + + &Utils::File::save_buffer ($buff, $file); +} + +sub delete_entry +{ + my ($share, $file) = @_; + my ($buff, $i, $line, @arr); + + $buff = &Utils::File::load_buffer ($file); + $i = 0; + + while ($$buff[$i]) + { + if (!&Utils::Util::ignore_line ($$buff[$i])) + { + @arr = split /[ \t]+/, $$buff[$i]; + delete $$buff[$i] if ($arr[0] eq $$share[0]); + } + + $i++; + } + + &Utils::File::clean_buffer ($buff); + &Utils::File::save_buffer ($buff, $file); +} + +sub change_entry +{ + my ($old_share, $share, $file) = @_; + my ($buff, $i, $line, @arr); + + $buff = &Utils::File::load_buffer ($file); + $i = 0; + + while ($$buff[$i]) + { + if (!&Utils::Util::ignore_line ($$buff[$i])) + { + @arr = split /[ \t]+/, $$buff[$i]; + $$buff[$i] = &get_export_line ($share) if ($arr[0] eq $$old_share[0]); + } + + $i++; + } + + &Utils::File::clean_buffer ($buff); + &Utils::File::save_buffer ($buff, $file); +} + +sub get +{ + my ($nfs_exports_name); + my (@sections, @table, $entries); + my $point, $share_info; + + $nfs_exports_name = &get_distro_nfs_file (); + + $entries = &Utils::Parse::split_hash_with_continuation ($nfs_exports_name, "[ \t]+", "[ \t]+"); + + foreach $point (keys %$entries) + { + my $clients = $$entries{$point}; + + $share_info = &get_share_info ($clients); + push @table, [ $point, $share_info ]; + } + + return \@table; +} + +sub set +{ + my ($config) = @_; + my ($nfs_exports_file); + my ($old_config, %shares); + my (%config_hash, %old_config_hash); + my ($state, $i); + + $nfs_exports_name = &get_distro_nfs_file (); + $old_config = &get (); + + foreach $i (@$config) + { + $shares{$$i[0]} |= 1; + $config_hash{$$i[0]} = $i; + } + + foreach $i (@$old_config) + { + $shares{$$i[0]} |= 2; + $old_config_hash{$$i[0]} = $i; + } + + foreach $i (sort keys (%shares)) + { + $state = $shares{$i}; + + if ($state == 1) + { + # These entries have been added + &add_entry ($config_hash{$i}, $nfs_exports_name); + } + elsif ($state == 2) + { + # These entries have been deleted + &delete_entry ($old_config_hash{$i}, $nfs_exports_name); + } + elsif (($state == 3) && + (!Utils::Util::struct_eq ($config_hash{$i}, $old_config_hash{$i}))) + { + # These entries have been modified + &change_entry ($old_config_hash{$i}, $config_hash{$i}, $nfs_exports_name); + } + } +} + +1; diff --git a/Shares/SMB.pm b/Shares/SMB.pm new file mode 100644 index 0000000..218f772 --- /dev/null +++ b/Shares/SMB.pm @@ -0,0 +1,319 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Shares::SMB; + +use Utils::File; + +# --- share_export_smb_info; information on a particular SMB export --- # + +sub gst_share_smb_info_set +{ + my ($info, $key, $value) = @_; + + if ($value eq "") + { + delete $info->{$key}; + } + else + { + $info->{$key} = $value; + } +} + +sub gst_share_smb_info_get_name +{ + return $_[0]->{'name'}; +} + +sub gst_share_smb_info_set_name +{ + &gst_share_smb_info_set ($_[0], 'name', $_[1]); +} + +sub gst_share_smb_info_get_point +{ + return $_[0]->{'point'}; +} + +sub gst_share_smb_info_set_point +{ + &gst_share_smb_info_set ($_[0], 'point', $_[1]); +} + +sub gst_share_smb_info_get_comment +{ + return $_[0]->{'comment'}; +} + +sub gst_share_smb_info_set_comment +{ + &gst_share_smb_info_set ($_[0], 'comment', $_[1]); +} + +sub gst_share_smb_info_get_enabled +{ + return $_[0]->{'enabled'}; +} + +sub gst_share_smb_info_set_enabled +{ + &gst_share_smb_info_set ($_[0], 'enabled', $_[1]); +} + +sub gst_share_smb_info_get_browse +{ + return $_[0]->{'browse'}; +} + +sub gst_share_smb_info_set_browse +{ + &gst_share_smb_info_set ($_[0], 'browse', $_[1]); +} + +sub gst_share_smb_info_get_public +{ + return $_[0]->{'public'}; +} + +sub gst_share_smb_info_set_public +{ + &gst_share_smb_info_set ($_[0], 'public', $_[1]); +} + +sub gst_share_smb_info_get_write +{ + return $_[0]->{'write'}; +} + +sub gst_share_smb_info_set_write +{ + &gst_share_smb_info_set ($_[0], 'write', $_[1]); +} + + +# --- share_smb_table; multiple instances of share_smb_info --- # + +sub smb_table_find +{ + my ($name, $shares) = @_; + + foreach $i (@$shares) + { + return $i if ($$i[0] eq $name) + } + + return undef; +} + +sub get_distro_smb_file +{ + my ($smb_comb); + + my %dist_map = + ( + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + + "redhat-7.0" => "debian-3.0", + "redhat-7.1" => "debian-3.0", + "redhat-7.2" => "debian-3.0", + "redhat-7.3" => "debian-3.0", + "redhat-8.0" => "debian-3.0", + "redhat-9" => "debian-3.0", + "openna-1.0" => "redhat-6.2", + + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "debian-3.0", + "mandrake-9.1" => "debian-3.0", + "mandrake-9.2" => "debian-3.0", + "mandrake-10.0" => "debian-3.0", + "mandrake-10.1" => "debian-3.0", + "mandrake-10.2" => "debian-3.0", + + "debian-2.2" => "debian-3.0", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + + "suse-9.0" => "debian-3.0", + "suse-9.1" => "debian-3.0", + + "turbolinux-7.0" => "debian-3.0", + + "slackware-8.0.0" => "debian-3.0", + "slackware-8.1" => "debian-3.0", + "slackware-9.0.0" => "debian-3.0", + "slackware-9.1.0" => "debian-3.0", + "slackware-10.0.0" => "debian-3.0", + "slackware-10.1.0" => "debian-3.0", + "slackware-10.2.0" => "debian-3.0", + + "gentoo" => "debian-3.0", + "vlos-1.2" => "debian-3.0", + + "archlinux" => "debian-3.0", + + "pld-1.0" => "pld-1.0", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "fedora-1" => "debian-3.0", + "fedora-2" => "debian-3.0", + "fedora-3" => "debian-3.0", + "rpath" => "debian-3.0", + + "vine-3.0" => "debian-3.0", + "vine-3.1" => "debian-3.0", + + "freebsd-5" => "freebsd-5", + "freebsd-6" => "freebsd-5", + ); + + my %dist_tables = + ( + "redhat-6.2" => "/etc/smb.conf", + "debian-3.0" => "/etc/samba/smb.conf", + "pld-1.0" => "/etc/smb/smb.conf", + "freebsd-5" => "/usr/local/etc/smb.conf", + ); + + my $dist = $dist_map {$Utils::Backend::tool{"platform"}}; + return $dist_tables{$dist} if $dist; + return undef; +} + +sub get_share_info +{ + my ($smb_conf_name, $section) = @_; + my @share; + + push @share, $section; + push @share, &Utils::Parse::get_from_ini ($smb_conf_name, $section, "path"); + push @share, &Utils::Parse::get_from_ini ($smb_conf_name, $section, "comment"); + push @share, &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "available"); + push @share, &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "browsable") || + &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "browseable"); + push @share, &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "public") || + &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "guest"); + push @share, &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "writable") || + &Utils::Parse::get_from_ini_bool ($smb_conf_name, $section, "writeable"); + + return \@share; +} + +sub set_share_info +{ + my ($smb_conf_file, $share) = @_; + my ($section); + + $section = shift (@$share); + + &Utils::Replace::set_ini ($smb_conf_file, $section, "path", shift (@$share)); + &Utils::Replace::set_ini ($smb_conf_file, $section, "comment", shift (@$share)); + &Utils::Replace::set_ini_bool ($smb_conf_file, $section, "available", shift (@$share)); + &Utils::Replace::set_ini_bool ($smb_conf_file, $section, "browsable", shift (@$share)); + &Utils::Replace::set_ini_bool ($smb_conf_file, $section, "public", shift (@$share)); + &Utils::Replace::set_ini_bool ($smb_conf_file, $section, "writable", shift (@$share)); + + &Utils::Replace::remove_ini_var ($smb_conf_file, $section, "browseable"); + &Utils::Replace::remove_ini_var ($smb_conf_file, $section, "guest"); + &Utils::Replace::remove_ini_var ($smb_conf_file, $section, "writeable"); +} + +sub get_shares +{ + my ($smb_conf_file); + my (@sections, @table, $share); + + $smb_conf_file = &get_distro_smb_file; + + # Get the sections. + @sections = &Utils::Parse::get_ini_sections ($smb_conf_file); + + for $section (@sections) + { + next if ($section =~ /^(global)|(homes)|(printers)|(print\$)$/); + next if (&Utils::Parse::get_from_ini_bool ($smb_conf_file, $section, "printable")); + + $share = &get_share_info ($smb_conf_file, $section); + push @table, $share; + } + + return \@table; +} + +sub get +{ + my ($shares, $workgroup, $desc, $wins, $winsserver); + + $shares = &get_shares (); + + $workgroup = &Utils::Parse::get_from_ini ($smb_conf, "global", "workgroup"); + $smbdesc = &Utils::Parse::get_from_ini ($smb_conf, "global", "server string"); + $wins = &Utils::Parse::get_from_ini_bool ($smb_conf, "global", "wins support"); + $winsserver = &Utils::Parse::get_from_ini ($smb_conf, "global", "wins server"); + + return ($shares, $workgroup, $smbdesc, $wins, $winsserver); +} + +sub set_shares +{ + my ($smb_conf_file, $shares) = @_; + my (@sections, $section, $share); + + # Get the sections. + @sections = &Utils::Parse::get_ini_sections ($smb_conf_file); + + # remove deleted sections + foreach $section (@sections) + { + next if ($section =~ /^(global)|(homes)|(printers)|(print\$)$/); + next if (&Utils::Parse::get_from_ini_bool ($smb_conf_file, $section, "printable")); + + if (!&smb_table_find ($section, $shares)) + { + Utils::Replace::remove_ini_section ($smb_conf_file, $section); + } + } + + for $share (@$shares) + { + &set_share_info ($smb_conf_file, $share); + } +} + +sub set +{ + my ($shares, $workgroup, $desc, $wins, $winsserver) = @_; + my ($smb_conf_file); + my (@sections, $export); + + $smb_conf_file = &get_distro_smb_file; + + &set_shares ($smb_conf_file, $shares); + + &Utils::Replace::set_ini ($smb_conf_file, "global", "workgroup", $workgroup); + &Utils::Replace::set_ini ($smb_conf_file, "global", "server string", $desc); + &Utils::Replace::set_ini_bool ($smb_conf_file, "global", "wins support", $wins); + &Utils::Replace::set_ini ($smb_conf_file, "global", "wins server", ($wins) ? "" : $winsserver); +} + +1; diff --git a/SharesList.pm b/SharesList.pm new file mode 100644 index 0000000..63da588 --- /dev/null +++ b/SharesList.pm @@ -0,0 +1,67 @@ +#!/usr/bin/env perl +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Shares list +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package SharesList; + +use base qw(Net::DBus::Object); +use Utils::Backend; +use Shares::Exports; + +my $OBJECT_NAME = "SharesList"; +my $SHARES_PATH = $Utils::Backend::DBUS_PATH . "/" . $OBJECT_NAME; + +sub new +{ + my $class = shift; + my $self = $class->SUPER::new ($SHARES_PATH, + { + $OBJECT_NAME => { + methods => { + "get" => { + params => [], + returns => [[ "array", [ "dict", "string", "string" ]]], + }, + }, + signals => { + "changed" => [], + }, + }, + }, + @_); + bless $self, $class; + Utils::Monitor::monitor_files (&Shares::Exports::get_files (), + $self, $OBJECT_NAME, "changed"); + return $self; +} + +sub get +{ + my ($self) = @_; + my ($smb_exports, $nfs_exports); + + ($smb_exports, $nfs_exports) = Shares::Exports::get_list (); + + return $smb_exports; +} + +1; diff --git a/SystemToolsBackends.pl.in b/SystemToolsBackends.pl.in new file mode 100755 index 0000000..5894933 --- /dev/null +++ b/SystemToolsBackends.pl.in @@ -0,0 +1,69 @@ +#!/usr/bin/env perl +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# Loader for the system tools backends. +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +BEGIN { + $SCRIPTSDIR = "@scriptsdir@"; + if ($SCRIPTSDIR !~ /^@scriptsdir[@]/) + { + push @INC, $SCRIPTSDIR; + } +} + +use Net::DBus; +use Net::DBus::Service; +use Net::DBus::Reactor; +use Utils::Backend; +use Utils::Monitor; +use Utils::Platform; + +use SMBConfig; +use NFSConfig; +use UsersConfig; +use GroupsConfig; +use TimeConfig; +use NTPConfig; +use HostsConfig; +use IfacesConfig; +use ServicesConfig; + +# Initialize tool +&Utils::Backend::init ($name, $version, $description, $directives, @ARGV); + +# Initialize bus +my $bus = &Utils::Backend::get_bus (); +my $service = $bus->export_service ($Utils::Backend::DBUS_PREFIX); + +#Initialize all objects +my $platforms_list = Utils::Platform->new ($service); +my $smb_config = SMBConfig->new ($service); +my $nfs_config = NFSConfig->new ($service); +my $users_config = UsersConfig->new ($service); +my $groups_config = GroupsConfig->new ($service); +my $time_config = TimeConfig->new ($service); +my $ntp_config = NTPConfig->new ($service); +my $hosts_config = HostsConfig->new ($service); +my $ifaces_config = IfacesConfig->new ($service); +my $services_config = ServicesConfig->new ($service); + +Net::DBus::Reactor->main->add_timeout (50, Net::DBus::Callback->new(method => \&Utils::Monitor::do_monitor_files)); +Net::DBus::Reactor->main->run (); @@ -0,0 +1,3 @@ +- Finish _set() in all objects +- check files authorship for typos when c&p headers +- add again support for command line parameters (--report and --fake-apply come to mind) diff --git a/Time/.cvsignore b/Time/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/Time/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/Time/Makefile.am b/Time/Makefile.am new file mode 100644 index 0000000..9902cee --- /dev/null +++ b/Time/Makefile.am @@ -0,0 +1,5 @@ +timedir = $(scriptsdir)/Time + +time_SCRIPTS = \ + NTP.pm \ + TimeDate.pm diff --git a/Time/NTP.pm b/Time/NTP.pm new file mode 100644 index 0000000..32c4cdd --- /dev/null +++ b/Time/NTP.pm @@ -0,0 +1,190 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# NTP Configuration handling +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# Carlos Garnacho <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Time::NTP; + +sub get_config_file () +{ + my %dist_map = + ( + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-6.2", + "redhat-7.3" => "redhat-6.2", + "redhat-8.0" => "redhat-6.2", + "redhat-9" => "redhat-6.2", + "openna-1.0" => "redhat-6.2", + + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "redhat-6.2", + "mandrake-9.1" => "redhat-6.2", + "mandrake-9.2" => "redhat-6.2", + "mandrake-10.0" => "redhat-6.2", + "mandrake-10.1" => "redhat-6.2", + + "debian-2.2" => "redhat-6.2", + "debian-3.0" => "redhat-6.2", + "debian-sarge" => "redhat-6.2", + + "suse-7.0" => "redhat-6.2", + "suse-9.0" => "redhat-6.2", + "suse-9.1" => "redhat-6.2", + + "turbolinux-7.0" => "redhat-6.2", + + "slackware-8.0.0" => "redhat-6.2", + "slackware-8.1" => "redhat-6.2", + "slackware-9.0.0" => "redhat-6.2", + "slackware-9.1.0" => "redhat-6.2", + "slackware-10.0.0" => "redhat-6.2", + "slackware-10.1.0" => "redhat-6.2", + + "gentoo" => "redhat-6.2", + + "pld-1.0" => "pld-1.0", + "pld-1.1" => "pld-1.0", + "pld-1.99" => "pld-1.0", + "fedora-1" => "redhat-6.2", + "fedora-2" => "redhat-6.2", + "fedora-3" => "redhat-6.2", + + "rpath" => "redhat-6.2", + + "vine-3.0" => "redhat-6.2", + "vine-3.1" => "redhat-6.2", + + "freebsd-5" => "redhat-6.2", + "freebsd-6" => "redhat-6.2", + ); + + my %dist_table = + ( + "redhat-6.2" => "/etc/ntp.conf", + "pld-1.0" => "/etc/ntp/ntp.conf" + ); + + my $dist = $dist_map{$Utils::Backend::tool{"platform"}}; + return $dist_table{$dist} if $dist; + + &Utils::Report::do_report ("platform_no_table", $$tool{"platform"}); + return undef; +} + +sub get_ntp_servers +{ + $ntp_conf = &get_config_file (); + + return &Utils::Parse::split_all_array_with_pos ($ntp_conf, "server", 0, "[ \t]+", "[ \t]+"); +} + +sub ntp_conf_replace +{ + my ($file, $key, $re, $value) = @_; + my ($fd, @line, @res); + my ($buff, $i); + my ($pre_space, $post_comment); + my ($line_key, $val, $rest); + my ($n, $ret); + + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_split", $key, $file); + + $buff = &Utils::File::load_buffer ($file); + + foreach $i (@$buff) + { + $pre_space = $post_comment = ""; + + chomp $i; + + $pre_space = $1 if $i =~ s/^([ \t]+)//; + $post_comment = $1 if $i =~ s/([ \t]*\#.*)//; + + if ($i ne "") + { + @line = split ($re, $i, 3); + $line_key = shift (@line); + $val = shift (@line); + $rest = shift (@line); + + # found the key? + if ($line_key eq $key) + { + $n = 0; + + while (@$value[$n] && (@$value[$n] ne $val)) + { + $n++; + } + + if (@$value[$n] ne $val) + { + $i = ""; + next; + } + + delete @$value[$n]; + chomp $val; + $i = &Utils::Replace::set_value ($key, $val, $re) . " " . $rest; + } + } + + $i = $pre_space . $i . $post_comment . "\n"; + } + + foreach $i (@$value) + { + push (@$buff, &Utils::Replace::set_value ($key, $i, $re) . "\n") if ($i ne ""); + } + + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); + return $ret; +} + +sub set_ntp_servers +{ + my (@config) = @_; + my ($ntp_conf); + + $ntp_conf = &get_config_file (); + return &ntp_conf_replace ($ntp_conf, "server", "[ \t]+", @config); +} + +sub get +{ + return &get_ntp_servers (); +} + +sub set +{ + return &set_ntp_servers (@_); +} + +1; diff --git a/Time/TimeDate.pm b/Time/TimeDate.pm new file mode 100644 index 0000000..b9a45bb --- /dev/null +++ b/Time/TimeDate.pm @@ -0,0 +1,432 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# Time/Date Configuration handling +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# Carlos Garnacho <carlosg@gnome.org> +# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) +# James Ogley <james@usr-local-bin.org> (SuSE 9.0 support) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Time::TimeDate; + +use File::Copy; + +sub get_utc_time +{ + my (%h, $trash); + + ($h{"second"}, $h{"minute"}, $h{"hour"}, $h{"monthday"}, $h{"month"}, $h{"year"}, + $trash, $trash, $trash) = gmtime (time); + + $h{"year"} += 1900; + + return \%h; +} + +# This function will force date format when setting time +sub change_timedate +{ + my ($time) = @_; + my ($command); + + my $system_table = { + "Linux" => "date -u %02d%02d%02d%02d%04d.%02d", + "FreeBSD" => "date -u -f %%m%%d%%H%%M%%Y.%%S %02d%02d%02d%02d%04d.%02d" + }; + + $command = sprintf ($$system_table {$Utils::Backend::tool{"system"}}, + $$time{"month"} + 1, $$time{"monthday"}, + $$time{"hour"}, $$time{"minute"}, + $$time{"year"}, $$time{"second"}); + + &Utils::Report::do_report ("time_localtime_set", $command); + return &Utils::File::run ($command); +} + +sub set_utc_time +{ + my ($time) = @_; + my ($res, $xscreensaver_owners); + + &Utils::Report::enter (); + + # FIXME: restore this, take into account other screensavers + # Kill screensaver, so it doesn't confuse the users. +# $xscreensaver_owners = &gst_service_proc_get_owners ("xscreensaver"); +# &gst_service_proc_stop_all ("xscreensaver"); + + $res = &change_timedate ($time); + + # Restart screensaver. +# &gst_service_proc_start_all ("xscreensaver -no-splash", $xscreensaver_owners); + + &Utils::Report::leave (); + return -1 if $res; + return 0; +} + +sub time_sync_hw_from_sys +{ + &Utils::File::run ("hwclock --systohc"); + return 0; +} + +sub get_timezone +{ + my ($local_time_file, $zoneinfo_dir) = @_; + local *TZLIST; + my $zone; + my $size_search; + my $size_test; + + *TZLIST = &Utils::File::open_read_from_names($zoneinfo_dir . "/zone.tab"); + if (not *TZLIST) { return; } + + &Utils::Report::do_report ("time_timezone_scan"); + + # Get the filesize for /etc/localtime so that we don't have to execute + # a diff for every file, only for file with the correct size. This speeds + # up loading + $size_search = (stat ($local_time_file))[7]; + + while (<TZLIST>) + { + if (/^\#/) { next; } # Skip comments. + ($d, $d, $zone) = split /[\t ]+/, $_; # Get 3rd column. + chomp $zone; # Remove linefeeds. + + + # See if this zone file matches the installed one. + &Utils::Report::do_report ("time_timezone_cmp", $zone); + $size_test = (stat("$zoneinfo_dir/$zone"))[7]; + if ($size_test eq $size_search) + { + if (!&Utils::File::run ("diff $zoneinfo_dir/$zone $local_time_file")) + { + # Found a match. + last; + } + } + + $zone = ""; + } + + return $zone; + close (TZLIST); +} + +sub set_timezone +{ + my ($localtime, $zonebase, $timezone) = @_; + + &Utils::Report::enter (); + &Utils::Report::do_report ("time_timezone_set", $timezone); + + $tz = "$zonebase/$timezone"; + + if (stat($tz) ne "") + { + unlink $localtime; # Important, since it might be a symlink. + + &Utils::Report::enter (); + $res = copy ($tz, $localtime); + &Utils::Report::leave (); + return -1 unless $res; + return 0; + } + + &Utils::Report::leave (); + return -1; +} + +sub conf_get_parse_table +{ + my %dist_map = + ( + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-6.2", + "redhat-7.3" => "redhat-6.2", + "redhat-8.0" => "redhat-6.2", + "redhat-9" => "redhat-6.2", + "openna-1.0" => "redhat-6.2", + + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "redhat-6.2", + "mandrake-9.1" => "redhat-6.2", + "mandrake-9.2" => "redhat-6.2", + "mandrake-10.0" => "redhat-6.2", + "mandrake-10.1" => "redhat-6.2", + + "debian-2.2" => "redhat-6.2", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + + "suse-7.0" => "redhat-6.2", + "suse-9.0" => "redhat-6.2", + "suse-9.1" => "redhat-6.2", + + "turbolinux-7.0" => "redhat-6.2", + + "slackware-8.0.0" => "redhat-6.2", + "slackware-8.1" => "redhat-6.2", + "slackware-9.0.0" => "redhat-6.2", + "slackware-9.1.0" => "redhat-6.2", + "slackware-10.0.0" => "redhat-6.2", + "slackware-10.1.0" => "redhat-6.2", + "slackware-10.2.0" => "redhat-6.2", + + "gentoo" => "redhat-6.2", + "vlos-1.2" => "redhat-6.2", + + "archlinux" => "archlinux", + + "pld-1.0" => "redhat-6.2", + "pld-1.1" => "redhat-6.2", + "pld-1.99" => "redhat-6.2", + "fedora-1" => "redhat-6.2", + "fedora-2" => "redhat-6.2", + "fedora-3" => "redhat-6.2", + "rpath" => "redhat-6.2", + + "vine-3.0" => "redhat-6.2", + "vine-3.1" => "redhat-6.2", + + "freebsd-5" => "redhat-6.2", + "freebsd-6" => "redhat-6.2", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + fn => + { + ZONEINFO => "/usr/share/zoneinfo", + LOCAL_TIME => "/etc/localtime" + }, + table => + [ + [ "local_time", \&get_utc_time ], + [ "timezone", \&get_timezone, [LOCAL_TIME, ZONEINFO] ], + ] + }, + + "debian-3.0" => + { + fn => + { + ZONEINFO => "/usr/share/zoneinfo", + LOCAL_TIME => "/etc/localtime" + }, + table => + [ + [ "local_time", \&get_utc_time ], + [ "timezone", \&get_timezone, [LOCAL_TIME, ZONEINFO] ], + ] + }, + + "archlinux" => + { + fn => + { + RC_LOCAL => "/etc/rc.local", + ZONEINFO => "/usr/share/zoneinfo", + LOCAL_TIME => "/etc/localtime" + }, + table => + [ + [ "local_time", \&get_utc_time ], + [ "timezone", \&Utils::Parse::get_sh, RC_LOCAL, TIMEZONE ], + ] + }, + ); + + my $dist = $dist_map {$Utils::Backend::tool{"platform"}}; + return %{$dist_tables{$dist}} if $dist; + + &Utils::Report::do_report ("platform_no_table", $Utils::backend::tool{"platform"}); + return undef; +} + +sub conf_get_replace_table +{ + my %dist_map = + ( + "redhat-6.0" => "redhat-6.2", + "redhat-6.1" => "redhat-6.2", + "redhat-6.2" => "redhat-6.2", + + "redhat-7.0" => "redhat-6.2", + "redhat-7.1" => "redhat-6.2", + "redhat-7.2" => "redhat-6.2", + "redhat-7.3" => "redhat-6.2", + "redhat-8.0" => "redhat-6.2", + "redhat-9" => "redhat-6.2", + "openna-1.0" => "redhat-6.2", + + "mandrake-7.1" => "redhat-6.2", + "mandrake-7.2" => "redhat-6.2", + "mandrake-9.0" => "redhat-6.2", + "mandrake-9.1" => "redhat-6.2", + "mandrake-9.2" => "redhat-6.2", + "mandrake-10.0" => "redhat-6.2", + "mandrake-10.1" => "redhat-6.2", + + "debian-2.2" => "redhat-6.2", + "debian-3.0" => "debian-3.0", + "debian-sarge" => "debian-3.0", + + "suse-7.0" => "redhat-6.2", + "suse-9.0" => "redhat-6.2", + "suse-9.1" => "redhat-6.2", + + "turbolinux-7.0" => "redhat-6.2", + + "slackware-8.0.0" => "redhat-6.2", + "slackware-8.1" => "redhat-6.2", + "slackware-9.0.0" => "redhat-6.2", + "slackware-9.1.0" => "redhat-6.2", + "slackware-10.0.0" => "redhat-6.2", + "slackware-10.1.0" => "redhat-6.2", + "slackware-10.2.0" => "redhat-6.2", + + "gentoo" => "redhat-6.2", + "vlos-1.2" => "redhat-6.2", + + "archlinux" => "archlinux", + + "pld-1.0" => "redhat-6.2", + "pld-1.1" => "redhat-6.2", + "pld-1.99" => "redhat-6.2", + "fedora-1" => "redhat-6.2", + "fedora-2" => "redhat-6.2", + "fedora-3" => "redhat-6.2", + "rpath" => "redhat-6.2", + + "vine-3.0" => "redhat-6.2", + "vine-3.1" => "redhat-6.2", + + "freebsd-5" => "redhat-6.2", + "freebsd-6" => "redhat-6.2", + ); + + my %dist_tables = + ( + "redhat-6.2" => + { + fn => + { + ZONEINFO => "/usr/share/zoneinfo", + LOCAL_TIME => "/etc/localtime" + }, + table => + [ + [ "timezone", \&set_timezone, [LOCAL_TIME, ZONEINFO] ], + [ "local_time", \&set_utc_time ], + ] + }, + + "debian-3.0" => + { + fn => + { + ZONEINFO => "/usr/share/zoneinfo", + LOCAL_TIME => "/etc/localtime", + TIMEZONE => "/etc/timezone" + }, + table => + [ + [ "timezone", \&set_timezone, [LOCAL_TIME, ZONEINFO] ], + [ "timezone", \&Utils::Replace::set_first_line, TIMEZONE ], + [ "local_time", \&set_utc_time ], + ] + }, + + "archlinux" => + { + fn => + { + RC_LOCAL => "/etc/rc.local", + ZONEINFO => "/usr/share/zoneinfo", + LOCAL_TIME => "/etc/localtime", + }, + table => + [ + [ "timezone", \&Utils::Replace::set_sh, RC_LOCAL, TIMEZONE ], + [ "timezone", \&set_timezone, [LOCAL_TIME, ZONEINFO] ], + [ "local_time", \&set_utc_time ], + ] + }, + ); + + my $dist = $dist_map {$Utils::Backend::tool{"platform"}}; + return %{$dist_tables{$dist}} if $dist; + + &Utils::Report::do_report ("platform_no_table", $Utils::Backend::tool{"platform"}); + return undef; +} + +sub get +{ + my %dist_attrib; + my $hash; + + %dist_attrib = &conf_get_parse_table (); + + $hash = &Utils::Parse::get_from_table ($dist_attrib{"fn"}, + $dist_attrib{"table"}); + $h = $$hash {"local_time"}; + + return ($$h {"year"}, $$h {"month"}, $$h {"monthday"}, + $$h {"hour"}, $$h {"minute"}, $$h {"second"}, + $$hash{"timezone"}); +} + +sub set +{ + my (@config) = @_; + my ($hash, %localtime); + + %localtime = ( + "year" => $config[0], + "month" => $config[1], + "monthday" => $config[2], + "hour" => $config[3], + "minute" => $config[4], + "second" => $config[5] + ); + + $$hash{"local_time"} = \%localtime; + $$hash{"timezone"} = $config[6]; + + %dist_attrib = &conf_get_replace_table (); + + $res = &Utils::Replace::set_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, $hash); + &time_sync_hw_from_sys (); + + return $res; +} + +1; diff --git a/TimeConfig.pm b/TimeConfig.pm new file mode 100644 index 0000000..05d06e2 --- /dev/null +++ b/TimeConfig.pm @@ -0,0 +1,66 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Time/Date configuration +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package TimeConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Utils::Backend; +use Time::TimeDate; + +my $OBJECT_NAME = "TimeConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + +# Utils::Monitor::monitor_files (&Users::Groups::get_files (), +# $self, $OBJECT_NAME, "changed"); + + return $self; +} + +dbus_method ("get", [], [ "int32", "int32", "int32", "int32", "int32", "int32", "string" ]); +dbus_method ("set", [ "int32", "int32", "int32", "int32", "int32", "int32", "string" ], []); +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + my $config; + + return Time::TimeDate::get (); +} + +sub set +{ + my ($self, @config) = @_; + + Time::TimeDate::set (@config); +} + +1; diff --git a/Users/.cvsignore b/Users/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/Users/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/Users/Groups.pm b/Users/Groups.pm new file mode 100644 index 0000000..e2935f4 --- /dev/null +++ b/Users/Groups.pm @@ -0,0 +1,243 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com>, +# Arturo Espinosa <arturo@ximian.com>, +# Tambet Ingo <tambet@ximian.com>. +# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Users::Groups; + +# enum like for verbose group array positions +my $LOGIN = 0; +my $PASSWD = 1; +my $GID = 2; +my $USERS = 3; + +# quite generic data +$group_names = "/etc/group"; + +# Where are the tools? +$cmd_groupdel = &Utils::File::locate_tool ("groupdel"); +$cmd_groupadd = &Utils::File::locate_tool ("groupadd"); +$cmd_groupmod = &Utils::File::locate_tool ("groupmod"); +$cmd_gpasswd = &Utils::File::locate_tool ("gpasswd"); +$cmd_pw = &Utils::File::locate_tool ("pw"); + +sub del_group +{ + my ($group) = @_; + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + $command = "$cmd_pw groupdel -n \'" . $$group[$LOGIN] . "\'"; + } + else + { + $command = "$cmd_groupdel \'" . $$group[$LOGIN] . "\'"; + } + + &Utils::File::run ($command); +} + +sub add_group +{ + my ($group) = @_; + my ($u, $user, $users); + + $u = $$group[$USERS]; + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + $users = join (",", sort @$u); + + $command = "$cmd_pw groupadd -n \'" . $$group[$LOGIN] . + "\' -g \'" . $$group[$GID] . + "\' -M \'" . $users . "\'"; + + &Utils::File::run ($command); + } + else + { + $command = "$cmd_groupadd -g \'" . $$group[$GID] . + "\' " . $$group[$LOGIN]; + + &Utils::File::run ($command); + + foreach $user (sort @$u) + { + $command = "$cmd_gpasswd -a \'" . $user . + "\' " . $$group[$LOGIN]; + + &Utils::File::run ($command); + } + } +} + +sub change_group +{ + my ($old_group, $new_group) = @_; + my (%users, $user, $users_arr, $str); + + my ($n, $o, $users, $i, $j, $max_n, $max_o, $r, @tmp); # for iterations + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + $users_arr = $$new_group[$USERS]; + $str = join (",", sort @$users_arr); + + $command = "$cmd_pw groupmod -n \'" . $$old_group[$LOGIN] . + "\' -g \'" . $$new_group[$GID] . + "\' -l \'" . $$new_group[$LOGIN] . + "\' -M \'" . $str . "\'"; + + &Utils::File::run ($command); + } + else + { + $command = "$cmd_groupmod -g \'" . $$new_group[$GID] . + "\' -n \'" . $$new_group[$LOGIN] . "\' " . + "\'" . $$old_group[$LOGIN] . "\'"; + + &Utils::File::run ($command); + + # Let's see if the users that compose the group have changed. + if (!Utils::Util::struct_eq ($$new_group[$USERS], $$old_group[$USERS])) + { + $users{$_} |= 1 foreach (@{$$new_group[$USERS]}); + $users{$_} |= 2 foreach (@{$$old_group[$USERS]}); + + foreach $user (keys %users) + { + $state = $users{$u}; + + if ($state == 2) + { + # users with state 2 are those that only appeared + # in the old group configuration, so we must delete them + $command = "$cmd_gpasswd -d \'" . $user . "\' \'" . + $$new_group[$LOGIN] . "\'"; + + &Utils::File::run ($command); + } + else + { + # users with state 1 are those who were added + # to the new group configuration + $command = "$cmd_gpasswd -a \'" . $user . "\' \'" . + $$new_group[$LOGIN] . "\'"; + + &Utils::File::run ($command); + } + } + } + } +} + +sub get +{ + my ($ifh, @groups, $group_last_modified); + my (@line, $copy, @a); + + # Find the file. + + $ifh = &Utils::File::open_read_from_names($group_names); + return unless ($ifh); + + # Parse the file. + @groups = (); + + while (<$ifh>) + { + chomp; + + # FreeBSD allows comments in the group file. */ + next if &Utils::Util::ignore_line ($_); + $_ = &Utils::XML::unquote ($_); + + @line = split ':', $_, -1; + @a = split ',', pop @line; + push @line, [@a]; + $copy = [@line]; + push (@groups, $copy); + } + + &Utils::File::close_file ($ifh); + + return \@groups; +} + +sub get_files +{ + my @arr; + + push @arr, $group_names; + return \@arr; +} + +sub set +{ + my ($config) = @_; + my ($old_config, %groups); + my (%config_hash, %old_config_hash); + + if ($config) + { + # Make backup manually, otherwise they don't get backed up. + &Utils::File::do_backup ($group_names); + + $old_config = &get (); + + foreach $i (@$config) + { + $groups{$$i[$LOGIN]} |= 1; + $config_hash{$$i[$LOGIN]} = $i; + } + + foreach $i (@$old_config) + { + $groups{$$i[$LOGIN]} |= 2; + $old_config_hash{$$i[$LOGIN]} = $i; + } + + # Delete all groups that only appeared in the old configuration + foreach $i (sort (keys (%groups))) + { + $state = $groups{$i}; + + if ($state == 1) + { + # Groups with state 1 have been added to the config + &add_group ($config_hash{$i}); + } + elsif ($state == 2) + { + # Groups with state 2 have been deleted from the config + &del_group ($old_config_hash{$i}); + } + elsif (($state == 3) && + (!Utils::Util::struct_eq ($config_hash{$i}, $old_config_hash{$i}))) + { + &change_group ($old_config_hash{$i}, $config_hash{$i}); + } + } + } +} + +1; diff --git a/Users/Makefile.am b/Users/Makefile.am new file mode 100644 index 0000000..1c0fdda --- /dev/null +++ b/Users/Makefile.am @@ -0,0 +1,6 @@ +usersdir = $(scriptsdir)/Users + +users_SCRIPTS = \ + Groups.pm \ + Shells.pm \ + Users.pm diff --git a/Users/Shells.pm b/Users/Shells.pm new file mode 100644 index 0000000..1c473ec --- /dev/null +++ b/Users/Shells.pm @@ -0,0 +1,99 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com>, +# Arturo Espinosa <arturo@ximian.com>, +# Tambet Ingo <tambet@ximian.com>. +# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) +# Carlos Garnacho <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Users::Shells; + +use Utils::Util; +use Utils::Report; +use Utils::File; +use Utils::Replace; + +# Totally generic atm +$shells_file = "/etc/shells"; + +sub get_files +{ + return $shells_file; +} + +sub get +{ + my ($ifh, @shells); + + # Init @shells, I think every *nix has /bin/false. + if (stat ("/bin/false")) + { + push @shells, "/bin/false"; + } + + $ifh = &Utils::File::open_read_from_names($shells_file); + return unless $ifh; + + while (<$ifh>) + { + next if &Utils::Util::ignore_line ($_); + chomp; + push @shells, $_ if (stat ($_)); + } + + &Utils::File::close_file ($ifh); + + return \@shells; +} + +sub set +{ + my ($shells) = @_; + my ($buff, $line, $nline); + + $buff = &Utils::File::load_buffer ($shells_file); + return unless $buff; + + &Utils::File::join_buffer_lines ($buff); + $nline = 0; + + # delete all file entries that really exist, + # this is done for not deleting entries that + # might be installed later + while ($nline <= $#$buff) + { + $line = $$buff[$nline]; + chomp $line; + + if (!&Utils::Util::ignore_line ($line)) + { + delete $$buff[$nline] if (stat ($line)); + } + + $nline++; + } + + # Add shells list + foreach $line (@$shells) + { + push @$buff, "$line\n" if (stat ($line)); + } + + &Utils::File::save_buffer ($buff, $shells_file); +} diff --git a/Users/Users.pm b/Users/Users.pm new file mode 100644 index 0000000..ae40d42 --- /dev/null +++ b/Users/Users.pm @@ -0,0 +1,707 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# Users account manager. Designed to be architecture and distribution independent. +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com>, +# Arturo Espinosa <arturo@ximian.com>, +# Tambet Ingo <tambet@ximian.com>. +# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +# Best viewed with 100 columns of width. + +# Configuration files affected: +# +# /etc/passwd +# /etc/group +# /etc/shadow +# /etc/login.defs +# /etc/shells +# /etc/skel/ + +# NIS support will come later. + +# Running programs affected/used: +# +# adduser: creating users. +# usermod: modifying user data. +# passwd: assigning or changing passwords. (Un)locking users. +# chfn: modifying finger information - Name, Office, Office phone, Home phone. +# pw: modifying users/groups and user/group data on FreeBSD. + +package Users::Users; + +use Utils::Util; +use Utils::Report; +use Utils::File; +use Utils::Backend; +use Utils::Replace; + +# --- System config file locations --- # + +# We list each config file type with as many alternate locations as possible. +# They are tried in array order. First found = used. +@passwd_names = ( "/etc/passwd" ); +@shadow_names = ( "/etc/shadow", "/etc/master.passwd" ); +@login_defs_names = ( "/etc/login.defs", "/etc/adduser.conf" ); +@shell_names = ( "/etc/shells" ); +@skel_dir = ( "/usr/share/skel", "/etc/skel" ); + +# Where are the tools? +$cmd_usermod = &Utils::File::locate_tool ("usermod"); +$cmd_userdel = &Utils::File::locate_tool ("userdel"); +$cmd_useradd = &Utils::File::locate_tool ("useradd"); +$cmd_chfn = &Utils::File::locate_tool ("chfn"); +$cmd_pw = &Utils::File::locate_tool ("pw"); + +# enum like for verbose group array positions +my $LOGIN = 0; +my $PASSWD = 1; +my $UID = 2; +my $GID = 3; +my $COMMENT = 4; +my $HOME = 5; +my $SHELL = 6; + +%login_defs_prop_map = (); +%profiles_prop_map = (); + +sub get_login_defs_prop_array +{ + my @prop_array; + my @login_defs_prop_array_default = + ( + "QMAIL_DIR", "qmail_dir", + "MAIL_DIR", "mailbox_dir", + "MAIL_FILE", "mailbox_file", + "PASS_MAX_DAYS", "pwd_maxdays", + "PASS_MIN_DAYS", "pwd_mindays", + "PASS_MIN_LEN", "pwd_min_length", + "PASS_WARN_AGE", "pwd_warndays", + "UID_MIN", "umin", + "UID_MAX", "umax", + "GID_MIN", "gmin", + "GID_MAX", "gmax", + "USERDEL_CMD", "del_user_additional_command", + "CREATE_HOME", "create_home", + "", ""); + + my @login_defs_prop_array_suse = + ( + "QMAIL_DIR", "qmail_dir", + "MAIL_DIR", "mailbox_dir", + "MAIL_FILE", "mailbox_file", + "PASS_MAX_DAYS", "pwd_maxdays", + "PASS_MIN_DAYS", "pwd_mindays", + "PASS_MIN_LEN", "pwd_min_length", + "PASS_WARN_AGE", "pwd_warndays", + "UID_MIN", "umin", + "UID_MAX", "umax", + "SYSTEM_GID_MIN", "gmin", + "GID_MAX", "gmax", + "USERDEL_CMD", "del_user_additional_command", + "CREATE_HOME", "create_home", + "", ""); + + if ($Utils::Backend::tool{"platform"} =~ /^suse/) + { + @prop_array = @login_defs_prop_array_suse; + } + else + { + @prop_array = @login_defs_prop_array_default; + } + + for ($i = 0; $prop_array [$i] ne ""; $i += 2) + { + $login_defs_prop_map {$prop_array [$i]} = $prop_array [$i + 1]; + $login_defs_prop_map {$prop_array [$i + 1]} = $prop_array [$i]; + } +} + +sub get_profiles_prop_array +{ + my @prop_array; + my @profiles_prop_array_default = + ( + "NAME" , "name", + "COMMENT", "comment", + "LOGINDEFS", "login_defs", + "HOME_PREFFIX", "home_prefix", + "SHELL", "shell", + "GROUP", "group", + "SKEL_DIR", "skel_dir", + "QMAIL_DIR" , "qmail_dir", + "MAIL_DIR" , "mailbox_dir", + "MAIL_FILE" , "mailbox_file", + "PASS_RANDOM", "pwd_random", + "PASS_MAX_DAYS" , "pwd_maxdays", + "PASS_MIN_DAYS" , "pwd_mindays", + "PASS_MIN_LEN" , "pwd_min_length", + "PASS_WARN_AGE" , "pwd_warndays", + "UID_MIN" , "umin", + "UID_MAX" , "umax", + "GID_MIN" , "gmin", + "GID_MAX" , "gmax", + "USERDEL_CMD" , "del_user_additional_command", + "CREATE_HOME" , "create_home", + "", ""); + + my @profiles_prop_array_suse = + ( + "NAME" , "name", + "COMMENT", "comment", + "LOGINDEFS", "login_defs", + "HOME_PREFFIX", "home_prefix", + "SHELL", "shell", + "GROUP", "group", + "SKEL_DIR", "skel_dir", + "QMAIL_DIR" , "qmail_dir", + "MAIL_DIR" , "mailbox_dir", + "MAIL_FILE" , "mailbox_file", + "PASS_RANDOM", "pwd_random", + "PASS_MAX_DAYS" , "pwd_maxdays", + "PASS_MIN_DAYS" , "pwd_mindays", + "PASS_MIN_LEN" , "pwd_min_length", + "PASS_WARN_AGE" , "pwd_warndays", + "UID_MIN" , "umin", + "UID_MAX" , "umax", + "GID_MIN" , "gmin", + "GID_MAX" , "gmax", + "USERDEL_CMD" , "del_user_additional_command", + "CREATE_HOME" , "create_home", + "", ""); + + if ($Utils::Backend::tool{"platform"} =~ /suse/) + { + @prop_array = @profiles_prop_array_suse; + } + else + { + @prop_array = @profiles_prop_array_default; + } + + for ($i = 0; $prop_array[$i] ne ""; $i += 2) + { + $profiles_prop_map {$prop_array [$i]} = $prop_array [$i + 1]; + $profiles_prop_map {$prop_array [$i + 1]} = $prop_array [$i]; + } +} + +my $rh_logindefs_defaults = { + 'shell' => '/bin/bash', + 'group' => '$user', + 'skel_dir' => '/etc/skel/', +}; + +my $gentoo_logindefs_defaults = { + 'shell' => '/bin/bash', + 'group' => 'users', + 'skel_dir' => '/etc/skel/', +}; + +my $freebsd_logindefs_defaults = { + 'shell' => '/bin/sh', + 'group' => '$user', + 'skel_dir' => '/etc/skel/', +}; + +my $logindefs_dist_map = { + 'redhat-5.2' => $rh_logindefs_defaults, + 'redhat-6.0' => $rh_logindefs_defaults, + 'redhat-6.1' => $rh_logindefs_defaults, + 'redhat-6.2' => $rh_logindefs_defaults, + 'redhat-7.0' => $rh_logindefs_defaults, + 'redhat-7.1' => $rh_logindefs_defaults, + 'redhat-7.2' => $rh_logindefs_defaults, + 'redhat-7.3' => $rh_logindefs_defaults, + 'redhat-8.0' => $rh_logindefs_defaults, + 'redhat-9' => $rh_logindefs_defaults, + 'openna-1.0' => $rh_logindefs_defaults, + 'mandrake-7.1' => $rh_logindefs_defaults, + 'mandrake-7.2' => $rh_logindefs_defaults, + 'mandrake-9.0' => $rh_logindefs_defaults, + 'mandrake-9.1' => $rh_logindefs_defaults, + 'mandrake-9.2' => $rh_logindefs_defaults, + 'mandrake-10.0' => $rh_logindefs_defaults, + 'mandrake-10.1' => $rh_logindefs_defaults, + 'pld-1.0' => $rh_logindefs_defaults, + 'pld-1.1' => $rh_logindefs_defaults, + 'pld-1.99' => $rh_logindefs_defaults, + 'fedora-1' => $rh_logindefs_defaults, + 'fedora-2' => $rh_logindefs_defaults, + 'fedora-3' => $rh_logindefs_defaults, + 'rpath' => $rh_logindefs_defaults, + 'debian-2.2' => $rh_logindefs_defaults, + 'debian-3.0' => $rh_logindefs_defaults, + 'debian-sarge' => $rh_logindefs_defaults, + 'ubuntu-5.04' => $rh_logindefs_defaults, + 'ubuntu-5.10' => $rh_logindefs_defaults, + 'ubuntu-6.04' => $rh_logindefs_defaults, + 'vine-3.0' => $rh_logindefs_defaults, + 'vine-3.1' => $rh_logindefs_defaults, + 'gentoo' => $gentoo_logindefs_defaults, + 'vlos-1.2' => $gentoo_logindefs_defaults, + 'archlinux' => $gentoo_logindefs_defaults, + 'slackware-9.1.0' => $gentoo_logindefs_defaults, + 'slackware-10.0.0' => $gentoo_logindefs_defaults, + 'slackware-10.1.0' => $gentoo_logindefs_defaults, + 'slackware-10.2.0' => $gentoo_logindefs_defaults, + 'freebsd-4' => $freebsd_logindefs_defaults, + 'freebsd-5' => $freebsd_logindefs_defaults, + 'freebsd-6' => $freebsd_logindefs_defaults, + 'suse-7.0' => $gentoo_logindefs_defaults, + 'suse-9.0' => $gentoo_logindefs_defaults, + 'suse-9.1' => $gentoo_logindefs_defaults, + + # FIXME: I don't know about those, so using RH values for now. + 'turbolinux-7.0' => $rh_logindefs_defaults, + 'slackware-8.0.0' => $rh_logindefs_defaults, + 'slackware-8.1' => $rh_logindefs_defaults, + 'slackware-9.0.0' => $rh_logindefs_defaults, +}; + + +# Add reporting table. + +&Utils::Report::add ({ + 'users_read_profiledb_success' => ['info', 'Profiles read successfully.'], + 'users_read_profiledb_fail' => ['warn', 'Profiles read failed.'], + 'users_read_users_success' => ['info', 'Users read successfully.'], + 'users_read_users_fail' => ['warn', 'Users read failed.'], + 'users_read_groups_success' => ['info', 'Groups read successfully.'], + 'users_read_groups_fail' => ['warn', 'Groups read failed.'], + 'users_read_shells_success' => ['info', 'Shells read successfully.'], + 'users_read_shells_fail' => ['warn', 'Reading shells failed.'], + + 'users_write_profiledb_success' => ['info', 'Profiles written successfully.'], + 'users_write_profiledb_fail' => ['warn', 'Writing profiles failed.'], + 'users_write_users_success' => ['info', 'Users written successfully.'], + 'users_write_users_fail' => ['warn', 'Writing users failed.'], + 'users_write_groups_success' => ['info', 'Groups written successfully.'], + 'users_write_groups_fail' => ['warn', 'Writing groups failed.'], +}); + + +sub do_get_use_md5 +{ + my ($file) = @_; + my ($fh, @line, $i, $use_md5); + + my $fh = &Utils::File::open_read_from_names ("/etc/pam.d/$file"); + return 0 if (!$fh); + + $use_md5 = 0; + + while (<$fh>) + { + next if &Utils::Util::ignore_line ($_); + chomp; + @line = split /[ \t]+/; + + if ($line[0] eq "\@include") + { + $use_md5 = &do_get_use_md5 ($line[1]); + } + elsif ($line[0] eq "password") + { + foreach $i (@line) + { + $use_md5 = 1 if ($i eq "md5"); + } + } + } + + close $fh; + return $use_md5; +} + +sub get_use_md5 +{ + return &do_get_use_md5 ("passwd"); +} + +sub logindefs_add_defaults +{ + # Common for all distros + my $logindefs = { + 'home_prefix' => '/home/', + }; + + &get_profiles_prop_array (); + + # Distro specific + my $dist_specific = $logindefs_dist_map->{$Utils::Backend::tool{"platform"}}; + + # Just to be 100% sure SOMETHING gets filled: + unless ($dist_specific) + { + $dist_specific = $rh_logindefs_defaults; + } + + foreach my $key (keys %$dist_specific) + { + # Make sure there's no crappy entries + if (exists ($profiles_prop_map{$key}) || $key eq "groups") + { + $logindefs->{$key} = $dist_specific->{$key}; + } + } + return $logindefs; +} + +sub get_logindefs +{ + my $logindefs; + + &get_login_defs_prop_array (); + $logindefs = &logindefs_add_defaults (); + + # Get new data in case someone has changed login_defs manually. + my $fh = &Utils::File::open_read_from_names (@login_defs_names); + + if ($fh) + { + while (<$fh>) + { + next if &Utils::Util::ignore_line ($_); + chomp; + my @line = split /[ \t]+/; + + if (exists $login_defs_prop_map{$line[0]}) + { + $logindefs->{$login_defs_prop_map{$line[0]}} = $line[1]; + } + } + + close $fh; + } + else + { + # Put safe defaults for distros/OS that don't have any defaults file + $logindefs->{"umin"} = '1000'; + $logindefs->{"umax"} = '60000'; + $logindefs->{"gmin"} = '1000'; + $logindefs->{"gmax"} = '60000'; + } + + return $logindefs; +} + +sub get +{ + my ($ifh, @users, %users_hash); + my (@line); + + # Find the passwd file. + $ifh = &Utils::File::open_read_from_names(@passwd_names); + return unless ($ifh); + + %users_hash = (); + + while (<$ifh>) + { + chomp; + # FreeBSD allows comments in the passwd file. + next if &Utils::Util::ignore_line ($_); + + @line = split ':', $_, -1; + + $login = $line[$LOGIN]; + @comment = split ',', $line[$COMMENT], 5; + + # we need to make sure that there are 5 elements + push @comment, "" while (scalar (@comment) < 5); + $line[$COMMENT] = [@comment]; + + $$users_hash{$login} = [@line]; + } + + &Utils::File::close_file ($ifh); + $ifh = &Utils::File::open_read_from_names(@shadow_names); + + if ($ifh) + { + while (<$ifh>) + { + chomp; + + # FreeBSD allows comments in the shadow passwd file. + next if &Utils::Util::ignore_line ($_); + + @line = split ':', $_, -1; + $login = shift @line; + $passwd = shift @line; + + $$users_hash{$login}[$PASSWD] = $passwd; + + # FIXME: add the rest of the fields? + #push @{$$users_hash{$login}}, @line; + } + + &Utils::File::close_file ($ifh); + } + + # transform the hash into an array + foreach $login (keys %$users_hash) + { + push @users, $$users_hash{$login}; + } + + return \@users; +} + +sub get_files +{ + my @arr; + + push @arr, @passwd_names; + push @arr, @shadow_names; + + return \@arr; +} + + +sub del_user +{ + my ($user) = @_; + my ($command); + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + $command = "$cmd_pw userdel -n \'" . $$user[$LOGIN] . "\' "; + } + else + { + $command = "$cmd_userdel \'" . $$user[$LOGIN] . "\'"; + } + + &Utils::File::run ($command); +} + +sub change_user_chfn +{ + my ($login, $old_comment, $comment) = @_; + my ($fname, $office, $office_phone, $home_phone); + my ($command); + + return if !$login; + + # Compare old and new data + return if (Utils::Util::struct_eq ($old_comment, $comment)); + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + my ($str); + + $str = join (",", @$comment); + $command = "$cmd_pw usermod -n " . $login . " -c \'" . $str . "\'"; + } + else + { + ($fname, $office, $office_phone, $home_phone) = @$comment; + + $command = "$cmd_chfn" . + " -f \'" . $fname . "\'" . + " -h \'" . $home_phone . "\'"; + + if ($Utils::Backend::tool{"platform"} =~ /^debian/ || + $Utils::Backend::tool{"platform"} =~ /^archlinux/) + { + $command .= " -r \'" . $office . "\'" . + " -w \'" . $office_phone . "\'"; + } + else + { + $command .= " -o \'" . $office . "\'" . + " -p \'" . $office_phone . "\'"; + } + } + + &Utils::File::run ($command); +} + +sub add_user +{ + my ($user) = @_; + my ($home_parents, $tool_mkdir); + + $tool_mkdir = &Utils::File::locate_tool ("mkdir"); + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + my $pwdpipe; + my $home; + + # FreeBSD doesn't create the home directory + $home = $$user[$HOME]; + &Utils::File::run ("$tool_mkdir -p $home"); + + $command = "$cmd_pw useradd " . + " -n \'" . $$user[$LOGIN] . "\'" . + " -u \'" . $$user[$UID] . "\'" . + " -d \'" . $$user[$HOME] . "\'" . + " -g \'" . $$user[$GID] . "\'" . + " -s \'" . $$user[$SHELL] . "\'" . + " -H 0"; # pw(8) reads password from STDIN + + $pwdpipe = &Utils::File::run_pipe_write ($command); + print $pwdpipe $$user[$PASSWD]; + &Utils::File::close_file ($pwdpipe); + } + else + { + $home_parents = $$user[$HOME]; + $home_parents =~ s/\/+[^\/]+\/*$//; + &Utils::File::run ("$tool_mkdir -p $home_parents"); + + $command = "$cmd_useradd -m" . + " -d \'" . $$user[$HOME] . "\'" . + " -g \'" . $$user[$GID] . "\'" . + " -p \'" . $$user[$PASSWD] . "\'" . + " -s \'" . $$user[$SHELL] . "\'" . + " -u \'" . $$user[$UID] . "\'" . + " \'" . $$user[$LOGIN] . "\'"; + + &Utils::File::run ($command); + } + + &change_user_chfn ($$user[$LOGIN], undef, $$user[$COMMENT]); +} + +sub change_user +{ + my ($old_user, $new_user) = @_; + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + my $pwdpipe; + + $command = "$cmd_pw usermod \'" . $$old_user[$LOGIN] . "\'" . + " -l \'" . $$new_user[$LOGIN] . "\'" . + " -u \'" . $$new_user[$UID] . "\'" . + " -d \'" . $$new_user[$HOME] . "\'" . + " -g \'" . $$new_user[$GID] . "\'" . + " -s \'" . $$new_user[$SHELL] . "\'" . + " -H 0"; # pw(8) reads password from STDIN + + $pwdpipe = &Utils::File::run_pipe_write ($command); + print $pwdpipe $$new_user[$PASSWD]; + &Utils::File::close_file ($pwdpipe); + } + else + { + $command = "$cmd_usermod" . + " -d \'" . $$new_user[$HOME] . "\'" . + " -g \'" . $$new_user[$GID] . "\'" . + " -l \'" . $$new_user[$LOGIN] . "\'" . + " -p \'" . $$new_user[$PASSWD] . "\'" . + " -s \'" . $$new_user[$SHELL] . "\'" . + " -u \'" . $$new_user[$UID] . "\'" . + " \'" . $$old_user[$LOGIN] . "\'"; + + &Utils::File::run ($command); + } + + &change_user_chfn ($$new_user[$LOGIN], $$old_user[$COMMENT], $$new_user[$COMMENT]); +} + +sub set_logindefs +{ + my ($config) = @_; + my ($logindefs, $key, $file); + + return unless $config; + + &get_login_defs_prop_array (); + + foreach $key (@login_defs_names) + { + if (-f $key) + { + $file = $key; + last; + } + } + + unless ($file) + { + &Utils::Report::do_report ("file_open_read_failed", join (", ", @login_defs_names)); + return; + } + + foreach $key (keys (%$config)) + { + # Write ONLY login.defs values. + if (exists ($login_defs_prop_map{$key})) + { + &Utils::Replace::split ($file, $login_defs_prop_map{$key}, "[ \t]+", $$config{$key}); + } + } +} + +sub set +{ + my ($config) = @_; + my ($old_config, %users); + my (%config_hash, %old_config_hash); + + if ($config) + { + # Make backups manually, otherwise they don't get backed up. + &Utils::File::do_backup ($_) foreach (@passwd_names); + &Utils::File::do_backup ($_) foreach (@shadow_names); + + $old_config = &get (); + + foreach $i (@$config) + { + $users{$$i[0]} |= 1; + $config_hash{$$i[0]} = $i; + } + + foreach $i (@$old_config) + { + $users{$$i[0]} |= 2; + $old_config_hash{$$i[0]} = $i; + } + + # Delete all groups that only appeared in the old configuration + foreach $i (sort (keys (%users))) + { + $state = $users{$i}; + + if ($state == 1) + { + # Groups with state 1 have been added to the config + &add_user ($config_hash{$i}); + } + elsif ($state == 2) + { + # Groups with state 2 have been deleted from the config + &del_user ($old_config_hash{$i}); + } + elsif (($state == 3) && + (!Utils::Util::struct_eq ($config_hash{$i}, $old_config_hash{$i}))) + { + &change_user ($old_config_hash{$i}, $config_hash{$i}); + } + } + } +} + +1; diff --git a/UsersConfig.pm b/UsersConfig.pm new file mode 100644 index 0000000..b582a6e --- /dev/null +++ b/UsersConfig.pm @@ -0,0 +1,82 @@ +#!/usr/bin/env perl +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# DBus object for the Users list +# +# Copyright (C) 2005 Carlos Garnacho +# +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package UsersConfig; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX); +use Utils::Backend; +use Users::Users; +use Users::Shells; + +my $OBJECT_NAME = "UsersConfig"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +sub new +{ + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); + + bless $self, $class; + + Utils::Monitor::monitor_files (&Users::Users::get_files (), + $self, $OBJECT_NAME, "changed"); + return $self; +} + +dbus_method ("get", [], + [[ "array", [ "struct", "string", "string", "int32", "int32", [ "array", "string"], "string", "string" ]], + ["array", "string" ], "int32", "int32", "int32", "string", "string" ]); +dbus_method ("set", + [[ "array", [ "struct", "string", "string", "int32", "int32", [ "array", "string"], "string", "string" ]], + ["array", "string" ], "int32", "int32", "int32", "string", "string" ], []); +dbus_signal ("changed", []); + +sub get +{ + my ($self) = @_; + my $logindefs, $users, $use_md5, $shells; + + $use_md5 = &Users::Users::get_use_md5 (); + $logindefs = &Users::Users::get_logindefs (); + $users = &Users::Users::get (); + $shells = &Users::Shells::get (); + + return ($users, $shells, $use_md5, $$logindefs{"umin"}, + $$logindefs{"umax"}, $$logindefs{"home_prefix"}, $$logindefs{"shell"}); +} + +sub set +{ + my ($self, @config) = @_; + + Users::Users::set ($config[0]); + Users::Shells::set ($config[1]); + Users::Users::set_logindefs ({"umin" => $config[3], + "umax" => $config[4], + "home_prefix" => $config[5], + "shell" => $config[6]}); +} + +1; diff --git a/Utils/.cvsignore b/Utils/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/Utils/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/general.pl.in b/Utils/Backend.pm index 809c77a..f43a135 100644 --- a/general.pl.in +++ b/Utils/Backend.pm @@ -21,17 +21,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Utils::Backend; -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} +use Utils::Report; +use Utils::XML; -require "$SCRIPTSDIR/report.pl$DOTIN"; -require "$SCRIPTSDIR/platform.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; +our $DBUS_PREFIX = "org.freedesktop.SystemToolsBackends"; +our $DBUS_PATH = "/org/freedesktop/SystemToolsBackends"; +our $tool; eval "use Locale::gettext"; $eval_gettext = $@; @@ -71,24 +68,12 @@ else # We should get rid of all these globals. -$gst_name = ""; # Short name of tool. -# $gst_version = ""; # Version of tool - [major.minor.revision]. Deprecated: now in hash -# structure generated by &gst_init. -# $gst_operation = ""; # Major operation user wants to perform - [get | set | filter]. Same as gst_version. - -$gst_prefix = ""; -$gst_do_verbose = 0; -$gst_do_report = 0; - -$gst_debug = 0; -$gst_do_immediate = 1; - +our $prefix = ""; +our $do_verbose = 0; +our $do_report = 0; +our $session_bus = 0; -# Location management stuff -$gst_location = ""; -$gst_no_archive = 0; - -sub gst_print_usage_synopsis +sub print_usage_synopsis { my ($tool) = @_; my ($ops_syn, $i); @@ -105,10 +90,10 @@ sub gst_print_usage_synopsis print STDERR " [--disable-immediate] [--prefix <location>]\n"; print STDERR " " x length $$tool{"name"}; - print STDERR " [--progress] [--report] [--verbose]\n\n"; + print STDERR " [--report] [--verbose]\n\n"; } -sub gst_print_usage_generic +sub print_usage_generic { my ($tool) = @_; my (%usage, $i); @@ -151,16 +136,15 @@ end_of_usage_generic; configuration is looked for or stored. When storing (with --set), directories and files may be created. - --progress Prints machine-readable progress information to standard - output, before any XML, consisting of three-digit - percentages always starting with \'0\'. - --report Prints machine-readable diagnostic messages to standard output, before any XML. Each message has a unique three-digit ID. The report ends in a blank line. -v --verbose Prints human-readable diagnostic messages to standard error. + + --session-bus Makes the backends to use the session bus. + end_of_usage_generic; $usage{"get"} =<< "end_of_usage_generic;"; @@ -193,109 +177,101 @@ end_of_usage_generic; } # if $exit_code is provided (ne undef), exit with that code at the end. -sub gst_print_usage +sub print_usage { my ($tool, $exit_code) = @_; - &gst_print_usage_synopsis ($tool); + &print_usage_synopsis ($tool); print STDERR $$tool{"description"} . "\n"; - &gst_print_usage_generic ($tool); + &print_usage_generic ($tool); exit $exit_code if $exit_code ne undef; } -sub gst_print_version +sub print_version { my ($tool, $exit_code) = @_; - print "$$tool{name} $$tool{version}\n"; - exit $exit_code if $exit_code ne undef; } # --- Initialization and finalization --- # -sub gst_set_operation +sub set_operation { my ($tool, $operation) = @_; if ($tool{"operation"} ne "") { print STDERR "Error: You may specify only one major operation.\n\n"; - &gst_print_usage ($tool, 1); + &print_usage ($tool, 1); exit (1); } $$tool{"operation"} = $operation; } -sub gst_set_with_param +sub set_with_param { my ($tool, $arg_name, $value) = @_; if ($$tool{$arg_name} ne "") { print STDERR "Error: You may specify --$arg_name only once.\n\n"; - &gst_print_usage ($tool, 1); + &print_usage ($tool, 1); } if ($value eq "") { print STDERR "Error: You must specify an argument to the --$arg_name option.\n\n"; - &gst_print_usage ($tool, 1); + &print_usage ($tool, 1); } $$tool{$arg_name} = $value; } -sub gst_set_op_directive +sub set_op_directive { my ($tool, $directive) = @_; - &gst_set_with_param ($tool, "directive", $directive); - &gst_set_operation ($tool, "directive"); + &set_with_param ($tool, "directive", $directive); + &set_operation ($tool, "directive"); } -sub gst_set_prefix +sub set_prefix { my ($tool, $prefix) = @_; - &gst_set_with_param ($tool, "prefix", $prefix); + &set_with_param ($tool, "prefix", $prefix); $gst_prefix = $prefix; } -sub gst_set_dist +sub set_dist { my ($tool, $dist) = @_; - - &gst_set_with_param ($tool, "platform", $dist); - $gst_dist = $dist; + + &Utils::Platform::set_platform ($dist); } -sub gst_set_location +sub set_session_bus { - my ($tool, $location) = @_; + my ($tool) = @_; - &gst_set_with_param ($tool, "location", $location); - $gst_location = $location; + &set_with_param ($tool, "session-bus", 1); + $session_bus = 1; } -sub gst_merge_std_directives +sub merge_std_directives { my ($tool) = @_; my ($directives, $i); my %std_directives = ( # platforms directive to do later. - "platforms" => [ \&gst_platform_list, [], - "Print XML showing platforms supported by backend." ], - "platform_set" => [ \&gst_platform_set, ["platform"], - "Force the selected platform. platform arg must be one of the listed in the" . - "reports." ], - "interface" => [ \&gst_interface_directive, [], + "interface" => [ \&print_interface_directive, [], "Print XML showing backend capabilities." ], - "end" => [ \&gst_end_directive, [], + "end" => [ \&end_directive, [], "Finish gracefuly and exit with success." ] ); @@ -307,7 +283,7 @@ sub gst_merge_std_directives } } -sub gst_is_tool +sub is_backend { my ($tool) = @_; @@ -321,13 +297,10 @@ sub gst_is_tool return 0; } -sub gst_init +sub init { my ($name, $version, $description, $directives, @args) = @_; - my (%tool, $arg); - - # print a CR for synchronysm with the frontend - print "\n"; + my ($arg); # Set the output autoflush. $old_fh = select (STDOUT); $| = 1; select ($old_fh); @@ -342,73 +315,62 @@ sub gst_init $tool{"description"} = $description; $tool{"directives"} = $directives; - &gst_merge_std_directives (\%tool); + &merge_std_directives (\%tool); # Parse arguments. while ($arg = shift (@args)) { - if ($arg eq "--get" || $arg eq "-g") { &gst_set_operation (\%tool, "get"); } - elsif ($arg eq "--set" || $arg eq "-s") { &gst_set_operation (\%tool, "set"); } - elsif ($arg eq "--filter" || $arg eq "-f") { &gst_set_operation (\%tool, "filter"); } - elsif ($arg eq "--directive" || $arg eq "-d") { &gst_set_op_directive (\%tool, shift @args); } - elsif ($arg eq "--interface" || $arg eq "-i") { &gst_interface_print (\%tool, 0); } - elsif ($arg eq "--help" || $arg eq "-h") { &gst_print_usage (\%tool, 0); } - elsif ($arg eq "--version") { &gst_print_version (\%tool, 0); } - elsif ($arg eq "--prefix" || $arg eq "-p") { &gst_set_prefix (\%tool, shift @args); } - elsif ($arg eq "--platform") { &gst_set_dist (\%tool, shift @args); } - elsif ($arg eq "--progress") { $tool{"progress"} = $gst_progress = 1; } - elsif ($arg eq "--location") { &gst_set_location (\%tool, shift @args); } - elsif ($arg eq "--no-archive") { $tool{"no_archive"} = $gst_no_archive = 1; } - elsif ($arg eq "--debug") { $tool{"debug"} = $gst_debug = 1; } + if ($arg eq "--get" || $arg eq "-g") { &set_operation (\%tool, "get"); } + elsif ($arg eq "--set" || $arg eq "-s") { &set_operation (\%tool, "set"); } + elsif ($arg eq "--filter" || $arg eq "-f") { &set_operation (\%tool, "filter"); } + elsif ($arg eq "--directive" || $arg eq "-d") { &set_op_directive (\%tool, shift @args); } + elsif ($arg eq "--interface" || $arg eq "-i") { &print_interface (\%tool, 0); } + elsif ($arg eq "--help" || $arg eq "-h") { &print_usage (\%tool, 0); } + elsif ($arg eq "--version") { &print_version (\%tool, 0); } + elsif ($arg eq "--prefix" || $arg eq "-p") { &set_prefix (\%tool, shift @args); } + elsif ($arg eq "--platform") { &set_dist (\%tool, shift @args); } + elsif ($arg eq "--session-bus") { &set_session_bus (\%tool); } elsif ($arg eq "--verbose" || $arg eq "-v") { - $tool{"do_verbose"} = $gst_do_verbose = 1; - &gst_report_set_threshold (99); + $tool{"do_verbose"} = $do_verbose = 1; + &Utils::Report::set_threshold (99); } elsif ($arg eq "--report") { - $tool{"do_report"} = $gst_do_report = 1; - &gst_report_set_threshold (99); + $tool{"do_report"} = $do_report = 1; + &Utils::Report::set_threshold (99); } else { print STDERR "Error: Unrecognized option '$arg'.\n\n"; - &gst_print_usage (\%tool, 1); + &print_usage (\%tool, 1); } } - # See if debug requested in env. - - $tool{"debug"} = $gst_debug = 1 if ($ENV{"SET_ME_UP_HARDER"}); - # Set up subsystems. - - &gst_platform_get_system (\%tool); - &gst_platform_guess (\%tool) if !$tool{"platform"}; - &gst_report_begin (); + &Utils::Report::begin (); return \%tool; } -sub gst_terminate +sub terminate { - &gst_report_set_threshold (-1); - &gst_debug_close_all (); + &Utils::Report::set_threshold (-1); exit (0); } -sub gst_end_directive +sub end_directive { my ($tool) = @_; - &gst_report_end (); - &gst_xml_print_request_end (); - &gst_terminate (); + &Utils::Report::end (); + &Utils::XML::print_request_end (); + &terminate (); } -sub gst_interface_print_comment +sub print_interface_comment { my ($name, $directive) = @_; my %std_comments = @@ -433,30 +395,30 @@ sub gst_interface_print_comment if ($comment) { - &gst_xml_print_line ("<comment>"); - &gst_xml_print_line ($comment); - &gst_xml_print_line ("</comment>"); + &Utils::XML::print_line ("<comment>"); + &Utils::XML::print_line ($comment); + &Utils::XML::print_line ("</comment>"); } } # if $exit_code is provided (ne undef), exit with that code at the end. -sub gst_interface_print +sub print_interface { my ($tool, $exit_code) = @_; my ($directives, $key); $directives = $$tool{"directives"}; - &gst_xml_print_begin ("interface"); + &Utils::XML::print_begin ("interface"); foreach $key (sort keys %$directives) { my $comment = $ {$$directives{$key}}[2]; my @args = @{ $ {$$directives{$key}}[1]}; my $arg; - &gst_xml_container_enter ("directive"); - &gst_xml_print_line ("<name>$key</name>"); - &gst_interface_print_comment ($key, $$directives{$key}); + &Utils::XML::container_enter ("directive"); + &Utils::XML::print_line ("<name>$key</name>"); + &print_interface_comment ($key, $$directives{$key}); while ($arg = shift (@args)) { @@ -464,46 +426,45 @@ sub gst_interface_print { my $tmp = $arg; - &gst_report ("directive_invalid", $key) if ($#args != -1); + &Utils::Report::do_report ("directive_invalid", $key) if ($#args != -1); chop $tmp; - &gst_xml_print_line ("<var-arguments>$tmp</var-arguments>"); + &Utils::XML::print_line ("<var-arguments>$tmp</var-arguments>"); } else { - &gst_xml_print_line ("<argument>$arg</argument>"); + &Utils::XML::print_line ("<argument>$arg</argument>"); } } - &gst_xml_container_leave (); + &Utils::XML::container_leave (); } - &gst_xml_print_end ("interface"); + &Utils::XML::print_end ("interface"); exit $exit_code if $exit_code ne undef; } -sub gst_interface_directive +sub print_interface_directive { my ($tool) = @_; - &gst_report_end (); - &gst_interface_print ($tool); + &Utils::Report::end (); + &print_interface ($tool); } -sub gst_directive_fail +sub directive_fail { my (@report_args) = @_; - &gst_report (@report_args); - &gst_report_end (); - &gst_xml_print_request_end (); - &gst_debug_close_all (); + &Utils::Report::do_report (@report_args); + &Utils::Report::end (); + &Utils::XML::print_request_end (); } # This sepparates a line in args by the directive line format, # doing the necessary escape sequence manipulations. -sub gst_directive_parse_line +sub directive_parse_line { my ($line) = @_; my ($arg, @args); @@ -561,19 +522,19 @@ sub gst_directive_parse_line # </directive> -sub gst_directive_run +sub directive_run { my ($tool, $line) = @_; my ($key, @args, $directives, $proc, $reqargs, $i); - ($key, @args) = &gst_directive_parse_line ($line); + ($key, @args) = &directive_parse_line ($line); $directives = $$tool{"directives"}; - &gst_report_begin (); + &Utils::Report::begin (); if (!exists $$directives{$key}) { - &gst_directive_fail ("directive_unsup", $key); + &directive_fail ("directive_unsup", $key); return; } @@ -585,7 +546,7 @@ sub gst_directive_run if (scalar @args < scalar @$reqargs) { - &gst_directive_fail ("directive_lowargs", $key, scalar (@$reqargs), join (',', $key, @args)); + &directive_fail ("directive_lowargs", $key, scalar (@$reqargs), join (',', $key, @args)); return; } @@ -593,21 +554,20 @@ sub gst_directive_run if ((scalar @args != scalar @$reqargs) && !($$reqargs[$#$reqargs] =~ /\*$/)) { - &gst_directive_fail ("directive_badargs", $key, scalar (@$reqargs), join (',', $key, @args)); + &directive_fail ("directive_badargs", $key, scalar (@$reqargs), join (',', $key, @args)); return; } - &gst_report ("directive_run", $key, join (',', @args)); + &Utils::Report::do_report ("directive_run", $key, join (',', @args)); $proc = $ {$$directives{$key}}[0]; &$proc ($tool, @args); - &gst_xml_print_request_end (); - &gst_debug_close_all (); + &Utils::XML::print_request_end (); } -sub gst_run +sub run { my ($tool) = @_; my ($line); @@ -627,18 +587,24 @@ sub gst_run } } - &gst_report_end (); + &Utils::Report::end (); if ($$tool{"directive"}) { - &gst_directive_run ($tool, $$tool{"directive"}); - &gst_terminate (); + &directive_run ($tool, $$tool{"directive"}); + &terminate (); } while ($line = <STDIN>) { - &gst_directive_run ($tool, $line); + &directive_run ($tool, $line); } } +sub get_bus +{ + return Net::DBus->session if ($session_bus); + return Net::DBus->system; +} + 1; diff --git a/file.pl.in b/Utils/File.pm index f3be154..41edd3e 100644 --- a/file.pl.in +++ b/Utils/File.pm @@ -22,60 +22,44 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Utils::File; + +use Utils::Report; use File::Path; use File::Copy; use File::Temp; use Carp; -$SCRIPTSDIR = "@scriptsdir@"; -$FILESDIR = "@filesdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $FILESDIR = "files"; - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/report.pl$DOTIN"; - -$GST_FILE_READ = 1; -$GST_FILE_WRITE = 2; +$FILE_READ = 1; +$FILE_WRITE = 2; # --- File operations --- # - -sub gst_file_get_base_path +sub get_base_path { - my $path = "/var/cache/setup-tool-backends"; + my $path = "/var/cache/system-tools-backends"; chmod (0755, $path); return $path; } -sub gst_file_get_tmp_path -{ - return (&gst_file_get_base_path () . "/tmp"); -} - - -sub gst_file_get_backup_path +sub get_tmp_path { - return (&gst_file_get_base_path () . "/backup"); + return (&get_base_path () . "/tmp"); } -sub gst_file_get_debug_path +sub get_backup_path { - return (&gst_file_get_base_path (). "/debug"); + return (&get_base_path () . "/backup"); } -sub gst_file_get_data_path +sub get_data_path { - my $path = &gst_file_get_base_path (). "/data"; + my $path = &get_base_path (). "/data"; chmod (0755, $path); return $path; } @@ -83,14 +67,14 @@ sub gst_file_get_data_path # Give a command, and it will put in C locale, some sane PATH values and find # the program to run in the path. Redirects stderr to null. -sub get_cmd_path +sub do_get_cmd_path { my ($cmd) = @_; my ($tool_name, @argline, $command, $tool_path); ($tool_name, @argline) = split("[ \t]+", $cmd); - $tool_path = &gst_file_locate_tool ($tool_name); + $tool_path = &locate_tool ($tool_name); return -1 if ($tool_path eq ""); @@ -100,16 +84,16 @@ sub get_cmd_path return $command; } -sub gst_file_get_cmd_path +sub get_cmd_path { my ($cmd) = @_; - my $command = &get_cmd_path ($cmd); + my $command = &do_get_cmd_path ($cmd); return ("LC_ALL=C PATH=\$PATH:/sbin:/usr/sbin $command 2> /dev/null"); } # necessary for some programs that output info through stderr -sub gst_file_get_cmd_path_with_stderr +sub get_cmd_path_with_stderr { my ($cmd) = @_; @@ -118,7 +102,7 @@ sub gst_file_get_cmd_path_with_stderr } -sub gst_file_create_path +sub create_path { my ($path, $perms) = @_; $prems = $perms || 0770; @@ -134,13 +118,13 @@ sub gst_file_create_path $path = "$path/"; } - &gst_report_enter (); - &gst_report ("file_create_path", $_[0]); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("file_create_path", $_[0]); + &Utils::Report::leave (); } -sub gst_file_create_path_for_file +sub create_path_for_file { my ($path, $perms) = @_; $prems = $perms || 0770; @@ -159,27 +143,27 @@ sub gst_file_create_path_for_file } } - &gst_report_enter (); - &gst_report ("file_create_path", $_[0]); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("file_create_path", $_[0]); + &Utils::Report::leave (); } -$gst_file_backup_dir_rotation_was_made = 0; +$rotation_was_made = 0; # If this is the first backup created by this tool on this invocation, # rotate the backup directories and create a new, empty one. -sub gst_file_backup_rotate_dirs +sub rotate_backup_dirs { my $backup_tool_dir = $_[0]; - &gst_report_enter (); + &Utils::Report::enter (); - if (!$gst_file_backup_dir_rotation_was_made) + if (!$rotation_was_made) { my $i; - $gst_file_backup_dir_rotation_was_made = 1; + $rotation_was_made = 1; if (-e "$backup_tool_dir/9") { if (-s "$backup_tool_dir/9") @@ -188,7 +172,7 @@ sub gst_file_backup_rotate_dirs } else { - &gst_file_rmtree ("$backup_tool_dir/9"); + &rmtree ("$backup_tool_dir/9"); } } @@ -202,58 +186,58 @@ sub gst_file_backup_rotate_dirs if (!stat ("$backup_tool_dir/First")) { - &gst_file_create_path ("$backup_tool_dir/First"); - &gst_file_run ("ln -s First $backup_tool_dir/1"); + &create_path ("$backup_tool_dir/First"); + &run ("ln -s First $backup_tool_dir/1"); } else { - &gst_file_create_path_for_file ("$backup_tool_dir/1/"); + &create_path_for_file ("$backup_tool_dir/1/"); } - &gst_report ("file_backup_rotate", $backup_tool_dir); + &Utils::Report::do_report ("file_backup_rotate", $backup_tool_dir); } - &gst_report_enter (); + &Utils::Report::enter (); } -sub gst_file_backup +sub do_backup { my $backup_file = $_[0]; my $backup_tool_dir; - &gst_report_enter (); + &Utils::Report::enter (); - $backup_tool_dir = &gst_file_get_backup_path () . "/$gst_name/"; + $backup_tool_dir = &get_backup_path () . "/$gst_name/"; - &gst_file_backup_rotate_dirs ($backup_tool_dir); + &rotate_backup_dirs ($backup_tool_dir); # If the file hasn't already been backed up on this invocation, copy the # file to the backup directory. if (!stat ("$backup_tool_dir/1/$backup_file")) { - &gst_file_create_path_for_file ("$backup_tool_dir/1/$backup_file"); + &create_path_for_file ("$backup_tool_dir/1/$backup_file"); copy ($backup_file, "$backup_tool_dir/1/$backup_file"); - &gst_report ("file_backup_success", $backup_tool_dir); + &Utils::Report::do_report ("file_backup_success", $backup_tool_dir); } - &gst_report_leave (); + &Utils::Report::leave (); } # Return 1/0 depending on file existance. -sub gst_file_exists +sub exists { my ($file) = @_; return (-f "$gst_prefix/$file")? 1: 0; } -sub gst_file_open_read_from_names +sub open_read_from_names { local *FILE; my $fname = ""; - &gst_report_enter (); + &Utils::Report::enter (); foreach $name (@_) { @@ -268,24 +252,24 @@ sub gst_file_open_read_from_names if ($fname eq "") { - &gst_report ("file_open_read_failed", "@_"); + &Utils::Report::do_report ("file_open_read_failed", "@_"); return undef; } - &gst_report ("file_open_read_success", $fullname); - &gst_report_leave (); + &Utils::Report::do_report ("file_open_read_success", $fullname); + &Utils::Report::leave (); return *FILE; } -sub gst_file_open_write_from_names +sub open_write_from_names { local *FILE; my $name; my $fullname; - &gst_report_enter (); + &Utils::Report::enter (); # Find out where it lives. @@ -295,45 +279,45 @@ sub gst_file_open_write_from_names { $name = $_[0]; (my $fullname = "$gst_prefix/$name") =~ tr/\//\//s; - &gst_report ("file_open_write_create", "@_", $fullname); + &Utils::Report::do_report ("file_open_write_create", "@_", $fullname); } else { (my $fullname = "$gst_prefix/$name") =~ tr/\//\//s; - &gst_report ("file_open_write_success", $fullname); + &Utils::Report::do_report ("file_open_write_success", $fullname); } ($name = "$gst_prefix/$name") =~ tr/\//\//s; # '//' -> '/' - &gst_file_create_path_for_file ($name); + &create_path_for_file ($name); # Make a backup if the file already exists - if the user specified a prefix, # it might not. if (stat ($name)) { - &gst_file_backup ($name); + &do_backup ($name); } - &gst_report_leave (); + &Utils::Report::leave (); # Truncate and return filehandle. if (!open (FILE, ">$name")) { - &gst_report ("file_open_write_failed", $name); + &Utils::Report::do_report ("file_open_write_failed", $name); return undef; } return *FILE; } -sub gst_file_open_filter_write_from_names +sub open_filter_write_from_names { local *INFILE; local *OUTFILE; my ($filename, $name, $elem); - &gst_report_enter (); + &Utils::Report::enter (); # Find out where it lives. @@ -351,41 +335,41 @@ sub gst_file_open_filter_write_from_names if ($prefix eq "") { - &gst_report ("file_open_filter_failed", "@_"); + &Utils::Report::do_report ("file_open_filter_failed", "@_"); return(0, 0); } else { $name = $_[0]; (my $fullname = "$gst_prefix/$name") =~ tr/\//\//s; - &gst_report ("file_open_filter_create", "@_", $fullname); + &Utils::Report::do_report ("file_open_filter_create", "@_", $fullname); } } else { (my $fullname = "$gst_prefix/$name") =~ tr/\//\//s; - &gst_report ("file_open_filter_success", $name, $fullname); + &Utils::Report::do_report ("file_open_filter_success", $name, $fullname); } ($filename) = $name =~ /.*\/(.+)$/; ($name = "$gst_prefix/$name") =~ tr/\//\//s; # '//' -> '/' - &gst_file_create_path_for_file ($name); + &create_path_for_file ($name); # Make a backup if the file already exists - if the user specified a prefix, # it might not. if (-e $name) { - &gst_file_backup ($name); + &do_backup ($name); } # Return filehandles. Make a copy to use as filter input. It might be # invalid (no source file), in which case the caller should just write to # OUTFILE without bothering with INFILE filtering. - my $tmp_path = &gst_file_get_tmp_path (); + my $tmp_path = &get_tmp_path (); - &gst_file_create_path ("$tmp_path"); + &create_path ("$tmp_path"); unlink ("$tmp_path/$gst_name-$filename"); copy ($name, "$tmp_path/$gst_name-$filename"); @@ -393,25 +377,25 @@ sub gst_file_open_filter_write_from_names if (!open (OUTFILE, ">$name")) { - &gst_report ("file_open_filter_failed", $name); - return; + &Utils::Report::do_report ("file_open_filter_failed", $name); + return (*INFILE, 0); } - &gst_report_leave (); + &Utils::Report::leave (); return (*INFILE, *OUTFILE); } -sub gst_file_open_write_compressed +sub open_write_compressed { local *FILE; my ($name, $fullname, $gzip); - $gzip = &gst_file_locate_tool ("gzip"); + $gzip = &locate_tool ("gzip"); return undef if (!$gzip); - &gst_report_enter (); + &Utils::Report::enter (); # Find out where it lives. @@ -421,32 +405,32 @@ sub gst_file_open_write_compressed { $name = $_[0]; (my $fullname = "$gst_prefix/$name") =~ tr/\//\//s; - &gst_report ("file_open_write_create", "@_", $fullname); + &Utils::Report::do_report ("file_open_write_create", "@_", $fullname); } else { (my $fullname = "$gst_prefix/$name") =~ tr/\//\//s; - &gst_report ("file_open_write_success", $fullname); + &Utils::Report::do_report ("file_open_write_success", $fullname); } ($name = "$gst_prefix/$name") =~ tr/\//\//s; # '//' -> '/' - &gst_file_create_path_for_file ($name); + &create_path_for_file ($name); # Make a backup if the file already exists - if the user specified a prefix, # it might not. if (stat ($name)) { - &gst_file_backup ($name); + &do_backup ($name); } - &gst_report_leave (); + &Utils::Report::leave (); # Truncate and return filehandle. if (!open (FILE, "| $gzip -c > $name")) { - &gst_report ("file_open_write_failed", $name); + &Utils::Report::do_report ("file_open_write_failed", $name); return; } @@ -454,86 +438,86 @@ sub gst_file_open_write_compressed } -sub gst_file_run_pipe +sub run_pipe { my ($cmd, $mode_mask, $stderr) = @_; my ($command); local *PIPE; - $mode_mask = $GST_FILE_READ if $mode_mask eq undef; + $mode_mask = $FILE_READ if $mode_mask eq undef; - &gst_report_enter (); + &Utils::Report::enter (); if ($stderr) { - $command = &gst_file_get_cmd_path_with_stderr ($cmd); + $command = &get_cmd_path_with_stderr ($cmd); } else { - $command = &gst_file_get_cmd_path ($cmd); + $command = &get_cmd_path ($cmd); } if ($command == -1) { - &gst_report ("file_run_pipe_failed", $command); - &gst_report_leave (); + &Utils::Report::do_report ("file_run_pipe_failed", $command); + &Utils::Report::leave (); return undef; } - $command .= " |" if $mode_mask & $GST_FILE_READ; - $command = "| $command > /dev/null" if $mode_mask & $GST_FILE_WRITE; + $command .= " |" if $mode_mask & $FILE_READ; + $command = "| $command > /dev/null" if $mode_mask & $FILE_WRITE; open PIPE, $command; - &gst_report ("file_run_pipe_success", $command); - &gst_report_leave (); + &Utils::Report::do_report ("file_run_pipe_success", $command); + &Utils::Report::leave (); return *PIPE; } -sub gst_file_run_pipe_read +sub run_pipe_read { my ($cmd) = @_; - return &gst_file_run_pipe ($cmd, $GST_FILE_READ); + return &run_pipe ($cmd, $FILE_READ); } -sub gst_file_run_pipe_read_with_stderr +sub run_pipe_read_with_stderr { my ($cmd) = @_; - return &gst_file_run_pipe ($cmd, $GST_FILE_READ, 1); + return &run_pipe ($cmd, $FILE_READ, 1); } -sub gst_file_run_pipe_write +sub run_pipe_write { my ($cmd) = @_; - return &gst_file_run_pipe ($cmd, $GST_FILE_WRITE); + return &run_pipe ($cmd, $FILE_WRITE); } -sub gst_file_run_backtick +sub run_backtick { my ($cmd, $stderr) = @_; my ($fd, $res); if ($stderr) { - $fd = &gst_file_run_pipe_read_with_stderr ($cmd); + $fd = &run_pipe_read_with_stderr ($cmd); } else { - $fd = &gst_file_run_pipe_read ($cmd); + $fd = &run_pipe_read ($cmd); } $res = join ('', <$fd>); - &gst_file_close ($fd); + &close_file ($fd); return $res; } -sub gst_file_close +sub close_file { my ($fd) = @_; @@ -541,23 +525,26 @@ sub gst_file_close } -sub gst_file_remove +sub remove { my ($name) = @_; + my ($file); - &gst_report_enter (); - &gst_report ("file_remove", $name); + &Utils::Report::enter (); + &Utils::Report::do_report ("file_remove", $name); - if (stat ($name)) + $file = "$gst_prefix/$name"; + + if (stat ($file)) { - &gst_file_backup ($name); + &do_backup ($file); } - unlink $name; - &gst_report_leave (); + unlink $file; + &Utils::Report::leave (); } -sub gst_file_rmtree +sub rmtree { my($roots, $verbose, $safe) = @_; my(@files); @@ -605,7 +592,7 @@ sub gst_file_rmtree @files = reverse @files if $Is_VMS; ($root = VMS::Filespec::unixify($root)) =~ s#\.dir\z## if $Is_VMS; @files = map("$root/$_", grep $_!~/^\.{1,2}\z/s,@files); - $count += &gst_file_rmtree(\@files,$verbose,$safe); + $count += &rmtree(\@files,$verbose,$safe); if ($safe && ($Is_VMS ? !&VMS::Filespec::candelete($root) : !-w $root)) { print "skipped $root\n" if $verbose; @@ -663,57 +650,52 @@ sub gst_file_rmtree # Open $file and put it into @buffer, for in-line editting. # \@buffer on success, undef on error. -sub gst_file_buffer_load +sub load_buffer { my ($file) = @_; my @buffer; my $fd; - &gst_report_enter (); - &gst_report ("file_buffer_load", $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("file_buffer_load", $file); - $fd = &gst_file_open_read_from_names ($file); + $fd = &open_read_from_names ($file); return [] unless $fd; @buffer = (<$fd>); - &gst_report_leave (); + &Utils::Report::leave (); return \@buffer; } # Same with an already open fd. -sub gst_file_buffer_load_fd +sub load_buffer_from_fd { my ($fd) = @_; my (@buffer); - &gst_report_enter (); - &gst_report ("file_buffer_load", $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("file_buffer_load", $file); @buffer = (<$fd>); - &gst_report_leave (); + &Utils::Report::leave (); return \@buffer; } # Take a $buffer and save it in $file. -1 is error, 0 success. -sub gst_file_buffer_save +sub save_buffer { my ($buffer, $file) = @_; my ($fd, $i); - &gst_report_enter (); - &gst_report ("file_buffer_save", $file); - - foreach $i (@$buffer) - { - &gst_debug_print_string ("|" . $i); - } + &Utils::Report::enter (); + &Utils::Report::do_report ("file_buffer_save", $file); - $fd = &gst_file_open_write_from_names ($file); + $fd = &open_write_from_names ($file); return -1 if !$fd; if (@$buffer < 1) @@ -733,9 +715,9 @@ sub gst_file_buffer_save } } - &gst_file_close ($fd); + &close_file ($fd); - &gst_report_leave (); + &Utils::Report::leave (); return 0; } @@ -743,7 +725,7 @@ sub gst_file_buffer_save # Erase all empty string elements from the $buffer. -sub gst_file_buffer_clean +sub clean_buffer { my $buffer = $_[0]; my $i; @@ -755,7 +737,7 @@ sub gst_file_buffer_clean } -sub gst_file_buffer_join_lines +sub join_buffer_lines { my $buffer = $_[0]; my $i; @@ -776,7 +758,7 @@ sub gst_file_buffer_join_lines # --- Command-line utilities --- # -# &gst_file_run (<command line>) +# &run (<command line>) # # Assumes the first word on the command line is the command-line utility # to run, and tries to locate it, replacing it with its full path. The path @@ -786,30 +768,30 @@ sub gst_file_buffer_join_lines # # Example: "mkswap /dev/hda3" -> 'PATH=$PATH:/sbin:/usr/sbin /sbin/mkswap /dev/hda3 2>/dev/null >/dev/null'. -sub gst_file_run +sub run { my ($cmd, $background) = @_; my ($command, $tool_name, $tool_path, @argline); - &gst_report_enter (); + &Utils::Report::enter (); - $command = &gst_file_get_cmd_path ($cmd); + $command = &get_cmd_path ($cmd); return -1 if $command == -1; $command .= " > /dev/null"; $command .= " &" if $background; - &gst_report ("file_run", $command); - &gst_report_leave (); + &Utils::Report::do_report ("file_run", $command); + &Utils::Report::leave (); # As documented in perlfunc, divide by 256. return (system ($command) / 256); } -sub gst_file_run_bg +sub run_bg { my ($cmd) = @_; - return &gst_file_run ($cmd, 1); + return &run ($cmd, 1); } # &gst_file_locate_tool @@ -823,7 +805,7 @@ sub gst_file_run_bg %gst_tool_paths = (); -sub gst_file_locate_tool +sub locate_tool { my ($tool) = @_; my $found = ""; @@ -834,14 +816,14 @@ sub gst_file_locate_tool { if (! (-x $tool)) { - &gst_report ("file_locate_tool_failed", $tool); + &Utils::Report::do_report ("file_locate_tool_failed", $tool); return ""; } return $tool; } - &gst_report_enter (); + &Utils::Report::enter (); $found = $gst_tool_paths{$tool}; if ($found eq "0") @@ -880,51 +862,51 @@ sub gst_file_locate_tool if ($found) { $gst_tool_paths{$tool} = $found; - &gst_report ("file_locate_tool_success", $tool); + &Utils::Report::do_report ("file_locate_tool_success", $tool); } else { $gst_tool_paths{$tool} = "0"; - &gst_report ("file_locate_tool_failed", $tool); + &Utils::Report::do_report ("file_locate_tool_failed", $tool); } } - &gst_report_leave (); + &Utils::Report::leave (); return ($found); } -sub gst_file_tool_installed +sub tool_installed { my ($tool) = @_; - $tool = &gst_file_locate_tool ($tool); + $tool = &locate_tool ($tool); return 0 if $tool eq ""; return 1; } -sub gst_file_copy +sub copy_file { my ($orig, $dest) = @_; - return if (!gst_file_exists ($orig)); + return if (!&exists ("$gst_prefix/$orig")); copy ("$gst_prefix/$orig", "$gst_prefix/$dest"); } -sub gst_file_get_temp_name +sub get_temp_name { my ($prefix) = @_; return mktemp ($prefix); } -sub gst_file_copy_from_stock +sub copy_file_from_stock { my ($orig, $dest) = @_; if (!copy ("$FILESDIR/$orig", $dest)) { - &gst_report ("file_copy_failed", "$FILESDIR/$orig", $dest); + &Utils::Report::do_report ("file_copy_failed", "$FILESDIR/$orig", $dest); return -1; } diff --git a/Utils/Makefile.am b/Utils/Makefile.am new file mode 100644 index 0000000..8486d8f --- /dev/null +++ b/Utils/Makefile.am @@ -0,0 +1,12 @@ +utilsdir = $(scriptsdir)/Utils + +utils_SCRIPTS = \ + Backend.pm \ + File.pm \ + Monitor.pm \ + Parse.pm \ + Platform.pm \ + Replace.pm \ + Report.pm \ + Util.pm \ + XML.pm diff --git a/Utils/Monitor.pm b/Utils/Monitor.pm new file mode 100644 index 0000000..345b621 --- /dev/null +++ b/Utils/Monitor.pm @@ -0,0 +1,93 @@ +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +# Authors: Carlos Garnacho Parro <carlosg@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +package Utils::Monitor; + +use Cwd; +use strict; +use base qw(Net::DBus::Object); +use Utils::Backend; +eval "use Sys::Gamin;"; +my $eval_gamin = $@; + +my $has_gamin = ($eval_gamin eq "") ? 1 : 0; +my $fm; +my %objects; + +if ($has_gamin) +{ + $fm = new Sys::Gamin; +} + +sub do_monitor_files +{ + my ($event, $data, $func, $path); + + return if (!$has_gamin); + + while ($fm->pending) + { + $event = $fm->next_event; + + if ($event->type eq "change") + { + $data = $objects {$event->filename}; + $path = $Utils::Backend::DBUS_PREFIX . "." . $$data{"name"}; + + &Net::DBus::Object::emit_signal ($$data {"object"}, + $path, + $$data {"signal"}); + } + } +} + +sub add_file +{ + my ($file, $object, $name, $signal) = @_; + my ($path); + + $path = &Cwd::abs_path ($file); + return unless -f $path; + + $objects {$path} = { "object" => $object, + "name" => $name, + "signal" => $signal}; + $fm->monitor ($path); +} + +sub monitor_files +{ + my ($files, $object, $name, $signal) = @_; + my ($f); + + return if (!$has_gamin); + + if (ref $files eq "ARRAY") + { + foreach $f (@$files) + { + &add_file ($f, $object, $name, $signal); + } + } + else + { + &add_file ($files, $object, $name, $signal); + } +} + +1; diff --git a/parse.pl.in b/Utils/Parse.pm index 9bad7d8..52be03b 100644 --- a/parse.pl.in +++ b/Utils/Parse.pm @@ -22,17 +22,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Utils::Parse; -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/){ - - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/debug.pl$DOTIN"; +use Utils::Util; +use Utils::File; # The concept of keyword (kw) here is a key, normaly in its own line, whose @@ -49,9 +42,9 @@ require "$SCRIPTSDIR/debug.pl$DOTIN"; # Expand substrings of the form #$substr# to the $value in # the string or recursively in the array $strarr. -sub gst_parse_expand +sub expand { - my ($strarr, $substr, $value) = @_; + my ($strarr, @args) = @_; if (ref $strarr eq "ARRAY") { @@ -60,17 +53,24 @@ sub gst_parse_expand $strarr = [ @$strarr ]; foreach $i (@$strarr) { - $i = &gst_parse_expand ($i, $substr, $value); + $i = &expand ($i, $substr, $value); } return $strarr; } - - $strarr =~ s/\#$substr\#/$value/; + + while (@args) + { + $substr = shift @args; + $value = shift @args; + + $strarr =~ s/\#$substr\#/$value/; + } + return $strarr; } -sub gst_parse_replace_hash_values +sub replace_hash_values { my ($cp, $hash) = @_; my ($j, $replace_key, $value); @@ -94,7 +94,6 @@ sub gst_parse_replace_hash_values } else { - &gst_debug_print_line ("Warning: gst_parse_replace_hash_values: key $replace_key doesn't exist."); return 0; } } @@ -103,7 +102,7 @@ sub gst_parse_replace_hash_values return 1; } -sub gst_parse_replace_files +sub replace_files { my ($values, $fn_hash) = @_; my @ret; @@ -129,11 +128,11 @@ sub gst_parse_replace_files # Additional abstraction: parse table entries can have # arrays inside. The parsing proc will be ran with every # combination that the arrays provide. Ex: -# ["user", \&gst_parse_foo, [0, 1], [2, 3] ] will parse +# ["user", \&get_foo, [0, 1], [2, 3] ] will parse # using the combinatory of [0, 1]x[2, 3] until a result # ne undef is given. Check RedHat 7.2's network parse table # for further enlightenment. -sub gst_parse_run_entry +sub run_entry { my ($hash, $key, $proc, $cp) = @_; my ($ncp, $i, $j, $res); @@ -146,7 +145,7 @@ sub gst_parse_run_entry foreach $j (@{$$cp[$i]}) { $$ncp[$i] = $j; - $res = &gst_parse_run_entry ($hash, $key, $proc, $ncp); + $res = &run_entry ($hash, $key, $proc, $ncp); return $res if $res ne undef; } return undef; @@ -155,11 +154,11 @@ sub gst_parse_run_entry # OK, the given entry didn't have any array refs in it... - return undef if (!&gst_parse_replace_hash_values ($cp, $hash)); + return undef if (!&replace_hash_values ($cp, $hash)); - &gst_report_enter (); - &gst_report ("parse_table", "$key"); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_table", "$key"); + &Utils::Report::leave (); $$hash{$key} = &$proc (@$cp); return $$hash{$key}; @@ -167,7 +166,7 @@ sub gst_parse_run_entry # OK, this is the good stuff: -# gst_parse_from_table takes a file mapping and a parse table. +# get_from_table takes a file mapping and a parse table. # # The functions in the replace tables, most of which are coded in # this file, receive the mapped files of the first argument, and then @@ -180,7 +179,7 @@ sub gst_parse_run_entry # can return undef if they failed to get the requested value. # # A ref to the hash with all the fetched values is returned. -sub gst_parse_from_table +sub get_from_table { my ($fn, $table) = @_; my %hash; @@ -195,12 +194,12 @@ sub gst_parse_from_table if ($hash{$key} eq undef) { $proc = shift (@cp); - @files = &gst_parse_replace_files (shift (@cp), $fn); + @files = &replace_files (shift (@cp), $fn); # Don't unshift the resulting files if none were given. unshift @cp, @files if (scalar @files) > 0; - &gst_parse_run_entry (\%hash, $key, $proc, \@cp); + &run_entry (\%hash, $key, $proc, \@cp); } } @@ -215,13 +214,13 @@ sub gst_parse_from_table # Just return the passed values. If there's just # one value, the value. If more, a reference to an # array with the values. -sub gst_parse_trivial +sub get_trivial { my (@res) = @_; - &gst_report_enter (); - &gst_report ("parse_trivial", "@res"); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_trivial", "@res"); + &Utils::Report::leave (); return $res[0] if (scalar @res) <= 1; return \@res; @@ -230,7 +229,7 @@ sub gst_parse_trivial # Try to read a line from $fd and remove any leading or # trailing white spaces. Return ref to read $line or # -1 if eof. -sub gst_parse_chomp_line_std +sub chomp_line_std { my ($fd) = @_; my $line; @@ -247,7 +246,7 @@ sub gst_parse_chomp_line_std # Assuming $line is a line read from a shell file, # remove comments. -sub gst_parse_process_sh_line +sub process_sh_line { my ($line) = @_; my ($pline); @@ -275,28 +274,28 @@ sub gst_parse_process_sh_line return $pline; } -# Same as gst_parse_chomp_line_std, but apply +# Same as chomp_line_std, but apply # the sh line processing before returning. # -1 if eof, ref to read $line if success. -sub gst_parse_chomp_line_hash_comment +sub chomp_line_hash_comment { my ($fd) = @_; my $line; - $line = &gst_parse_chomp_line_std ($fd); + $line = &chomp_line_std ($fd); return -1 if $line == -1; - $line = &gst_parse_process_sh_line ($$line); + $line = &process_sh_line ($$line); return \$line; } # Get an sh line, and remove the export keyword, if any. -sub gst_parse_chomp_line_sh_export +sub chomp_line_sh_export { my ($fd) = @_; my $line; - $line = &gst_parse_chomp_line_hash_comment ($fd); + $line = &chomp_line_hash_comment ($fd); return -1 if $line == -1; $line = $$line; @@ -309,17 +308,17 @@ sub gst_parse_chomp_line_sh_export # Parse a $file, wich is assumed to have a column-based format, with $re matching field separators # and one record per line. Search for $key, and return either a scalar with the first ocurrence, # or an array with all the found ocurrences. -sub gst_parse_split_ref +sub split_ref { my ($file, $key, $re, $all, $line_read_proc) = @_; my ($fd, @line, @res); - &gst_report_enter (); - &gst_report ("parse_split", $key, $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_split", $key, $file); - $proc = $line_read_proc? $line_read_proc : \&gst_parse_chomp_line_std; + $proc = $line_read_proc? $line_read_proc : \&chomp_line_std; - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); $all = 0 if !$fd; while (($line = &$proc ($fd)) != -1) @@ -336,59 +335,59 @@ sub gst_parse_split_ref } else { - &gst_report_leave (); - &gst_file_close ($fd); + &Utils::Report::leave (); + &Utils::File::close_file ($fd); return \$line[0]; } } } - &gst_report_leave (); - &gst_file_close ($fd); + &Utils::Report::leave (); + &Utils::File::close_file ($fd); return \@res if ($all); return -1; } -sub gst_parse_split +sub split { my $res; # Don't pass @_ like this anywhere. This is bad practice. - $res = &gst_parse_split_ref (@_); + $res = &split_ref (@_); return $$res if ref $res eq "SCALAR"; return @$res if ref $res eq "ARRAY"; return undef; } -# This gives meaning to the $all flag of gst_parse_split, and returns a reference to the array, which +# This gives meaning to the $all flag of &split, and returns a reference to the array, which # is what we want. (ie search a.com\nsearch b.com\nsearch c.com) -sub gst_parse_split_all +sub split_all { my ($file, $key, $re, $line_read_proc) = @_; my @a; - @a = &gst_parse_split ($file, $key, $re, 1, $line_read_proc); + @a = &split ($file, $key, $re, 1, $line_read_proc); return \@a; } # Same, but use the hash_comment routine for line analysis. -sub gst_parse_split_all_hash_comment +sub split_all_hash_comment { my ($file, $key, $re) = @_; - return &gst_parse_split_all ($file, $key, $re, \&gst_parse_chomp_line_hash_comment); + return &split_all ($file, $key, $re, \&chomp_line_hash_comment); } # Make the elements of the resulting array unique. -sub gst_parse_split_all_unique_hash_comment +sub split_all_unique_hash_comment { my ($file, $key, $re) = @_; my ($arr, @res); my (%hash, $i); - $arr = &gst_parse_split_all ($file, $key, $re, \&gst_parse_chomp_line_hash_comment); + $arr = &split_all ($file, $key, $re, \&chomp_line_hash_comment); foreach $i (@$arr) { @@ -400,12 +399,12 @@ sub gst_parse_split_all_unique_hash_comment return \@res; } -sub gst_parse_split_all_array_with_pos +sub split_all_array_with_pos { my ($file, $key, $pos, $re, $sep, $line_read_proc) = @_; my ($arr, @s, @ret, $i); - $arr = &gst_parse_split_all ($file, $key, $re, $line_read_proc); + $arr = &split_all ($file, $key, $re, $line_read_proc); foreach $i (@$arr) { @@ -417,55 +416,55 @@ sub gst_parse_split_all_array_with_pos } # Same, but for $all = 0. (ie nameserver 10.0.0.1) -sub gst_parse_split_first_str +sub split_first_str { my ($file, $key, $re, $line_read_proc) = @_; - return &gst_parse_split ($file, $key, $re, 0, $line_read_proc); + return &split ($file, $key, $re, 0, $line_read_proc); } # Interpret the result as a boolean. (ie multi on) -sub gst_parse_split_first_bool +sub split_first_bool { my ($file, $key, $re, $line_read_proc) = @_; my $ret; - $ret = &gst_parse_split_first_str ($file, $key, $re, $line_read_proc); + $ret = &split_first_str ($file, $key, $re, $line_read_proc); return undef if ($ret eq undef); - return (&gst_util_read_boolean ($ret)? 1: 0); + return (&Utils::Util::read_boolean ($ret)? 1: 0); } # After getting the first field, split the result with $sep matching separators. (ie order hosts,bind) -sub gst_parse_split_first_array +sub split_first_array { my ($file, $key, $re, $sep, $line_read_proc) = @_; my @ret; - @ret = split ($sep, &gst_parse_split ($file, $key, $re, 0, $line_read_proc)); + @ret = split ($sep, &split ($file, $key, $re, 0, $line_read_proc)); return \@ret; } -sub gst_parse_split_first_array_pos +sub split_first_array_pos { my ($file, $key, $pos, $re, $sep, $line_read_proc) = @_; my (@ret); - @ret = split ($sep, &gst_parse_split ($file, $key, $re, 0, $line_read_proc)); + @ret = split ($sep, &split ($file, $key, $re, 0, $line_read_proc)); return $ret[$pos]; } -# Do an gst_parse_split_first_array and then make +# Do an split_first_array and then make # the array elements unique. This is to fix broken # searchdomain entries in /etc/resolv.conf, for example. -sub gst_parse_split_first_array_unique +sub split_first_array_unique { my ($file, $key, $re, $sep, $line_read_proc) = @_; my (@arr, @res); my (%hash, $i); - - @arr = split ($sep, &gst_parse_split ($file, $key, $re, 0, $line_read_proc)); + + @arr = split ($sep, &split ($file, $key, $re, 0, $line_read_proc)); foreach $i (@arr) { @@ -483,15 +482,15 @@ sub gst_parse_split_first_array_unique # you don't know what keys you are going to parse # (i.e. /etc/hosts). Any other application will not # be very portable and should be avoided. -sub gst_parse_split_hash +sub split_hash { my ($file, $key_re, $value_re) = @_; my ($fd, @line, %res, $key); - &gst_report_enter (); - &gst_report ("parse_split_hash", $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_split_hash", $file); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); while (<$fd>) { @@ -506,24 +505,24 @@ sub gst_parse_split_hash push @{$res{$key}}, split ($value_re, $line[0]); } - &gst_file_close ($fd); - &gst_report_leave (); + &Utils::File::close_file ($fd); + &Utils::Report::leave (); return undef if (scalar keys (%res) == 0); return \%res; } # Same as above, but join lines that end with '\'. -sub gst_parse_split_hash_with_continuation +sub split_hash_with_continuation { my ($file, $key_re, $value_re) = @_; my ($fd, $l, @line, %res, $key); - &gst_report_enter (); - &gst_report ("parse_split_hash_cont", $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_split_hash_cont", $file); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); - while (($l = &gst_parse_ini_line_read ($fd)) != -1) + while (($l = &ini_line_read ($fd)) != -1) { $_ = $$l; chomp; @@ -537,14 +536,14 @@ sub gst_parse_split_hash_with_continuation $res{$key} = [ split ($value_re, $line[0]) ]; } - &gst_file_close ($fd); - &gst_report_leave (); + &Utils::File::close_file ($fd); + &Utils::Report::leave (); return undef if (scalar keys (%res) == 0); return \%res; } # Remove escape sequences in a shell value. -sub gst_parse_shell_unescape +sub unescape { my $ret = $_[0]; @@ -561,7 +560,7 @@ sub gst_parse_shell_unescape } # unescape (escape (x)) == x -sub gst_parse_shell_escape +sub escape { my ($value) = @_; @@ -572,39 +571,39 @@ sub gst_parse_shell_escape } # For files which are a list of /bin/sh shell variable declarations. (ie GATEWAY=10.10.10.1) -sub gst_parse_sh +sub get_sh { my ($file, $key) = @_; my $ret; - &gst_report_enter (); - &gst_report ("parse_sh", $key, $file); - $ret = &gst_parse_split_first_str ($file, $key, "[ \t]*=[ \t]*", - \&gst_parse_chomp_line_hash_comment); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_sh", $key, $file); + $ret = &split_first_str ($file, $key, "[ \t]*=[ \t]*", + \&chomp_line_hash_comment); + &Utils::Report::leave (); - return &gst_parse_shell_unescape ($ret); + return &unescape ($ret); } # Same, but interpret the returning value as a bool. (ie NETWORKING=yes) -sub gst_parse_sh_bool +sub get_sh_bool { my ($file, $key) = @_; my $ret; - $ret = &gst_parse_sh ($file, $key); + $ret = &get_sh ($file, $key); return undef if ($ret eq undef); - return (&gst_util_read_boolean ($ret)? 1: 0); + return (&Utils::Util::read_boolean ($ret)? 1: 0); } # Get an sh value and then split with $re, returning ref to resulting array. -sub gst_parse_sh_split +sub get_sh_split { my ($file, $key, $re) = @_; my (@ret, $val); - $val = &gst_parse_sh ($file, $key); + $val = &get_sh ($file, $key); @ret = split ($re, $val); return \@ret; @@ -612,62 +611,62 @@ sub gst_parse_sh_split # Get a fully qualified hostname from a $key shell var in $file # and extract the hostname from there. e.g.: suse70's /etc/rc.config's FQHOSTNAME. -sub gst_parse_sh_get_hostname +sub get_sh_hostname { my ($file, $key) = @_; my ($val); - $val = &gst_parse_sh_split ($file, $key, "\\."); + $val = &get_sh_split ($file, $key, "\\."); return $$val[0]; } # Get a fully qualified hostname from a $key shell var in $file # and extract the domain from there. e.g.: suse70's /etc/rc.config's FQHOSTNAME. -sub gst_parse_sh_get_domain +sub get_sh_domain { my ($file, $key) = @_; my ($val); - $val = &gst_parse_sh_split ($file, $key, "\\."); + $val = &get_sh_split ($file, $key, "\\."); return join ".", @$val[1..$#$val]; } # For files which are a list of /bin/sh shell variable exports. (eg export GATEWAY=10.10.10.1) -sub gst_parse_sh_export +sub get_sh_export { my ($file, $key) = @_; my $ret; - &gst_report_enter (); - &gst_report ("parse_sh", $key, $file); - $ret = &gst_parse_split_first_str ($file, $key, "[ \t]*=[ \t]*", - \&gst_parse_chomp_line_sh_export); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_sh", $key, $file); + $ret = &split_first_str ($file, $key, "[ \t]*=[ \t]*", + \&chomp_line_sh_export); + &Utils::Report::leave (); - return &gst_parse_shell_unescape ($ret); + return &unescape ($ret); } # Same, but interpret the returing value as a bool. (ie export NETWORKING=yes) -sub gst_parse_sh_export_bool +sub get_sh_export_bool { my ($file, $key) = @_; my $ret; - $ret = &gst_parse_sh_export ($file, $key); + $ret = &get_sh_export ($file, $key); return undef if ($ret eq undef); - return (&gst_util_read_boolean ($ret)? 1: 0); + return (&Utils::Util::read_boolean ($ret)? 1: 0); } # Same, but accepting a regexp and returning the value between the paren operator -sub gst_parse_sh_re +sub get_sh_re { my ($file, $key, $re) = @_; my $ret; - $ret = &gst_parse_sh ($file, $key); + $ret = &get_sh ($file, $key); $ret =~ /$re/i; return $1; @@ -676,60 +675,60 @@ sub gst_parse_sh_re # Search for $keyword in $file, delimited by $re (default " ") or EOL. # If keyword exists, return 1, else 0. -sub gst_parse_kw +sub get_kw { my ($file, $keyword, $re, $line_read_proc) = @_; my $res; - &gst_report_enter (); - &gst_report ("parse_kw", $keyword, $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_kw", $keyword, $file); if (! -f "$gst_prefix/$file") { - &gst_report_enter (); - &gst_report ("file_open_read_failed", $file); - &gst_report_leave (); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("file_open_read_failed", $file); + &Utils::Report::leave (); + &Utils::Report::leave (); return undef; } $re = " " if $re eq undef; - $res = &gst_parse_split_ref ($file, $keyword, $re, 0, $line_read_proc); + $res = &split_ref ($file, $keyword, $re, 0, $line_read_proc); - &gst_report_leave (); + &Utils::Report::leave (); return 0 if $res == -1; return 1; } # A file containing the desired value in its first line. (ie /etc/hostname) -sub gst_parse_line_first +sub get_first_line { my ($file) = @_; my ($fd, $res); - &gst_report_enter (); - &gst_report ("parse_line_first", $file); - $fd = &gst_file_open_read_from_names ($file); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_line_first", $file); + $fd = &Utils::File::open_read_from_names ($file); + &Utils::Report::leave (); return undef if !$fd; chomp ($res = <$fd>); - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return $res; } # parse a chat file, searching for an entry that matches $re. # $re must have one paren operator (ie "^atd[^0-9]*([0-9, -]+)"). -sub gst_parse_chat +sub get_from_chatfile { my ($file, $re) = @_; my ($fd, $found); - &gst_report_enter (); - &gst_report ("parse_chat", $file); - $fd = &gst_file_open_read_from_names ("$file"); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_chat", $file); + $fd = &Utils::File::open_read_from_names ("$file"); + &Utils::Report::leave (); return undef if !$fd; while (<$fd>) @@ -753,20 +752,20 @@ sub gst_parse_chat # If it looks like what we're looking for, return what matched the parens. if ($found =~ /$re/i) { - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return $1; } } } - &gst_file_close ($fd); + &Utils::File::close_file ($fd); # Oops: not found. return undef; } # Clean an ini line of comments and leading or # trailing spaces. -sub gst_parse_ini_line_clean +sub ini_line_clean { $_ = $_[0]; @@ -781,7 +780,7 @@ sub gst_parse_ini_line_clean # Read an ini line, which may have to be joined # with the next one if it ends with '\'. -sub gst_parse_ini_line_read +sub ini_line_read { my $fd = $_[0]; my $l; @@ -789,50 +788,50 @@ sub gst_parse_ini_line_read $l = <$fd>; return -1 if ($l eq undef); - $l = &gst_parse_ini_line_clean ($l); + $l = &ini_line_clean ($l); while ($l =~ /\\$/) { $l =~ s/\\$//; - $l .= &gst_parse_ini_line_clean (scalar <$fd>); + $l .= &ini_line_clean (scalar <$fd>); } return \$l; } # Return an array of all found sections in $file. -sub gst_parse_ini_sections +sub get_ini_sections { my ($file) = @_; my (@sections, $line); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); - while (($line = &gst_parse_ini_line_read ($fd)) != -1) + while (($line = &ini_line_read ($fd)) != -1) { $_ = $$line; next if (/^$/); push @sections, $1 if (/\[([^\]]+)\]/i); } - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return @sections; } # Get the value of a $var in a $section from $file. -sub gst_parse_ini +sub get_from_ini { my ($file, $section, $var) = @_; my ($fd, $res, $line); my $found_section_flag = 0; - &gst_report_enter (); - &gst_report ("parse_ini", $var, $file, $section); - $fd = &gst_file_open_read_from_names ($file); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_ini", $var, $file, $section); + $fd = &Utils::File::open_read_from_names ($file); + &Utils::Report::leave (); $res = undef; - while (($line = &gst_parse_ini_line_read ($fd)) != -1) + while (($line = &ini_line_read ($fd)) != -1) { $_ = $$line; next if (/^$/); @@ -858,330 +857,26 @@ sub gst_parse_ini } } - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return $res; } # Same, but treat value as bool and return 1/0. -sub gst_parse_ini_bool +sub get_from_ini_bool { my ($file, $section, $var) = @_; my $ret; - $ret = &gst_parse_ini ($file, $section, $var); + $ret = &get_from_ini ($file, $section, $var); - return undef if ($ret eq undef); - return (&gst_util_read_boolean ($ret)? 1: 0); -} - -sub gst_parse_cap_line_clean -{ - $_ = $_[0]; - - chomp; - s/^[ \t]*\#.*//; - s/;.*//; - s/^[ \t]+//; - s/[ \t]+$//; - - return $_; -} - -sub gst_parse_cap_line_read -{ - my $fd = $_[0]; - my $l; - - $l = <$fd>; - return -1 if ($l eq undef); - - $l = &gst_parse_cap_line_clean ($l); - while ($l =~ /\\$/) - { - $l =~ s/\\$//; - $l .= &gst_parse_cap_line_clean (scalar <$fd>); - } - - return \$l; -} - -sub gst_parse_cap_sections -{ - my ($file) = @_; - my (@sections, $line); - - $fd = &gst_file_open_read_from_names ($file); - - while (($line = &gst_parse_cap_line_read ($fd)) != -1) - { - $_ = $$line; - next if (/^$/); - push @sections, $1 if (/^([^:|]+)/i); - } - - &gst_file_close ($fd); - return @sections; -} - -sub gst_parse_cap -{ - my ($file, $section, $var) = @_; - my ($fd, $res, $line); - my $found_section_flag = 0; - - $fd = &gst_file_open_read_from_names ($file); - $res = undef; - - while (($line = &gst_parse_ini_line_read ($fd)) != -1) - { - $_ = $$line; - next if (/^$/); - if (/^$section[:|]/i) - { - $found_section_flag = 1; - } - - if ($found_section_flag && /:$var\#/i) - { - $_ =~ /:$var\#([^:]*)/; - $res = $1; - last; - } -# if ($found_section_flag && /:$var[#=]/i) -# { -# $_ =~ /:$var[#=]([^:]*)/; -# $res = $1; -# last; -# } - } - - &gst_file_close ($fd); - return $res; -} - -sub gst_parse_cap_bool -{ - my ($file, $section, $var) = @_; - my ($fd, $res, $line); - my $found_section_flag = 0; - - $fd = &gst_file_open_read_from_names ($file); - $res = 0; - - while (($line = &gst_parse_ini_line_read ($fd)) != -1) - { - $_ = $$line; - next if (/^$/); - if (/^$section[:|]/i) - { - $found_section_flag = 1; - } - - if ($found_section_flag && /:$var[:\#=]/i) - { - $res = 1; - last; - } - } - - &gst_file_close ($fd); - return $res; -} - -# Load a printcap file to buffer, join \ lines and split them back up into a -# 'one option, printtool comment or section name per line' format. -sub gst_parse_printcap_buffer_load -{ - my ($file) = @_; - my ($inbuf, @outbuf); - - $inbuf = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($inbuf); - - for $i (@$inbuf) - { - my ($comment) = (""); - - chomp $i; - $comment = $1 if $i =~ s/^([ \t]*[\#].*)//; - - if ($i ne "") - { - my @line = split /:/, $i; - - if ($i =~ /^[a-z0-9]+/i) - { - push @outbuf, ($line [0] . ":\n"); - shift @line; - } - - for $elem (@line) - { - $elem =~ s/^[ \t]//; - $elem =~ s/[ \t]$//; - if ($elem ne "") - { - push @outbuf, ("\t:$elem:\n"); - } - } - } - elsif ($comment ne "") - { - push @outbuf, ($comment . "\n"); - } - else - { - push @outbuf, "\n"; - } - } - - return \@outbuf; -} - -# Find next printer definition, returning (printtool-comment-lineno, stanza-name-lineno). -sub gst_parse_printcap_get_next_stanza -{ - my ($buf, $line_no) = @_; - my ($last_printtool_line) = (-1); - - while ($line_no <= $#$buf) - { - if ($$buf [$line_no] =~ /^\#\#PRINTTOOL3\#\#/) - { - $last_printtool_line = $line_no; - } - elsif ($$buf [$line_no] =~ /^[a-z0-9]+/i) - { - return ($last_printtool_line, $line_no); - } - - $line_no++; - } - - return (-1, -1); -} - -# Find next printer option. -sub gst_parse_printcap_get_next_option -{ - my ($buf, $line_no) = @_; - - while ($line_no <= $#$buf) - { - if ($$buf [$line_no] =~ /^\#\#PRINTTOOL3\#\#/ || - $$buf [$line_no] =~ /^[a-z0-9]+/i) - { - last; - } - - if ($$buf [$line_no] =~ /^\t:/) - { - return $line_no; - } - - $line_no++; - } - - return -1; -} - -sub gst_parse_printcap_parse_stanza -{ - my ($stanza) = @_; - my ($key); - - $key = $1 if $stanza =~ /^([a-z0-9]+)/i; - return $key; -} - -sub gst_parse_printcap_parse_option -{ - my ($option) = @_; - my ($key, $value); - - $key = $1 if $option =~ /^\t:([a-z0-9]+)/i; - $value = $1 if $option =~ /^\t:[a-z0-9]+[\#=]([a-z0-9\/_-]*)/i; - return ($key, $value); -} - -# Locate stanza line for $printer in $buf, starting at $line_no. -sub gst_parse_printcap_find_stanza -{ - my ($buf, $line_no, $printer) = @_; - my ($printtool_line_no, $found_printer); - - while ((($printtool_line_no, $line_no) = &gst_parse_printcap_get_next_stanza ($buf, $line_no))) - { - if ($line_no == -1) { last; } - - $found_printer = &gst_parse_printcap_parse_stanza ($$buf [$line_no]); - return ($printtool_line_no, $line_no) if ($found_printer eq $printer); - $line_no++; - } - - return (-1, -1); -} - -# Search buffer for option with key $key, starting -# at $line_no position. Return line number, or -1 if not found. -sub gst_parse_printcap_find_option -{ - my ($buf, $line_no, $key) = @_; - my $found_key; - - while (($line_no = &gst_parse_printcap_get_next_option ($buf, $line_no)) != -1) - { - ($found_key) = &gst_parse_printcap_parse_option ($$buf [$line_no]); - return $line_no if ($found_key eq $key); - $line_no++; - } - - return -1; -} - -# High-level API. -sub gst_parse_printcap -{ - my ($file, $section, $var) = @_; - my ($printtool_line_no, $stanza_line_no, $option_line_no); - my ($buf); - my ($key, $value); - - $buf = &gst_parse_printcap_buffer_load ($file); - - ($printtool_line_no, $stanza_line_no) = &gst_parse_printcap_find_stanza ($buf, 0, $section); - return undef if ($stanza_line_no == -1); - - $option_line_no = &gst_parse_printcap_find_option ($buf, $stanza_line_no + 1, $var); - return undef if ($option_line_no == -1); - - ($key, $value) = &gst_parse_printcap_parse_option ($$buf [$option_line_no]); - return $value; -} - -# High-level API. -sub gst_parse_printcap_bool -{ - my ($file, $section, $var) = @_; - my ($printtool_line_no, $stanza_line_no, $option_line_no); - my ($buf); - my ($key, $value); - - $buf = &gst_parse_printcap_buffer_load ($file); - - ($printtool_line_no, $stanza_line_no) = &gst_parse_printcap_find_stanza ($buf, 0, $section); - return 0 if ($stanza_line_no == -1); - - $option_line_no = &gst_parse_printcap_find_option ($buf, $stanza_line_no + 1, $var); - return 0 if ($option_line_no == -1); - - return 1; + return 0 if ($ret eq undef); + return (&Utils::Util::read_boolean ($ret)? 1 : 0); } # Debian interfaces(5) states that files starting with # are comments. # Also, leading and trailing spaces are ignored. -sub gst_parse_interfaces_line_clean +sub interfaces_line_clean { $_ = $_[0]; @@ -1194,7 +889,7 @@ sub gst_parse_interfaces_line_clean } # interfaces(5) also states that \ line continuation is possible. -sub gst_parse_interfaces_line_read +sub interfaces_line_read { my $fd = $_[0]; my $l; @@ -1202,11 +897,11 @@ sub gst_parse_interfaces_line_read $l = <$fd>; return -1 if ($l eq undef); - $l = &gst_parse_interfaces_line_clean ($l); + $l = &interfaces_line_clean ($l); while ($l =~ /\\$/) { $l =~ s/\\$//; - $l .= &gst_parse_interfaces_line_clean (scalar <$fd>); + $l .= &interfaces_line_clean (scalar <$fd>); } return \$l; @@ -1214,12 +909,12 @@ sub gst_parse_interfaces_line_read # Read lines until a stanza, a line starting with $stanza_type is found. # Return ref to an array with the stanza params split. -sub gst_parse_interfaces_get_next_stanza +sub interfaces_get_next_stanza { my ($fd, $stanza_type) = @_; my $line; - while (($line = &gst_parse_interfaces_line_read ($fd)) != -1) + while (($line = &interfaces_line_read ($fd)) != -1) { $_ = $$line; if (/^$stanza_type[ \t]+[^ \t]/) @@ -1234,12 +929,12 @@ sub gst_parse_interfaces_get_next_stanza # Read lines until a line not recognized as a stanza is # found, and split in a "tuple" of key/value. -sub gst_parse_interfaces_get_next_option +sub interfaces_get_next_option { my $fd = $_[0]; my $line; - while (($line = &gst_parse_interfaces_line_read ($fd)) != -1) + while (($line = &interfaces_line_read ($fd)) != -1) { $_ = $$line; next if /^$/; @@ -1252,38 +947,38 @@ sub gst_parse_interfaces_get_next_option } # Get all stanzas from file. Return array. -sub gst_parse_interfaces_stanzas +sub get_interfaces_stanzas { my ($file, $stanza_type) = @_; my ($fd, @res); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); $res = undef; - while (($_ = &gst_parse_interfaces_get_next_stanza ($fd, $stanza_type)) != -1) + while (($_ = &interfaces_get_next_stanza ($fd, $stanza_type)) != -1) { push @res, $_; } - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return @res; } # Find stanza for $iface in $file, and return # tuple for option with $key. Return -1 if unexisting. -sub gst_parse_interfaces_option_tuple +sub get_interfaces_option_tuple { my ($file, $iface, $key, $all) = @_; my ($fd, @res); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); - while (($stanza = &gst_parse_interfaces_get_next_stanza ($fd, "iface")) != -1) + while (($stanza = &interfaces_get_next_stanza ($fd, "iface")) != -1) { if ($$stanza[0] eq $iface) { - while (($tuple = &gst_parse_interfaces_get_next_option ($fd)) != -1) + while (($tuple = &interfaces_get_next_option ($fd)) != -1) { if ($$tuple[0] =~ /$key/) { @@ -1302,19 +997,19 @@ sub gst_parse_interfaces_option_tuple # Go get option $kw for $iface stanza. If found, # return 1 (true), else, false. -sub gst_parse_interfaces_option_kw +sub get_interfaces_option_kw { my ($file, $iface, $kw) = @_; my $tuple; - &gst_report_enter (); - &gst_report ("parse_ifaces_kw", $kw, $file); - $tuple = &gst_parse_interfaces_option_tuple ($file, $iface, $kw); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_ifaces_kw", $kw, $file); + $tuple = &get_interfaces_option_tuple ($file, $iface, $kw); + &Utils::Report::leave (); if ($tuple != -1) { - &gst_report ("parse_ifaces_kw_strange", $iface, $file) if ($$tuple[1] ne ""); + &Utils::Report::do_report ("parse_ifaces_kw_strange", $iface, $file) if ($$tuple[1] ne ""); return 1; } @@ -1324,23 +1019,23 @@ sub gst_parse_interfaces_option_kw # For such keywords as noauto, whose existence means # a false value. -sub gst_parse_interfaces_option_kw_not +sub get_interfaces_option_kw_not { my ($file, $iface, $kw) = @_; - return &gst_parse_interfaces_option_kw ($file, $iface, $kw)? 0 : 1; + return &get_interfaces_option_kw ($file, $iface, $kw)? 0 : 1; } # Go get option $key for $iface in $file and return value. -sub gst_parse_interfaces_option_str +sub get_interfaces_option_str { my ($file, $iface, $key) = @_; my $tuple; - &gst_report_enter (); - &gst_report ("parse_ifaces_str", $kw, $file); - $tuple = &gst_parse_interfaces_option_tuple ($file, $iface, $key); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("parse_ifaces_str", $kw, $file); + $tuple = &get_interfaces_option_tuple ($file, $iface, $key); + &Utils::Report::leave (); if ($tuple != -1) { @@ -1353,12 +1048,12 @@ sub gst_parse_interfaces_option_str # Implementing pump(8) pump.conf file format parser. # May be useful for dhcpd too. -sub gst_parse_pump_get_next_option +sub pump_get_next_option { my ($fd) = @_; my $line; - while (($line = &gst_parse_interfaces_line_read ($fd)) != -1) + while (($line = &interfaces_line_read ($fd)) != -1) { $line = $$line; if ($line ne "") @@ -1370,12 +1065,12 @@ sub gst_parse_pump_get_next_option return -1; } -sub gst_parse_pump_get_device +sub pump_get_device { my ($fd, $iface) = @_; my ($opt); - while (($opt = &gst_parse_pump_get_next_option ($fd)) != -1) + while (($opt = &pump_get_next_option ($fd)) != -1) { if ($$opt[0] eq "device") { @@ -1387,20 +1082,20 @@ sub gst_parse_pump_get_device return 0; } -sub gst_parse_pump_get_iface_option_ref +sub get_pump_iface_option_ref { my ($file, $iface, $key) = @_; my ($fd, $opt, $ret); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); - if (&gst_parse_pump_get_device ($fd, $iface)) + if (&pump_get_device ($fd, $iface)) { - while (($opt = &gst_parse_pump_get_next_option ($fd)) != -1) + while (($opt = &pump_get_next_option ($fd)) != -1) { if ($$opt[0] eq $key) { - $ret = &gst_parse_shell_unescape ($$opt[1]); + $ret = &unescape ($$opt[1]); return \$ret; } @@ -1411,130 +1106,31 @@ sub gst_parse_pump_get_iface_option_ref return -1; } -sub gst_parse_pump_get_iface_kw +sub get_pump_iface_kw { my ($file, $iface, $key) = @_; my ($ret); - return 1 if &gst_parse_pump_get_iface_option_ref ($file, $iface, $key) != -1; + return 1 if &get_pump_iface_option_ref ($file, $iface, $key) != -1; return 0; } -sub gst_parse_pump_get_iface_kw_not +sub get_pump_iface_kw_not { my ($file, $iface, $key) = @_; - return 0 if &gst_parse_pump_get_iface_option_ref ($file, $iface, $key) != -1; + return 0 if &get_pump_iface_option_ref ($file, $iface, $key) != -1; return 1; } -# Read a variable out of an XML document. The varpath is the '/'-separated path to the -# XML tag. If the name of a property is passed, that property of the leaf tag is read, -# otherwise the tag's PCDATA. -sub gst_parse_xml -{ - my ($file, $varpath, $property) = @_; - my ($model, $branch); - - ($model) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_find ($model, $varpath); - - if ($branch) - { - return &gst_xml_model_get_attribute ($branch, $property) if $property ne ""; - return &gst_xml_model_get_pcdata ($branch); - } - - return undef; -} - -sub gst_parse_xml_child_names -{ - my ($file, $varpath) = @_; - my ($model, $branch, @children); - - ($model) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_find ($model, $varpath); - - if (!$branch) { return @children; } - - my @list = @$branch; - shift @list; # Attributes - - while (@list) - { - if ($list [0] ne "__unparsed__" && $list [0] ne "0") - { - push @children, shift @list; - } - else - { - shift @list; - } - - shift @list; - } - - return @children; -} - -sub gst_parse_alchemist -{ - my ($file, $varpath) = @_; - - $varpath = "/adm_context/datatree/" . $varpath; - return &gst_parse_xml ($file, $varpath, "VALUE"); -} - -sub gst_parse_alchemist_print -{ - my ($file, $printer, $varpath) = @_; - - $varpath = "printconf/print_queues/" . $printer . "/" . $varpath; - return &gst_parse_alchemist ($file, $varpath); -} - -sub gst_parse_alchemist_print_option -{ - my ($file, $printer, $name) = @_; - my ($varpath, $model, $branch, $fd, $options, $option); - - ($model) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_find ($model, "/adm_context/datatree/printconf/print_queues/" . $printer . - "/filter_data/foomatic_defaults"); - - return undef if (!$branch); - - $options = &gst_xml_model_get_children ($branch); - - foreach $o (@$options) - { - my $opt_node = &gst_xml_model_find ($o, "name"); - next if (!$opt_node); - - if (&gst_xml_model_get_attribute ($opt_node, "VALUE") eq $name) - { - $option = $o; - last; - } - } - - return undef if (!$option); - - my $node = &gst_xml_model_find ($option, "default"); - return undef if (!$node); - - return &gst_xml_model_get_attribute ($node, "VALUE"); -} - # extracts hostname from a fully qualified hostname # contained in a file -sub gst_parse_fq_hostname +sub get_fq_hostname { my ($file) = @_; my ($ret); - $ret = &gst_parse_line_first ($file); + $ret = &get_first_line ($file); $ret =~ s/\..*//; #remove domain return $ret; @@ -1542,18 +1138,18 @@ sub gst_parse_fq_hostname # extracts domain from a fully qualified hostname # contained in a file -sub gst_parse_fq_domain +sub get_fq_domain { my ($file) = @_; my ($ret); - $ret = &gst_parse_line_first ($file); + $ret = &get_first_line ($file); $ret =~ s/^[^\.]*\.//; return $ret; } -sub gst_parse_rcinet1conf +sub get_rcinet1conf { my ($file, $iface, $kw) = @_; my ($line); @@ -1563,21 +1159,21 @@ sub gst_parse_rcinet1conf #we must double escape those [] $line = "$kw\\[$iface\\]"; - return &gst_parse_sh ($file, $line); + return &get_sh ($file, $line); } -sub gst_parse_rcinet1conf_bool +sub get_rcinet1conf_bool { my ($file, $iface, $kw) = @_; my ($ret); - $ret = &gst_parse_rcinet1conf ($file, $iface, $kw); + $ret = &get_rcinet1conf ($file, $iface, $kw); return undef if ($ret eq undef); - return (&gst_util_read_boolean ($ret)? 1: 0); + return (&Utils::Util::read_boolean ($ret)? 1: 0); } -sub gst_parse_wireless_opts +sub get_wireless_opts { my ($file, $iface, $proc, $kw) = @_; my $ifaces = &$proc (); @@ -1593,7 +1189,7 @@ sub gst_parse_wireless_opts return undef if (!$found); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); while (<$fd>) { $line = $_; @@ -1621,17 +1217,17 @@ sub gst_parse_wireless_opts } } - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return $val; } # function for parsing /etc/start_if.$iface files in FreeBSD -sub gst_parse_startif +sub get_startif { my ($file, $regex) = @_; my ($fd, $line, $val); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); $val = undef; return undef if ($fd eq undef); @@ -1659,7 +1255,7 @@ sub gst_parse_startif } # functions for parsing /etc/ppp/ppp.conf sections in FreeBSD -sub gst_parse_pppconf_find_next_stanza +sub pppconf_find_next_stanza { my ($buff, $line_no) = @_; @@ -1678,12 +1274,12 @@ sub gst_parse_pppconf_find_next_stanza return -1; } -sub gst_parse_pppconf_find_stanza +sub pppconf_find_stanza { my ($buff, $section) = @_; my ($line_no) = 0; - while (($line_no = &gst_parse_pppconf_find_next_stanza ($buff, $line_no)) != -1) + while (($line_no = &pppconf_find_next_stanza ($buff, $line_no)) != -1) { return $line_no if ($$buff[$line_no] =~ /^$section\:/); $line_no++; @@ -1692,12 +1288,12 @@ sub gst_parse_pppconf_find_stanza return -1; } -sub gst_parse_pppconf_common +sub get_pppconf_common { my ($file, $section, $key) = @_; my ($fd, $val); - $fd = &gst_file_open_read_from_names ($file); + $fd = &Utils::File::open_read_from_names ($file); return undef if ($fd eq undef); $val = undef; @@ -1736,12 +1332,12 @@ sub gst_parse_pppconf_common $val .= $_; } - &gst_file_close ($fd); + &Utils::File::close_file ($fd); if ($val eq undef) { return undef if ($section eq "default"); - return &gst_parse_pppconf_common ($file, "default", $key); + return &get_pppconf_common ($file, "default", $key); } else { @@ -1752,12 +1348,12 @@ sub gst_parse_pppconf_common } } -sub gst_parse_pppconf +sub get_pppconf { my ($file, $section, $key) = @_; my ($val); - $val = &gst_parse_pppconf_common ($file, $section, $key); + $val = &get_pppconf_common ($file, $section, $key); if ($val =~ /$key[ \t]+(.+)/) { @@ -1765,23 +1361,23 @@ sub gst_parse_pppconf } } -sub gst_parse_pppconf_bool +sub get_pppconf_bool { my ($file, $section, $key) = @_; my ($val); - $val = &gst_parse_pppconf_common ($file, $section, $key); + $val = &get_pppconf_common ($file, $section, $key); return 1 if ($val ne undef); return 0; } -sub gst_parse_pppconf_re +sub get_pppconf_re { my ($file, $section, $key, $re) = @_; my ($val); - $val = &gst_parse_pppconf_common ($file, $section, $key); + $val = &get_pppconf_common ($file, $section, $key); if ($val =~ /$re/i) { @@ -1789,12 +1385,37 @@ sub gst_parse_pppconf_re } } -sub gst_parse_confd_net +sub get_ppp_options_re +{ + my ($file, $re) = @_; + my ($fd, @res); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_get_ppp_option", &Utils::Replace::regexp_to_separator ($re), $file); + $fd = &Utils::File::open_read_from_names ("$file"); + &Utils::Report::leave (); + + return undef if !$fd; + + while (($_ = &chomp_line_hash_comment ($fd)) != -1) + { + $_ = $$_; + + if (/$re/) + { + return $1; + } + } + + return undef; +} + +sub get_confd_net { my ($file, $key) = @_; my ($str, $contents, $i); - $contents = &gst_file_buffer_load ($file); + $contents = &Utils::File::load_buffer ($file); for ($i = 0; $i <= scalar (@$contents); $i++) { @@ -1814,15 +1435,17 @@ sub gst_parse_confd_net return $str; } -sub gst_parse_confd_net_re +sub get_confd_net_re { my ($file, $key, $re) = @_; my ($str); - $str = &gst_parse_confd_net ($file, $key); + $str = &get_confd_net ($file, $key); if ($str =~ /$re/i) { return $1; } } + +1; diff --git a/platform.pl.in b/Utils/Platform.pm index db0481c..d37c16b 100644 --- a/platform.pl.in +++ b/Utils/Platform.pm @@ -22,82 +22,85 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Utils::Platform; -# --- System guessing --- # +use Utils::XML; +use Utils::Parse; +use Utils::Backend; + +use base qw(Net::DBus::Object); +use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX . ".Platform"); + +my $OBJECT_NAME = "Platform"; +my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME"; + +dbus_method ("getPlatformList", [], [[ "array", [ "struct", "string", "string", "string", "string" ]]]); +dbus_method ("getPlatform", [], [ "string" ]); +dbus_method ("setPlatform", [ "string" ], []); +dbus_signal ("noPlatformDetected", []); +# --- System guessing --- # -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; - - -$PLATFORM_INFO = { - "debian-2.2" => "Debian GNU/Linux 2.2 Potato", - "debian-3.0" => "Debian GNU/Linux 3.0 Woody", - "debian-sarge" => "Debian GNU/Linux Sarge", - "ubuntu-5.04" => "Ubuntu GNU/Linux Hoary", - "ubuntu-5.10" => "Ubuntu GNU/Linux Breezy", - "ubuntu-6.04" => "Ubuntu GNU/Linux Dapper", - "redhat-5.2" => "Red Hat Linux 5.2 Apollo", - "redhat-6.0" => "Red Hat Linux 6.0 Hedwig", - "redhat-6.1" => "Red Hat Linux 6.1 Cartman", - "redhat-6.2" => "Red Hat Linux 6.2 Zoot", - "redhat-7.0" => "Red Hat Linux 7.0 Guinness", - "redhat-7.1" => "Red Hat Linux 7.1 Seawolf", - "redhat-7.2" => "Red Hat Linux 7.2 Enigma", - "redhat-7.3" => "Red Hat Linux 7.3 Valhalla", - "redhat-8.0" => "Red Hat Linux 8.0 Psyche", - "redhat-9" => "Red Hat Linux 9.0 Shrike", - "openna-1.0" => "OpenNA Linux 1.0 VSLC", - "mandrake-7.1" => "Linux Mandrake 7.1", - "mandrake-7.2" => "Linux Mandrake 7.2 Odyssey", - "mandrake-8.0" => "Linux Mandrake 8.0 Traktopel", - "mandrake-9.0" => "Linux Mandrake 9.0 Dolphin", - "mandrake-9.1" => "Linux Mandrake 9.1 Bamboo", - "mandrake-9.2" => "Linux Mandrake 9.2 FiveStar", - "mandrake-10.0" => "Linux Mandrake 10.0", - "mandrake-10.1" => "Linux Mandrake 10.1", - "mandrake-10.2" => "Linux Mandrake 2005 LE", - "mandriva-2006.0" => "Mandriva Linux 2006.0", - "mandriva-2006.1" => "Mandriva Linux 2006.1", - "yoper-2.2" => "Yoper Linux 2.2", - "blackpanther-4.0" => "Black Panther OS 4.0", - "conectiva-9" => "Conectiva Linux 9", - "conectiva-10" => "Conectiva Linux 10", - "suse-7.0" => "SuSE Linux 7.0", - "suse-9.0" => "SuSE Linux 9.0", - "suse-9.1" => "SuSE Linux 9.1", - "turbolinux-7.0" => "Turbolinux 7.0", - "slackware-8.0.0" => "Slackware 8.0.0", - "slackware-8.1" => "Slackware 8.1", - "slackware-9.0.0" => "Slackware 9.0.0", - "slackware-9.1.0" => "Slackware 9.1.0", - "slackware-10.0.0" => "Slackware 10.0.0", - "slackware-10.1.0" => "Slackware 10.1.0", - "slackware-10.2.0" => "Slackware 10.2.0", - "freebsd-4" => "FreeBSD 4", - "freebsd-5" => "FreeBSD 5", - "freebsd-6" => "FreeBSD 6", - "gentoo" => "Gentoo Linux", - "vlos-1.2" => "Vida Linux OS 1.2", - "archlinux" => "Arch Linux", - "pld-1.0" => "PLD 1.0 Ra", - "pld-1.1" => "PLD 1.1 Ra", - "pld-1.99" => "PLD 1.99 Ac-pre", - "vine-3.0" => "Vine Linux 3.0", - "vine-3.1" => "Vine Linux 3.1", - "fedora-1" => "Fedora Core 1 (Yarrow)", - "fedora-2" => "Fedora Core 2 (Tettnang)", - "fedora-3" => "Fedora Core 3 (Heidelberg)", - "fedora-4" => "Fedora Core 4 (Stentz)", - "rpath" => "rPath Linux", - "ark" => "Ark Linux", +my $PLATFORM_INFO = { + "debian-2.2" => [ "Debian GNU/Linux", "2.2", "Potato" ], + "debian-3.0" => [ "Debian GNU/Linux", "3.0", "Woody" ], + "debian-sarge" => [ "Debian GNU/Linux", "3.1", "Sarge" ], + "ubuntu-5.04" => [ "Ubuntu Linux", "5.04", "Hoary" ], + "ubuntu-5.10" => [ "Ubuntu Linux", "5.10", "Breezy" ], + "ubuntu-6.04" => [ "Ubuntu Linux", "6.04", "Dapper" ], + "redhat-5.2" => [ "Red Hat Linux", "5.2", "Apollo" ], + "redhat-6.0" => [ "Red Hat Linux", "6.0", "Hedwig" ], + "redhat-6.1" => [ "Red Hat Linux", "6.1", "Cartman" ], + "redhat-6.2" => [ "Red Hat Linux", "6.2", "Zoot" ], + "redhat-7.0" => [ "Red Hat Linux", "7.0", "Guinness" ], + "redhat-7.1" => [ "Red Hat Linux", "7.1", "Seawolf" ], + "redhat-7.2" => [ "Red Hat Linux", "7.2", "Enigma" ], + "redhat-7.3" => [ "Red Hat Linux", "7.3", "Valhalla" ], + "redhat-8.0" => [ "Red Hat Linux", "8.0", "Psyche" ], + "redhat-9" => [ "Red Hat Linux", "9.0", "Shrike" ], + "openna-1.0" => [ "OpenNA Linux", "1.0", "VSLC" ], + "mandrake-7.1" => [ "Linux Mandrake", "7.1" ], + "mandrake-7.2" => [ "Linux Mandrake", "7.2", "Odyssey" ], + "mandrake-8.0" => [ "Linux Mandrake", "8.0", "Traktopel" ], + "mandrake-9.0" => [ "Linux Mandrake", "9.0", "Dolphin" ], + "mandrake-9.1" => [ "Linux Mandrake", "9.1", "Bamboo" ], + "mandrake-9.2" => [ "Linux Mandrake", "9.2", "FiveStar" ], + "mandrake-10.0" => [ "Linux Mandrake", "10.0" ], + "mandrake-10.1" => [ "Linux Mandrake", "10.1" ], + "mandrake-10.2" => [ "Linux Mandrake", "2005" ], + "mandriva-2006.0" => [ "Mandriva Linux", "2006.0" ], + "mandriva-2006.1" => [ "Mandriva Linux", "2006.1" ], + "yoper-2.2" => [ "Yoper Linux", "2.2" ], + "blackpanther-4.0" => [ "Black Panther OS", "4.0", "" ], + "conectiva-9" => [ "Conectiva Linux", "9", "" ], + "conectiva-10" => [ "Conectiva Linux", "10", "" ], + "suse-9.0" => [ "SuSE Linux", "9.0", "" ], + "suse-9.1" => [ "SuSE Linux", "9.1", "" ], + "turbolinux-7.0" => [ "Turbolinux", "7.0", "" ], + "slackware-8.0.0" => [ "Slackware", "8.0.0", "" ], + "slackware-8.1" => [ "Slackware", "8.1", "" ], + "slackware-9.0.0" => [ "Slackware", "9.0.0", "" ], + "slackware-9.1.0" => [ "Slackware", "9.1.0", "" ], + "slackware-10.0.0" => [ "Slackware", "10.0.0", "" ], + "slackware-10.1.0" => [ "Slackware", "10.1.0", "" ], + "slackware-10.2.0" => [ "Slackware", "10.2.0", "" ], + "freebsd-4" => [ "FreeBSD", "4", "" ], + "freebsd-5" => [ "FreeBSD", "5", "" ], + "freebsd-6" => [ "FreeBSD", "6", "" ], + "gentoo" => [ "Gentoo Linux", "", "" ], + "vlos-1.2" => [ "Vida Linux OS", "1.2" ], + "archlinux" => [ "Arch Linux", "", "" ], + "pld-1.0" => [ "PLD", "1.0", "Ra" ], + "pld-1.1" => [ "PLD", "1.1", "Ra" ], + "pld-1.99" => [ "PLD", "1.99", "Ac-pre" ], + "vine-3.0" => [ "Vine Linux", "3.0", "" ], + "vine-3.1" => [ "Vine Linux", "3.1", "" ], + "fedora-1" => [ "Fedora Core", "1", "Yarrow" ], + "fedora-2" => [ "Fedora Core", "2", "Tettnang" ], + "fedora-3" => [ "Fedora Core", "3", "Heidelberg" ], + "fedora-4" => [ "Fedora Core", "4", "Stentz" ], + "rpath" => [ "rPath Linux", "", "" ], + "ark" => [ "Ark Linux" ] }; sub check_lsb @@ -112,9 +115,8 @@ sub check_lsb ("Conectiva" => "conectiva"), ("Blackpanther" => "blackpanther"); - # gst_prefix not required here: parse already does that for us. - $dist = lc (&gst_parse_sh ("/etc/lsb-release", "DISTRIB_ID")); - $ver = lc (&gst_parse_sh ("/etc/lsb-release", "DISTRIB_RELEASE")); + $dist = lc (&Utils::Parse::get_sh ("/etc/lsb-release", "DISTRIB_ID")); + $ver = lc (&Utils::Parse::get_sh ("/etc/lsb-release", "DISTRIB_RELEASE")); # $ver = $vermap{$ver} if exists $vermap{$ver}; $dist = $distmap{$dist} if exists $dirmap{$dir}; @@ -333,7 +335,7 @@ sub check_rpath close RPATH; return "rpath"; } - if ($ver =~ /Foresight/) + elsif ($ver =~ /Foresight/) { close RPATH; return "rpath"; @@ -419,8 +421,7 @@ sub check_vlos sub check_archlinux { - # Since Arch stores gnome in /opt/gnome, use full dir - return "archlinux" if stat ("/etc/arch-release"); + return "archlinux" if stat ("$gst_prefix/etc/arch-release"); return -1; } @@ -495,7 +496,7 @@ sub check_freebsd { my ($sysctl_cmd, @output); - $sysctl_cmd = &gst_file_locate_tool ("sysctl"); + $sysctl_cmd = &Utils::File::locate_tool ("sysctl"); @output = (readpipe("$sysctl_cmd -n kern.version")); foreach (@output) { @@ -523,145 +524,140 @@ sub check_solaris # Solaris 7: unknown, assume 7.0 # Solaris 8: unknown, assume 8.0 # - $fd = &gst_file_run_pipe_read ("uname -r"); + $fd = &Utils::File::run_pipe_read ("uname -r"); return -1 if $fd eq undef; chomp ($dist = <$fd>); - &gst_file_close ($fd); + &Utils::File::close_file ($fd); if ($dist =~ /^5\.(\d)/) { return "solaris-2.$1" } else { if ($dist =~ /^([78])\.\d/) { return "solaris-$1.0" } } return -1; } -sub gst_platform_get_system +sub get_system { - my ($tool) = @_; - # get the output of 'uname -s', it returns the system we are running - $$tool{"system"} = &gst_file_run_backtick ("uname -s"); - chomp ($$tool{"system"}); + $Utils::Backend::tool{"system"} = &Utils::File::run_backtick ("uname -s"); + chomp ($Utils::Backend::tool{"system"}); +} + +sub set_platform +{ + my ($platform) = @_; + my ($p); + + foreach $p (keys %$PLATFORM_INFO) + { + if ($p eq $platform) + { + $Utils::Backend::tool{"platform"} = $gst_dist = $platform; + &Utils::Report::do_report ("platform_success", $platform); + &Utils::Report::end (); + return; + } + } + + &set_platform_unsupported ($object); + &Utils::Report::do_report ("platform_unsup", $platform); + &Utils::Report::end (); +} + +sub set_platform_unsupported +{ + my ($object) = @_; + + $Utils::Backend::tool{"platform"} = $gst_dist = undef; + #&Net::DBus::Object::emit_signal ($object, "noPlatformDetected"); +} + +sub ensure_platform +{ + my ($platform) = @_; + my ($p); + + foreach $p (keys %$PLATFORM_INFO) + { + return $platform if ($p eq $platform); + } + + return undef; } -sub gst_platform_guess +sub guess { - my ($tool) = @_; + my ($object) = @_; my %check = ( # Red Hat check must run after Vine, Mandrake and Fedora, and Mandrake after BlackPanther - "Linux" => [ \&check_lsb, \&check_debian, \&check_caldera, \&check_suse, \&check_blackpanther, \&check_vine, - \&check_fedora, \&check_mandrake, \&check_mandriva, \&check_conectiva, \&check_linuxppc, \&check_redhat, \&check_openna, - \&check_turbolinux, \&check_slackware, \&check_vlos, \&check_gentoo, \&check_pld, \&check_rpath, \&check_archlinux, \&check_ark ], + "Linux" => [ \&check_lsb, \&check_debian, \&check_caldera, \&check_suse, \&check_blackpanther, \&check_vine, + \&check_fedora, \&check_mandrake, \&check_mandriva, \&check_conectiva, \&check_linuxppc, \&check_redhat, \&check_openna, + \&check_turbolinux, \&check_slackware, \&check_vlos, \&check_gentoo, \&check_pld, \&check_rpath, \&check_archlinux, \&check_ark, \&check_yoper ], "FreeBSD" => [ \&check_freebsd ], "SunOS" => [ \&check_solaris ] ); my $plat; - # Fool-the-backend hack. - if (exists $ENV{"GST_DIST"}) - { - $$tool{"platform"} = $gst_dist = $ENV{"GST_DIST"}; - return; - } - foreach $plat (keys %check) { - if ($$tool{"system"} =~ /$plat/) + if ($Utils::Backend::tool{"system"} =~ /$plat/) { my ($check, $dist); foreach $check (@{$check{$plat}}) { $dist = &$check (); - if ($dist != -1) + if ($dist != -1 && &ensure_platform ($dist)) { - $$tool{"platform"} = $gst_dist = $dist; + $Utils::Backend::tool{"platform"} = $gst_dist = $dist; return; } } } } - $$tool{"platform"} = $gst_dist = "unknown"; + &set_platform_unsupported ($tool, $object); + &Utils::Report::do_report ("platform_unsup", $platform); + &Utils::Report::end (); } - -# gst_platform_ensure_supported -# -# Takes a list of supported platforms and sees if the one detected is found in -# this list. If not, will report a list of supported platforms and fail. - -sub gst_platform_ensure_supported +sub new { - my ($tool, @supported) = @_; + my $class = shift; + my $service = shift; + my $self = $class->SUPER::new ($service, $OBJECT_PATH); - $$tool{"platforms"} = [ @supported ]; + bless $self, $class; + &get_system (); + &guess ($self) if !$Utils::Backend::tool{"platform"}; - foreach $platform (@supported) - { - if ($platform eq $$tool{"platform"}) - { - &gst_report ("platform_success", $platform, $$PLATFORM_INFO{$platform}); - return; - } - } - - # Not supported. - if (exists $$tool{"platform"}) - { - &gst_report ("platform_unsup", $$tool{"platform"}); - } - else - { - &gst_report ("platform_undet"); - } + return $self; } - -# A directive handler that sets the currently selected platform. -sub gst_platform_set +sub getPlatformList { - my ($tool, $platform) = @_; - my ($p); + my ($self) = @_; + my ($arr, $key); - foreach $p (@{ $$tool{"platforms"}}) + foreach $key (keys %$PLATFORM_INFO) { - if ($p eq $platform) - { - $$tool{"platform"} = $gst_dist = $platform; - &gst_report ("platform_success", $platform, $$PLATFORM_INFO{$platform}); - &gst_report_end (); - return; - } + push @$arr, [ $$PLATFORM_INFO{$key}[0], + $$PLATFORM_INFO{$key}[1], + $$PLATFORM_INFO{$key}[2], + $key ]; } - &gst_report ("platform_unsup", $platform); - &gst_report_end (); + return $arr; } -sub gst_platform_print_list +sub getPlatform { - my ($platforms) = @_; - my ($platform, $name); - - &gst_xml_print_begin ("platforms"); - foreach $platform (sort @$platforms) - { - $name = $$PLATFORM_INFO{$platform}; - - &gst_xml_container_enter ("platform"); - &gst_xml_print_line ("<key>$platform</key>"); - &gst_xml_print_line ("<name>$name</name>"); - &gst_xml_container_leave (); - } - &gst_xml_print_end ("platforms"); + return $Utils::Backend::tool{"platform"}; } -sub gst_platform_list +# A directive handler that sets the currently selected platform. +sub setPlatform { - my ($tool) = @_; + my ($self, $platform) = @_; - &gst_report_end (); - &gst_platform_print_list ($$tool{"platforms"}); + &set_platform ($platform); } - -1; diff --git a/replace.pl.in b/Utils/Replace.pm index 79e5cf2..5fa81d1 100644 --- a/replace.pl.in +++ b/Utils/Replace.pm @@ -24,17 +24,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Utils::Replace; -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; +use Utils::Util; +use Utils::File; +use Utils::Parse; # General rules: all replacing is in-line. Respect unsupported values, comments @@ -54,7 +48,7 @@ require "$SCRIPTSDIR/parse.pl$DOTIN"; # # Most of these functions have a parsing counterpart. The convention is # that parse becomes replace and split becomes join: -# gst_parse_split_first_str -> gst_replace_join_first_str +# split_first_str -> join_first_str # Additional abstraction: replace table entries can have # arrays inside. The replace proc will be ran with every @@ -63,7 +57,7 @@ require "$SCRIPTSDIR/parse.pl$DOTIN"; # using all possibilities in the combinatory of [0, 1]x[2, 3]. # Check RedHat 7.2's network replace table for further # enlightenment. -sub gst_replace_run_entry +sub run_entry { my ($values_hash, $key, $proc, $cp, $value) = @_; my ($ncp, $i, $j, $res); @@ -76,7 +70,7 @@ sub gst_replace_run_entry foreach $j (@{$$cp[$i]}) { $$ncp[$i] = $j; - $res = -1 if &gst_replace_run_entry ($values_hash, $key, $proc, $ncp, $value); + $res = -1 if &run_entry ($values_hash, $key, $proc, $ncp, $value); } return $res; } @@ -84,8 +78,7 @@ sub gst_replace_run_entry # OK, the given entry didn't have any array refs in it... - &gst_debug_print_line ("gst_replace_from_table: $key"); - return -1 if (!&gst_parse_replace_hash_values ($ncp, $values_hash)); + return -1 if (!&Utils::Parse::replace_hash_values ($ncp, $values_hash)); push (@$ncp, $$values_hash{$key}) unless $key eq "_always_"; $res = -1 if &$proc (@$ncp); return $res; @@ -102,7 +95,7 @@ sub gst_replace_run_entry # this file, receive the mapped files of the first argument, and then # a set of values. The last argument is the value of the $values_hash # for the corresponding key of the entry. -sub gst_replace_from_table +sub set_from_table { my ($fn, $table, $values_hash, $old_hash) = @_; my ($key, $proc, @param); @@ -116,17 +109,17 @@ sub gst_replace_from_table $key = shift (@cp); $proc = shift (@cp); - @files = &gst_parse_replace_files (shift (@cp), $fn); + @files = &Utils::Parse::replace_files (shift (@cp), $fn); unshift @cp, @files if (scalar @files) > 0; if ((exists $$values_hash{$key}) or ($key eq "_always_")) { - $res = &gst_replace_run_entry ($values_hash, $key, $proc, \@cp, $$values_hash{$key}); + $res = &run_entry ($values_hash, $key, $proc, \@cp, $$values_hash{$key}); } elsif ((!exists $$values_hash{$key}) && (exists $$old_hash{$key})) { # we need to remove all the instances of the known variables that doesn't exist in the XML - $res = &gst_replace_run_entry ($values_hash, $key, $proc, \@cp, undef); + $res = &run_entry ($values_hash, $key, $proc, \@cp, undef); } } @@ -135,7 +128,7 @@ sub gst_replace_from_table # Wacky function that tries to create a field separator from a regular expression. # Doesn't work with all possible regular expressions: just with the ones we are working with. -sub gst_replace_regexp_to_separator +sub regexp_to_separator { $_ = $_[0]; @@ -147,29 +140,17 @@ sub gst_replace_regexp_to_separator return $_; } -sub is_array_ref -{ - my $val; - - return 1 if (ref ($val) eq "ARRAY"); - return 0 if (ref ($val) eq undef); - - &gst_debug_print_line ("is_array_ref: We shouldn't be here!"); - - return 0; -} - sub set_value { my ($key, $val, $re) = @_; - return $key . &gst_replace_regexp_to_separator ($re) . $val; + return $key . ®exp_to_separator ($re) . $val; } # Edit a $file, wich is assumed to have a column-based format, with $re matching field separators # and one record per line. Search for lines with the corresponding $key. # The last arguments can be any number of standard strings. -sub gst_replace_split +sub split { my ($file, $key, $re, @value) = @_; my ($fd, @line, @res); @@ -177,10 +158,10 @@ sub gst_replace_split my ($pre_space, $post_comment); my ($line_key, $val, $ret); - &gst_report_enter (); - &gst_report ("replace_split", $key, $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_split", $key, $file); - $buff = &gst_file_buffer_load ($file); + $buff = &Utils::File::load_buffer ($file); foreach $i (@$buff) { @@ -221,95 +202,95 @@ sub gst_replace_split push (@$buff, &set_value ($key, $i, $re) . "\n") if ($i ne ""); } - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); return $ret; } # Replace all key/values in file with those in @$value, # deleting exceeding ones and appending those required. -sub gst_replace_join_all +sub join_all { my ($file, $key, $re, $value) = @_; - return &gst_replace_split ($file, $key, $re, @$value); + return &split ($file, $key, $re, @$value); } # Find first $key value and replace with $value. Append if not found. -sub gst_replace_join_first_str +sub join_first_str { my ($file, $key, $re, $value) = @_; - return &gst_replace_split ($file, $key, $re, $value); + return &split ($file, $key, $re, $value); } # Treat value as a bool value, using val_off and val_on as corresponding # boolean representations. -sub gst_replace_join_first_bool +sub join_first_bool { my ($file, $key, $re, $val_on, $val_off, $value) = @_; # Fixme: on and off should be a parameter. $value = ($value == 1)? $val_on: $val_off; - return &gst_replace_split ($file, $key, $re, $value); + return &split ($file, $key, $re, $value); } # Find first key in file, and set array join as value. -sub gst_replace_join_first_array +sub join_first_array { my ($file, $key, $re1, $re2, $value) = @_; - return &gst_replace_split ($file, $key, $re1, join (&gst_replace_regexp_to_separator ($re2), @$value)); + return &split ($file, $key, $re1, join (®exp_to_separator ($re2), @$value)); } # Escape $value in /bin/sh way, find/append key and set escaped value. -sub gst_replace_sh +sub set_sh { my ($file, $key, $value) = @_; my $ret; - $value = &gst_parse_shell_escape ($value); + $value = &Utils::Parse::escape ($value); - &gst_report_enter (); - &gst_report ("replace_sh", $key, $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_sh", $key, $file); # This will expunge the whole var if the value is empty. if ($value eq "") { - $ret = &gst_replace_split ($file, $key, "[ \t]*=[ \t]*"); + $ret = &split ($file, $key, "[ \t]*=[ \t]*"); } else { - $ret = &gst_replace_split ($file, $key, "[ \t]*=[ \t]*", $value); + $ret = &split ($file, $key, "[ \t]*=[ \t]*", $value); } - &gst_report_leave (); + &Utils::Report::leave (); return $ret; } # Escape $value in /bin/sh way, find/append key and set escaped value, make sure line har -sub gst_replace_sh_export +sub set_sh_export { my ($file, $key, $value) = @_; my $ret; - $value = &gst_parse_shell_escape ($value); + $value = &Utils::Parse::escape ($value); # This will expunge the whole var if the value is empty. # FIXME: Just adding "export " works for the case I need, though it doesn't - # handle arbitraty whitespace. Something should be written to replace gst_replace_split() + # handle arbitraty whitespace. Something should be written to replace split() # here. if ($value eq "") { - $ret = &gst_replace_split ($file, "export " . $key, "[ \t]*=[ \t]*"); + $ret = &split ($file, "export " . $key, "[ \t]*=[ \t]*"); } else { - $ret = &gst_replace_split ($file, "export " . $key, "[ \t]*=[ \t]*", $value); + $ret = &split ($file, "export " . $key, "[ \t]*=[ \t]*", $value); } return $ret; @@ -317,8 +298,8 @@ sub gst_replace_sh_export # Treat value as a yes/no bool, replace in shell style. # val_true and val_false have default yes/no values. -# use &gst_replace_sh_bool (file, key, value) if defaults are desired. -sub gst_replace_sh_bool +# use &set_sh_bool (file, key, value) if defaults are desired. +sub set_sh_bool { my ($file, $key, $val_true, $val_false, $value) = @_; @@ -334,11 +315,11 @@ sub gst_replace_sh_bool $value = ($value == 1)? $val_true: $val_false; - return &gst_replace_sh ($file, $key, $value); + return &set_sh ($file, $key, $value); } # Treat value as a yes/no bool, replace in export... shell style. -sub gst_replace_sh_export_bool +sub set_sh_export_bool { my ($file, $key, $val_true, $val_false, $value) = @_; @@ -354,48 +335,48 @@ sub gst_replace_sh_export_bool $value = ($value == 1)? $val_true: $val_false; - return &gst_replace_sh_export ($file, $key, $value); + return &set_sh_export ($file, $key, $value); } # Get a fully qualified hostname from a $key shell var in $file # and set the hostname part. e.g.: suse70's /etc/rc.config's FQHOSTNAME. -sub gst_replace_sh_set_hostname +sub set_hostname { my ($file, $key, $value) = @_; my ($domain); - $domain = &gst_parse_sh_get_domain ($file, $key); - return &gst_replace_sh ($file, $key, "$value.$domain"); + $domain = &Utils::Parse::get_sh_domain ($file, $key); + return &set_sh ($file, $key, "$value.$domain"); } # Get a fully qualified hostname from a $key shell var in $file # and set the domain part. e.g.: suse70's /etc/rc.config's FQHOSTNAME. -sub gst_replace_sh_set_domain +sub set_domain { my ($file, $key, $value) = @_; my ($hostname); - $hostname = &gst_parse_sh_get_hostname ($file, $key); - return &gst_replace_sh ($file, $key, "$hostname.$value"); + $hostname = &Utils::Parse::get_sh_hostname ($file, $key); + return &set_sh ($file, $key, "$hostname.$value"); } # Join the array pointed by $value with the corresponding $re separator # and assign that to the $key shell variable in $file. -sub gst_replace_sh_join +sub set_sh_join { my ($file, $key, $re, $value) = @_; - return &gst_replace_sh ($file, $key, - join (&gst_replace_regexp_to_separator ($re), @$value)); + return &set_sh ($file, $key, + join (®exp_to_separator ($re), @$value)); } # replace a regexp with $value -sub gst_replace_sh_re +sub set_sh_re { my ($file, $key, $re, $value) = @_; my ($val); - $val = &gst_parse_sh ($file, $key); + $val = &Utils::Parse::get_sh ($file, $key); if ($val =~ /$re/) { @@ -408,50 +389,50 @@ sub gst_replace_sh_re $val = '"' . $val . '"' if ($val !~ /^\".*\"$/); - return &gst_replace_split ($file, $key, "[ \t]*=[ \t]*", $val) + return &split ($file, $key, "[ \t]*=[ \t]*", $val) } # Quick trick to set a keyword $key in $file. (think /etc/lilo.conf keywords). -sub gst_replace_kw +sub set_kw { my ($file, $key, $value) = @_; my $ret; - &gst_report_enter (); - &gst_report ("replace_kw", $key, $file); - $ret = &gst_replace_split ($file, $key, "\$", ($value)? "\n" : ""); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_kw", $key, $file); + $ret = &split ($file, $key, "\$", ($value)? "\n" : ""); + &Utils::Report::leave (); return $ret; } # The kind of $file whose $value is its first line contents. # (/etc/hostname) -sub gst_replace_line_first +sub set_first_line { my ($file, $value) = @_; my $fd; - &gst_report_enter (); - &gst_report ("replace_line_first", $file); - $fd = &gst_file_open_write_from_names ($file); - &gst_report_leave (); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_line_first", $file); + $fd = &Utils::File::open_write_from_names ($file); + &Utils::Report::leave (); return -1 if !$fd; print $fd "$value\n"; - &gst_file_close ($fd); + &Utils::File::close_file ($fd); return 0; } # For every key in %$value, replace/append the corresponding key/value pair. # The separator for $re1 -sub gst_replace_join_hash +sub join_hash { my ($file, $re1, $re2, $value) = @_; my ($i, $res, $tmp, $val); my ($oldhash, %merge); - $oldhash = &gst_parse_split_hash ($file, $re1, $re2); + $oldhash = &Utils::Parse::split_hash ($file, $re1, $re2); foreach $i (keys (%$value), keys (%$oldhash)) { $merge{$i} = 1; @@ -463,13 +444,13 @@ sub gst_replace_join_hash { if (exists $$value{$i}) { - $val = join (&gst_replace_regexp_to_separator ($re2), @{$$value{$i}}); - $tmp = &gst_replace_split ($file, $i, $re1, $val); + $val = join (®exp_to_separator ($re2), @{$$value{$i}}); + $tmp = &split ($file, $i, $re1, $val); } else { # This deletes the entry. - $tmp = &gst_replace_split ($file, $i, $re1); + $tmp = &split ($file, $i, $re1); } $res = $tmp if !$res; } @@ -479,14 +460,14 @@ sub gst_replace_join_hash # Find $re matching send string and replace parenthesyzed # part of $re with $value. FIXME: apply meeks' more general impl. -sub gst_replace_chat +sub set_chat { my ($file, $re, $value) = @_; my ($buff, $i, $bak, $found, $substr, $ret); - &gst_report_enter (); - &gst_report ("replace_chat", $file); - $buff = &gst_file_buffer_load ($file); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_chat", $file); + $buff = &Utils::File::load_buffer ($file); SCAN: foreach $i (@$buff) { @@ -545,26 +526,26 @@ sub gst_replace_chat $i = $bak . "\n"; } - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); return $ret; } # Find/append $section in ini $file and replace/append # $var = $value pair. FIXME: should reimplement with # interfaces style. This is too large. -sub gst_replace_ini +sub set_ini { my ($file, $section, $var, $value) = @_; my ($buff, $i, $found_flag, $ret); my ($pre_space, $post_comment, $sec_save); - &gst_report_enter (); - &gst_report ("replace_ini", $var, $section, $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_ini", $var, $section, $file); - $buff = &gst_file_buffer_load ($file); + $buff = &Utils::File::load_buffer ($file); - &gst_file_buffer_join_lines ($buff); + &Utils::File::join_buffer_lines ($buff); $found_flag = 0; foreach $i (@$buff) @@ -620,25 +601,25 @@ sub gst_replace_ini push @$buff, "\n[$section]\n" if (!$found_flag); push @$buff, "$var = $value\n" if ($found_flag < 2 && $value ne ""); - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); return $ret; } # Well, removes a $section from an ini type $file. -sub gst_replace_remove_ini_section +sub remove_ini_section { my ($file, $section) = @_; my ($buff, $i, $found_flag, $ret); my ($pre_space, $post_comment, $sec_save); - &gst_report_enter (); - &gst_report ("replace_del_ini_sect", $section, $file); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_del_ini_sect", $section, $file); - $buff = &gst_file_buffer_load ($file); + $buff = &Utils::File::load_buffer ($file); - &gst_file_buffer_join_lines ($buff); + &Utils::File::join_buffer_lines ($buff); $found_flag = 0; foreach $i (@$buff) @@ -680,294 +661,30 @@ sub gst_replace_remove_ini_section } } - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); return $ret; } # Removes a $var in $section of a ini type $file. -sub gst_replace_remove_ini_var +sub remove_ini_var { my ($file, $section, $var) = @_; - &gst_replace_ini ($file, $section, $var, ""); + &set_ini ($file, $section, $var, ""); } # Replace using boolean $value with a yes/no representation, # ini style. -sub gst_replace_ini_bool +sub set_ini_bool { my ($file, $section, $var, $value) = @_; $value = ($value == 1)? "yes": "no"; - return &gst_replace_ini ($file, $section, $var, $value); -} - -# *cap replacement methods. -#sub gst_replace_cap -#{ -# my ($file, $section, $var, $value) = @_; -# my ($buff, $i, $found_flag, $ret); -# my ($pre_space, $post_comment, $sec_save); -# -# $buff = &gst_file_buffer_load ($file); -## &gst_file_buffer_join_lines ($buff); -# $found_flag = 0; -# -# foreach $i (@$buff) -# { -# $pre_space = $post_comment = ""; -# -# chomp $i; -# $pre_space = $1 if $i =~ s/^([ \t]+)//; -# $post_comment = $1 if $i =~ s/^([ \t]*[\#].*)//; -# -# if ($i ne "") -# { -# if ($i =~ /^$section[|:]/i) -# { -# $i =~ s/^($section)//i; -# $sec_save = $1; -# $found_flag = 1; -# } -# -# if ($found_flag) -# { -# if ($i =~ /^[a-z0-9]+[|:]/) -# { -# $i = "\t:$var=$value:\n$i"; -# $found_flag = 2; -# } -# -# if ($found_flag && $i =~ /^:$var[=:]/i) -# { -# if ($value ne "") -# { -# $i =~ s/^(:$var)[^:]*/$1=$value/i; -# } -# else -# { -# $i = ""; -# } -# $found_flag = 2; -# } -# } -# } -# -# if ($found_flag && $sec_save ne "") -# { -# $i = $sec_save . $i; -# $sec_save = ""; -# } -# -# $i = $pre_space . $i . $post_comment . "\n"; -# last if $found_flag == 2; -# } -# -# push @$buff, "\n$section:\\\n" if (!$found_flag); -# push @$buff, "\t:$var=$value:\n" if ($found_flag < 2 && $value ne ""); -# -# &gst_file_buffer_clean ($buff); -# $ret = &gst_file_buffer_save ($buff, $file); -# return $ret; -#} - -sub gst_replace_remove_cap_section -{ - my ($file, $section) = @_; - my ($buff, $i, $found_flag, $ret); - my ($pre_space, $post_comment, $sec_save); - - $buff = &gst_file_buffer_load ($file); - $found_flag = 0; - - foreach $i (@$buff) - { - $pre_space = $post_comment = ""; - - chomp $i; - $pre_space = $1 if $i =~ s/^([ \t]+)//; - $post_comment = $1 if $i =~ s/^([ \t]*[\#].*)//; - - if ($i ne "") - { - if ($i =~ /^$section[|:]/i) - { - $i = ""; - $found_flag = 1; - } - elsif ($found_flag && $i =~ /^[a-z0-9]+[|:]/i) - { - $i = $pre_space . $i . $post_comment . "\n"; - last; - } - } - - if ($found_flag) - { - if ($post_comment =~ /^[ \t]*$/) - { - $i = ""; - } - else - { - $i = $post_comment . "\n"; - } - } - else - { - $i = $pre_space . $i . $post_comment . "\n"; - } - } - - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - return $ret; -} - -# Save a printcap buffer to file. This doesn't do any extra processing for now, -# but it may do so in the future. -sub gst_replace_printcap_buffer_save -{ - my ($file, $buf) = @_; - my $ret; - - &gst_file_buffer_clean ($buf); - $ret = &gst_file_buffer_save ($buf, $file); - return $ret; -} - -sub gst_replace_printcap_print_stanza -{ - my ($stanza) = @_; - return $stanza . ":\n"; -} - -sub gst_replace_printcap_print_option -{ - my ($option, $type, $value) = @_; - return "\t:" . $option . $type . $value . ":\n"; -} - -sub gst_replace_printcap_add_stanza -{ - my ($buf, $stanza) = @_; - - push @$buf, "\n"; - push @$buf, "##PRINTTOOL3## LOCAL unknown NAxNA {} Unknown Default {}\n"; - push @$buf, &gst_replace_printcap_print_stanza ($stanza); - - return ($#$buf - 1, $#$buf); -} - -sub gst_replace_printcap_add_option_slot -{ - my ($buf, $stanza_line_no) = @_; - my (@buf_tail); - - @buf_tail = splice (@$buf, $stanza_line_no + 1); - push @$buf, "\t:NEW_OPTION:\n"; - push @$buf, @buf_tail; - - return $stanza_line_no + 1; + return &set_ini ($file, $section, $var, $value); } -sub gst_replace_printcap_remove_stanza_from_buf -{ - my ($buf, $printtool_line_no, $stanza_line_no) = @_; - my ($next_printtool_line_no, $next_stanza_line_no); - my ($splice_start, $splice_end); - - ($next_printtool_line_no, $next_stanza_line_no) = - &gst_parse_printcap_get_next_stanza ($buf, $stanza_line_no + 1); - - if ($printtool_line_no != -1) - { - $splice_start = $printtool_line_no; - } - else - { - $splice_start = $stanza_line_no; - } - - if ($next_printtool_line_no != -1) - { - $splice_end = $next_printtool_line_no; - } - else - { - $splice_end = $next_stanza_line_no; - } - - if ($splice_end != -1) - { - splice (@$buf, $splice_start, $splice_end - $splice_start); - } - else - { - splice (@$buf, $splice_start); - } -} - -sub gst_replace_printcap_remove_option_slot -{ - my ($buf, $option_line_no) = @_; - splice (@$buf, $option_line_no, 1); -} - -# High-level API. -sub gst_replace_printcap_remove_printer -{ - my ($file, $printer) = @_; - my ($buf, $printtool_line_no, $stanza_line_no); - - $buf = &gst_parse_printcap_buffer_load ($file); - - ($printtool_line_no, $stanza_line_no) = &gst_parse_printcap_find_stanza ($buf, 0, $printer); - &gst_replace_printcap_remove_stanza_from_buf ($buf, $printtool_line_no, $stanza_line_no); - - $ret = &gst_replace_printcap_buffer_save ($file, $buf); - return $ret; -} - -# High-level API. -sub gst_replace_printcap -{ - my ($file, $section, $var, $type, $value) = @_; - my ($printtool_line_no, $stanza_line_no, $option_line_no); - my ($buf, $ret); - - $buf = &gst_parse_printcap_buffer_load ($file); - - ($printtool_line_no, $stanza_line_no) = &gst_parse_printcap_find_stanza ($buf, 0, $section); - if ($stanza_line_no == -1) - { - ($printtool_line_no, $stanza_line_no) = &gst_replace_printcap_add_stanza ($buf, $section); - } - - $option_line_no = &gst_parse_printcap_find_option ($buf, $stanza_line_no + 1, $var); - if ($option_line_no == -1) - { - $option_line_no = &gst_replace_printcap_add_option_slot ($buf, $stanza_line_no); - } - - if ($type ne "") - { - $$buf [$option_line_no] = "\t:" . $var . $type . $value . ":\n"; - } - elsif ($value == 1) - { - $$buf [$option_line_no] = "\t:" . $var . ":\n"; - } - else - { - &gst_replace_printcap_remove_option_slot ($buf, $option_line_no); - } - - $ret = &gst_replace_printcap_buffer_save ($file, $buf); - return $ret; -} # Debian /etc/network/interfaces in-line replacing methods. @@ -975,7 +692,7 @@ sub gst_replace_printcap # interfaces format stanza. Return array ref with all stanza args. # -1 if not found. # NOTE: $line_no is a scalar ref. and gives the position of next stanza. -sub gst_replace_interfaces_get_next_stanza +sub interfaces_get_next_stanza { my ($buff, $line_no, $stanza_type) = @_; my ($i, $line); @@ -983,7 +700,7 @@ sub gst_replace_interfaces_get_next_stanza while ($$line_no < (scalar @$buff)) { $_ = $$buff[$$line_no]; - $_ = &gst_parse_interfaces_line_clean ($_); + $_ = &Utils::Parse::interfaces_line_clean ($_); if (/^$stanza_type[ \t]+[^ \t]/) { @@ -996,7 +713,7 @@ sub gst_replace_interfaces_get_next_stanza return -1; } -sub gst_replace_interfaces_line_is_stanza +sub interfaces_line_is_stanza { my ($line) = @_; @@ -1007,7 +724,7 @@ sub gst_replace_interfaces_line_is_stanza # Scan for next option. An option is something that is # not a stanza. Return key/value tuple ref, -1 if not found. # $$line_no will contain position. -sub gst_replace_interfaces_get_next_option +sub interfaces_get_next_option { my ($buff, $line_no) = @_; my ($i, $line, $empty_lines); @@ -1017,11 +734,11 @@ sub gst_replace_interfaces_get_next_option while ($$line_no < (scalar @$buff)) { $_ = $$buff[$$line_no]; - $_ = &gst_parse_interfaces_line_clean ($_); + $_ = &Utils::Parse::interfaces_line_clean ($_); if (!/^$/) { - return [ split ("[ \t]+", $_, 2) ] if (! &gst_replace_interfaces_line_is_stanza ($_)); + return [ split ("[ \t]+", $_, 2) ] if (! &interfaces_line_is_stanza ($_)); $$line_no -= $empty_lines; return -1; } @@ -1040,12 +757,12 @@ sub gst_replace_interfaces_get_next_option # Search buffer for option with key $key, starting # at $$line_no position. Return 1/0 found result. # $$line_no will show position. -sub gst_replace_interfaces_option_locate +sub interfaces_option_locate { my ($buff, $line_no, $key) = @_; my $option; - while (($option = &gst_replace_interfaces_get_next_option ($buff, $line_no)) != -1) + while (($option = &interfaces_get_next_option ($buff, $line_no)) != -1) { return 1 if ($$option[0] eq $key); $$line_no ++; @@ -1055,33 +772,33 @@ sub gst_replace_interfaces_option_locate } # Locate stanza line for $iface in $buff, starting at $$line_no. -sub gst_replace_interfaces_next_stanza_locate +sub interfaces_next_stanza_locate { my ($buff, $line_no) = @_; - return &gst_replace_interfaces_get_next_stanza ($buff, \$$line_no, "(iface|auto|mapping)"); + return &interfaces_get_next_stanza ($buff, \$$line_no, "(iface|auto|mapping)"); } -sub gst_replace_interfaces_iface_stanza_locate +sub interfaces_iface_stanza_locate { my ($buff, $line_no, $iface) = @_; - return &gst_replace_interfaces_generic_stanza_locate ($buff, \$$line_no, $iface, "iface"); + return &interfaces_generic_stanza_locate ($buff, \$$line_no, $iface, "iface"); } -sub gst_replace_interfaces_auto_stanza_locate +sub interfaces_auto_stanza_locate { my ($buff, $line_no, $iface) = @_; - return &gst_replace_interfaces_generic_stanza_locate ($buff, \$$line_no, $iface, "auto"); + return &interfaces_generic_stanza_locate ($buff, \$$line_no, $iface, "auto"); } -sub gst_replace_interfaces_generic_stanza_locate +sub interfaces_generic_stanza_locate { my ($buff, $line_no, $iface, $stanza_name) = @_; my $stanza; - while (($stanza = &gst_replace_interfaces_get_next_stanza ($buff, \$$line_no, $stanza_name)) != -1) + while (($stanza = &interfaces_get_next_stanza ($buff, \$$line_no, $stanza_name)) != -1) { return 1 if ($$stanza[0] eq $iface); $$line_no++; @@ -1092,7 +809,7 @@ sub gst_replace_interfaces_generic_stanza_locate # Create a Debian Woody stanza, type auto, with the requested # @ifaces as values. -sub gst_replace_interfaces_auto_stanza_create +sub interfaces_auto_stanza_create { my ($buff, @ifaces) = @_; my ($count); @@ -1102,7 +819,7 @@ sub gst_replace_interfaces_auto_stanza_create } # Append a stanza for $iface to buffer. -sub gst_replace_interfaces_iface_stanza_create +sub interfaces_iface_stanza_create { my ($buff, $iface) = @_; my ($count); @@ -1113,18 +830,18 @@ sub gst_replace_interfaces_iface_stanza_create } # Delete $iface stanza and all its option lines. -sub gst_replace_interfaces_iface_stanza_delete +sub interfaces_iface_stanza_delete { my ($file, $iface) = @_; my ($buff, $line_no, $line_end, $stanza); - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); $line_no = 0; - return -1 if (!&gst_replace_interfaces_iface_stanza_locate ($buff, \$line_no, $iface)); + return -1 if (!&interfaces_iface_stanza_locate ($buff, \$line_no, $iface)); $line_end = $line_no + 1; - &gst_replace_interfaces_next_stanza_locate ($buff, \$line_end); + &interfaces_next_stanza_locate ($buff, \$line_end); while ($line_no < $line_end) { @@ -1133,10 +850,10 @@ sub gst_replace_interfaces_iface_stanza_delete } $line_no = 0; - if (&gst_replace_interfaces_auto_stanza_locate ($buff, \$line_no, $iface)) + if (&interfaces_auto_stanza_locate ($buff, \$line_no, $iface)) { $line_end = $line_no + 1; - &gst_replace_interfaces_next_stanza_locate ($buff, \$line_end); + &interfaces_next_stanza_locate ($buff, \$line_end); while ($line_no < $line_end) { @@ -1145,26 +862,26 @@ sub gst_replace_interfaces_iface_stanza_delete } } - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); + &Utils::File::clean_buffer ($buff); + return &Utils::File::save_buffer ($buff, $file); } # Find $iface stanza line and replace $pos value (ie the method). -sub gst_replace_interfaces_stanza_value +sub set_interfaces_stanza_value { my ($file, $iface, $pos, $value) = @_; my ($buff, $line_no, $stanza); my ($pre_space, $line, $line_arr); - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); $line_no = 0; - if (!&gst_replace_interfaces_iface_stanza_locate ($buff, \$line_no, $iface)) + if (!&interfaces_iface_stanza_locate ($buff, \$line_no, $iface)) { $line_no = 0; - &gst_replace_interfaces_iface_stanza_create ($buff, $iface); - &gst_replace_interfaces_iface_stanza_locate ($buff, \$line_no, $iface); + &interfaces_iface_stanza_create ($buff, $iface); + &interfaces_iface_stanza_locate ($buff, \$line_no, $iface); } $line = $$buff[$line_no]; @@ -1175,34 +892,34 @@ sub gst_replace_interfaces_stanza_value $line_arr[$pos] = $value; $$buff[$line_no] = $pre_space . "iface " . join (' ', @line_arr) . "\n"; - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); + &Utils::File::clean_buffer ($buff); + return &Utils::File::save_buffer ($buff, $file); } # Find/append $key option in $iface stanza and set $value. -sub gst_replace_interfaces_option_str +sub set_interfaces_option_str { my ($file, $iface, $key, $value) = @_; my ($buff, $line_no, $stanza, $ret); my ($pre_space, $line, $line_arr); - &gst_report_enter (); - &gst_report ("replace_ifaces_str", $key, $iface); + &Utils::Report::enter (); + &Utils::Report::do_report ("replace_ifaces_str", $key, $iface); - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); + $buff = &Utils::File::load_buffer ($file); + &Utils::File::join_buffer_lines ($buff); $line_no = 0; - if (!&gst_replace_interfaces_iface_stanza_locate ($buff, \$line_no, $iface)) + if (!&interfaces_iface_stanza_locate ($buff, \$line_no, $iface)) { $line_no = 0; - &gst_replace_interfaces_iface_stanza_create ($buff, $iface); - &gst_replace_interfaces_iface_stanza_locate ($buff, \$line_no, $iface); + &interfaces_iface_stanza_create ($buff, $iface); + &interfaces_iface_stanza_locate ($buff, \$line_no, $iface); } $line_no++; - if (&gst_replace_interfaces_option_locate ($buff, \$line_no, $key)) + if (&interfaces_option_locate ($buff, \$line_no, $key)) { if ($value eq "") # Delete option if value is empty. { @@ -1223,26 +940,26 @@ sub gst_replace_interfaces_option_str $$buff[$line_no] .= $value . "\n" if $value ne ""; - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); return $ret; } # $key option is keyword. $value says if it should exist or not. -sub gst_replace_interfaces_option_kw +sub set_interfaces_option_kw { my ($file, $iface, $key, $value) = @_; - return &gst_replace_interfaces_option_str ($file, $iface, $key, $value? " ": ""); + return &set_interfaces_option_str ($file, $iface, $key, $value? " ": ""); } # !$value says if keyword should exist or not (ie noauto). -sub gst_replace_interfaces_option_kw_not +sub set_interfaces_option_kw_not { my ($file, $iface, $key, $value) = @_; - return &gst_replace_interfaces_option_kw ($file, $iface, $key, !$value); + return &set_interfaces_option_kw ($file, $iface, $key, !$value); } @@ -1252,14 +969,14 @@ sub gst_replace_interfaces_option_kw_not # Try to find the next option, returning an array ref # with the found key and the rest of the options in # two items, or -1 if not found. -sub gst_replace_pump_get_next_option +sub pump_get_next_option { my ($buff, $line_no) = @_; while ($$line_no < (scalar @$buff)) { $_ = $$buff[$$line_no]; - $_ = &gst_parse_interfaces_line_clean ($_); + $_ = &Utils::Parse::interfaces_line_clean ($_); if ($_ ne "") { return [ split ("[ \t]+", $_, 2) ]; @@ -1274,12 +991,12 @@ sub gst_replace_pump_get_next_option # Iterate with get_next_option, starting at $line_no # until the option with $key is found, or eof. # Return 0/1 as found. -sub gst_replace_pump_option_locate +sub pump_option_locate { my ($buff, $line_no, $key) = @_; my ($opt); - while (($opt = &gst_replace_pump_get_next_option ($buff, $line_no)) != -1) + while (($opt = &pump_get_next_option ($buff, $line_no)) != -1) { return 1 if $$opt[0] eq $key; return 0 if $$opt[0] eq "}"; @@ -1292,12 +1009,12 @@ sub gst_replace_pump_option_locate # Try to find a "device" option whose interface is $iface, # starting at $$line_no. Return 0/1 as found. -sub gst_replace_pump_get_device +sub pump_get_device { my ($buff, $line_no, $iface) = @_; my ($opt); - while (($opt = &gst_replace_pump_get_next_option ($buff, $line_no)) != -1) + while (($opt = &pump_get_next_option ($buff, $line_no)) != -1) { if ($$opt[0] eq "device") { @@ -1312,7 +1029,7 @@ sub gst_replace_pump_get_device } # Add a device entry for $iface at the end of $buff. -sub gst_replace_pump_add_device +sub pump_add_device { my ($buff, $iface) = @_; @@ -1324,24 +1041,24 @@ sub gst_replace_pump_add_device # Find a "device" section for $iface and # replace/add/delete the $key option inside the section. -sub gst_replace_pump_iface_option_str +sub set_pump_iface_option_str { my ($file, $iface, $key, $value) = @_; my ($line_no, $ret); - $buff = &gst_file_buffer_load ($file); + $buff = &Utils::File::load_buffer ($file); $line_no = 0; - if (!&gst_replace_pump_get_device ($buff, \$line_no, $iface)) + if (!&pump_get_device ($buff, \$line_no, $iface)) { $line_no = 0; - &gst_replace_pump_add_device ($buff, $iface); - &gst_replace_pump_get_device ($buff, \$line_no, $iface); + &pump_add_device ($buff, $iface); + &pump_get_device ($buff, \$line_no, $iface); } $line_no ++; - if (&gst_replace_pump_option_locate ($buff, \$line_no, $key)) + if (&pump_option_locate ($buff, \$line_no, $key)) { if ($value eq "") { @@ -1364,228 +1081,100 @@ sub gst_replace_pump_iface_option_str { $value =~ s/^[ \t]+//; $value =~ s/[ \t]+$//; - $$buff[$line_no] .= &gst_parse_shell_escape ($value) . "\n"; + $$buff[$line_no] .= &Utils::Parse::escape ($value) . "\n"; } - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); return $ret; } # Same as function above, except $key is a keyword. -sub gst_replace_pump_iface_kw +sub set_pump_iface_kw { my ($file, $iface, $key, $value) = @_; - return &gst_replace_pump_iface_option_str ($file, $iface, $key, $value? " ": ""); + return &set_pump_iface_option_str ($file, $iface, $key, $value? " ": ""); } # Same, but use the negative of $value (i.e. nodns) -sub gst_replace_pump_iface_kw_not +sub set_pump_iface_kw_not { my ($file, $iface, $key, $value) = @_; - return &gst_replace_pump_iface_kw ($file, $iface, $key, !$value); + return &set_pump_iface_kw ($file, $iface, $key, !$value); } -sub gst_replace_xml_pcdata +sub set_xml_pcdata { my ($file, $varpath, $data) = @_; my ($model, $branch, $fd, $compressed); - ($model, $compressed) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_ensure ($model, $varpath); + ($model, $compressed) = &Utils::XML::model_scan ($file); + $branch = &Utils::XML::model_ensure ($model, $varpath); - &gst_xml_model_set_pcdata ($branch, $data); + &Utils::XML::model_set_pcdata ($branch, $data); - return &gst_xml_model_save ($model, $file, $compressed); + return &Utils::XML::model_save ($model, $file, $compressed); } -sub gst_replace_xml_attribute +sub set_xml_attribute { my ($file, $varpath, $attr, $value) = @_; my ($model, $branch, $fd, $compressed); - ($model, $compressed) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_ensure ($model, $varpath); + ($model, $compressed) = &Utils::XML::model_scan ($file); + $branch = &Utils::XML::model_ensure ($model, $varpath); - &gst_xml_model_set_attribute ($branch, $attr, $value); + &Utils::XML::model_set_attribute ($branch, $attr, $value); - return &gst_xml_model_save ($model, $file, $compressed); + return &Utils::XML::model_save ($model, $file, $compressed); } -sub gst_replace_xml_pcdata_with_type +sub set_xml_pcdata_with_type { my ($file, $varpath, $type, $data) = @_; my ($model, $branch, $fd, $compressed); - ($model, $compressed) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_ensure ($model, $varpath); + ($model, $compressed) = &Utils::XML::model_scan ($file); + $branch = &Utils::XML::model_ensure ($model, $varpath); - &gst_xml_model_set_pcdata ($branch, $data); - &gst_xml_model_set_attribute ($branch, "TYPE", $type); + &Utils::XML::model_set_pcdata ($branch, $data); + &Utils::XML::model_set_attribute ($branch, "TYPE", $type); - return &gst_xml_model_save ($model, $file, $compressed); + return &Utils::XML::model_save ($model, $file, $compressed); } -sub gst_replace_xml_attribute_with_type +sub set_xml_attribute_with_type { my ($file, $varpath, $attr, $type, $value) = @_; my ($model, $branch, $fd, $compressed); - ($model, $compressed) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_ensure ($model, $varpath); - - &gst_xml_model_set_attribute ($branch, $attr, $value); - &gst_xml_model_set_attribute ($branch, "TYPE", $type); + ($model, $compressed) = &Utils::XML::model_scan ($file); + $branch = &Utils::XML::model_ensure ($model, $varpath); - return &gst_xml_model_save ($model, $file, $compressed); -} - -sub gst_replace_alchemist_ensure_list_types -{ - my ($model, $varpath, $setpath) = @_; - my ($branch, @path); - - $branch = &gst_xml_model_find ($model, $varpath); - @path = split /\//, $setpath; - - # NOTE: The following could be done with a depth-iterator callback from a func - # similar to gst_xml_model_find (). - - for $elem (@path) - { - next if ($elem eq ""); - my @children = @$branch; - shift @children; # Attributes - $branch = undef; - - while (@children) - { - if ($children [0] eq $elem) - { - shift @children; - $branch = shift @children; - &gst_xml_model_set_attribute ($branch, "TYPE", "LIST"); - last; - } - - shift @children; - shift @children; - } + &Utils::XML::model_set_attribute ($branch, $attr, $value); + &Utils::XML::model_set_attribute ($branch, "TYPE", $type); - last if ($branch == undef); - } -} - -sub gst_replace_alchemist -{ - my ($file, $varpath, $type, $value) = @_; - my ($fullpath, $model, $branch, $fd, $compressed); - - $fullpath = "/adm_context/datatree/" . $varpath; - ($model, $compressed) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_ensure ($model, $fullpath); - &gst_replace_alchemist_ensure_list_types ($model, "/adm_context/datatree/", $varpath); - - &gst_xml_model_set_attribute ($branch, "VALUE", $value); - &gst_xml_model_set_attribute ($branch, "TYPE", $type); - - return &gst_xml_model_save ($model, $file, $compressed); + return &Utils::XML::model_save ($model, $file, $compressed); } -sub gst_replace_alchemist_print -{ - my ($file, $printer, $varpath, $type, $value) = @_; - my ($fullpath, $model, $branch, $fd, $compressed); - - $fullpath = "/adm_context/datatree/printconf/print_queues/" . $printer . "/" . $varpath; - ($model, $compressed) = &gst_xml_model_scan ($file); - - $branch = &gst_xml_model_ensure ($model, $fullpath); - - &gst_replace_alchemist_ensure_list_types ($model, "/adm_context/datatree/", - "printconf/print_queues/" . $printer . "/" . $varpath); - - &gst_xml_model_set_attribute ($branch, "VALUE", $value); - &gst_xml_model_set_attribute ($branch, "TYPE", $type); - - $branch = &gst_xml_model_find ($model, "/adm_context/datatree/printconf/print_queues/" . $printer); - &gst_xml_model_set_attribute ($branch, "ATOMIC", "TRUE"); - - return &gst_xml_model_save ($model, $file, $compressed); -} - -# This could be split up. -sub gst_replace_alchemist_print_option -{ - my ($file, $printer, $name, $type, $value) = @_; - my ($varpath, $model, $branch, $fd, $compressed, $options, $option); - - ($model, $compressed) = &gst_xml_model_scan ($file); - $branch = &gst_xml_model_ensure ($model, "/adm_context/datatree/printconf/print_queues/" . $printer . - "/filter_data/foomatic_defaults"); - &gst_replace_alchemist_ensure_list_types ($model, "/adm_context/datatree/", "printconf/print_queues/" . - $printer . "/filter_data/foomatic_defaults"); - &gst_xml_model_set_attribute ($branch, "ANONYMOUS", "TRUE"); - - # See if option is already defined. - - $options = &gst_xml_model_get_children ($branch); - - foreach $o (@$options) - { - my $opt_node = &gst_xml_model_find ($o, "name"); - next if (!$opt_node); - - if (&gst_xml_model_get_attribute ($opt_node, "VALUE") eq $name) - { - $option = $o; - last; - } - } - - # If not, create node for it. - - if (!$option) - { - $option = &gst_xml_model_add ($branch, "", $option_default); - &gst_xml_model_set_attribute ($option, "TYPE", "LIST"); - } - - # Set the option attributes. - - my $node = &gst_xml_model_ensure ($option, "name"); - &gst_xml_model_set_attribute ($node, "TYPE", "STRING"); - &gst_xml_model_set_attribute ($node, "VALUE", $name); - - $node = &gst_xml_model_ensure ($option, "type"); - &gst_xml_model_set_attribute ($node, "TYPE", "STRING"); - &gst_xml_model_set_attribute ($node, "VALUE", $type); - - $node = &gst_xml_model_ensure ($option, "default"); - &gst_xml_model_set_attribute ($node, "TYPE", "STRING"); - &gst_xml_model_set_attribute ($node, "VALUE", $value); - - return &gst_xml_model_save ($model, $file, $compressed); -} - -sub gst_replace_fq_hostname +sub set_fq_hostname { my ($file, $hostname, $domain) = @_; if ($domain eq undef) { - return &gst_replace_line_first ($file, "$hostname"); + return &set_first_line ($file, "$hostname"); } else { - return &gst_replace_line_first ($file, "$hostname.$domain"); + return &set_first_line ($file, "$hostname.$domain"); } } -sub gst_replace_rcinet1conf +sub set_rcinet1conf { my ($file, $iface, $kw, $val) = @_; my ($line); @@ -1595,19 +1184,19 @@ sub gst_replace_rcinet1conf $val = "\"$val\"" if ($val ne undef); - return &gst_replace_split ($file, $line, "[ \t]*=[ \t]*", $val); + return &split ($file, $line, "[ \t]*=[ \t]*", $val); } -sub gst_replace_rcinet1conf_global +sub set_rcinet1conf_global { my ($file, $kw, $val) = @_; $val = "\"$val\""; - return &gst_replace_split ($file, $kw, "[ \t]*=[ \t]*", $val) + return &split ($file, $kw, "[ \t]*=[ \t]*", $val) } -sub gst_replace_wireless_opts +sub set_wireless_opts { my ($file, $iface, $proc, $kw, $value) = @_; my $ifaces = &$proc (); @@ -1620,7 +1209,7 @@ sub gst_replace_wireless_opts $found = 1 if ($iface eq $i); } - $buff = &gst_file_buffer_load ($file); + $buff = &Utils::File::load_buffer ($file); foreach $i (@$buff) { @@ -1646,26 +1235,26 @@ sub gst_replace_wireless_opts push @$buff, "$kw=\"$value\""; } - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); + &Utils::File::clean_buffer ($buff); + return &Utils::File::save_buffer ($buff, $file); } # Functions for replacing in FreeBSD's /etc/ppp/ppp.conf -sub gst_replace_pppconf_common +sub set_pppconf_common { my ($pppconf, $section, $key, $string) = @_; my ($buff, $line_no, $end_line_no, $i, $found); - $buff = &gst_file_buffer_load ($pppconf); + $buff = &Utils::File::load_buffer ($pppconf); - $line_no = &gst_parse_pppconf_find_stanza ($buff, $section); + $line_no = &Utils::Parse::pppconf_find_stanza ($buff, $section); if ($line_no ne -1) { # The stanza exists $line_no++; - $end_line_no = &gst_parse_pppconf_find_next_stanza ($buff, $line_no); + $end_line_no = &Utils::Parse::pppconf_find_next_stanza ($buff, $line_no); $end_line_no = scalar @$buff + 1 if ($end_line_no == -1); $end_line_no--; @@ -1699,30 +1288,78 @@ sub gst_replace_pppconf_common } } - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $pppconf); + &Utils::File::clean_buffer ($buff); + return &Utils::File::save_buffer ($buff, $pppconf); } -sub gst_replace_pppconf +sub set_pppconf { my ($pppconf, $section, $key, $value) = @_; - &gst_replace_pppconf_common ($pppconf, $section, $key, "set $key $value"); + &set_pppconf_common ($pppconf, $section, $key, "set $key $value"); } -sub gst_replace_pppconf_bool +sub set_pppconf_bool { my ($pppconf, $section, $key, $value) = @_; - &gst_replace_pppconf_common ($pppconf, $section, $key, - ($value == 1)? "enable $key" : "disable $key"); + &set_pppconf_common ($pppconf, $section, $key, + ($value == 1)? "enable $key" : "disable $key"); } -sub gst_replace_confd_net_re +sub set_ppp_options_re +{ + my ($file, $re, $value) = @_; + my ($buff, $line, $replaced, $ret); + my ($pre_space, $post_comment); + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_set_ppp_option", &Utils::Replace::regexp_to_separator ($re), $file); + + $buff = &Utils::File::load_buffer ($file); + + foreach $line (@$buff) + { + $pre_space = $post_comment = ""; + chomp $line; + $pre_space = $1 if $line =~ s/^([ \t]+)//; + $post_comment = $1 if $line =~ s/([ \t]*\#.*)//; + + if ($line =~ /$re/) + { + $line = "$value\n"; + $replaced = 1; + last; + } + + $line = $pre_space . $line . $post_comment . "\n"; + } + + push @$buff, "$value\n" if !$replaced; + + &Utils::File::clean_buffer ($buff); + $ret = &Utils::File::save_buffer ($buff, $file); + &Utils::Report::leave (); + return $ret; +} + +sub set_ppp_options_connect +{ + my ($file, $value) = @_; + my $ret; + + &Utils::Report::enter (); + &Utils::Report::do_report ("network_set_ppp_connect", $file); + $ret = &set_ppp_options_re ($file, "^connect", "connect \"/usr/sbin/chat -v -f $value\""); + &Utils::Report::leave (); + return $ret; +} + +sub set_confd_net_re { my ($file, $key, $re, $value) = @_; my ($str, $contents, $i, $found, $done); $found = $done = 0; - $contents = &gst_file_buffer_load ($file); + $contents = &Utils::File::load_buffer ($file); for ($i = 0; $i <= scalar (@$contents); $i++) { @@ -1759,12 +1396,15 @@ sub gst_replace_confd_net_re push @$contents, "$key=(\"$value\")\n"; } - return &gst_file_buffer_save ($contents, $file); + return &Utils::File::save_buffer ($contents, $file); } -sub gst_replace_confd_net +sub set_confd_net { my ($file, $key, $value) = @_; - return &gst_replace_confd_net_re ($file, $key, ".*", $value); + return &set_confd_net_re ($file, $key, ".*", $value); } + + +1; diff --git a/report.pl.in b/Utils/Report.pm index a1c23d3..a2df640 100644 --- a/report.pl.in +++ b/Utils/Report.pm @@ -21,90 +21,37 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +# --- Report printing --- # -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; - -# --- Progress printing --- # - - -$gst_progress_current = 0; # Compat with old $progress_max use. -$gst_progress_last_percentage = 0; - - -sub gst_progress -{ - my $prc = $_[0]; - - # /* Don't go backwards. */ - $prc = $gst_progress_last_percentage if ($prc < $gst_progress_last_percentage); - - # /* Don't go above 99%. */ - $prc = 99 if ($prc >= 100); - - if ($gst_progress && (int $prc > int $gst_progress_last_percentage)) - { - &gst_report ("progress", $prc); - $gst_progress_last_percentage = $prc; - } -} - - -sub gst_progress_begin -{ - &gst_progress (0); -} - - -sub gst_progress_end -{ - &gst_progress (99); -} - - -sub gst_print_progress # Compat with old $progress_max use. -{ - my $prc; - - $gst_progress_current++; - &gst_progress (($gst_progress_current * 100) / $progress_max); -} - +package Utils::Report; -# --- Report printing --- # +my $report_threshold = 0; +my $report_table = \%gst_report_message; -sub gst_report_begin +sub begin { my ($tool) = @_; - &gst_report ("begin"); - &gst_report_enter (); - &gst_progress_begin (); + &do_report ("begin"); + &enter (); } -sub gst_report_end +sub end { - &gst_progress_end (); - &gst_report_leave (); - &gst_report ("end"); + &leave (); + &do_report ("end"); } -sub gst_report_set_threshold +sub set_threshold { - $gst_report_threshold = $_[0]; + $report_threshold = $_[0]; } -sub gst_report_enter +sub enter { # This has been trivialized because it is not working # correctly at the moment and is causing some trouble. @@ -116,7 +63,7 @@ sub gst_report_enter } -sub gst_report_leave +sub leave { # $gst_report_level --; $gst_report_level = 0; @@ -124,7 +71,7 @@ sub gst_report_leave # Escapes a report using the report line format. -sub gst_report_escape +sub escape_report { my ($args) = @_; my ($arg); @@ -141,26 +88,26 @@ $gst_report_level = 0; $gst_report_started = 0; # Just to trap these errors with the debugger easily. -sub gst_report_stderr +sub do_report_stderr { my ($major, $key, $res) = @_; - print STDERR "$gst_name - $major::${key}::$res"; + print STDERR "$major::${key}::$res"; } -sub gst_report +sub do_report { my (@args) = @_; my ($key, $major, $minor, $str, $format, $res); - my $report_message = &gst_report_table (); + my $report_message = $report_table; - &gst_report_escape (\@args); + &escape_report (\@args); $key = shift @args; if (! (exists $$report_message{$key})) { - &gst_report ("report_minor_unk", $key); + &do_report ("report_minor_unk", $key); return; } @@ -168,7 +115,7 @@ sub gst_report if (! (exists $gst_report_valid_majors{$major})) { - &gst_report ("report_major_unk", $major, join ("::", $key, @args)); + &do_report ("report_major_unk", $major, join ("::", $key, @args)); return; } @@ -178,51 +125,35 @@ sub gst_report $format = "$str\n"; $res = sprintf ($format, @args); - if ($gst_do_verbose || + if ($Utils::Backend::do_verbose || $major eq "error" || $major eq "debug") { - &gst_report_stderr ($major, $key, $res); - } - - if ($key ne "progress") - { - return if ($gst_report_level >= $gst_report_threshold || !$gst_report_started); + &do_report_stderr ($major, $key, $res); } # Report (--report) output is machine-readable. - if ($gst_do_report) + if ($Utils::Backend::do_report) { print STDOUT join ("::", $major, $key, $str, @args) . "\n"; } - - &gst_debug_print_indented_string ($gst_report_level, "report $major:$key: $res"); } -# Internal +sub add { - my $report_table = \%gst_report_message; - sub gst_report_table - { - my $table = shift @_; + my $table = shift @_; - if ($table) # Add - { - foreach my $key (keys %$table) - { - $$report_table{$key} = $$table{$key} unless exists $$report_table{$key}; - } - } - - else # Get + if ($table) # Add + { + foreach my $key (keys %$table) { - return $report_table; + $$report_table{$key} = $$table{$key} unless exists $$report_table{$key}; } } } # This disables reporting. -&gst_report_set_threshold (0); +&set_threshold (0); %gst_report_valid_majors = ( "sys" => 1, @@ -236,7 +167,6 @@ sub gst_report ( "begin" => ["sys", "Start of work report."], "end" => ["sys", "End of work report."], - "progress" => ["sys", "%d"], "compat" => ["info", "%s."], "report_major_unk" => ["error", "Unknown major [%s] in report [%s]."], diff --git a/util.pl.in b/Utils/Util.pm index dea7036..f3a714a 100644 --- a/util.pl.in +++ b/Utils/Util.pm @@ -27,25 +27,19 @@ # --- Utilities for strings, arrays and other data structures --- # +package Utils::Util; -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -sub gst_max +sub max { return ($_[0] > $_[1])? $_[0]: $_[1]; } # Boolean <-> strings conversion. -sub gst_util_read_boolean +sub read_boolean { my ($v) = @_; - + return 1 if ($v =~ "true" || $v =~ "yes" || $v =~ "YES" || @@ -55,21 +49,21 @@ sub gst_util_read_boolean } -sub gst_print_boolean_yesno +sub print_boolean_yesno { if ($_[0] == 1) { return "yes"; } return "no"; } -sub gst_print_boolean_truefalse +sub print_boolean_truefalse { if ($_[0] == 1) { return "true"; } return "false"; } -sub gst_print_boolean_onoff +sub print_boolean_onoff { if ($_[0] == 1) { return "on"; } return "off"; @@ -80,7 +74,7 @@ sub gst_print_boolean_onoff # I'm sure there's a smarter way to do this. Should only be used for small # lists, as it's O(N^2). Larger lists with unique members should use a hash. -sub gst_push_unique +sub push_unique { my $arr = $_[0]; my $found; @@ -104,7 +98,7 @@ sub gst_push_unique # Merges scr array into dest array. -sub gst_arr_merge +sub arr_merge { my ($dest, $src) = @_; my (%h, $i); @@ -120,7 +114,7 @@ sub gst_arr_merge # Given an array and a pattern, it returns the index of the # array that contains it -sub gst_array_find_index +sub find_array_index { my($arrayRef, $pattern) = @_; my(@array) = @{$arrayRef}; @@ -133,8 +127,7 @@ sub gst_array_find_index } - -sub gst_ignore_line +sub ignore_line { if (($_[0] =~ /^[ \t]*\#/) || ($_[0] =~ /^[ \t\n\r]*$/)) { return 1; } return 0; @@ -148,7 +141,7 @@ sub gst_ignore_line # * An array. # this function will return 1 if the scalar value is in the array, 0 otherwise. -sub gst_item_is_in_list +sub item_is_in_list { my ($value, @arr) = @_; my ($item); @@ -165,7 +158,7 @@ sub gst_item_is_in_list # Recursively compare a structure made of nested arrays and hashes, diving # into references, if necessary. Circular references will cause a loop. # Watch it: arrays must have elements in the same order to be equal. -sub gst_util_struct_eq +sub struct_eq { my ($a1, $a2) = @_; my ($type1, $type2); @@ -189,17 +182,17 @@ sub gst_util_struct_eq for ($i = 0; $i <= $#$a1; $i++) { - return 0 if !&gst_util_struct_eq ($$a1[$i], $$a2[$i]); + return 0 if !&struct_eq ($$a1[$i], $$a2[$i]); } } elsif ($type1 eq "HASH") { @keys1 = sort keys (%$a1); @keys2 = sort keys (%$a2); - return 0 if !&gst_util_struct_eq (\@keys1, \@keys2); + return 0 if !&struct_eq (\@keys1, \@keys2); foreach $i (@keys1) { - return 0 if !&gst_util_struct_eq ($$a1{$i}, $$a2{$i}); + return 0 if !&struct_eq ($$a1{$i}, $$a2{$i}); } } else @@ -221,7 +214,7 @@ sub gst_util_struct_eq # sub-hash-table) seeing if one of them matches up with an item in the # match_list. If so, the key will be returned. -sub gst_get_key_for_subkeys +sub get_key_for_subkeys { my %hash = %{$_[0]}; my @match_list = @{$_[1]}; @@ -252,7 +245,7 @@ sub gst_get_key_for_subkeys # * sub-key equals match_key. # * sub-key associated sub-value is contained in the match_list. -sub gst_get_key_for_subkey_and_subvalues +sub get_key_for_subkey_and_subvalues { my %hash = %{$_[0]}; my $key; @@ -279,11 +272,11 @@ sub gst_get_key_for_subkey_and_subvalues # --- IP calculation --- # -# &gst_ip_calc_network (<IP>, <netmask>) +# ip_calc_network (<IP>, <netmask>) # # Calculates the network address and returns it as a string. -sub gst_ip_calc_network +sub ip_calc_network { my @ip_reg1; my @ip_reg2; @@ -300,11 +293,11 @@ sub gst_ip_calc_network } -# &gst_ip_calc_network (<IP>, <netmask>) +# ip_calc_broadcast (<IP>, <netmask>) # # Calculates the broadcast address and returns it as a string. -sub gst_ip_calc_broadcast +sub ip_calc_broadcast { my @ip_reg1; my @ip_reg2; @@ -325,7 +318,7 @@ sub gst_ip_calc_broadcast # Forks a process, running $proc with @args in the child, and # printing the returned value of $proc in the pipe. Parent # returns a structure with useful data about the process. -sub gst_process_fork +sub process_fork { my ($proc, @args) = @_; my $pid; @@ -365,18 +358,18 @@ sub gst_process_fork # Close pipe, kill process, wait for it to finish. -sub gst_process_kill +sub process_kill { my ($proc) = @_; - &gst_file_close ($$proc{"fd"}); + &Utils::File::close_file ($$proc{"fd"}); kill 2, $$proc{"pid"}; waitpid ($$proc{"pid"}, undef); } # Populate a bitmap of the used file descriptors. -sub gst_process_list_build_fd_bitmap +sub process_list_build_fd_bitmap { my ($procs) = @_; my ($bits, $proc); @@ -395,13 +388,13 @@ sub gst_process_list_build_fd_bitmap # set the "ready" key to true in all the procs that are ready # to return values, false otherwise. Returns time left before # timeout. -sub gst_process_list_check_ready +sub process_list_check_ready { my ($timeout, $procs) = @_; my ($bits, $bitsleft, $bitsready, $timestamp, $timeleft); $procs = [ $procs ] if ref ($procs) ne 'ARRAY'; - $bits = &gst_process_list_build_fd_bitmap ($procs); + $bits = &process_list_build_fd_bitmap ($procs); # Check with timeout which descriptors are ready with info. $timeout = undef if $timeout == 0; @@ -430,7 +423,7 @@ sub gst_process_list_check_ready } -sub gst_process_result_collect +sub process_result_collect { my ($proc, $func, @args) = @_; my ($value, $tmp, $lines); @@ -454,7 +447,7 @@ sub gst_process_result_collect } PROC_KILL: - &gst_process_kill ($proc); + &process_kill ($proc); return $value; } @@ -23,18 +23,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +package Utils::XML; -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/debug.pl$DOTIN"; - +use Utils::Util; +use Utils::Backend; use Text::ParseWords; $has_encode = 0; @@ -58,63 +50,63 @@ my $gst_have_vspace = 0; my @gst_xml_stack; -sub gst_xml_print_comment # (comment text) +sub print_comment # (comment text) { my ($comment) = @_; - &gst_xml_print_line ("<!-- $comment -->") if $comment; + &print_line ("<!-- $comment -->") if $comment; } -sub gst_xml_print_begin +sub print_begin { my ($name) = @_; - $name = $gst_name if !$name; + $name = "response" if !$name; - &gst_xml_print_string ("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n"); - &gst_xml_print_string ("<!DOCTYPE $name []>\n\n"); - &gst_xml_print_string ("<$name>\n"); + &print_string ("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n"); + &print_string ("<!DOCTYPE $name []>\n\n"); + &print_string ("<$name>\n"); - &gst_xml_enter (); + &enter (); - &gst_xml_print_vspace (); + &print_vspace (); } # The frontend expects exactly this string. Don not alter. -sub gst_xml_print_request_end +sub print_request_end { print "\n<!-- GST: end of request -->\n"; } -sub gst_xml_print_end +sub print_end { my ($name) = @_; - $name = $gst_name if !$name; + $name = "response" if !$name; - &gst_xml_leave (); + &leave (); - &gst_xml_print_vspace (); - &gst_xml_print_string ("</$name>\n"); + &print_vspace (); + &print_string ("</$name>\n"); } -sub gst_xml_enter +sub enter { $gst_indent_level += 2; } -sub gst_xml_leave +sub leave { $gst_indent_level -= 2; } -sub gst_xml_print_string +sub print_string { if ($has_encode) { @@ -131,69 +123,69 @@ sub gst_xml_print_string print $_[0]; } -sub gst_xml_format_indent +sub format_indent { $gst_have_vspace = 0; return " " x $gst_indent_level; } -sub gst_xml_print_indent +sub print_indent { - &gst_xml_print_string(&gst_xml_format_indent ()); + &print_string(&format_indent ()); } -sub gst_xml_print_vspace +sub print_vspace { if (not $gst_have_vspace) { - &gst_xml_print_string ("\n"); + &print_string ("\n"); $gst_have_vspace = 1; } } -sub gst_xml_print_line +sub print_line { my $line; $line = join ("", @_); $line =~ tr/\n//d; - &gst_xml_print_indent (); - &gst_xml_print_string ($line . "\n"); + &print_indent (); + &print_string ($line . "\n"); } -sub gst_xml_format_pcdata # (name, pcdata) +sub format_pcdata # (name, pcdata) { my ($name, $pcdata) = @_; return "<$name>$pcdata</$name>" if defined ($name) || defined ($pcdata); } -sub gst_xml_print_pcdata # (name, pcdata) +sub print_pcdata # (name, pcdata) { my ($name, $pcdata) = @_; - my $line = &gst_xml_format_pcdata ($name, $pcdata); + my $line = &format_pcdata ($name, $pcdata); - &gst_xml_print_line ($line) if $line; + &print_line ($line) if $line; } -sub gst_xml_format_state_tag +sub format_state_tag { my ($name, $state) = @_; - my $boolean = &gst_print_boolean_truefalse ($state); + my $boolean = &Utils::Util::print_boolean_truefalse ($state); return "<$name state='$boolean'/>"; } -sub gst_xml_print_state_tag +sub print_state_tag { my ($name, $state) = @_; - my $state_tag = &gst_xml_format_state_tag ($name, $state); + my $state_tag = &format_state_tag ($name, $state); - &gst_xml_print_line ($state_tag); + &print_line ($state_tag); } # Pass a hash and the keys whose items are scalars. Print <key>val</key>. -sub gst_xml_print_scalars +sub print_scalars { my ($h, @scalar_keys) = @_; my ($i, $val); @@ -202,8 +194,8 @@ sub gst_xml_print_scalars while ($i = shift @scalar_keys) { - $val = &gst_xml_quote ($$h{$i}); - &gst_xml_print_line ("<$i>$val</$i>\n") if exists $$h{$i}; + $val = "e ($$h{$i}); + &print_line ("<$i>$val</$i>\n") if exists $$h{$i}; } } @@ -211,87 +203,87 @@ sub gst_xml_print_scalars # Print the @$array using <$tag>val</$tag> foreach val in the array. # Actually lets print_structure do that now. Just print sequentially # the given elements, using as $tag as the surrounding tags. -sub gst_xml_print_array +sub print_array { my ($array, $tag) = @_; my ($i, $val); return if (scalar @$array <= 0); - &gst_xml_print_vspace (); + &print_vspace (); foreach $i (@$array) { - &gst_xml_print_structure ($i, $tag); + &print_structure ($i, $tag); } } # Pass a hash and the keys whose items are arrays. Print <key>val</key> foreach val # in the array at hash{key} -sub gst_xml_print_arrays +sub print_arrays { my ($h, @array_keys) = @_; my ($i, $j, $val); foreach $i (sort @array_keys) { - &gst_xml_print_array ($$h{$i}, $i) if (exists $$h{$i}) + &print_array ($$h{$i}, $i) if (exists $$h{$i}) } } # Pass a hash, create a parent tag $tag and print <key>val</key> for every # value pair in the hash. If structure refs are found, these are recursively # printed with print_structure. -sub gst_xml_print_hash +sub print_hash { my ($hash, $tag) = @_; my ($j, $val); - &gst_xml_print_vspace (); + &print_vspace (); if (defined $tag) { - &gst_xml_print_line ("<$tag>\n"); - &gst_xml_enter (); + &print_line ("<$tag>\n"); + &enter (); } foreach $j (sort keys (%$hash)) { - &gst_xml_print_structure ($$hash{$j}, $j); + &print_structure ($$hash{$j}, $j); } if (defined $tag) { - &gst_xml_leave (); - &gst_xml_print_line ("</$tag>\n"); + &leave (); + &print_line ("</$tag>\n"); } } # Call the corresponding function depending on the reference # type of $x. If just a scalar, print <$tag>$x</$tag>. -sub gst_xml_print_structure +sub print_structure { my ($x, $tag) = @_; - if (ref $x eq "ARRAY") { &gst_xml_print_array ($x, $tag); } - elsif (ref $x eq "HASH") { &gst_xml_print_hash ($x, $tag); } + if (ref $x eq "ARRAY") { &print_array ($x, $tag); } + elsif (ref $x eq "HASH") { &print_hash ($x, $tag); } else { - &gst_xml_print_line ("<$tag>" . &gst_xml_quote ($x) . "</$tag>\n"); + &print_line ("<$tag>" . "e ($x) . "</$tag>\n"); } } # Treats hash as an array: doesn't use the keys as tags for its # elements, but the given tag. -sub gst_xml_print_hash_hash +sub print_hash_hash { my ($h, $tag) = @_; my $i; foreach $i (sort keys %$h) { - &gst_xml_print_hash ($$h{$i}, $tag); + &print_hash ($$h{$i}, $tag); } } -sub gst_xml_container_enter # (name) +sub container_enter # (name) { my ($container) = @_; @@ -299,40 +291,40 @@ sub gst_xml_container_enter # (name) ## so it is global push @gst_xml_stack, $container; - &gst_xml_print_line ("<$container>"); - &gst_xml_enter(); + &print_line ("<$container>"); + &enter(); } -sub gst_xml_container_leave +sub container_leave { ## checks if there is a start tag if ($#gst_xml_stack >= 0) { my $current_container = pop @gst_xml_stack; - &gst_xml_leave (); - &gst_xml_print_line ("</$current_container>"); + &leave (); + &print_line ("</$current_container>"); } } -sub gst_xml_print_container # (name, @strings) +sub print_container # (name, @strings) { my ($name, @strings) = @_; if (@strings) { - &gst_xml_container_enter ($name); + &container_enter ($name); foreach $tag (@strings) { - &gst_xml_print_line ("$tag"); + &print_line ("$tag"); } - &gst_xml_container_leave (); + &container_leave (); } } # --- XML printing from in-memory model --- # -sub gst_xml_model_print_attributes +sub model_print_attributes { my ($tree) = @_; my ($attrs, $string); @@ -347,7 +339,7 @@ sub gst_xml_model_print_attributes return $string; } -sub gst_xml_model_print_recurse +sub model_print_recurse { my ($tree, $indent) = @_; my ($string); @@ -369,12 +361,12 @@ sub gst_xml_model_print_recurse } elsif (@$branch == 1) # Empty tag. { - $string .= "<" . $children [0] . &gst_xml_model_print_attributes ($branch) . "/>"; + $string .= "<" . $children [0] . &model_print_attributes ($branch) . "/>"; } else { - $string .= "<" . $children [0] . &gst_xml_model_print_attributes ($branch) . ">"; - $string .= &gst_xml_model_print_recurse ($branch); + $string .= "<" . $children [0] . &model_print_attributes ($branch) . ">"; + $string .= &model_print_recurse ($branch); $string .= "</" . $children [0] . ">"; } @@ -384,19 +376,19 @@ sub gst_xml_model_print_recurse # if ($branch) # { -# return &gst_xml_get_attribute ($branch, $property) if $property ne ""; -# return &gst_xml_get_pcdata ($branch); +# return &get_attribute ($branch, $property) if $property ne ""; +# return &get_pcdata ($branch); # } return $string; } -sub gst_xml_model_print +sub model_print { my ($tree) = @_; my ($string); - $string = &gst_xml_model_print_recurse ($tree); + $string = &model_print_recurse ($tree); chomp $string; $string .= "\n"; @@ -408,7 +400,7 @@ sub gst_xml_model_print # This code tries to replace XML::Parser scanning from stdin in tree mode. -sub gst_xml_scan_make_kid_array +sub scan_make_kid_array { my $line = shift; my (%hash, @sublist, @attr, @list); @@ -436,7 +428,7 @@ sub gst_xml_scan_make_kid_array } -sub gst_xml_scan_recurse +sub scan_recurse { my ($gst_xml_scan_list, $list_arg) = @_; my @list; @@ -451,7 +443,7 @@ sub gst_xml_scan_recurse { $el =~ /^\<([a-zA-Z0-9_-]+).*\/\>$/s; push (@list, $1); - push (@list, &gst_xml_scan_make_kid_array ($el)); + push (@list, &scan_make_kid_array ($el)); } elsif ($el =~ /^\<\/.*\>$/s) # End. { @@ -461,8 +453,8 @@ sub gst_xml_scan_recurse { $el =~ /^\<([a-zA-Z0-9_-]+).*\>$/s; push (@list, $1); - $sublist = &gst_xml_scan_make_kid_array ($el); - push (@list, &gst_xml_scan_recurse ($gst_xml_scan_list, $sublist)); + $sublist = &scan_make_kid_array ($el); + push (@list, &scan_recurse ($gst_xml_scan_list, $sublist)); next; } elsif ($el ne "") # PCDATA. @@ -476,7 +468,7 @@ sub gst_xml_scan_recurse } -sub gst_xml_read_file +sub read_file { my ($file) = @_; my ($doc, $i); @@ -490,15 +482,15 @@ sub gst_xml_read_file } -sub gst_xml_read_compressed_file +sub read_compressed_file { my ($file) = @_; my ($doc, $i, $fd); - $fd = &gst_file_run_pipe_read ("gunzip -c $file"); + $fd = &Utils::File::run_pipe_read ("gunzip -c $file"); return undef if $fd eq undef; $doc .= $i while ($i = <$fd>); - &gst_file_close ($fd); + &Utils::File::close_file ($fd); if (length ($doc) < 4) # Allow for one blank line from gzip, '\n\r'. { @@ -509,7 +501,7 @@ sub gst_xml_read_compressed_file } -sub gst_xml_read_stdin +sub read_stdin { my ($i, $doc); @@ -529,7 +521,7 @@ sub gst_xml_read_stdin # file could also contain xml document. # If tool is an gst_tool, stores the read buffer in # $$tool{"xml_doc"}. -sub gst_xml_scan +sub scan { my ($file, $tool) = @_; my ($doc, @tree, @gst_xml_scan_list); @@ -538,7 +530,7 @@ sub gst_xml_scan if ($file && stat ($file)) { - $doc = &gst_xml_read_file ($file); + $doc = &read_file ($file); } elsif ($file) { @@ -546,25 +538,23 @@ sub gst_xml_scan } else { - $doc = &gst_xml_read_stdin (); + $doc = &read_stdin (); } # remove any blank or carriage return at the beginning of the xml $doc =~ s/^[ \n]*//; - &gst_debug_print_log_to_file ("in.xml", $doc); - - $$tool{"xml_doc"} = $doc if (&gst_is_tool ($tool)); + $$tool{"xml_doc"} = $doc if (&Utils::Backend::is_backend ($tool)); @gst_xml_scan_list = ($doc =~ /([^\<]*)(\<[^\>]*\>)[ \t\n\r]*/mg); # pcdata, tag, pcdata, tag, ... - $tree = &gst_xml_scan_recurse (\@gst_xml_scan_list); + $tree = &scan_recurse (\@gst_xml_scan_list); return $tree; } # XML scanning that preserves more exact attributes of the scanned XML. -sub gst_xml_model_scan_recurse +sub model_scan_recurse { my @list; if (@_) { @list = $_[0]->[0]; } @@ -587,7 +577,7 @@ sub gst_xml_model_scan_recurse { $el =~ /^\<([a-zA-Z0-9_-]+).*\/\>$/s; push (@list, $1); - push (@list, &gst_xml_scan_make_kid_array ($el)); + push (@list, &scan_make_kid_array ($el)); } elsif ($el =~ /^\<\/.*\>$/s) # End. { @@ -597,8 +587,8 @@ sub gst_xml_model_scan_recurse { $el =~ /^\<([a-zA-Z0-9_-]+).*\>$/s; push (@list, $1); - $sublist = &gst_xml_scan_make_kid_array ($el); - push (@list, &gst_xml_model_scan_recurse ($sublist)); + $sublist = &scan_make_kid_array ($el); + push (@list, &model_scan_recurse ($sublist)); next; } elsif ($el ne "") # PCDATA. @@ -611,7 +601,7 @@ sub gst_xml_model_scan_recurse return \@list; } -sub gst_xml_model_scan # (file) If no file specified, reads stdin. +sub model_scan # (file) If no file specified, reads stdin. { my ($file) = @_; my ($doc, $tree, $compressed); @@ -620,10 +610,10 @@ sub gst_xml_model_scan # (file) If no file specified, reads stdin. if ($file) { - $doc = &gst_xml_read_compressed_file ($file); + $doc = &read_compressed_file ($file); if (!$doc) { - $doc = &gst_xml_read_file ($file); + $doc = &read_file ($file); $compressed = 0; } else @@ -637,29 +627,29 @@ sub gst_xml_model_scan # (file) If no file specified, reads stdin. } @gst_xml_scan_list = ($doc =~ /([^\<]*)(\<[^\>]*\>)/mg); # pcdata, tag, pcdata, tag, ... - $tree = &gst_xml_model_scan_recurse; + $tree = &model_scan_recurse; return $tree, $compressed; } -sub gst_xml_model_save +sub model_save { my ($model, $file, $compressed) = @_; my $fd; if ($compressed == 1) { - $fd = &gst_file_open_write_compressed ($file); + $fd = &Utils::File::open_write_compressed ($file); } else { - $fd = &gst_file_open_write_from_names ($file); + $fd = &Utils::File::open_write_from_names ($file); } if ($fd == -1) { return -1; } - print $fd &gst_xml_model_print ($model); - &gst_file_close ($fd); + print $fd &model_print ($model); + &Utils::File::close_file ($fd); return 0; } @@ -669,7 +659,7 @@ sub gst_xml_model_save @gst_xml_entities = ( "<", '<', ">", '>', "'", '\'', """, '"', "&", '&' ); -sub gst_xml_quote +sub quote { my $in = $_[0]; my $out = ""; @@ -699,7 +689,7 @@ sub gst_xml_quote } -sub gst_xml_unquote +sub unquote { my $ret = $_[0]; my $i; @@ -727,7 +717,7 @@ sub gst_xml_unquote # --- XML parsing --- # -sub gst_xml_get_pcdata +sub get_pcdata { my $tree = $_[0]; my $retval; @@ -738,8 +728,7 @@ sub gst_xml_get_pcdata { if ($$tree[0] == 0) { - $retval = &gst_xml_unquote ($$tree[1]); - &gst_debug_print_line ("gst_xml_get_pcdata: $retval"); + $retval = &unquote ($$tree[1]); return ($retval); } @@ -752,12 +741,12 @@ sub gst_xml_get_pcdata # Compresses node into a word and returns it. -sub gst_xml_get_word +sub get_word { my $tree = $_[0]; my $retval; - $retval = &gst_xml_get_pcdata ($tree); + $retval = &get_pcdata ($tree); $retval =~ tr/ \n\r\t\f//d; return $retval; } @@ -765,12 +754,12 @@ sub gst_xml_get_word # Compresses node into a size and returns it. -sub gst_xml_get_size +sub get_size { my $tree = $_[0]; my $retval; - $retval = &gst_xml_get_word ($tree); + $retval = &get_word ($tree); if ($retval =~ /Mb$/) { $retval =~ tr/ Mb//d; @@ -783,12 +772,12 @@ sub gst_xml_get_size # Replaces misc. whitespace with spaces and returns text. -sub gst_xml_get_text +sub get_text { my $tree = $_[0]; my $retval; - $retval = &gst_xml_get_pcdata ($tree); + $retval = &get_pcdata ($tree); my $type = ref ($retval); if (!$type) { $retval =~ tr/\n\r\t\f/ /; } @@ -796,25 +785,25 @@ sub gst_xml_get_text return $retval; } -sub gst_xml_get_attribute +sub get_attribute { my ($tree, $attr) = @_; return $$tree[0]->{$attr}; } -sub gst_xml_get_state +sub get_state { my ($tree) = @_; # Check attribute; 'yes', 'true', 'no', 'false'. - return &gst_util_read_boolean ($$tree[0]->{state}); + return &Utils::Util::read_boolean ($$tree[0]->{state}); } # XML model operations. # Locate a node from the branch leading up to it. -sub gst_xml_model_find +sub model_find { my ($model, $varpath) = @_; my ($branch, @path); @@ -849,13 +838,13 @@ sub gst_xml_model_find } # Add a branch to another branch. Allows duplicates. -sub gst_xml_model_add +sub model_add { my ($model, $varpath, $addpath) = @_; my ($branch, @path); @path = split /\//, $addpath; - $branch = &gst_xml_model_find ($model, $varpath); + $branch = &model_find ($model, $varpath); if ($branch == undef) { return -1; @@ -878,7 +867,7 @@ sub gst_xml_model_add } # Ensure a branch exists, by extending the branch with given elements, if needed. -sub gst_xml_model_ensure +sub model_ensure { my ($model, $varpath) = @_; my ($branch, @path); @@ -926,13 +915,13 @@ sub gst_xml_model_ensure return $branch; } -sub gst_xml_model_remove +sub model_remove { my ($model, $varpath, $tag) = @_; my ($branch, $i); @path = split /\//, $addpath; - $branch = &gst_xml_model_find ($model, $varpath); + $branch = &model_find ($model, $varpath); if ($branch == undef) { return -1; @@ -950,7 +939,7 @@ sub gst_xml_model_remove return -1; } -sub gst_xml_model_get_children +sub model_get_children { my ($branch) = @_; my (@children); @@ -968,7 +957,7 @@ sub gst_xml_model_get_children return \@children; } -sub gst_xml_model_get_pcdata +sub model_get_pcdata { my ($branch) = @_; my ($i); @@ -977,7 +966,7 @@ sub gst_xml_model_get_pcdata { if ($$branch [$i] == 0) { - my $retval = &gst_xml_unquote ($$branch [$i + 1]); + my $retval = &unquote ($$branch [$i + 1]); return ($retval); } } @@ -985,24 +974,24 @@ sub gst_xml_model_get_pcdata return ""; } -sub gst_xml_model_set_pcdata +sub model_set_pcdata { my ($branch, $pcdata) = @_; @$branch = (@$branch [0]); $$branch [1] = 0; - $$branch [2] = &gst_xml_quote ($pcdata); + $$branch [2] = "e ($pcdata); } -sub gst_xml_model_get_attribute +sub model_get_attribute { my ($branch, $attr) = @_; return $$branch[0]->{$attr}; } -sub gst_xml_model_set_attribute +sub model_set_attribute { my ($branch, $attr, $value) = @_; diff --git a/add_amp.sh b/add_amp.sh deleted file mode 100644 index eb7313c..0000000 --- a/add_amp.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -echo This has bugs: substitutes stuff between quotes. - -for i in `grep ^sub *-conf.in be.pl.in | cut -f2 -d' ' | sort | uniq`; do - for j in *-conf.in be.pl.in; do - echo $i:$j - sed ' - s/\([^_a-z]\)'$i'/\1\&'$i'/g; - s/\&\+'$i'/\&'$i'/g; - s/^sub \&\+'$i'/sub '$i'/g; - s/\$\&/\$/g;s/\@\&/\@/g;s/\%\&/\%/g - ' $j > $j.1 - mv $j.1 $j - done -done @@ -9,7 +9,7 @@ cd $srcdir PROJECT=system-tools-backends TEST_TYPE=-f -FILE=system-tools-backends.pc.in +FILE=system-tools-backends-2.0.pc.in DIE=0 diff --git a/boot-conf.in b/boot-conf.in deleted file mode 100644 index 494bd90..0000000 --- a/boot-conf.in +++ /dev/null @@ -1,270 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Boot manager configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Tambet Ingo <tambet@ximian.com> -# Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files that may be affected: -# -# /etc/lilo.conf -# /boot/grub/menu.lst -# /etc/grub.conf -# /boot/grub/grub.conf - -# Running programs affected: -# -# /sbin/lilo - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/parse.pl$DOTIN"; - require "$SCRIPTSDIR/boot.pl$DOTIN"; - require "$SCRIPTSDIR/boot-lilo.pl$DOTIN"; - require "$SCRIPTSDIR/boot-grub.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "boot"; -$version = "@VERSION@"; - -$description =<<"end_of_description;"; - Configures Boot manager (LILO and GRUB at the moment). -end_of_description; - -# --- XML parsing --- - -# Scan XML from standard input to an internal tree. - - -sub xml_parse -{ - my ($tree, %hash, $elem); - # Scan XML to tree. - - $tree = &gst_xml_scan (); - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "boot" tag. - - while ($elem = shift @$tree) - { - if ($elem eq "boot") { &xml_parse_boot (shift @$tree, \%hash); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return(\%hash); -} - - -sub xml_parse_boot -{ - my ($tree, $hash) = @_; - my (@entries, $elem); - - shift @$tree; # Skip attributes. - - $$hash{"timeout"} = -1; - - while ($elem = shift @$tree) - { - if ($elem eq "prompt") { $$hash{"prompt"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "boot") { $$hash{"boot"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "root") { $$hash{"root"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "timeout") { $$hash{"timeout"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "default") { $$hash{"default"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "append") { $$hash{"append"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "pixmap") { $$hash{"pixmap"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "pixmapsup") { $$hash{"pixmapsup"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "entry") { &xml_parse_entry (shift @$tree, \@entries); } - elsif ($elem eq "partitions") { shift @$tree; } # Just skip it. - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"entry"} = \@entries unless scalar @entries == 0; -} - - -sub xml_parse_entry -{ - my ($tree, $entries) = @_; - my (%hash, $buf); - - shift @$tree; - - while ($elem = shift @$tree) - { - $hash{$elem} = &gst_xml_get_pcdata (shift @$tree); - } - - push @$entries, \%hash; -} - - -# --- XML printing --- # - -sub xml_print -{ - my ($h) = @_; - my @scalars = qw(default timeout pixmap pixmapsup prompt boot root); - - &gst_xml_print_begin (); - - &gst_xml_print_structure ($$h{"bootloaders"}, "bootloaders") if ($$h{"bootloaders"} ne undef); - - &gst_xml_print_hash ($$h{"partitions"}, "partitions") if ($$h{"partitions"} ne undef); - &gst_xml_print_vspace (); - &gst_xml_print_scalars ($h, @scalars); - &gst_xml_print_structure ($$h{"entry"}, "entry") if ($$h{"entry"} ne undef); - - &gst_xml_print_end (); -} - - -# Top-level actions. -sub get -{ - my ($hash, $bootl) = @_; - my ($count); - - #FIXME: do mount in a more generic way, this is done because /boot may be unmounted - gst_file_run ("mount /boot"); - - ($count, $hash) = &gst_boot_bootloader_list (); - - if (($bootl ne undef) || ($count == 1)) - { - $bootloader = $bootl; - $bootloader = &gst_boot_bootloader_get () if ($bootl eq undef); - - $hash = &gst_boot_conf_get ($bootloader); - &gst_boot_fix ($hash); - } - - &gst_report_end (); - &xml_print ($hash); -} - - -# --- Set (write) config --- # -sub set -{ - my ($hash); - - #FIXME: do mount in a more generic way, this is done because /boot may be unmounted - gst_file_run ("mount /boot"); - - $hash = &xml_parse (); - - if ($hash) - { - $bootloader = &gst_boot_bootloader_get () if ($bootloader eq undef); - - &gst_boot_fix ($hash); - &gst_boot_conf_set ($hash); - - if ($bootloader eq "lilo") - { - &gst_file_run (&gst_file_locate_tool ("lilo")); - } - elsif ($bootloader eq "yaboot") - { - &gst_file_run (&gst_file_locate_tool ("ybin")); - } - } - else - { - # TODO: report error. - 1; - } - - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # -sub filter -{ - my $hash = &xml_parse; - - &gst_report_end (); - &xml_print ($hash); -} - -sub verify_print -{ - my ($res) = @_; - - &gst_xml_print_begin ("verify"); - &gst_xml_print_structure ($res, "result"); - &gst_xml_print_end ("verify"); -} - -sub verify -{ - my ($hash, $key, @values) = @_; - my ($i, $proc, $res); - - my %bootloader_func = - ( - "lilo" => \&gst_boot_lilo_verify, - "grub" => \&gst_boot_grub_verify, - "yaboot" => \&gst_boot_yaboot_verify - ); - - $bootloader = &gst_boot_bootloader_get () if ($bootloader eq undef); - $proc = $bootloader_func{$bootloader}; - $res = &$proc ($key, @values); - - &gst_report_end (); - &verify_print ($res); -} - - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "getfrom" => [ \&get, [ "bootloader" ], "Get the configuration from an specified bootloader."], - "verify" => [ \&verify, [ "type", "value", "xtravalues*" ], "Verifies the values, depending on the type." ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_run ($tool); diff --git a/boot-grub.pl.in b/boot-grub.pl.in deleted file mode 100644 index 567c83e..0000000 --- a/boot-grub.pl.in +++ /dev/null @@ -1,1067 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Boot manager configurator: grub-related routines. -# -# Copyright (C) 2001 Ximian, Inc. -# -# Authors: Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; -require "$SCRIPTSDIR/partition.pl$DOTIN"; - -my @grub_common_image_vars = qw (title); -my @grub_image_vars = (@grub_common_image_vars, qw (root kernel )); -my @grub_other_vars = (@grub_common_image_vars, qw (rootnoverify makeactive chainloader)); - -sub gst_boot_grub_verify -{ - return "success"; -} - -sub gst_boot_grub_get_config_file -{ - return "/boot/grub/menu.lst" if -f "/boot/grub/menu.lst"; - return "/boot/grub/grub.conf" if -f "/boot/grub/grub.conf"; - return "/etc/grub.conf" if (-f "/etc/grub.conf"); - - return undef; -} - -# find out which is the partition where the file (image or initrd) is stored in, just to -# put /file instead of /path-to-boot/file -sub gst_boot_grub_set_file_path -{ - my ($image, $root) = @_; - my ($mtab, $dir); - - $mtab = "$gst_prefix/etc/mtab"; - $mntopts = &gst_parse_split_first_array ($mtab, $root, "[ \t]+", "[ \t]+"); - $dir = $$mntopts[0]; - - if ($dir ne "") - { - if ($dir ne "/") # if mount point is /, we don't need to remove it - { - $image =~ s/^$dir//; - } - } - - return $image; -} - -sub gst_boot_grub_known_var -{ - my $key = shift; - my $list = shift; - my $from_xml = shift; - - if (ref ($list) ne "ARRAY") - { - # TODO: Give warning; - return 0; - } - - $key = lc ($key); - - # Hard coded known variables which are not standard variables. - return 0 if ($key eq "key" && $from_xml); # "key" is valid in xml only. - return 0 if ($key eq "type" && $from_xml); # "key" is valid in xml only. - - return &gst_item_is_in_list ($key, @$list); -} - -# Scans @buff until finds first line which looks like entry. -# Returns line number or -1 if no entry found. -sub gst_boot_grub_find_entry -{ - my ($buff, $lineno) = @_; - my $i; - - for (; $lineno <= $#$buff; $lineno++) - { - $i = $$buff[$lineno]; - - return $lineno if ($i =~ /^[ \t]*(title)[ \t]+\S+/); - } - - # Not found. - return -1; -} - -sub gst_boot_grub_delete_entry -{ - my ($buff, $lineno) = @_; - my ($end); - - $end = &gst_boot_grub_find_entry ($buff, $lineno + 1); - $end = scalar @$buff if ($end < 0); - - # We delete all entry lines - for ($lineno; $lineno < $end; $lineno++) - { -# delete $$buff[$lineno]; - $$buff[$lineno] = ""; - } - - return $buff; -} - -sub gst_boot_grub_add_entry -{ - my ($entry, $buff, $lineno, $device_map) = @_; - my ($end, $val, $value, $image, $initrd, $module); - - if (exists ($entry->{"image"})) - { - # It's a linux image - $value = $entry->{"root"}; - $value = &gst_boot_grub_system2grub ($device_map, $value); - - $image = &gst_boot_grub_set_file_path ($entry->{"image"}, $entry->{"root"}); - if (exists ($entry->{"initrd"}) && ($entry->{"initrd"} ne "")) { - $initrd = &gst_boot_grub_set_file_path ($entry->{"initrd"}, $entry->{"root"}); - } - - if (exists ($entry->{"module"}) && ($entry->{"module"} ne "")) { - $module = &gst_boot_grub_set_file_path ($entry->{"module"}, $entry->{"root"}); - } - - $val = "title " . $entry->{"label"} . "\n"; - $val .= "\troot (". $value. ")\n"; - $val .= "\tkernel " . $image . " " . $entry->{"append"} . "\n"; - if ($initrd ne "") - { - $val .= "\tinitrd ". $initrd . "\n"; - } - - if ($module ne "") - { - $val .= "\tmodule ". $module. "\n"; - } - } - elsif (exists ($entry->{"other"})) - { - # It's another boot - $value = $entry->{"other"}; - $value = &gst_boot_grub_system2grub ($device_map, $value); - - $val = "title " . $entry->{"label"} . "\n"; - $val .= "\trootnoverify (" . $value . ")\n"; - $val .= "\tmakeactive\n"; - $val .= "\tchainloader +1\n"; - } - else - { - return; - } - - if (exists ($entry->{"password"})) - { - $val .= "\tpassword " . $entry->{"password"} . "\n"; - } - - $val .= "\n"; - - $$buff [$lineno - 1] = $$buff [$lineno - 1] . $val; -} - -sub gst_boot_grub_entry_is_valid -{ - my ($buff, $lineno) = @_; - my ($end, $value, $line, $i); - - $value = 0; - $end = &gst_boot_grub_find_entry ($buff, $lineno + 1); - - if ($end < 1) - { - # no more entries left, get the size of the array - $end = @$buff; - } - - for ($i = $lineno; $i < $end; $i++) - { - $line = $$buff[$i]; - - if (($line =~ /[\t ]*kernel.*/) || - ($line =~ /[\t ]*rootnoverify.*/)) { - $value = 1; - } - } - - return $value; -} - -sub gst_boot_grub_entries_set -{ - my ($file, $device_map, $mtab, $entries) = @_; - my ($buff, $lineno, $entry, $entry_nr, $found); - - return if (scalar @$entries <=0); - - $buff = &gst_file_buffer_load ($file); - - if ($buff eq undef) - { - &gst_report ("boot_conf_read_failed", $file); - return undef; - } - - &gst_file_buffer_join_lines ($buff); - - $lineno = &gst_boot_grub_find_entry ($buff, 0); - - # delete all known entries - while ($lineno > 0) - { - if (&gst_boot_grub_entry_is_valid ($buff, $lineno)) - { - $buff = &gst_boot_grub_delete_entry ($buff, $lineno); - } - - $lineno = &gst_boot_grub_find_entry ($buff, $lineno + 1); - } - - # insert all entries just before all the unknown entries (if any) - $lineno = &gst_boot_grub_find_entry ($buff, 0); - - if ($lineno < 0) - { - $lineno = @$buff; - } - - foreach $entry (@$entries) - { - &gst_boot_grub_add_entry ($entry, $buff, $lineno, $device_map); - } - - # save the buffer - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); -} - -# Grub device notation converters. -sub gst_boot_grub_system2grub -{ - my ($device_map, $dev) = @_; - my ($fd, $line, $res, $path, $drive, $part); - - if (($$tool{"system"} eq "Linux") && - ($dev =~ /(.*\/)?(fd[0-9]|hd|sd|scd)([a-z]*)([0-9]*)/)) - { - $path = "/dev/"; - $path = $1 if ($1 ne undef); - $drive = $2 . $3; - $part = $4 - 1 if ($4 ne undef); - } - elsif (($$tool{"system"} eq "FreeBSD") && - ($dev =~ /(.*\/)?(fd|da|ad|ar|fla|afd|mlx|amrd|idad|twed|aacd|ipsd|wd)([0-9]+)s?([0-9]*)/)) - { - $path = "/dev/"; - $path = $1 if ($1 ne undef); - $drive = $2 . $3; - $part = $4 - 1 if ($4 ne undef); - } - else - { - &gst_report ("boot_grub_convert_failed", $dev); - return undef; - } - - $fd = &gst_file_open_read_from_names ($device_map); - $res = undef; - - while ($line = <$fd>) - { - chomp $line; - if ($line =~ /\(([^\)]+)\)[ \t]+$path$drive$/) - { - $res = $1; - last; - } - } - close $fd; - - if ($res eq undef) - { - # ok, the device doesn't exist in device.map, try to guess it - &gst_report ("boot_grub_convert_failed", $dev); - - if ($drive =~ /(fd.|hd.)/) - { - if ($$tool{"system"} eq "Linux") - { - $res = "hd0" if $drive eq "hda"; - $res = "hd1" if $drive eq "hdb"; - $res = "hd2" if $drive eq "hdc"; - $res = "hd3" if $drive eq "hdd"; - $res = $drive if $drive =~ /fd[0-9]/; - } - elsif ($$tool{"system"} eq "FreeBSD") - { - $res = "hd0" if $drive eq "ad0"; - $res = "hd1" if $drive eq "ad1"; - $res = "hd2" if $drive eq "ad2"; - $res = "hd3" if $drive eq "ad3"; - $res = $drive if $drive =~ /fd[0-9]/; - } - } - else - { - # no way, the entry will be broken - return undef; - } - } - - $res .= ",$part" if $part ne undef; - - return $res; -} - -sub gst_boot_grub_grub2system -{ - my ($device_map, $grubdev) = @_; - ($drive, $part, @add) = split (',', $grubdev); - - $dev = &gst_parse_split_first_str ($device_map, "\\($drive\\)", "[ \t]+"); - - if ($dev eq undef) - { - # ok, the device doesn't exist in devices.map, we'll have to guess it - if ($drive =~ /fd[0-9]/) - { - $dev = "/dev/" . $drive; - } - else - { - if ($$tool{"system"} eq "Linux") - { - $dev = "/dev/hda" if $drive eq "hd0"; - $dev = "/dev/hdb" if $drive eq "hd1"; - $dev = "/dev/hdc" if $drive eq "hd2"; - $dev = "/dev/hdd" if $drive eq "hd3"; - } - elsif ($$tool{"system"} eq "FreeBSD") - { - $dev = "/dev/ad0" if $drive eq "hd0"; - $dev = "/dev/ad1" if $drive eq "hd1"; - $dev = "/dev/ad2" if $drive eq "hd2"; - $dev = "/dev/ad3" if $drive eq "hd3"; - } - } - } - - # FreeBSD insists in putting an "s" between the device and the partition number - $dev .= "s" if ($$tool{"system"} eq "FreeBSD"); - - $dev .= $part + 1 if $part ne undef; - - return $dev; -} - -sub gst_boot_grub_clean_line -{ - my ($line) = @_; - - chomp $line; - $line =~ s/\#.*//; - - $line =~ s/^[ \t]+//; - $line =~ s/[ \t]+$//; - - return $line; -} - -sub gst_boot_grub_line_is_title -{ - my ($line) = @_; - - if ($line =~ /^title[= \t][ \t]*(.*)$/) - { - return $1; - } - - return undef; -} - -sub gst_boot_grub_get_next_entry -{ - my ($buff, $line_no) = @_; - my ($line, $res); - - while ($$line_no < scalar (@$buff)) - { - $line = $$buff[$$line_no]; - - $line = &gst_boot_grub_clean_line ($line); - $res = &gst_boot_grub_line_is_title ($line); - last if $res ne undef; - - $$line_no ++; - } - - return $res; -} - -sub gst_boot_grub_search_entry -{ - my ($buff, $line_no, $entry) = @_; - my ($key, $title); - - $key = 0; - while ($title = &gst_boot_grub_get_next_entry ($buff, $line_no)) - { - return $title if $key == $entry; - $key ++; - $$line_no ++; - } - - return undef; -} - -sub gst_boot_grub_get_entries -{ - my ($grub_conf) = @_; - my ($fd, $line, @res, $title, $i); - my ($buff, $line_no); - - $grub_conf = [$grub_conf] if (ref $grub_conf eq undef); - - foreach $i (@$grub_conf) - { - $fd = &gst_file_open_read_from_names ($i); - last if $fd; - } - - if (!$fd) - { - &gst_report ("boot_conf_read_failed", "/boot/grub/menu.lst"); - return undef; - } - - $buff = &gst_file_buffer_load_fd ($fd); - $line_no = 0; - - while ($title = &gst_boot_grub_get_next_entry ($buff, \$line_no)) - { - push @res, $title; - $line_no ++; - } - - return @res; -} - -sub gst_boot_grub_get_entries_fn -{ - my ($fn) = @_; - - return &gst_boot_grub_get_entries ($$fn{"GRUB_CONF"}); -} - -sub gst_boot_grub_insert_entry -{ - my ($buff, $line_no, $title) = @_; - - splice (@$buff, $line_no, 0, "title $title\n"); -} - -sub gst_boot_grub_remove_entry -{ - my ($buff, $line_no) = @_; - - $$buff[$$line_no] = ""; - $$line_no ++; - - while (&gst_boot_grub_line_is_title ($$buff[$$line_no]) eq undef) - { - $$buff[$$line_no] = "" if (! ($$buff[$$line_no] =~ /^\#/)); - $$line_no ++; - } -} - -# @$entries must be sorted. -sub gst_boot_grub_remove_entries -{ - my ($fn, $entries) = @_; - my ($grub_conf, $buff, $line_no); - my ($find, $curr); - - return 0 if scalar (@$entries) == 0; - - $grub_conf = $$fn{"GRUB_CONF"}; - $buff = &gst_file_buffer_load ($grub_conf); - $buff = [] if $buff eq undef; - $line_no = 0; - - $curr = 0; - $find = shift (@$entries); - - while (&gst_boot_grub_get_next_entry ($buff, \$line_no)) - { - if ($find == $curr) - { - &gst_boot_grub_remove_entry ($buff, \$line_no); - $find = shift (@$entries); - last if $find eq undef; - } - else - { - $line_no ++; - } - $curr ++; - } - - return &gst_file_buffer_save ($buff, $grub_conf); -} - -sub gst_boot_grub_search_cmd -{ - my ($buff, $line_no, $cmd) = @_; - my ($line); - - while ($$line_no < scalar (@$buff)) - { - $line = $$buff[$$line_no]; - - $line = &gst_boot_grub_clean_line ($line); - if ($line eq "") - { - $$line_no ++; - next; - } - - return 0 if &gst_boot_grub_line_is_title ($line) ne undef; - return 1 if ($line =~ /^$cmd[= \t]/); - - $$line_no ++; - } - - return 0; -} - -sub gst_boot_grub_parse_cmd -{ - my ($grub_conf, $cmd, $entry) = @_; - my ($line, $buff, $line_no); - - $buff = &gst_file_buffer_load ($grub_conf); - return undef if $buff eq undef; - $line_no = 0; - - if ($entry ne undef) - { - return undef if &gst_boot_grub_search_entry ($buff, \$line_no, $entry) eq undef; - $line_no ++; - } - - if (&gst_boot_grub_search_cmd ($buff, \$line_no, $cmd)) - { - $line = &gst_boot_grub_clean_line ($$buff[$line_no]); - if ($line =~ /^$cmd[= \t][ \t]*(.*)/) - { - return 1 if $1 eq ""; - return $1; - } - } - - return undef; -} - -sub gst_boot_grub_insert_cmd -{ - my ($buff, $line_no, $cmd, $value) = @_; - - splice (@$buff, $line_no, 0, "$cmd $value\n") unless $value eq undef; -} - -sub gst_boot_grub_parse_file_cmd -{ - my ($grub_conf, $cmd, $device_map, $mtab, $entry) = @_; - my ($value, $mtopts, $grubdev, $file, $dev, $root); - - $value = &gst_boot_grub_parse_cmd ($grub_conf, $cmd, $entry); - return undef if $value eq undef; - - $value =~ /^\(([^\)]+)\)(.*)/; - $grubdev = $1; - $file = $2; - - if ($grubdev eq undef) - { - $file = $value; - $root = &gst_boot_grub_parse_cmd ($grub_conf, "root", $entry); - $root =~ /^\(([^\)]+)\)/; - $grubdev = $1; - } - - $file =~ s/[ \t].*//; - $dev = &gst_boot_grub_grub2system ($device_map, $grubdev); - - $mntopts = &gst_parse_split_first_array ($mtab, $dev, "[ \t]+", "[ \t]+"); - - $res = $$mntopts[0] . "/$file"; - $res =~ s/\/+/\//g; - - return $res; -} - -sub gst_boot_grub_parse_pixmap -{ - my ($grub_conf, $device_map, $mtab) = @_; - - return &gst_boot_grub_parse_file_cmd ($grub_conf, "splashimage", $device_map, $mtab); -} - -sub gst_boot_grub_parse_image -{ - my ($grub_conf, $device_map, $mtab, $entry) = @_; - my ($image); - - $image = &gst_boot_grub_parse_file_cmd ($grub_conf, "kernel", $device_map, $mtab, $entry); - - return $image; -} - -sub gst_boot_grub_parse_other -{ - my ($grub_conf, $device_map, $mtab, $entry) = @_; - my ($value, $grubdev, $dev, $root); - - $value = &gst_boot_grub_parse_cmd ($grub_conf, "rootnoverify", $entry); - $value = &gst_boot_grub_parse_cmd ($grub_conf, "root", $entry) if ($value eq undef); - return undef if $value eq undef; - - $value =~ /^\(([^\)]+)\)/; - $grubdev = $1; - - if ($grubdev eq undef) - { - $root = &gst_boot_grub_parse_cmd ($grub_conf, "root", $entry); - $root =~ /^\(([^\)]+)\)/; - $grubdev = $1; - } - - $dev = &gst_boot_grub_grub2system ($device_map, $grubdev); - return $dev; -} - -sub gst_boot_grub_parse_timeout -{ - my ($grub_conf) = @_; - my ($timeout); - - $timeout = &gst_boot_grub_parse_cmd ($grub_conf, "timeout"); - return undef if $timeout eq undef; - return $timeout * 10; -} - -sub gst_boot_grub_parse_prompt -{ - my ($grub_conf) = @_; - - return (&gst_boot_grub_parse_cmd ($grub_conf, "hiddenmenu"))? 0: 1; -} - -sub gst_boot_grub_parse_default -{ - my ($grub_conf) = @_; - my ($default, @entries); - - @entries = &gst_boot_grub_get_entries ($grub_conf); - return undef if (scalar @entries) == 0; - - $default = &gst_boot_grub_parse_cmd ($grub_conf, "default"); - $default = 0 if $default eq undef; - - return $entries[$default]; -} - -sub gst_boot_grub_parse_root -{ - my ($grub_conf, $device_map, $entry) = @_; - my ($value, $dev); - - # we check if there is the 'root' label, then extract root device from it - $value = &gst_boot_grub_parse_cmd ($grub_conf, "root", $entry); - if ($value ne undef) - { - $value =~ s/[()]//g; - return &gst_boot_grub_grub2system ($device_map, $value); - } - return undef; -} - -sub gst_boot_grub_parse_append -{ - my ($grub_conf, $entry) = @_; - my ($cmd); - - $cmd = &gst_boot_grub_parse_cmd ($grub_conf, "kernel", $entry); - return undef if $cmd eq undef; - - $cmd =~ s/^[^ \t]+[ \t]?//; - - return $cmd; -} - -sub gst_boot_grub_parse_type -{ - my ($grub_conf, $entry, $partition, $rootdev) = @_; - my ($line, $res, $buff, $line_no); - - $buff = &gst_file_buffer_load ($grub_conf); - return undef if $buff eq undef; - $line_no = 0; - return undef if &gst_boot_grub_search_entry ($buff, \$line_no, $entry) eq undef; - - $line_no ++; - while ($line_no < scalar (@$buff)) - { - $line = $$buff[$line_no]; - - last if &gst_boot_grub_line_is_title ($line) ne undef; - - if ($line =~ /^\#[ \t]*GstEntryType[ \t]+(.*)$/) - { - $res = $1; - last; - } - - $line_no ++; - } - - if ($res eq undef) - { - $rootdev =~ s/.*\///; - $res = $ {$$partition{$rootdev}}{"typestr"} if exists $$partition{$rootdev}; - } - return $res; -} - -sub gst_boot_grub_parse_initrd -{ - my ($grub_conf, $device_map, $mtab, $entry) = @_; - my ($initrd); - - $initrd = &gst_boot_grub_parse_file_cmd ($grub_conf, "initrd", $device_map, $mtab, $entry); - - return $initrd; -} - -sub gst_boot_grub_parse_module -{ - my ($grub_conf, $device_map, $mtab, $entry) = @_; - my ($module); - - $module = &gst_boot_grub_parse_file_cmd ($grub_conf, "module", $device_map, $mtab, $entry); - - return $module; -} - -sub gst_boot_grub_parse_password -{ - my ($grub_conf, $entry) = @_; - - return &gst_boot_grub_parse_cmd ($grub_conf, "password", $entry); -} - -# Watch it: this assumes that the entry exists. -sub gst_boot_grub_replace_cmd_in_buff -{ - my ($buff, $cmd, $value, $entry) = @_; - my ($line, $line_no); - my ($pre, $post); - $line_no = 0; - - if ($entry ne undef) - { - # Watch it: this assumes that the entry exists. - &gst_boot_grub_search_entry ($buff, \$line_no, $entry); - $line_no ++; - } - - if (&gst_boot_grub_search_cmd ($buff, \$line_no, $cmd)) - { - if ($value eq undef) - { - $$buff[$line_no] = ""; - } - else - { - $line = $$buff[$line_no]; - - $line =~ s/^([ \t]+)//; - $pre = $1; - - $line =~ s/([ \t]+)$//; - $post = $1; - - $line =~ s/^$cmd([= \t][ \t]*).*/$pre$cmd\1$value$post/; - $$buff[$line_no] = $line; - } - } - else - { - $cmd = "\t$cmd" if $entry ne undef; - &gst_boot_grub_insert_cmd ($buff, $line_no, $cmd, $value) if ($value ne undef); - } -} - -sub gst_boot_grub_replace_cmd -{ - my ($grub_conf, $cmd, $value, $entry) = @_; - $buff = &gst_file_buffer_load ($grub_conf); - $buff = [] if $buff eq undef; - - &gst_boot_grub_replace_cmd_in_buff ($buff, $cmd, $value, $entry); - - return &gst_file_buffer_save ($buff, $grub_conf); -} - -sub gst_boot_grub_get_stat -{ - my ($file, $field) = @_; - my (@tmp); - - @tmp = stat ($file); - return $tmp[$field]; -} - -sub gst_boot_grub_find_device -{ - my ($file) = @_; - my ($filedev, $dev, $res); - local *DIR; - - $res = undef; - $filedev = &gst_boot_grub_get_stat ($file, 0); - - opendir (DIR, "/dev"); - - while ($dev = readdir (DIR)) - { - $dev = "/dev/$dev"; - if ((-b $dev) && (&gst_boot_grub_get_stat ($dev, 6) eq $filedev)) - { - $res = $dev; - last; - } - } - - closedir (DIR); - return $res; -} - -sub gst_boot_grub_replace_file_cmd -{ - my ($grub_conf, $cmd, $device_map, $mtab, $value, $entry) = @_; - my ($grubdev, $file, $dev, $root); - my ($mntopts, $res, $dev, $dir, $oldval); - - $file = $value; - - $dev = &gst_boot_grub_find_device ($file); - $mntopts = &gst_parse_split_first_array ($mtab, $dev, "[ \t]+", "[ \t]+"); - $dir = $$mntopts[0]; - - $file =~ s/^$dir//; - $file =~ s/\/+/\//g; - - $grubdev = &gst_boot_grub_system2grub ($device_map, $dev); - - $res = "($grubdev)$file"; - - $oldval = &gst_boot_grub_parse_cmd ($grub_conf, $cmd, $entry); - $oldval =~ s/^[^ \t]+//; - $res .= $oldval; - - return &gst_boot_grub_replace_cmd ($grub_conf, $cmd, $res, $entry); -} - -sub gst_boot_grub_replace_pixmap -{ - my ($grub_conf, $device_map, $mtab, $value) = @_; - - return &gst_boot_grub_replace_file_cmd ($grub_conf, "splashimage", $device_map, $mtab, $value); -} - -sub gst_boot_grub_replace_image -{ - my ($grub_conf, $device_map, $mtab, $entry, $value) = @_; - - return &gst_boot_grub_replace_cmd ($grub_conf, "kernel", $value, $entry); -} - -sub gst_boot_grub_replace_other -{ - my ($grub_conf, $device_map, $entry, $value) = @_; - my ($grubdev); - - $grubdev = &gst_boot_grub_system2grub ($device_map, $value); - &gst_boot_grub_replace_cmd ($grub_conf, "rootnoverify", "($grubdev)", $entry); -# &gst_boot_grub_replace_cmd ($grub_conf, "makeactive", " ", $entry); - return &gst_boot_grub_replace_cmd ($grub_conf, "chainloader", "+1", $entry); -} - -sub gst_boot_grub_replace_timeout -{ - my ($grub_conf, $value) = @_; - my ($timeout); - - if ($value == -1 || $value eq undef) - { - return &gst_boot_grub_replace_cmd ($grub_conf, "timeout", undef); - } - - $timeout = int ($value / 10); - - return &gst_boot_grub_replace_cmd ($grub_conf, "timeout", $timeout); -} - -sub gst_boot_grub_replace_prompt -{ - my ($grub_conf, $value) = @_; - - return &gst_boot_grub_replace_cmd ($grub_conf, "hiddenmenu", ($value)? undef: " "); -} - -sub gst_boot_grub_replace_default -{ - my ($grub_conf, $entries, $value) = @_; - my ($default); - - return -1 if (scalar @$entries) == 0; - for ($default = 0; $default < scalar (@$entries); $default++) - { - last if $value eq $$entries[$default]{"label"}; - } - return -1 if $default == scalar (@$entries); # didn't find it. - return &gst_boot_grub_replace_cmd ($grub_conf, "default", $default); -} - -sub gst_boot_grub_replace_root -{ - my ($grub_conf, $device_map, $entry, $type, $value) = @_; - my ($root, $buff, $line_no, $entry_line, $currval, $root_dev); - - $root_dev = "(". &gst_boot_grub_system2grub ($device_map, $value) . ")"; - return &gst_boot_grub_replace_cmd ($grub_conf, "root", $root_dev, $entry); -} - -sub gst_boot_grub_replace_append -{ - my ($grub_conf, $device_map, $entry, $value) = @_; - my ($kernel, $append, $currval, $root); - - $kernel = &gst_boot_grub_parse_cmd ($grub_conf, "kernel", $entry); - $currval = &gst_boot_grub_parse_cmd ($grub_conf, "root", $entry); - $currval =~ s/[()]//g; - $root = &gst_boot_grub_grub2system ($device_map, $currval); - - $kernel .= " root=$root $value"; - return &gst_boot_grub_replace_cmd ($grub_conf, "kernel", $kernel, $entry); -} - -sub gst_boot_grub_replace_type -{ - my ($grub_conf, $entry, $value) = @_; - my ($buff, $line_no, $line, $res); - - $buff = &gst_file_buffer_load ($grub_conf); - $buff = [] if $buff eq undef; - $line_no = 0; - return -1 if &gst_boot_grub_search_entry ($buff, \$line_no, $entry) eq undef; - - $line_no ++; - while ($line_no < scalar (@$buff)) - { - $line = $$buff[$line_no]; - - last if &gst_boot_grub_line_is_title ($line) ne undef; - - if ($line =~ /^\#[ \t]*GstEntryType[ \t]+(.*)$/) - { - $res = $1; - last; - } - - $line_no ++; - } - - if ($res eq undef) - { - &gst_boot_grub_insert_cmd ($buff, $line_no, "#\tGstEntryType", $value); - } - else - { - $$buff[$line_no] =~ s/^(\#[ \t]*GstEntryType[ \t]+).*$/\1$value/; - } - - return &gst_file_buffer_save ($buff, $grub_conf); -} - -sub gst_boot_grub_replace_label -{ - my ($grub_conf, $entry, $value) = @_; - my ($buff, $line_no, $title); - - $buff = &gst_file_buffer_load ($grub_conf); - $buff = [] if $buff eq undef; - $line_no = 0; - - $title = &gst_boot_grub_search_entry ($buff, \$line_no, $entry); - if ($title eq undef) - { - $line_no ++; - &gst_boot_grub_insert_entry ($buff, \$line_no, $value); - } - else - { - $$buff[$line_no] =~ s/^title([= \t][ \t]*).*/title\1$value/; - } - - return &gst_file_buffer_save ($buff, $grub_conf); -} - -sub gst_boot_grub_check_device_map -{ - my ($file) = "$gst_prefix/boot/grub/device.map"; - my ($fd); - - if (! -f $file) - { - $fd = &gst_file_run_pipe_write ("grub --batch --device-map=$file"); - print $fd "quit\n"; - &gst_file_close ($fd); - } -} - -1; diff --git a/boot-lilo.pl.in b/boot-lilo.pl.in deleted file mode 100644 index 46f8e78..0000000 --- a/boot-lilo.pl.in +++ /dev/null @@ -1,597 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Boot manager configurator: LILO-related routines. -# -# Copyright (C) 2001 Ximian, Inc. -# -# Authors: Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; -require "$SCRIPTSDIR/partition.pl$DOTIN"; - -my @lilo_global_vars = qw (default prompt delay timeout append boot root); -my @lilo_common_image_vars = qw (label password); -my @lilo_image_vars = (@lilo_common_image_vars, qw (image append root vga initrd)); -my @lilo_other_vars = (@lilo_common_image_vars, qw (other)); - -sub gst_boot_lilo_verify_entrylabel -{ - my ($label) = @_; - - return "toolong" if length ($label) > 15; - $label =~ s/[\w!%^&*()_\-:;+\[\]{}?\/<>]//g; - return "badchar" if $label ne ""; - return "success"; -} - -sub gst_boot_lilo_verify -{ - my ($key, @values) = @_; - my ($i); - my %keymap = - ( - "entrylabel" => \&gst_boot_lilo_verify_entrylabel - ); - - return "notable" if not exists ($keymap{$key}); - return &{$keymap{$key}}(@values); -} - -sub gst_boot_lilo_known_var -{ - my $key = shift; - my $list = shift; - my $from_xml = shift; - - if (ref ($list) ne "ARRAY") - { - # TODO: Give warning; - return 0; - } - - $key = lc ($key); - - # Hard coded known variables which are not standard lilo.conf variables. - return 0 if ($key eq "key" && $from_xml); # "key" is valid in xml only. - return 0 if ($key eq "type" && $from_xml); # "key" is valid in xml only. - - return &gst_item_is_in_list ($key, @$list); -} - -sub gst_boot_lilo_parse_global_kw -{ - my ($file, $key) = @_; - my $fd; - - return undef unless &gst_boot_lilo_known_var ($key, \@lilo_global_vars, 0); - $fd = &gst_file_open_read_from_names ($file); - if (! $fd) - { - &gst_report ("boot_conf_read_failed", $file); - return undef; - } - - while (<$fd>) - { - chomp; - s/^[ \t]+//; - next if (/^\#/ || /^$/); - last if (/^(image|other)/); - - if ($key eq $_) - { - &gst_file_close ($fd); - return 1; - } - } - - &gst_file_close ($fd); - return undef; -} - - -sub gst_boot_lilo_parse_global -{ - my ($file, $key) = @_; - my ($fd, $line, $re); - - return undef unless &gst_boot_lilo_known_var ($key, \@lilo_global_vars, 0); - - $re = "[ \t]*=[ \t]*"; - $fd = &gst_file_open_read_from_names ($file); - if (! $fd) - { - &gst_report ("boot_conf_read_failed", $file); - return undef; - } - - while ($line = <$fd>) - { - chomp $line; - $line =~ s/^[ \t]+//; - $line = &gst_parse_process_sh_line ($line); - - next if ($line eq ""); - last if ($line =~ /^(image|other)/); - my @line = split ($re, $line, 2); - - if (shift (@line) eq $key) - { - &gst_file_close ($fd); - return $line[0]; - } - } - - &gst_file_close ($fd); - return undef; -} - -sub gst_boot_lilo_set_default_type -{ - my ($entry, $partition) = @_; - my ($dev, $type); - - $dev = $$entry{"root"}; - $dev = $$entry{"other"} if $dev eq undef; - $dev =~ s/.*\///; - - if (exists $$partition{$dev}) - { - $type = $ {$$partition{$dev}}{"typestr"}; - $$entry{"type"} = $type if $type ne undef; - } -} - -sub gst_boot_lilo_parse_entries -{ - my ($file, $partition) = @_; - my ($fd, $line, @entries, $entry); - my ($line, $known_vars, $found); - - $found = -1; - - $fd = &gst_file_open_read_from_names ($file); - if (! $fd) - { - &gst_report ("boot_conf_read_failed", $file); - return undef; - } - - while (($line = <$fd>)) - { - chomp $line; - $line =~ s/^[ \t]+//; - - if ($line =~ /^image/i) - { - $found++; - $known_vars = \@lilo_image_vars; - $entries[$found]{"key"} = $found; - } - elsif ($line =~ /^other/i) - { - $found++; - $known_vars = \@lilo_other_vars; - $entries[$found]{"key"} = $found; - } - - next if $found < 0; - - next if $line =~ /^\#/; - - $line = &gst_parse_process_sh_line ($line); - next if $line eq ""; - - my @line = split ("[ \t]*=[ \t]*", $line, 2); - my $key = shift @line; - - # Only deal with known variables - next unless &gst_boot_lilo_known_var ($key, $known_vars, 0); - - my $val = shift @line; - $val =~ s/^[ \t]+//; - $val =~ s/\"//g; - $val =~ s/[ \t]+$//; - - #if the variable is "vga", we append it to the "append" var - if ($key eq "vga") - { - $entries[$found]{"append"} .= " vga=" . $val. " "; - } - else - { - $entries[$found]{$key} = $val; - } - } - - &gst_file_close ($fd); - - foreach $entry (@entries) - { - &gst_boot_lilo_set_default_type ($entry, $partition); - } - - return \@entries; -} - - -sub gst_boot_lilo_replace_global_kw -{ - my ($file, $key) = @_; - my ($buff, $i, $found); - my $lineno = 0; - - return 0 unless &gst_boot_lilo_known_var ($key, \@lilo_global_vars, 0); - - $buff = &gst_file_buffer_load ($file); - $found = 0; - - foreach $i (@$buff) - { - if (&gst_ignore_line ($i)) - { - $lineno++; - next; - } - - if ($i =~ /^[ \t]*$key/) - { - $found++; - last; - } - - if ($i =~ /^[ \t]*(image|other)/) - { - $lineno--; # "pop" it back - last; - } - $lineno++; - } - - # Not found, let's add - if (!$found) - { - # pop back empty lines - while ($lineno > 0 && $$buff[$lineno] =~ /^\s*$/) - { - $lineno--; - } - - $$buff[$lineno] .= $key . "\n"; - } - - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); -} - -sub gst_boot_lilo_replace_global -{ - my ($file, $key, $val) = @_; - my ($buff, $i, $found); - my $quote = '"'; - my $lineno = 0; - - return 0 unless &gst_boot_lilo_known_var ($key, \@lilo_global_vars, 0); - - $val = "\"$val\"" if ($val =~ /[ \t]/ && (! ($val =~ /^\".+\"$/))); - $val = "\"$val\"" if ($val =~ /\=/ && (!($val =~ /^\".+\"$/))); - - $buff = &gst_file_buffer_load ($file); - $found = 0; - - foreach $i (@$buff) - { - if (&gst_ignore_line ($i)) - { - $lineno++; - next; - } - - if ($i =~ /^[ \t]*(image|other)/) - { - $lineno--; - last; - } - - if ($i =~ /^[ \t]*$key([ \t]*=[ \t]*)/) - { - $found++; - my $op = $1; - - chomp $i; - - my $pre_space = $1 if $i =~ s/^([ \t]+)//; - my $post_comment = $1 if $i =~ s/([ \t]*\#.*)//; - - $i = $pre_space . $key . $op . $val . $post_comment . "\n"; - last; - } - - $lineno++; - } - - if (!$found) - { - # pop back empty lines - while ($lineno > 0 && $$buff[$lineno] =~ /^\s*$/) - { - $lineno--; - } - - $$buff[$lineno] .= $key . " = " . $val . "\n"; - } - - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); -} - - -sub gst_boot_lilo_del_global -{ - my ($file, $key) = @_; - my ($buff, $i); - - return 0 unless &gst_boot_lilo_known_var ($key, \@lilo_global_vars, 0); - - $buff = &gst_file_buffer_load ($file); - - foreach $i (@$buff) - { - last if ($i =~ /^[ \t]*(image|other)/); - - if ($i =~ /^[ \t]*$key/) - { - $i = ""; - last; - } - } - - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); -} - - -# Scans @buff until finds first line which looks like entry. -# Returns line number or -1 if no entry found. -sub gst_boot_lilo_find_entry -{ - my ($buff, $lineno) = @_; - my $i; - - for (; $lineno <= $#$buff; $lineno++) - { - $i = $$buff[$lineno]; - - return $lineno if ($i =~ /^[ \t]*(image)|(other)[ \t]*=[ \t]*\S+/); - } - - # Not found. - return -1; -} - - -# Deletes lines from $buff starting from $lineno till the next entry -# or till end of the file if no more entries left. -sub gst_boot_lilo_delete_entry -{ - my ($buff, $lineno) = @_; - my ($end, $i); - - $end = &gst_boot_lilo_find_entry ($buff, $lineno + 1); - $end = scalar @$buff if ($end < 0); - - for ($i = $lineno; $i < $end; $i++) - { - $$buff[$i] = ""; - } - - return $buff; -} - - -# Edit entry in $buff which starts at $lineno. Get changes from $entry. -sub gst_boot_lilo_edit_entry -{ - my ($entry, $buff, $lineno) = @_; - - my $known_vars = \@lilo_image_vars if (exists $entry->{'image'}); - $known_vars = \@lilo_other_vars if (!$known_vars && exists $entry->{'other'}); - return $buff unless $known_vars; - - my $end = &gst_boot_lilo_find_entry ($buff, $lineno + 1); - $end = scalar @$buff if ($end < 0); - - # extract the "vga" var from the "append" var, this is done this way for - # compatibility with grub - if ($entry->{"append"} =~ /[ \t]*vga[ \t]*=[ \t]*(((0x)?[0-9][0-9][0-9]|ask))/) - { - $entry->{"vga"} = $1; - $entry->{"append"} =~ s/[ \t]*vga[ \t]*=[ \t]*((0x)?[0-9][0-9][0-9]|ask)//; - } - - for ($lineno; $lineno < $end; $lineno++) - { - # Get the variable. - my $key = $1 if ($$buff[$lineno] =~ /^[ \t]*([\w\-]+)/); - next if ($key && (!&gst_boot_lilo_known_var ($key, $known_vars, 0))); - next unless $key; - - unless (exists ($entry->{$key})) - { - # Keyword is known, but isn't in entry. - delete $$buff[$lineno]; - next; - } - - # Read old value - my $old_val = $$buff[$lineno]; - - $old_val =~ s/^[ \t]*$key[ \t]*=[ \t]*//; #everything till value - - $old_val =~ s/[ \t]*\#.*$//; #post comment; - chomp $old_val; - - if ($old_val) - { - # String. - my $val = $entry->{$key}; - $val = "\"$val\"" if ($val =~ /[ \t]/ && (! ($val =~ /^\".+\"$/))); - $val = "\"$val\"" if ($val =~ /\=/ && (!($val =~ /^\".+\"$/))); - - $$buff[$lineno] =~ s/$old_val/$val/; - } - - delete $entry->{$key}; - } - - # Add new fields. - foreach my $key (keys %$entry) - { - next unless &gst_boot_lilo_known_var ($key, $known_vars, 1); - - my $val = $entry->{$key}; - $val = "\"$val\"" if ($val =~ /[ \t]/ && (! ($val =~ /^\".+\"$/))); - $val = "\"$val\"" if ($val =~ /\=/ && (!($val =~ /^\".+\"$/))); - - my $line = "\t$key";; - - $line .= " = $val" if $val; - $line .= "\n"; - - $$buff[$end -1] .= $line; - } -} - - -# Add $entry to the end of $buff. -sub gst_boot_lilo_add_entry -{ - my ($entry, $buff) = @_; - my ($line, $key, $value, $known_vars); - - # Entry line - if (exists $entry->{'image'}) - { - $known_vars = \@lilo_image_vars; - $value = 'image'; - } - elsif (exists $entry->{'other'}) - { - $known_vars = \@lilo_other_vars; - $value = 'other'; - } - else - { - return; - } - - $line = $value . " = " . $$entry{$value} . "\n"; - push @$buff, $line; - delete $$entry{$value}; - - # extract the "vga" var from the "append" var, this is done this way for - # compatibility with grub - if ($entry->{"append"} =~ /[ \t]*vga[ \t]*=[ \t]*(((0x)?[0-9][0-9][0-9]|ask))/) - { - $entry->{"vga"} = $1; - $entry->{"append"} =~ s/[ \t]*vga[ \t]*=[ \t]*((0x)?[0-9][0-9][0-9]|ask)//; - } - - # Parameters for entry - foreach $key (keys %$entry) - { - next unless &gst_boot_lilo_known_var ($key, $known_vars, 1); - - $value = $$entry{$key}; - $value = "\"$value\"" if ($value =~ /[ \t]/ && (!($value =~ /^\".+\"$/))); - $value = "\"$value\"" if ($value =~ /\=/&& (!($value =~ /^\".+\"$/))); - - $line = "\t$key"; - - $line .= " = " . $value if $value; - $line .= "\n"; - - push @$buff, $line; - } -} - -sub gst_boot_lilo_entries_set -{ - my ($file, $entries) = @_; - my ($buff, $lineno, $found, $entry); - - return if (scalar @$entries <= 0); - - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); - - my $entry_nr = -1; - $lineno = &gst_boot_lilo_find_entry ($buff, 0); - while ($lineno > 0) - { - $entry_nr++; - $found = 0; - foreach $entry (@$entries) - { - next unless $entry; - - if (exists ($entry->{"key"})) - { - $found++ if $entry->{"key"} == $entry_nr; - - if ($found > 0) - { - # Found entry, change it if necessary, - # remove %entry from @entries and find new entry. - &gst_boot_lilo_edit_entry ($entry, $buff, $lineno); - $entry = undef; - last; - } - } - } - - # Found entry wasn't in our @entries list: delete. - $buff = &gst_boot_lilo_delete_entry ($buff, $lineno) if ($found <= 0); - - # Search new entry line. - $lineno = &gst_boot_lilo_find_entry ($buff, $lineno + 1); - } - - # At this point @entries contains only new entries, let's add them. - foreach $entry (@$entries) - { - &gst_boot_lilo_add_entry ($entry, $buff); - } - - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); -} - diff --git a/boot-yaboot.pl.in b/boot-yaboot.pl.in deleted file mode 100644 index 85293f5..0000000 --- a/boot-yaboot.pl.in +++ /dev/null @@ -1,349 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Boot manager configurator: YABOOT-related routines. -# -# Copyright (C) 2001 Ximian, Inc. -# -# Authors: Carlos Garnacho Parro <garnacho@tuxerver.net> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; -require "$SCRIPTSDIR/partition.pl$DOTIN"; - -my @yaboot_global_vars = qw (default prompt delay timeout append boot root); -my @yaboot_image_vars = qw (label image append initrd root); -my @yaboot_other_vars = qw (bsd macos macosx darwin); - -sub gst_boot_yaboot_verify -{ - return "success"; -} - -sub gst_boot_yaboot_parse_entries -{ - my ($file, $partition, $root) = @_; - my ($fd, $line, @entries, $entry); - my ($line, $known_vars, $found); - - $found = -1; - - $fd = &gst_file_open_read_from_names ($file); - if (! $fd) - { - &gst_report ("boot_conf_read_failed", $file); - return undef; - } - - while (($line = <$fd>)) - { - chomp $line; - $line =~ s/^[ \t]+//; - - if ($line =~ /^image/i) - { - $found++; - $known_vars = \@yaboot_image_vars; - $entries[$found]{"key"} = $found; - } - elsif ($line =~ /^(bsd|macos|macosx|darwin)/) - { - $found++; - $known_vars = \@yaboot_other_vars; - $entries[$found]{"key"} = $found; - } - - next if $found < 0; - - next if $line =~ /^\#/; - - $line = &gst_parse_process_sh_line ($line); - next if $line eq ""; - - my @line = split ("[ \t]*=[ \t]*", $line, 2); - my $key = shift @line; - - # Only deal with known variables - next unless &gst_boot_lilo_known_var ($key, $known_vars, 0); - - my $val = shift @line; - $val =~ s/^[ \t]+//; - $val =~ s/\"//g; - $val =~ s/[ \t]+$//; - - if ($key =~ /^(bsd|macos|macosx|darwin)$/) - { - $entries[$found]{"label"} = $key; - $key = "other"; - } - - $entries[$found]{$key} = $val; - - # the root parameter may not exist, then we take the global parameter - if (($entries[$found]{"root"} eq undef) && ($entries[$found]{"image"} ne undef)) - { - $entries[$found]{"root"} = $root; - } - } - - &gst_file_close ($fd); - - foreach $entry (@entries) - { - &gst_boot_lilo_set_default_type ($entry, $partition); - } - - return \@entries; -} - -sub gst_boot_yaboot_find_entry -{ - my ($buff, $lineno) = @_; - my $i; - - for (; $lineno <= $#$buff; $lineno++) - { - $i = $$buff[$lineno]; - - return $lineno if ($i =~ /^[ \t]*(image|bsd|macos|macosx|darwin)[ \t]*=[ \t]*\S+/); - } - - # Not found. - return -1; -} - -sub gst_boot_yaboot_delete_entry -{ - my ($buff, $lineno) = @_; - my ($end, $i); - - $end = &gst_boot_yaboot_find_entry ($buff, $lineno + 1); - $end = scalar @$buff if ($end < 0); - - for ($i = $lineno; $i < $end; $i++) - { - $$buff[$i] = ""; - } - - return $buff; -} - -sub gst_boot_yaboot_edit_entry -{ - my ($entry, $buff, $lineno) = @_; - - my $known_vars = \@yaboot_image_vars if (exists $entry->{'image'}); - $known_vars = \@yaboot_other_vars if (!$known_vars && exists $entry->{'other'}); - return $buff unless $known_vars; - - my $end = &gst_boot_yaboot_find_entry ($buff, $lineno + 1); - $end = scalar @$buff if ($end < 0); - - for ($lineno; $lineno < $end; $lineno++) - { - # Get the variable. - my $key = $1 if ($$buff[$lineno] =~ /^[ \t]*([\w\-]+)/); - next if ($key && (!&gst_boot_lilo_known_var ($key, $known_vars, 0))); - next unless $key; - - if (exists ($entry->{"other"})) - { - my $old_val = $$buff[$lineno]; - $old_val =~ s/^[ \t]*$key[ \t]*=[ \t]*//; #everything till value - $old_val =~ s/[ \t]*\#.*$//; #post comment; - chomp $old_val; - - if ($old_val) - { - # String. - my $val = $entry->{"other"}; - $val = "\"$val\"" if ($val =~ /[ \t]/ && (! ($val =~ /^\".+\"$/))); - $val = "\"$val\"" if ($val =~ /\=/ && (!($val =~ /^\".+\"$/))); - - $$buff[$lineno] =~ s/$old_val/$val/; - } - } - else - { - unless (exists ($entry->{$key})) - { - # Keyword is known, but isn't in entry. - delete $$buff[$lineno]; - next; - } - - # Read old value - my $old_val = $$buff[$lineno]; - - $old_val =~ s/^[ \t]*$key[ \t]*=[ \t]*//; #everything till value - $old_val =~ s/[ \t]*\#.*$//; #post comment; - chomp $old_val; - - if ($old_val) - { - # String. - my $val = $entry->{$key}; - $val = "\"$val\"" if ($val =~ /[ \t]/ && (! ($val =~ /^\".+\"$/))); - $val = "\"$val\"" if ($val =~ /\=/ && (!($val =~ /^\".+\"$/))); - - $$buff[$lineno] =~ s/$old_val/$val/; - } - - delete $entry->{$key}; - } - } - - # Add new fields. - foreach my $key (keys %$entry) - { - next unless &gst_boot_lilo_known_var ($key, $known_vars, 1); - - my $val = $entry->{$key}; - $val = "\"$val\"" if ($val =~ /[ \t]/ && (! ($val =~ /^\".+\"$/))); - $val = "\"$val\"" if ($val =~ /\=/ && (!($val =~ /^\".+\"$/))); - - my $line = "\t$key";; - - $line .= " = $val" if $val; - $line .= "\n"; - - $$buff[$end -1] .= $line; - } -} - -# Add $entry to the end of $buff. -sub gst_boot_yaboot_add_entry -{ - my ($entry, $buff) = @_; - my ($line, $key, $value, $known_vars); - - # Entry line - if (exists $entry->{'image'}) - { - $known_vars = \@yaboot_image_vars; - $value = 'image'; - - $line = $value . " = " . $$entry{$value} . "\n"; - } - elsif (exists $entry->{'other'}) - { - $known_vars = \@yaboot_other_vars; - - # FIXME: this is a really terrible hack, the xml needs to be redesigned - if ($entry->{'label'} =~ /(macos|macosx|bsd|darwin)/) - { - $value = $entry->{'label'}; - } - else - { - $value = 'macosx'; - } - - $line = $value . " = " . $$entry{"other"} . "\n"; - } - else - { - return; - } - - push @$buff, $line; - delete $$entry{$value}; - - # Parameters for entry - foreach $key (keys %$entry) - { - next unless &gst_boot_lilo_known_var ($key, $known_vars, 1); - - $value = $$entry{$key}; - $value = "\"$value\"" if ($value =~ /[ \t]/ && (!($value =~ /^\".+\"$/))); - $value = "\"$value\"" if ($value =~ /\=/&& (!($value =~ /^\".+\"$/))); - - $line = "\t$key"; - - $line .= " = " . $value if $value; - $line .= "\n"; - - push @$buff, $line; - } -} - -sub gst_boot_yaboot_entries_set -{ - my ($file, $entries) = @_; - my ($buff, $lineno, $found, $entry); - - return if (scalar @$entries <= 0); - - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); - - my $entry_nr = -1; - $lineno = &gst_boot_yaboot_find_entry ($buff, 0); - - while ($lineno > 0) - { - $entry_nr++; - $found = 0; - - foreach $entry (@$entries) - { - next unless $entry; - - if (exists ($entry->{"key"})) - { - $found++ if $entry->{"key"} == $entry_nr; - - if ($found > 0) - { - # Found entry, change it if necessary, - # remove %entry from @entries and find new entry. - &gst_boot_yaboot_edit_entry ($entry, $buff, $lineno); - $entry = undef; - last; - } - } - } - - # Found entry wasn't in our @entries list: delete. - $buff = &gst_boot_yaboot_delete_entry ($buff, $lineno) if ($found <= 0); - - # Search new entry line. - $lineno = &gst_boot_yaboot_find_entry ($buff, $lineno + 1); - } - - # At this point @entries contains only new entries, let's add them. - foreach $entry (@$entries) - { - next if ($entry eq undef); - &gst_boot_yaboot_add_entry ($entry, $buff); - } - - &gst_file_buffer_clean ($buff); - return &gst_file_buffer_save ($buff, $file); -} diff --git a/boot.pl.in b/boot.pl.in deleted file mode 100644 index 66ac661..0000000 --- a/boot.pl.in +++ /dev/null @@ -1,506 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Boot manager configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Tambet Ingo <tambet@ximian.com> -# Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; -require "$SCRIPTSDIR/boot-grub.pl$DOTIN"; -require "$SCRIPTSDIR/boot-lilo.pl$DOTIN"; -require "$SCRIPTSDIR/boot-yaboot.pl$DOTIN"; - -# ---------------------------------------------------------------------------- -# Fix functions. -# -# The main reason for these functions is to add default values to xml so the -# frontend doesn't have to know anything about lilo or its defaults. - -sub gst_boot_fix_default -{ - my ($hash) = @_; - my ($entries, $found, $entry); - - $entries = $$hash{"entry"}; - return unless $entries; - - # 'default' - if (exists ($$hash{"default"})) - { - # Check if valid - foreach $entry (@$entries) - { - if ($$hash{"default"} eq $$entry{"label"}) - { - $found = 1; - last; - } - } - delete $$hash{"default"} unless $found; - } - - if (not exists ($$hash{"default"})) - { - # No 'default', let's add - foreach $entry (@$entries) - { - if ($$hash{"key"} == 0) - { - $$hash{"default"} = $$entry{"label"}; - last; - } - } - } -} - -# Internal. Should be run after fix_entries. -sub gst_boot_fix_globals -{ - my ($hash) = @_; - - return unless $hash; - &gst_boot_fix_default ($hash); -} - -# Internal -sub gst_boot_fix_entry -{ - my ($entry) = @_; - my ($name); - - return unless $entry; - - $name = $$entry{"image"} if exists $$entry{"image"}; - $name = $$entry{"other"} if (!$name && exists $$entry{"other"}); - - # Remove entries without entry identifier 'entry' or 'other'. - unless ($name) { - undef $entry; - return; - } - - # Add 'label' field which is optional in lilo.conf - unless (exists $$entry{"label"}) - { - $$entry{"label"} = $1 if ($name =~ /\S+\/(\S+)$/); - } -} - -# Internal -sub gst_boot_fix_entries -{ - my ($hash) = @_; - my ($entries, $entry); - - return unless $hash; - - $entries = $$hash{"entry"}; - return unless $entries; - - foreach $entry (@$entries) - { - &gst_boot_fix_entry ($entry); - } -} - -sub gst_boot_fix -{ - my ($hash) = @_; - - return unless $hash; - - &gst_boot_fix_entries ($hash); - &gst_boot_fix_globals ($hash); -} - -# -------------------------------------------------------- - -sub gst_boot_bootloader_list -{ - my (@list); - - if (gst_file_locate_tool ("lilo")) - { - push @list, { "name" => "LILO", - "exec" => "lilo" }; - } - - if (gst_file_locate_tool ("grub-install")) - { - push @list, { "name" => "Grub", - "exec" => "grub" }; - } - - if (gst_file_locate_tool ("ybin")) - { - push @list, { "name" => "YaBoot", - "exec" => "yaboot" }; - } - - return (scalar @list, { "bootloaders" => { "bootloader" => \@list }}); -} - -sub gst_boot_bootloader_get -{ - my ($current_tool, $current_date, $bootl, $date); - - $current_date = 0; - $bootl = gst_file_locate_tool ("lilo"); - if ($bootl ne "") - { - $date = (stat ($bootl)) [8]; - if ($date > $current_date) - { - $current_date = $date; - $current_tool = "lilo"; - } - } - - $bootl = gst_file_locate_tool ("grub-install"); - if ($bootl ne "") - { - $date = (stat ($bootl)) [8]; - if ($date > $current_date) - { - $current_date = $date; - $current_tool = "grub"; - } - } - - $bootl = gst_file_locate_tool ("ybin"); - if ($bootl ne "") - { - $date = (stat ($bootl)) [8]; - if ($date > $current_date) - { - $current_date = $date; - $current_tool = "yaboot"; - } - } - - if ($current_date eq 0) - { - &gst_report ("platform_no_bootloader", $main::gst_dist); - return undef; - } - return $current_tool; -} - - -sub gst_boot_entries_get -{ - my ($partition) = @_; - my (%dist_attrib, @res, %fn, @entries, $entry); - my ($dist, $value, $file, $proc); - my ($entry, $j, $key, $tmp); - - %dist_attrib = &gst_boot_get_entry_parse_table (); - %fn = %{$dist_attrib{"fn"}}; - $proc = $dist_attrib{"entries_get"}; - @entries = &$proc (\%fn); - - &gst_boot_grub_check_device_map (); - - ${$dist_attrib{"fn"}}{"PARTITION"} = $partition; - - $key = 0; - foreach $entry (@entries) - { - foreach $j (keys (%fn)) - { - $tmp = &gst_parse_expand ($fn{$j}, "key", $key); - $ {$dist_attrib{"fn"}}{$j} = &gst_parse_expand ($tmp, "label", $entry); - } - - $entry = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - - if (exists ($$entry {"image"})) - { - # this is filled even when it's a linux style entry, delete it - delete $$entry {"other"}; - push @res, $entry; - } - elsif (exists ($$entry {"other"})) - { - # this may be filled, but it's not necessary - delete $$entry {"root"}; - push @res, $entry; - } - - $key++; - } - - return \@res; -} - - -sub gst_boot_conf_get -{ - my ($bootl) = @_; - my $config_file = &gst_boot_grub_get_config_file (); - my %tool_tables = - ( - "lilo" => - { - fn => - { - LILO_CONF => "/etc/lilo.conf" - }, - table => - [ - [ "partitions", \&gst_partition_scan_info ], -# [ "pixmapsup", \&gst_parse_trivial, 0 ], - [ "timeout", \&gst_boot_lilo_parse_global, LILO_CONF, "delay" ], - [ "prompt", \&gst_boot_lilo_parse_global_kw, LILO_CONF, "prompt" ], - [ "default", \&gst_boot_lilo_parse_global, LILO_CONF, "default" ], - [ "boot", \&gst_boot_lilo_parse_global, LILO_CONF, "boot" ], -# [ "root", \&gst_boot_lilo_parse_global, LILO_CONF, "root" ], - [ "entry", \&gst_boot_lilo_parse_entries, LILO_CONF, "%partitions%" ], - ] - }, - - "grub" => - { - fn => - { - GRUB_CONF => $config_file, - DEVICE_MAP => "/boot/grub/device.map", -# MTAB => "/etc/mtab" - }, - table => - [ - [ "partitions", \&gst_partition_scan_info ], -# [ "pixmapsup", \&gst_parse_trivial, 1 ], -# [ "pixmap", \&gst_boot_grub_parse_pixmap, [GRUB_CONF, DEVICE_MAP, MTAB] ], - [ "timeout", \&gst_boot_grub_parse_timeout, GRUB_CONF ], - [ "prompt", \&gst_boot_grub_parse_prompt, GRUB_CONF ], - [ "default", \&gst_boot_grub_parse_default, GRUB_CONF ], - [ "entry", \&gst_boot_entries_get, "%partitions%" ], - ] - }, - - "yaboot" => - { - fn => - { - YABOOT_CONF => "/etc/yaboot.conf", - }, - table => - [ - [ "partitions", \&gst_partition_scan_info ], - [ "timeout", \&gst_boot_lilo_parse_global, YABOOT_CONF, "timeout" ], - [ "default", \&gst_boot_lilo_parse_global, YABOOT_CONF, "default" ], - [ "boot", \&gst_boot_lilo_parse_global, YABOOT_CONF, "boot" ], - [ "root", \&gst_boot_lilo_parse_global, YABOOT_CONF, "root" ], - [ "entry", \&gst_boot_yaboot_parse_entries, YABOOT_CONF, "%partitions%", "%root%" ] - ] - } - ); - - return &gst_parse_from_table ($ {$tool_tables{$bootl}}{"fn"}, - $ {$tool_tables{$bootl}}{"table"}); -} - -sub gst_boot_get_entry_parse_table -{ - my $config_file = &gst_boot_grub_get_config_file (); - my %tool_tables = - ( - entries_get => \&gst_boot_grub_get_entries_fn, - fn => - { - KEY => "#key#", - LABEL => "#label#", - GRUB_CONF => $config_file, - DEVICE_MAP => "/boot/grub/device.map", - MTAB => "/etc/mtab" - }, - table => - [ - ["key", \&gst_parse_trivial, [KEY]], - ["label", \&gst_parse_trivial, [LABEL]], - ["root", \&gst_boot_grub_parse_root, [GRUB_CONF, DEVICE_MAP, KEY]], - ["type", \&gst_boot_grub_parse_type, [GRUB_CONF, KEY, PARTITION], "%root%"], - ["image", \&gst_boot_grub_parse_image, [GRUB_CONF, DEVICE_MAP, MTAB, KEY]], - ["other", \&gst_boot_grub_parse_other, [GRUB_CONF, DEVICE_MAP, MTAB, KEY]], - ["append", \&gst_boot_grub_parse_append, [GRUB_CONF, KEY]], - ["initrd", \&gst_boot_grub_parse_initrd, [GRUB_CONF, DEVICE_MAP, MTAB, KEY]], - ["module", \&gst_boot_grub_parse_module, [GRUB_CONF, DEVICE_MAP, MTAB, KEY]], - ["password", \&gst_boot_grub_parse_password, [GRUB_CONF, KEY]] - ] - ); - - return %tool_tables; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_boot_entry_set -{ - my ($dist_attrib, $values_hash) = @_; - my ($j, %fn, $res); - - %fn = %{$$dist_attrib{"fn"}}; - foreach $j (keys (%fn)) - { - $fn{$j} = &gst_parse_expand ($ {$$dist_attrib{"fn"}}{$j}, "key", $$values_hash{"key"}); - } - - return &gst_replace_from_table (\%fn, $$dist_attrib{"table"}, $values_hash); -} - -sub gst_boot_entries_set -{ - my ($entries) = @_; - my (%dist_attrib, %fn, @old, @new, @del); - my ($i, $proc, $entry); - my ($tmp, $res); - %dist_attrib = &gst_boot_get_entry_replace_table (); - %fn = %{$dist_attrib{"fn"}}; - - foreach $entry (@$entries) - { - $new[$$entry{"key"}] = $entry; - } - $proc = $dist_attrib{"entries_get"}; - @old = &$proc (\%fn); - - for ($i = 0; $i < &gst_max (scalar @old, scalar @$entries); $i++) - { - if ($new[$i] ne undef) - { - $tmp = &gst_boot_entry_set (\%dist_attrib, $new[$i]); - $res = $tmp if !$res; - } - else - { - push @del, $i; - } - } - - # Delete all old entries that are not in the hash. - $proc = $dist_attrib{"entries_del"}; - $tmp = &$proc (\%fn, \@del); - $res = $tmp if !$res; - - return $res; -} - -sub gst_boot_conf_set -{ - my $values_hash = $_[0]; - my $config_file = &gst_boot_grub_get_config_file (); - $bootl = &gst_boot_bootloader_get (); - - my %tool_tables = - ( - "lilo" => { - fn => { LILO_CONF => "/etc/lilo.conf"}, - table => [ - [ "boot", \&gst_boot_lilo_replace_global, LILO_CONF, "boot" ], -# [ "root", \&gst_boot_lilo_replace_global, LILO_CONF, "root" ], - [ "timeout", \&gst_boot_lilo_replace_global, LILO_CONF, "timeout" ], - [ "timeout", \&gst_boot_lilo_replace_global, LILO_CONF, "delay" ], - [ "prompt", \&gst_boot_lilo_replace_global_kw, LILO_CONF, "prompt" ], - [ "default", \&gst_boot_lilo_replace_global, LILO_CONF, "default" ], - [ "entry", \&gst_boot_lilo_entries_set, LILO_CONF ], - ] - }, - - "grub" => - { - fn => - { - GRUB_CONF => $config_file, - DEVICE_MAP => "/boot/grub/device.map", - MTAB => "/etc/mtab" - }, - table => - [ - # [ "pixmap", \&gst_boot_grub_replace_pixmap, [GRUB_CONF, DEVICE_MAP, MTAB] ], - [ "timeout", \&gst_boot_grub_replace_timeout, GRUB_CONF ], - [ "prompt", \&gst_boot_grub_replace_prompt, GRUB_CONF ], - [ "default", \&gst_boot_grub_replace_default, GRUB_CONF , "%entry%"], - [ "entry", \&gst_boot_grub_entries_set, [GRUB_CONF, DEVICE_MAP, MTAB] ], - ] - }, - - "yaboot" => - { - fn => { YABOOT_CONF => "/etc/yaboot.conf" }, - table => - [ - [ "boot", \&gst_boot_lilo_replace_global, YABOOT_CONF, "boot" ], - [ "timeout", \&gst_boot_lilo_replace_global, YABOOT_CONF, "timeout" ], - [ "default", \&gst_boot_lilo_replace_global, YABOOT_CONF, "default" ], - [ "entry", \&gst_boot_yaboot_entries_set, YABOOT_CONF ], - ] - } - ); - - return &gst_replace_from_table ($ {$tool_tables{$bootl}}{"fn"}, - $ {$tool_tables{$bootl}}{"table"}, $values_hash); -} - -sub gst_boot_get_entry_replace_table -{ - my $config_file = &gst_boot_grub_get_config_file (); - my %tool_tables = - ( - entries_get => \&gst_boot_grub_get_entries_fn, - entries_del => \&gst_boot_grub_remove_entries, - fn => - { - KEY => "#key#", - GRUB_CONF => $config_file, - DEVICE_MAP => "/boot/grub/device.map", - MTAB => "/etc/mtab" - }, - table => - [ - # label has to go first, because it creates the entry if non-existent. - ["label", \&gst_boot_grub_replace_label, [GRUB_CONF, KEY]], -# ["type", \&gst_boot_grub_replace_type, [GRUB_CONF, KEY]], - ["root", \&gst_boot_grub_replace_root, [GRUB_CONF, DEVICE_MAP, KEY, "%type%"]], - ["image", \&gst_boot_grub_replace_image, [GRUB_CONF, DEVICE_MAP, MTAB, KEY]], - ["other", \&gst_boot_grub_replace_other, [GRUB_CONF, DEVICE_MAP, KEY]], - ["append", \&gst_boot_grub_replace_append, [GRUB_CONF, DEVICE_MAP, KEY]], - ] - ); - return %tool_tables; -} - - @@ -1,35 +1,246 @@ #! /bin/sh - # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# Generated by GNU Autoconf 2.59 for system-tools-backends 1.9.0. # +# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help - --enable-shared[=PKGS] build shared libraries [default=yes]" -ac_help="$ac_help - --enable-static[=PKGS] build static libraries [default=yes]" -ac_help="$ac_help - --enable-fast-install[=PKGS] optimize for fast installation [default=yes]" -ac_help="$ac_help - --with-gnu-ld assume the C compiler uses GNU ld [default=no]" - -# Find the correct PATH separator. Usually this is `:', but -# DJGPP uses `;' like DOS. -if test "X${PATH_SEPARATOR+set}" != Xset; then - UNAME=${UNAME-`uname 2>/dev/null`} - case X$UNAME in - *-DOS) lt_cv_sys_path_separator=';' ;; - *) lt_cv_sys_path_separator=':' ;; +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false fi +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} @@ -48,7 +259,7 @@ if test "X$1" = X--no-reexec; then elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then # Yippee, $echo works! : else @@ -60,22 +271,22 @@ if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <<EOF - +$* EOF exit 0 fi # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. -if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test -z "$ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if (echo_test_string="`eval $cmd`") 2>/dev/null && - echo_test_string="`eval $cmd`" && + if (echo_test_string=`eval $cmd`) 2>/dev/null && + echo_test_string=`eval $cmd` && (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null then break @@ -94,8 +305,9 @@ else # # So, first we look for a working echo in the user's PATH. - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && @@ -104,7 +316,7 @@ else break fi done - IFS="$save_ifs" + IFS="$lt_save_ifs" if test "X$echo" = Xecho; then # We didn't find a better echo, so look for alternatives. @@ -177,20 +389,90 @@ if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then fi -ac_help="$ac_help - --disable-libtool-lock avoid locking (might break parallel builds)" -ac_help="$ac_help - --with-pic try to use only PIC/non-PIC objects [default=use both]" + + +tagnames=${tagnames+${tagnames},}CXX + +tagnames=${tagnames+${tagnames},}F77 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME='system-tools-backends' +PACKAGE_TARNAME='system-tools-backends' +PACKAGE_VERSION='1.9.0' +PACKAGE_STRING='system-tools-backends 1.9.0' +PACKAGE_BUGREPORT='' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# if HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#if HAVE_STRINGS_H +# include <strings.h> +#endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL scriptsdir filesdir DBUS_SERVICES_DIR LIBOBJS LTLIBOBJS' +ac_subst_files='' # Initialize some variables set by options. +ac_init_help= +ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. -build=NONE -cache_file=./config.cache +cache_file=/dev/null exec_prefix=NONE -host=NONE no_create= -nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE @@ -199,10 +481,15 @@ program_transform_name=s,x,x, silent= site= srcdir= -target=NONE verbose= x_includes=NONE x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' @@ -216,17 +503,9 @@ oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - ac_prev= for ac_option do - # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" @@ -234,59 +513,59 @@ do continue fi - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case "$ac_option" in + case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; + bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) - ac_prev=build ;; + ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; + build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) - datadir="$ac_optarg" ;; + datadir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "enable_${ac_feature}='$ac_optarg'" ;; + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -295,95 +574,47 @@ do -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; + exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; -host | --host | --hos | --ho) - ac_prev=host ;; + ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; + host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; + includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; + infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; + libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; + libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ @@ -392,19 +623,19 @@ EOF -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; + localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; + mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) + | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ @@ -418,26 +649,26 @@ EOF -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; + oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; + prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; + program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; + program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ @@ -454,7 +685,7 @@ EOF | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; + program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) @@ -464,7 +695,7 @@ EOF ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; + sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ @@ -475,58 +706,57 @@ EOF | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; + sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; + site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; + srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; + sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; + ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; + target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "with_${ac_package}='$ac_optarg'" ;; + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -537,99 +767,110 @@ EOF ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; + x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; + x_libraries=$ac_optarg ;; - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } fi -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac done -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=configure.in # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. @@ -639,13 +880,514 @@ else fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } fi fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP +ac_env_CXX_set=${CXX+set} +ac_env_CXX_value=$CXX +ac_cv_env_CXX_set=${CXX+set} +ac_cv_env_CXX_value=$CXX +ac_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_env_CXXFLAGS_value=$CXXFLAGS +ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_cv_env_CXXFLAGS_value=$CXXFLAGS +ac_env_CXXCPP_set=${CXXCPP+set} +ac_env_CXXCPP_value=$CXXCPP +ac_cv_env_CXXCPP_set=${CXXCPP+set} +ac_cv_env_CXXCPP_value=$CXXCPP +ac_env_F77_set=${F77+set} +ac_env_F77_value=$F77 +ac_cv_env_F77_set=${F77+set} +ac_cv_env_F77_value=$F77 +ac_env_FFLAGS_set=${FFLAGS+set} +ac_env_FFLAGS_value=$FFLAGS +ac_cv_env_FFLAGS_set=${FFLAGS+set} +ac_cv_env_FFLAGS_value=$FFLAGS + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures system-tools-backends 1.9.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of system-tools-backends 1.9.0:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-shared[=PKGS] + build shared libraries [default=yes] + --enable-static[=PKGS] + build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors + --disable-libtool-lock avoid locking (might break parallel builds) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-tags[=TAGS] + include additional configurations [automatic] + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have + headers in a nonstandard directory <include dir> + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + F77 Fortran 77 compiler command + FFLAGS Fortran 77 compiler flags + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd "$ac_popdir" + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF +system-tools-backends configure 1.9.0 +generated by GNU Autoconf 2.59 + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by system-tools-backends $as_me 1.9.0, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then @@ -656,44 +1398,115 @@ if test -z "$CONFIG_SITE"; then fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi else - echo "creating cache $cache_file" - > $cache_file + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file fi -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac fi -else - ac_n= ac_c='\c' ac_t= +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + + + + + + + ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do +for ac_dir in . $srcdir/.; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" @@ -702,15 +1515,24 @@ for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break fi done if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in . $srcdir/." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in . $srcdir/." >&2;} + { (exit 1); exit 1; }; } fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + + ac_config_headers="$ac_config_headers config.h" +am__api_version="1.7" # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -718,484 +1540,1216 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:727: checking for a BSD compatible install" >&5 +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 fi fi done - ;; - esac - done - IFS="$ac_save_IFS" + done + ;; +esac +done + fi if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" + INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. - INSTALL="$ac_install_sh" + INSTALL=$ac_install_sh fi fi -echo "$ac_t""$INSTALL" 1>&6 +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:780: checking whether build environment is sane" >&5 +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 # Just in case sleep 1 -echo timestamp > conftestfile +echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. - set X `ls -t $srcdir/configure conftestfile` + set X `ls -t $srcdir/configure conftest.file` fi - if test "$*" != "X $srcdir/configure conftestfile" \ - && test "$*" != "X conftestfile $srcdir/configure"; then + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". - { echo "configure: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" 1>&2; exit 1; } + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } fi - test "$2" = conftestfile + test "$2" = conftest.file ) then # Ok. : else - { echo "configure: error: newly created file is older than distributed files! -Check your system clock" 1>&2; exit 1; } -fi -rm -f conftest* -echo "$ac_t""yes" 1>&6 -if test "$program_transform_name" = s,x,x,; then - program_transform_name= -else - # Double any \ or $. echo might interpret backslashes. - cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g -EOF_SED - program_transform_name="`echo $program_transform_name|sed -f conftestsed`" - rm -f conftestsed + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 test "$program_prefix" != NONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" + program_transform_name="s,^,$program_prefix,;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && - program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi -# sed with no file args requires a program. -test "$program_transform_name" = "" && program_transform_name="s,x,x," +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:837: checking whether ${MAKE-make} sets \${MAKE}" >&5 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 else - cat > conftestmake <<\EOF + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF all: - @echo 'ac_maketemp="${MAKE}"' -EOF + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi -rm -f conftestmake +rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$ac_t""yes" 1>&6 + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 SET_MAKE= else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + + # test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi -PACKAGE=setup-tool-backends +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi -VERSION=0.6.1 -if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then - { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } -fi -cat >> confdefs.h <<EOF +# Define the identity of the package. + PACKAGE=system-tools-backends + VERSION=1.9.0 + + +cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" -EOF +_ACEOF + -cat >> confdefs.h <<EOF +cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" -EOF +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} -missing_dir=`cd $ac_aux_dir && pwd` -echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:883: checking for working aclocal" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (aclocal --version) < /dev/null > /dev/null 2>&1; then - ACLOCAL=aclocal - echo "$ac_t""found" 1>&6 + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ACLOCAL="$missing_dir/missing aclocal" - echo "$ac_t""missing" 1>&6 -fi + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:896: checking for working autoconf" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoconf --version) < /dev/null > /dev/null 2>&1; then - AUTOCONF=autoconf - echo "$ac_t""found" 1>&6 +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 else - AUTOCONF="$missing_dir/missing autoconf" - echo "$ac_t""missing" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:909: checking for working automake" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (automake --version) < /dev/null > /dev/null 2>&1; then - AUTOMAKE=automake - echo "$ac_t""found" 1>&6 -else - AUTOMAKE="$missing_dir/missing automake" - echo "$ac_t""missing" 1>&6 fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done -echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:922: checking for working autoheader" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoheader --version) < /dev/null > /dev/null 2>&1; then - AUTOHEADER=autoheader - echo "$ac_t""found" 1>&6 + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 else - AUTOHEADER="$missing_dir/missing autoheader" - echo "$ac_t""missing" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:935: checking for working makeinfo" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (makeinfo --version) < /dev/null > /dev/null 2>&1; then - MAKEINFO=makeinfo - echo "$ac_t""found" 1>&6 + STRIP=$ac_ct_STRIP else - MAKEINFO="$missing_dir/missing makeinfo" - echo "$ac_t""missing" 1>&6 + STRIP="$ac_cv_prog_STRIP" fi +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. - echo $ac_n "checking for strerror in -lcposix""... $ac_c" 1>&6 -echo "configure:951: checking for strerror in -lcposix" >&5 -ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac else - ac_save_LIBS="$LIBS" -LIBS="-lcposix $LIBS" -cat > conftest.$ac_ext <<EOF -#line 959 "configure" -#include "confdefs.h" -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char strerror(); + enable_shared=yes +fi; -int main() { -strerror() -; return 0; } -EOF -if { (eval echo configure:970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + enable_static=yes +fi; + +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi; + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + fi -rm -f conftest* -LIBS="$ac_save_LIBS" +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - LIBS="$LIBS -lcposix" +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +DEPDIR="${am__leading_dot}deps" + + ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' else - echo "$ac_t""no" 1>&6 + AMDEP_TRUE='#' + AMDEP_FALSE= fi - -# Extract the first word of "gcc", so it can be a program name with args. + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:995: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC else - echo "$ac_t""no" 1>&6 + CC="$ac_cv_prog_CC" fi +fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1025: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift - if test $# -gt 0; then + if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - set dummy "$ac_dir/$ac_word" "$@" - shift - ac_cv_prog_CC="$@" + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1076: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - ;; - esac + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1108: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + test -n "$ac_ct_CC" && break +done -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross + CC=$ac_ct_CC +fi -cat > conftest.$ac_ext << EOF +fi -#line 1119 "configure" -#include "confdefs.h" -main(){return(0);} -EOF -if { (eval echo configure:1124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no else - ac_cv_prog_cc_cross=yes + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1150: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1155: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1164: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done else - ac_cv_prog_gcc=no -fi + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 -if test $ac_cv_prog_gcc = yes; then - GCC=yes +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done else - GCC= + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } fi -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1183: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then - ac_cv_prog_cc_g=yes + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes else - ac_cv_prog_cc_g=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" + CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" @@ -1209,29 +2763,19 @@ else CFLAGS= fi fi - - - - -echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 -echo "configure:1218: checking for ${CC-cc} option to accept ANSI C" >&5 -if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - am_cv_prog_cc_stdc=no -ac_save_CC="$CC" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - cat > conftest.$ac_ext <<EOF -#line 1234 "configure" -#include "confdefs.h" + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> #include <sys/types.h> @@ -1254,297 +2798,405 @@ static char *f (char * (*g) (char **, int), char **p, ...) va_end (v); return s; } + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; - -int main() { - +int +main () +{ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - -; return 0; } -EOF -if { (eval echo configure:1271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - am_cv_prog_cc_stdc="$ac_arg"; break + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext done -CC="$ac_save_CC" +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC fi -if test -z "$am_cv_prog_cc_stdc"; then - echo "$ac_t""none needed" 1>&6 -else - echo "$ac_t""$am_cv_prog_cc_stdc" 1>&6 -fi -case "x$am_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $am_cv_prog_cc_stdc" ;; +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; esac -echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1295: checking for Cygwin environment" >&5 -if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1300 "configure" -#include "confdefs.h" - -int main() { - -#ifndef __CYGWIN__ -#define __CYGWIN__ __CYGWIN32__ +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me #endif -return __CYGWIN__; -; return 0; } -EOF -if { (eval echo configure:1311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_cygwin=yes +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include <stdlib.h> +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_cygwin=no -fi -rm -f conftest* -rm -f conftest* -fi + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -echo "$ac_t""$ac_cv_cygwin" 1>&6 -CYGWIN= -test "$ac_cv_cygwin" = yes && CYGWIN=yes -echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1328: checking for mingw32 environment" >&5 -if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break else - cat > conftest.$ac_ext <<EOF -#line 1333 "configure" -#include "confdefs.h" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -int main() { -return __MINGW32__; -; return 0; } -EOF -if { (eval echo configure:1340: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_mingw32=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_mingw32=no fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done rm -f conftest* -rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h fi -echo "$ac_t""$ac_cv_mingw32" 1>&6 -MINGW32= -test "$ac_cv_mingw32" = yes && MINGW32=yes -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1357: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 1372 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1378: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 1389 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1395: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext <<EOF -#line 1406 "configure" -#include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1412: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi - CPP="$ac_cv_prog_CPP" +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_CPP="$CPP" -fi -echo "$ac_t""$CPP" 1>&6 + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + : > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf -# Check whether --enable-shared or --disable-shared was given. -if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - p=${PACKAGE-default} -case $enableval in -yes) enable_shared=yes ;; -no) enable_shared=no ;; -*) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_shared=yes + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # (even with -Werror). So we grep stderr for any message + # that says an option was ignored. + if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi fi done - IFS="$ac_save_ifs" - ;; -esac + + cd .. + rm -rf conftest.dir else - enable_shared=yes + am_cv_CC_dependencies_compiler_type=none fi -# Check whether --enable-static or --disable-static was given. -if test "${enable_static+set}" = set; then - enableval="$enable_static" - p=${PACKAGE-default} -case $enableval in -yes) enable_static=yes ;; -no) enable_static=no ;; -*) - enable_static=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac -else - enable_static=yes fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type -# Check whether --enable-fast-install or --disable-fast-install was given. -if test "${enable_fast_install+set}" = set; then - enableval="$enable_fast_install" - p=${PACKAGE-default} -case $enableval in -yes) enable_fast_install=yes ;; -no) enable_fast_install=no ;; -*) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," - for pkg in $enableval; do - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$ac_save_ifs" - ;; -esac + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' else - enable_fast_install=yes + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= fi -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 +if test "${lt_cv_path_SED+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done + fi -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:1512: checking host system type" >&5 +SED=$lt_cv_path_SED +echo "$as_me:$LINENO: result: $SED" >&5 +echo "${ECHO_T}$SED" >&6 -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1533: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 # Check whether --with-gnu-ld or --without-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then @@ -1552,13 +3204,12 @@ if test "${with_gnu_ld+set}" = set; then test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no -fi - +fi; ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. - echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1562: checking for ld used by GCC" >&5 + echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -1568,12 +3219,12 @@ echo "configure:1562: checking for ld used by GCC" >&5 esac case $ac_prog in # Accept absolute paths. - [\\/]* | [A-Za-z]:[\\/]*) + [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; @@ -1587,32 +3238,36 @@ echo "configure:1562: checking for ld used by GCC" >&5 ;; esac elif test "$with_gnu_ld" = yes; then - echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1592: checking for GNU ld" >&5 + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 else - echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1595: checking for non-GNU ld" >&5 + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 fi -if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do + IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. + # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. - if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break - else + ;; + *) test "$with_gnu_ld" != yes && break - fi + ;; + esac fi done - IFS="$ac_save_ifs" + IFS="$lt_save_ifs" else lt_cv_path_LD="$LD" # Let the user override the test with a path. fi @@ -1620,103 +3275,128 @@ fi LD="$lt_cv_path_LD" if test -n "$LD"; then - echo "$ac_t""$LD" 1>&6 + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } -echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1630: checking if the linker ($LD) is GNU ld" >&5 -if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - # I'd rather use --version here, but apparently some GNU ld's only accept -v. -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) lt_cv_prog_gnu_ld=yes -else + ;; +*) lt_cv_prog_gnu_ld=no + ;; +esac fi -fi - -echo "$ac_t""$lt_cv_prog_gnu_ld" 1>&6 +echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 with_gnu_ld=$lt_cv_prog_gnu_ld -echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:1647: checking for $LD option to reload object files" >&5 -if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 +echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 +if test "${lt_cv_ld_reload_flag+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_ld_reload_flag='-r' fi - -echo "$ac_t""$lt_cv_ld_reload_flag" 1>&6 +echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 +echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 reload_flag=$lt_cv_ld_reload_flag -test -n "$reload_flag" && reload_flag=" $reload_flag" +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac -echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1659: checking for BSD-compatible nm" >&5 -if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 +if test "${lt_cv_path_NM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" - for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do - test -z "$ac_dir" && ac_dir=. - tmp_nm=$ac_dir/${ac_tool_prefix}nm - if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then - lt_cv_path_NM="$tmp_nm -B" - break - elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - lt_cv_path_NM="$tmp_nm -p" - break - else - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac fi - fi + done + IFS="$lt_save_ifs" done - IFS="$ac_save_ifs" test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi fi - +echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 +echo "${ECHO_T}$lt_cv_path_NM" >&6 NM="$lt_cv_path_NM" -echo "$ac_t""$NM" 1>&6 -echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1697: checking whether ln -s works" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - rm -f conftestdata -if ln -s X conftestdata 2>/dev/null -then - rm -f conftestdata - ac_cv_prog_LN_S="ln -s" -else - ac_cv_prog_LN_S=ln -fi -fi -LN_S="$ac_cv_prog_LN_S" -if test "$ac_cv_prog_LN_S" = "ln -s"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 fi -echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6 -echo "configure:1718: checking how to recognise dependant libraries" >&5 -if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 +echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 +if test "${lt_cv_deplibs_check_method+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= @@ -1727,8 +3407,8 @@ lt_cv_deplibs_check_method='unknown' # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. -# ['file_magic [regex]'] -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given egrep regex. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. @@ -1741,37 +3421,36 @@ beos*) lt_cv_deplibs_check_method=pass_all ;; -bsdi4*) +bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; -cygwin* | mingw* | pw32*) +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump'. lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) - lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' - lt_cv_file_magic_cmd='/usr/bin/file -L' - case "$host_os" in - rhapsody* | darwin1.012) - lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` - ;; - *) # Darwin 1.3 on - lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' - ;; - esac + lt_cv_deplibs_check_method=pass_all ;; -freebsd*) +freebsd* | kfreebsd*-gnu | dragonfly*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; @@ -1785,50 +3464,49 @@ gnu*) lt_cv_deplibs_check_method=pass_all ;; -hpux10.20*|hpux11*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' +hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - -irix5* | irix6*) - case $host_os in - irix5*) - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac - lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` + ;; + +interix3*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. -linux-gnu*) - case $host_cpu in - alpha* | i*86 | powerpc* | sparc* | ia64* ) - lt_cv_deplibs_check_method=pass_all ;; - *) - # glibc up to 2.1.1 does not perform some relocations on ARM - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; - esac - lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` +linux*) + lt_cv_deplibs_check_method=pass_all ;; -netbsd*) +netbsd* | netbsdelf*-gnu | knetbsd*-gnu) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$' + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else - lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$' + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; @@ -1838,27 +3516,27 @@ newos6*) lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; -osf3* | osf4* | osf5*) - # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' - lt_cv_file_magic_test_file=/shlib/libc.so - lt_cv_deplibs_check_method=pass_all +nto-qnx*) + lt_cv_deplibs_check_method=unknown ;; -sco3.2v5*) - lt_cv_deplibs_check_method=pass_all +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi ;; -solaris*) +osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all - lt_cv_file_magic_test_file=/lib/libc.so ;; -sysv5uw[78]* | sysv4*uw2*) +solaris*) lt_cv_deplibs_check_method=pass_all ;; -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) +sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' @@ -1876,89 +3554,1928 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; esac ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; esac fi - -echo "$ac_t""$lt_cv_deplibs_check_method" 1>&6 +echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 +echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + -echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1891: checking for object suffix" >&5 -if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 3622 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 +if test "${lt_cv_cc_needs_belf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - rm -f conftest* -echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1897: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - for ac_file in conftest.*; do - case $ac_file in - *.c) ;; - *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lt_cv_cc_needs_belf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +lt_cv_cc_needs_belf=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) LD="${LD-ld} -64" ;; + esac + ;; esac + fi + rm -rf conftest* + ;; + + +esac + +need_locks="$enable_libtool_lock" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ctype.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------------ ## +## Report this to the system-tools-backends lists. ## +## ------------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CXX" && break done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6 else - { echo "configure: error: installation or configuration problem; compiler does not work" 1>&2; exit 1; } + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi + + test -n "$ac_ct_CXX" && break +done +test -n "$ac_ct_CXX" || ac_ct_CXX="g++" + + CXX=$ac_ct_CXX +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cxx_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include <stdlib.h> +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h fi -echo "$ac_t""$ac_cv_objext" 1>&6 -OBJEXT=$ac_cv_objext -ac_objext=$ac_cv_objext +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +depcc="$CXX" am_compiler_list= +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + : > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf -echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1917: checking for executable suffix" >&5 -if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # (even with -Werror). So we grep stderr for any message + # that says an option was ignored. + if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir else - if test "$CYGWIN" = yes || test "$MINGW32" = yes; then - ac_cv_exeext=.exe + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' else - rm -f conftest* - echo 'int main () { return 0; }' > conftest.$ac_ext - ac_cv_exeext= - if { (eval echo configure:1927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then - for file in conftest.*; do - case $file in - *.c | *.o | *.obj) ;; - *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; - esac + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + + +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +echo "$as_me:$LINENO: result: $CXXCPP" >&5 +echo "${ECHO_T}$CXXCPP" >&6 +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag else - { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; } + ac_cpp_err= fi - rm -f conftest* - test x"${ac_cv_exeext}" = x && ac_cv_exeext=no +else + ac_cpp_err=yes fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -EXEEXT="" -test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} -echo "$ac_t""${ac_cv_exeext}" 1>&6 -ac_exeext=$EXEEXT + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +fi + + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$F77"; then + ac_cv_prog_F77="$F77" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_F77="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +F77=$ac_cv_prog_F77 +if test -n "$F77"; then + echo "$as_me:$LINENO: result: $F77" >&5 +echo "${ECHO_T}$F77" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$F77" && break + done +fi +if test -z "$F77"; then + ac_ct_F77=$F77 + for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_F77"; then + ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_F77="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_F77=$ac_cv_prog_ac_ct_F77 +if test -n "$ac_ct_F77"; then + echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 +echo "${ECHO_T}$ac_ct_F77" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_F77" && break +done + + F77=$ac_ct_F77 +fi + + +# Provide some information about the compiler. +echo "$as_me:5206:" \ + "checking for Fortran 77 compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +rm -f a.out + +# If we don't use `.F' as extension, the preprocessor is not run on the +# input file. (Note that this only needs to work for GNU compilers.) +ac_save_ext=$ac_ext +ac_ext=F +echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6 +if test "${ac_cv_f77_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF + program main +#ifndef __GNUC__ + choke me +#endif + + end +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_f77_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6 +ac_ext=$ac_save_ext +ac_test_FFLAGS=${FFLAGS+set} +ac_save_FFLAGS=$FFLAGS +FFLAGS= +echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 +echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_f77_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + FFLAGS=-g +cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_f77_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_f77_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 +echo "${ECHO_T}$ac_cv_prog_f77_g" >&6 +if test "$ac_test_FFLAGS" = set; then + FFLAGS=$ac_save_FFLAGS +elif test $ac_cv_prog_f77_g = yes; then + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-g -O2" + else + FFLAGS="-g" + fi +else + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-O2" + else + FFLAGS= + fi +fi + +G77=`test $ac_compiler_gnu = yes && echo yes` +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! + +# find the maximum length of command line arguments +echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 +echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 +if test "${lt_cv_sys_max_cmd_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac + +fi -if test $host != $build; then - ac_tool_prefix=${host_alias}- +if test -n $lt_cv_sys_max_cmd_len ; then + echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 +echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 else - ac_tool_prefix= + echo "$as_me:$LINENO: result: none" >&5 +echo "${ECHO_T}none" >&6 fi # Check for command to grab the raw symbol name followed by C symbol from nm. -echo $ac_n "checking command to parse $NM output""... $ac_c" 1>&6 -echo "configure:1958: checking command to parse $NM output" >&5 -if eval "test \"`echo '$''{'lt_cv_sys_global_symbol_pipe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 +echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - + # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] @@ -1968,11 +5485,11 @@ symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' -# Transform the above into a raw symbol and a C symbol. -symxfrm='\1 \2\3 \3' - # Transform an extracted symbol line into a proper C declaration -lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" # Define system-specific variables. case $host_os in @@ -1983,13 +5500,36 @@ cygwin* | mingw* | pw32*) symcode='[ABCDGISTW]' ;; hpux*) # Its linker distinguishes data from code symbols - lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDGIRSTW]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi ;; -irix*) +irix* | nonstopux*) symcode='[BCDEGRST]' ;; -solaris* | sysv5*) - symcode='[BDT]' +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' @@ -1998,25 +5538,30 @@ esac # Handle CRLF in mingw tool chain opt_cr= -case $host_os in +case $build_os in mingw*) opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # If we're using GNU nm, then use its standard symbol codes. -if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - symcode='[ABCDGISTW]' -fi +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac # Try without a prefix undercore, then with it. for ac_symprfx in "" "_"; do + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + # Write the raw and C identifiers. -lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" # Check to see that the pipe works correctly. pipe_works=no + rm -f conftest* cat > conftest.$ac_ext <<EOF #ifdef __cplusplus @@ -2030,10 +5575,18 @@ void nm_test_func(){} int main(){nm_test_var='a';nm_test_func();return(0);} EOF - if { (eval echo configure:2034: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then # Now try to grab the symbols. nlist=conftest.nm - if { (eval echo configure:2037: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then + if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -2042,8 +5595,8 @@ EOF fi # Make sure that we snagged all the symbols we need. - if egrep ' nm_test_var$' "$nlist" >/dev/null; then - if egrep ' nm_test_func$' "$nlist" >/dev/null; then + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then cat <<EOF > conftest.$ac_ext #ifdef __cplusplus extern "C" { @@ -2051,7 +5604,7 @@ extern "C" { EOF # Now generate the symbol file. - eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' cat <<EOF >> conftest.$ac_ext #if defined (__STDC__) && __STDC__ @@ -2069,7 +5622,7 @@ const struct { lt_preloaded_symbols[] = { EOF - sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" >> conftest.$ac_ext + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext cat <<\EOF >> conftest.$ac_ext {0, (lt_ptr_t) 0} }; @@ -2080,15 +5633,19 @@ EOF EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$no_builtin_flag" - if { (eval echo configure:2088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext}; then pipe_works=yes fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi @@ -2114,93 +5671,400 @@ done fi -global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" if test -z "$lt_cv_sys_global_symbol_pipe"; then - global_symbol_to_cdecl= + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + echo "$as_me:$LINENO: result: failed" >&5 +echo "${ECHO_T}failed" >&6 else - global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" + echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 fi -if test -z "$global_symbol_pipe$global_symbol_to_cdecl"; then - echo "$ac_t""failed" 1>&6 + +echo "$as_me:$LINENO: checking for objdir" >&5 +echo $ECHO_N "checking for objdir... $ECHO_C" >&6 +if test "${lt_cv_objdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs else - echo "$ac_t""ok" 1>&6 + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null fi +echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 +echo "${ECHO_T}$lt_cv_objdir" >&6 +objdir=$lt_cv_objdir + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' -for ac_hdr in dlfcn.h +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2134: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2139 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2144: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false" fi -rm -f conftest* fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi + + AR=$ac_ct_AR +else + AR="$ac_cv_prog_AR" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done done +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then - echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 -echo "configure:2179: checking for ${ac_tool_prefix}file" >&5 -if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 +echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in - /*) +[\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; - ?:/*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. - ;; - *) - ac_save_MAGIC_CMD="$MAGIC_CMD" - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="/usr/bin:$PATH" +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) - file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - egrep "$file_magic_regex" > /dev/null; then + $EGREP "$file_magic_regex" > /dev/null; then : else cat <<EOF 1>&2 @@ -2221,48 +6085,48 @@ EOF break fi done - IFS="$ac_save_ifs" - MAGIC_CMD="$ac_save_MAGIC_CMD" + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then - echo "$ac_t""$MAGIC_CMD" 1>&6 + echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then - echo $ac_n "checking for file""... $ac_c" 1>&6 -echo "configure:2241: checking for file" >&5 -if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for file" >&5 +echo $ECHO_N "checking for file... $ECHO_C" >&6 +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in - /*) +[\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; - ?:/*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. - ;; - *) - ac_save_MAGIC_CMD="$MAGIC_CMD" - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="/usr/bin:$PATH" +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) - file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - egrep "$file_magic_regex" > /dev/null; then + $EGREP "$file_magic_regex" > /dev/null; then : else cat <<EOF 1>&2 @@ -2283,17 +6147,19 @@ EOF break fi done - IFS="$ac_save_ifs" - MAGIC_CMD="$ac_save_MAGIC_CMD" + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then - echo "$ac_t""$MAGIC_CMD" 1>&6 + echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 fi else @@ -2305,816 +6171,624 @@ fi ;; esac -# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2312: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -if test -z "$ac_cv_prog_RANLIB"; then -if test -n "$ac_tool_prefix"; then - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2344: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" -fi -fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -else - RANLIB=":" -fi -fi - -# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2379: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -STRIP="$ac_cv_prog_STRIP" -if test -n "$STRIP"; then - echo "$ac_t""$STRIP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - -if test -z "$ac_cv_prog_STRIP"; then -if test -n "$ac_tool_prefix"; then - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2411: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_STRIP="strip" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_STRIP" && ac_cv_prog_STRIP=":" -fi -fi -STRIP="$ac_cv_prog_STRIP" -if test -n "$STRIP"; then - echo "$ac_t""$STRIP" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -else - STRIP=":" -fi -fi - - enable_dlopen=no enable_win32_dll=no # Check whether --enable-libtool-lock or --disable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then enableval="$enable_libtool_lock" - : -fi +fi; test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -*-*-irix6*) - # Find out which ABI we are using. - echo '#line 2460 "configure"' > conftest.$ac_ext - if { (eval echo configure:2461: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:2482: checking whether the C compiler needs -belf" >&5 -if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +# Check whether --with-pic or --without-pic was given. +if test "${with_pic+set}" = set; then + withval="$with_pic" + pic_mode="$withval" else - - ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. + pic_mode=default +fi; +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +lt_save_CC="$CC" +ac_ext=c ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu - cat > conftest.$ac_ext <<EOF -#line 2495 "configure" -#include "confdefs.h" -int main() { +# Source file extension for C test sources. +ac_ext=c -; return 0; } -EOF -if { (eval echo configure:2502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - lt_cv_cc_needs_belf=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - lt_cv_cc_needs_belf=no -fi -rm -f conftest* - ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross +# Object file extension for compiled C test sources. +objext=o +objext=$objext -fi +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" -echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' -esac +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} -# Same as above, but do not quote variable references. -double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' +# Allow CC to be a program name with arguments. +compiler=$CC -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' -# Constants: -rm="rm -f" +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* -# Global variables: -default_ofile=libtool -can_build_shared=yes +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" -need_locks="$enable_libtool_lock" -old_CC="$CC" -old_CFLAGS="$CFLAGS" -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -if test x"$host" != x"$build"; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi +lt_prog_compiler_no_builtin_flag= -# Transform linux* to *-*-linux-gnu*, to support old configure scripts. -case $host_os in -linux-gnu*) ;; -linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` -esac +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= +echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:6267: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:6271: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* -if test -n "$RANLIB"; then - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 -# Allow CC to be a program name with arguments. -set dummy $CC -compiler="$2" - -echo $ac_n "checking for objdir""... $ac_c" 1>&6 -echo "configure:2615: checking for objdir" >&5 -rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - objdir=.libs +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else - # MS-DOS does not allow filenames that begin with a dot. - objdir=_libs + : fi -rmdir .libs 2>/dev/null -echo "$ac_t""$objdir" 1>&6 - -# Check whether --with-pic or --without-pic was given. -if test "${with_pic+set}" = set; then - withval="$with_pic" - pic_mode="$withval" -else - pic_mode=default fi -test -z "$pic_mode" && pic_mode=default +lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= -# We assume here that the value for lt_cv_prog_cc_pic will not be cached -# in isolation, and that seeing it set (from the cache) indicates that -# the associated values are set (in the cache) correctly too. -echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6 -echo "configure:2642: checking for $compiler option to produce PIC" >&5 -if eval "test \"`echo '$''{'lt_cv_prog_cc_pic'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - lt_cv_prog_cc_pic= - lt_cv_prog_cc_shlib= - lt_cv_prog_cc_wl= - lt_cv_prog_cc_static= - lt_cv_prog_cc_no_builtin= - lt_cv_prog_cc_can_build_shared=$can_build_shared +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "$GCC" = yes; then - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-static' + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' case $host_os in - aix*) - # Below there is a dirty hack to force normal static linking with -ldl - # The problem is because libdl dynamically linked with both libc and - # libC (AIX C++ library), which obviously doesn't included in libraries - # list by gcc. This cause undefined symbols with -static flags. - # This hack allows C programs to be linked with "-static -ldl", but - # we not sure about C++ programs. - lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi ;; + amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. - lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; - beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files - lt_cv_prog_cc_pic='-fno-common' + lt_prog_compiler_pic='-fno-common' ;; - cygwin* | mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_cv_prog_cc_pic='-DDLL_EXPORT' + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + sysv4*MP*) if test -d /usr/nec; then - lt_cv_prog_cc_pic=-Kconform_pic + lt_prog_compiler_pic=-Kconform_pic fi ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + *) - lt_cv_prog_cc_pic='-fPIC' + lt_prog_compiler_pic='-fPIC' ;; esac else - # PORTME Check for PIC flags for the system compiler. + # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in - aix3* | aix4* | aix5*) - # All AIX code is PIC. + aix*) + lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Wl,' + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' else - lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic='-qnocommon' + lt_prog_compiler_wl='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; hpux9* | hpux10* | hpux11*) - # Is there a better lt_cv_prog_cc_static that works with the bundled CC? - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" - lt_cv_prog_cc_pic='+Z' + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' ;; - irix5* | irix6*) - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-non_shared' + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' ;; - cygwin* | mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_cv_prog_cc_pic='-DDLL_EXPORT' + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' ;; - newsos6) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' + linux*) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + esac ;; osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. - lt_cv_prog_cc_wl='-Wl,' - lt_cv_prog_cc_static='-non_shared' - ;; - - sco3.2v5*) - lt_cv_prog_cc_pic='-Kpic' - lt_cv_prog_cc_static='-dn' - lt_cv_prog_cc_shlib='-belf' + lt_prog_compiler_static='-non_shared' ;; solaris*) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac ;; sunos4*) - lt_cv_prog_cc_pic='-PIC' - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Qoption ld ' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - lt_cv_prog_cc_pic='-KPIC' - lt_cv_prog_cc_static='-Bstatic' - if test "x$host_vendor" = xsni; then - lt_cv_prog_cc_wl='-LD' - else - lt_cv_prog_cc_wl='-Wl,' - fi + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' ;; - uts4*) - lt_cv_prog_cc_pic='-pic' - lt_cv_prog_cc_static='-Bstatic' + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then - lt_cv_prog_cc_pic='-Kconform_pic' - lt_cv_prog_cc_static='-Bstatic' + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' fi ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + *) - lt_cv_prog_cc_can_build_shared=no + lt_prog_compiler_can_build_shared=no ;; esac fi -fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic" >&6 -if test -z "$lt_cv_prog_cc_pic"; then - echo "$ac_t""none" 1>&6 -else - echo "$ac_t""$lt_cv_prog_cc_pic" 1>&6 +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then - # Check to make sure the pic_flag actually works. - echo $ac_n "checking if $compiler PIC flag $lt_cv_prog_cc_pic works""... $ac_c" 1>&6 -echo "configure:2794: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 - if eval "test \"`echo '$''{'lt_cv_prog_cc_pic_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" - cat > conftest.$ac_ext <<EOF -#line 2801 "configure" -#include "confdefs.h" - -int main() { + lt_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:6535: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:6539: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works=yes + fi + fi + $rm conftest* -; return 0; } -EOF -if { (eval echo configure:2808: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - case $host_os in - hpux9* | hpux10* | hpux11*) - # On HP-UX, both CC and GCC only warn that PIC is supported... then - # they create non-PIC objects. So, if there were any warnings, we - # assume that PIC is not supported. - if test -s conftest.err; then - lt_cv_prog_cc_pic_works=no - else - lt_cv_prog_cc_pic_works=yes - fi - ;; - *) - lt_cv_prog_cc_pic_works=yes - ;; - esac - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - lt_cv_prog_cc_pic_works=no - fi -rm -f conftest* - CFLAGS="$save_CFLAGS" - -fi - - - if test "X$lt_cv_prog_cc_pic_works" = Xno; then - lt_cv_prog_cc_pic= - lt_cv_prog_cc_can_build_shared=no - else - lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" - fi - - echo "$ac_t""$lt_cv_prog_cc_pic_works" 1>&6 +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 + +if test x"$lt_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no fi -# Check for any special shared library compilation flags. -if test -n "$lt_cv_prog_cc_shlib"; then - echo "configure: warning: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" 1>&2 - if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]" >/dev/null; then : - else - echo "configure: warning: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" 1>&2 - lt_cv_prog_cc_can_build_shared=no - fi fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac -echo $ac_n "checking if $compiler static flag $lt_cv_prog_cc_static works""... $ac_c" 1>&6 -echo "configure:2860: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 -if eval "test \"`echo '$''{'lt_cv_prog_cc_static_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - lt_cv_prog_cc_static_works=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" - cat > conftest.$ac_ext <<EOF -#line 2868 "configure" -#include "confdefs.h" - -int main() { + lt_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works=yes + fi + else + lt_prog_compiler_static_works=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" -; return 0; } -EOF -if { (eval echo configure:2875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - lt_cv_prog_cc_static_works=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 fi -rm -f conftest* - LDFLAGS="$save_LDFLAGS" - -fi - - -# Belt *and* braces to stop my trousers falling down: -test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= -echo "$ac_t""$lt_cv_prog_cc_static_works" 1>&6 - -pic_flag="$lt_cv_prog_cc_pic" -special_shlib_compile_flags="$lt_cv_prog_cc_shlib" -wl="$lt_cv_prog_cc_wl" -link_static_flag="$lt_cv_prog_cc_static" -no_builtin_flag="$lt_cv_prog_cc_no_builtin" -can_build_shared="$lt_cv_prog_cc_can_build_shared" - - -# Check to see if options -o and -c are simultaneously supported by compiler -echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6 -echo "configure:2902: checking if $compiler supports -c -o file.$ac_objext" >&5 -if eval "test \"`echo '$''{'lt_cv_compiler_c_o'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - -$rm -r conftest 2>/dev/null -mkdir conftest -cd conftest -echo "int some_variable = 0;" > conftest.$ac_ext -mkdir out -# According to Tom Tromey, Ian Lance Taylor reported there are C compilers -# that will create temporary files in the current directory regardless of -# the output directory. Thus, making CWD read-only will cause this test -# to fail, enabling locking or at least warning the user not to do parallel -# builds. -chmod -w . -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" -compiler_c_o=no -if { (eval echo configure:2921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s out/conftest.err; then - lt_cv_compiler_c_o=no - else - lt_cv_compiler_c_o=yes - fi -else - # Append any errors to the config.log. - cat out/conftest.err 1>&5 - lt_cv_compiler_c_o=no -fi -CFLAGS="$save_CFLAGS" -chmod u+w . -$rm conftest* out/* -rmdir out -cd .. -rmdir conftest -$rm -r conftest 2>/dev/null +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 +if test x"$lt_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= fi -compiler_c_o=$lt_cv_compiler_c_o -echo "$ac_t""$compiler_c_o" 1>&6 -if test x"$compiler_c_o" = x"yes"; then - # Check to see if we can write to a .lo - echo $ac_n "checking if $compiler supports -c -o file.lo""... $ac_c" 1>&6 -echo "configure:2950: checking if $compiler supports -c -o file.lo" >&5 - if eval "test \"`echo '$''{'lt_cv_compiler_o_lo'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - - lt_cv_compiler_o_lo=no - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -c -o conftest.lo" - cat > conftest.$ac_ext <<EOF -#line 2959 "configure" -#include "confdefs.h" + lt_cv_prog_compiler_c_o=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:6639: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:6643: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* -int main() { -int some_variable = 0; -; return 0; } -EOF -if { (eval echo configure:2966: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - lt_cv_compiler_o_lo=no - else - lt_cv_compiler_o_lo=yes - fi - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* - CFLAGS="$save_CFLAGS" - fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 - compiler_o_lo=$lt_cv_compiler_o_lo - echo "$ac_t""$compiler_c_lo" 1>&6 -else - compiler_o_lo=no -fi -# Check to see if we can do hard links to lock some files if needed hard_links="nottested" -if test "$compiler_c_o" = no && test "$need_locks" != no; then +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user - echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6 -echo "configure:2996: checking if we can lock with hard links" >&5 + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$ac_t""$hard_links" 1>&6 + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then - echo "configure: warning: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" 1>&2 + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi -if test "$GCC" = yes; then - # Check to see if options -fno-rtti -fno-exceptions are supported by compiler - echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6 -echo "configure:3015: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 - echo "int some_variable = 0;" > conftest.$ac_ext - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" - compiler_rtti_exceptions=no - cat > conftest.$ac_ext <<EOF -#line 3021 "configure" -#include "confdefs.h" +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag= + enable_shared_with_static_runtimes=no + archive_cmds= + archive_expsym_cmds= + old_archive_From_new_cmds= + old_archive_from_expsyms_cmds= + export_dynamic_flag_spec= + whole_archive_flag_spec= + thread_safe_flag_spec= + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_direct=no + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + link_all_deplibs=unknown + hardcode_automatic=no + module_cmds= + module_expsym_cmds= + always_export_symbols=no + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -int main() { -int some_variable = 0; -; return 0; } -EOF -if { (eval echo configure:3028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - compiler_rtti_exceptions=no - else - compiler_rtti_exceptions=yes + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no fi - -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 -fi -rm -f conftest* - CFLAGS="$save_CFLAGS" - echo "$ac_t""$compiler_rtti_exceptions" 1>&6 - - if test "$compiler_rtti_exceptions" = "yes"; then - no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' - else - no_builtin_flag=' -fno-builtin' - fi -fi - -# See if the linker supports building shared libraries. -echo $ac_n "checking whether the linker ($LD) supports shared libraries""... $ac_c" 1>&6 -echo "configure:3055: checking whether the linker ($LD) supports shared libraries" >&5 - -allow_undefined_flag= -no_undefined_flag= -need_lib_prefix=unknown -need_version=unknown -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -archive_cmds= -archive_expsym_cmds= -old_archive_from_new_cmds= -old_archive_from_expsyms_cmds= -export_dynamic_flag_spec= -whole_archive_flag_spec= -thread_safe_flag_spec= -hardcode_into_libs=no -hardcode_libdir_flag_spec= -hardcode_libdir_separator= -hardcode_direct=no -hardcode_minus_L=no -hardcode_shlibpath_var=unsupported -runpath_var= -link_all_deplibs=unknown -always_export_symbols=no -export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' -# include_expsyms should be a list of space-separated symbols to be *always* -# included in the symbol list -include_expsyms= -# exclude_expsyms can be an egrep regular expression of symbols to exclude -# it will be wrapped by ` (' and `)$', so one must not match beginning or -# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', -# as well as any symbol that contains `d'. -exclude_expsyms="_GLOBAL_OFFSET_TABLE_" -# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out -# platforms (ab)use it in PIC code, but their linkers get confused if -# the symbol is explicitly referenced. Since portable code cannot -# rely on this symbol name, it's probably fine to never include it in -# preloaded symbol tables. -extract_expsyms_cmds= - -case $host_os in -cygwin* | mingw* | pw32* ) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) with_gnu_ld=no - fi - ;; + ;; + esac -esac + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' -ld_shlibs=yes -if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX, the GNU linker is very broken - # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. - ld_shlibs=no - cat <<EOF 1>&2 + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <<EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. @@ -3123,124 +6797,120 @@ if test "$with_gnu_ld" = yes; then *** so that a non-GNU linker is found, and then restart. EOF - ;; + fi + ;; - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs=no + ;; - # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can use - # them. - ld_shlibs=no - ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; - beos*) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' allow_undefined_flag=unsupported - # Joseph Beckenbach <jrb3@best.com> says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs=no - fi - ;; - - cygwin* | mingw* | pw32*) - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec='-L$libdir' - allow_undefined_flag=unsupported - always_export_symbols=yes - - extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ - sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ - test -f $output_objdir/impgen.exe || (cd $output_objdir && \ - if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ - else $CC -o impgen impgen.c ; fi)~ - $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' - - old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' - - # cygwin and mingw dlls have different entry points and sets of symbols - # to exclude. - # FIXME: what about values for MSVC? - dll_entry=__cygwin_dll_entry@12 - dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ - case $host_os in - mingw*) - # mingw values - dll_entry=_DllMainCRTStartup@12 - dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi ;; - esac - # mingw and cygwin differ, and it's simplest to just exclude the union - # of the two symbol sets. - dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 + interix3*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; - # recent cygwin and mingw systems supply a stub DllMain which the user - # can override, but on older systems we have to supply one (in ltdll.c) - if test "x$lt_cv_need_dllmain" = "xyes"; then - ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " - ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < [$]0 > $output_objdir/$soname-ltdll.c~ - test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' - else - ltdll_obj= - ltdll_cmds= - fi + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - # Extract the symbol export list from an `--export-all' def file, - # then regenerate the def file from the symbol export list, so that - # the compiled dll only exports the symbol export list. - # Be careful not to strip the DATA tag left be newer dlltools. - export_symbols_cmds="$ltdll_cmds"' - $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ - sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' - - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is. - # If DATA tags from a recent dlltool are present, honour them! - archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname-def; + if test $supports_anon_versioning = yes; then + archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + link_all_deplibs=no else - echo EXPORTS > $output_objdir/$soname-def; - _lt_hint=1; - cat $export_symbols | while read symbol; do - set dummy \$symbol; - case \$# in - 2) echo " \$2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; - *) echo " \$2 @ \$_lt_hint \$3 ; " >> $output_objdir/$soname-def;; - esac; - _lt_hint=`expr 1 + \$_lt_hint`; - done; - fi~ - '"$ltdll_cmds"' - $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ - $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ - $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ - $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' - ;; + ld_shlibs=no + fi + ;; - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; - solaris* | sysv5*) - if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then - ld_shlibs=no - cat <<EOF 1>&2 + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool @@ -3250,469 +6920,813 @@ EOF *** used, and then restart. EOF - elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; - sunos4*) - archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 - *) - if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - ld_shlibs=no - fi - ;; - esac +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. - if test "$ld_shlibs" = yes; then - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' - case $host_os in - cygwin* | mingw* | pw32*) - # dlltool doesn't understand --whole-archive et. al. - whole_archive_flag_spec= +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no ;; + *) - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else - whole_archive_flag_spec= + ld_shlibs=no fi ;; esac - fi -else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - allow_undefined_flag=unsupported - always_export_symbols=yes - archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$link_static_flag"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - hardcode_direct=unsupported - fi - ;; - - aix4* | aix5*) - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - archive_cmds='' - hardcode_libdir_separator=':' - if test "$GCC" = yes; then - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported fi - shared_flag='-shared' - else + ;; + + aix4* | aix5*) if test "$host_cpu" = ia64; then - shared_flag='-G' + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" else - shared_flag='${wl}-bM:SRE' + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' fi - hardcode_direct=yes - fi - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # Test if we are trying to use run time linking, or normal AIX style linking. - # If -brtl is somewhere in LDFLAGS, we need to do run time linking. - aix_use_runtimelinking=no - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl" ); then - aix_use_runtimelinking=yes - break - fi - done - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - # It seems that -bexpall can do strange things, so it is better to - # generate a list of symbols to export. - always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' - allow_undefined_flag=' -Wl,-G' - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-znodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi else - hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' - # Warning - without using the other run time loading flags, -berok will - # link without error, but may produce a broken library. - allow_undefined_flag='${wl}-berok" - # This is a bit strange, but is similar to how AIX traditionally builds - # it's shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi fi - fi - ;; - amigaos*) - archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - # see comment about different semantics on the GNU ld section - ld_shlibs=no - ;; + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - ;; - - darwin* | rhapsody*) - allow_undefined_flag='-undefined suppress' - # FIXME: Relying on posixy $() will cause problems for - # cross-compilation, but unfortunately the echo tests do not - # yet detect zsh echo's removal of \ escapes. - archive_cmds='$CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linkopts -install_name $rpath/$soname $(test -n "$verstring" -a x$verstring != x0.0 && echo $verstring)' - # We need to add '_' to the symbols in $export_symbols first - #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' - hardcode_direct=yes - hardcode_shlibpath_var=no - whole_archive_flag_spec='-all_load $convenience' - ;; - - freebsd1*) - ld_shlibs=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ - hpux9* | hpux10* | hpux11*) - case $host_os in - hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; - *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; - esac - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_direct=yes - hardcode_minus_L=yes # Not in the search PATH, but as the default - # location of the library. - export_dynamic_flag_spec='${wl}-E' - ;; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 - irix5* | irix6*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - link_all_deplibs=yes - ;; +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' else - archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs=no + ;; + esac fi - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; + ;; - newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' - hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - hardcode_shlibpath_var=no - ;; + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; - openbsd*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_direct=yes - hardcode_shlibpath_var=no - ;; + freebsd1*) + ld_shlibs=no + ;; - os2*) - hardcode_libdir_flag_spec='-L$libdir' - hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; - osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator=: - ;; + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - else - allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; - #Both c and cxx compiler support -rpath directly - hardcode_libdir_flag_spec='-rpath $libdir' - fi - hardcode_libdir_separator=: - ;; + # GNU/kFreeBSD uses gcc -shared to do shared libraries. + kfreebsd*-gnu) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + link_all_deplibs=no + ;; - sco3.2v5*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ;; + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes - solaris*) - no_undefined_flag=' -z defs' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - hardcode_libdir_flag_spec='-R$libdir' - hardcode_shlibpath_var=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; - esac - link_all_deplibs=yes - ;; + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - hardcode_libdir_flag_spec='-L$libdir' - hardcode_direct=yes - hardcode_minus_L=yes - hardcode_shlibpath_var=no - ;; + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: - sysv4) - if test "x$host_vendor" = xsno; then - archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linkopts' - hardcode_direct=yes # is this really true??? - else + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld='-rpath $libdir' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=no #Motorola manual says yes, but my tests say they lie - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; - sysv4.3*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_shlibpath_var=no - export_dynamic_flag_spec='-Bexport' - ;; + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; - sysv5*) - no_undefined_flag=' -z text' - # $CC -shared without GNU ld will not create a library from C++ - # object files and a static libstdc++, better avoid it by now - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - hardcode_libdir_flag_spec= - hardcode_shlibpath_var=no - runpath_var='LD_RUN_PATH' - ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; - uts4*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; - dgux*) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-L$libdir' - hardcode_shlibpath_var=no - ;; + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + *) + whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; - sysv4*MP*) - if test -d /usr/nec; then + sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - ld_shlibs=yes - fi - ;; + export_dynamic_flag_spec='-Bexport' + ;; - sysv4.2uw2*) - archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' - hardcode_direct=yes - hardcode_minus_L=no - hardcode_shlibpath_var=no - hardcode_runpath_var=yes - runpath_var=LD_RUN_PATH - ;; + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; - sysv5uw7* | unixware7*) - no_undefined_flag='${wl}-z ${wl}text' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - runpath_var='LD_RUN_PATH' - hardcode_shlibpath_var=no - ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' - *) - ld_shlibs=no - ;; - esac -fi -echo "$ac_t""$ld_shlibs" 1>&6 -test "$ld_shlibs" = no && can_build_shared=no + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; -# Check hardcoding attributes. -echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6 -echo "configure:3671: checking how to hardcode library paths into programs" >&5 -hardcode_action= -if test -n "$hardcode_libdir_flag_spec" || \ - test -n "$runpath_var"; then + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; - # We can hardcode non-existant directories. - if test "$hardcode_direct" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$hardcode_shlibpath_var" != no && - test "$hardcode_minus_L" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action=immediate + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action=unsupported -fi -echo "$ac_t""$hardcode_action" 1>&6 -striplib= -old_striplib= -echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6 -echo "configure:3699: checking whether stripping libraries is possible" >&5 -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - echo "$ac_t""yes" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi +echo "$as_me:$LINENO: result: $ld_shlibs" >&5 +echo "${ECHO_T}$ld_shlibs" >&6 +test "$ld_shlibs" = no && can_build_shared=no -reload_cmds='$LD$reload_flag -o $output$reload_objs' -test -z "$deplibs_check_method" && deplibs_check_method=unknown +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 +echo "${ECHO_T}$archive_cmds_need_lc" >&6 + ;; + esac + fi + ;; +esac -# PORTME Fill in your ld.so characteristics -echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6 -echo "configure:3713: checking dynamic linker characteristics" >&5 +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' soname_spec= +shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= @@ -3722,23 +7736,45 @@ shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" -sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown case $host_os in aix3*) version_type=linux - library_names_spec='${libname}${release}.so$versuffix $libname.a' + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH - # AIX has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}.so$major' + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' ;; aix4* | aix5*) version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 - library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file @@ -3747,13 +7783,13 @@ aix4* | aix5*) # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in - aix4 | aix4.[01] | aix4.[01].*) + aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : else - can_build_shared=no + can_build_shared=no fi ;; esac @@ -3761,42 +7797,41 @@ aix4* | aix5*) # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib<name>.so instead of - # lib<name>.a to let people know that these are not typical AIX shared libraries. - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}.so$major' + soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH - deplibs_check_method=pass_all fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; beos*) - library_names_spec='${libname}.so' + library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; -bsdi4*) +bsdi[45]*) version_type=linux need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - export_dynamic_flag_spec=-rdynamic # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs @@ -3804,29 +7839,56 @@ bsdi4*) cygwin* | mingw* | pw32*) version_type=windows + shrext_cmds=".dll" need_version=no need_lib_prefix=no + case $GCC,$host_os in - yes,cygwin*) + yes,cygwin* | yes,mingw* | yes,pw32*) library_names_spec='$libname.dll.a' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' - postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ - $install_prog .libs/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac ;; - yes,mingw*) - library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` - ;; - yes,pw32*) - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/./-/g'`${versuffix}.dll' - ;; + *) - library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' @@ -3839,30 +7901,65 @@ darwin* | rhapsody*) version_type=darwin need_lib_prefix=no need_version=no - # FIXME: Relying on posixy $() will cause problems for - # cross-compilation, but unfortunately the echo tests do not - # yet detect zsh echo's removal of \ escapes. - library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' - soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) - library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac @@ -3871,10 +7968,19 @@ freebsd*) freebsd2*) shlibpath_overrides_runpath=yes ;; - *) + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; esac ;; @@ -3882,8 +7988,8 @@ gnu*) version_type=linux need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; @@ -3891,33 +7997,87 @@ gnu*) hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. - dynamic_linker="$host_os dld.sl" version_type=sunos need_lib_prefix=no need_version=no - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' - soname_spec='${libname}${release}.sl$major' + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; -irix5* | irix6*) - version_type=irix +interix3*) + version_type=linux need_lib_prefix=no need_version=no - soname_spec='${libname}${release}.so$major' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) case $host_os in - irix5*) + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; @@ -3926,20 +8086,21 @@ irix5* | irix6*) shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. -linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) +linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. -linux-gnu*) +linux*) version_type=linux need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -3948,6 +8109,12 @@ linux-gnu*) # before this can be enabled. hardcode_into_libs=yes + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, @@ -3957,17 +8124,41 @@ linux-gnu*) dynamic_linker='GNU/Linux ld.so' ;; +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH @@ -3977,53 +8168,73 @@ netbsd*) newsos6) version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - need_version=no - fi - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi ;; os2*) libname_spec='$name' + shrext_cmds=".dll" need_lib_prefix=no - library_names_spec='$libname.dll $libname.a' + library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf + need_lib_prefix=no need_version=no - soname_spec='${libname}${release}.so' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; -sco3.2v5*) - version_type=osf - soname_spec='${libname}${release}.so$major' - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - shlibpath_var=LD_LIBRARY_PATH - ;; - solaris*) version_type=linux need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes @@ -4033,7 +8244,7 @@ solaris*) sunos4*) version_type=sunos - library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes @@ -4043,14 +8254,20 @@ sunos4*) need_version=yes ;; -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) +sysv4 | sysv4.3*) version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no ;; motorola) need_lib_prefix=no @@ -4061,42 +8278,85 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) esac ;; -uts4*) - version_type=linux - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi ;; -dgux*) - version_type=linux +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' ;; -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' - soname_spec='$libname.so.$major' - shlibpath_var=LD_LIBRARY_PATH - fi +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac -echo "$ac_t""$dynamic_linker" 1>&6 +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no -# Report the final consequences. -echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6 -echo "configure:4099: checking if libtool supports shared libraries" >&5 -echo "$ac_t""$can_build_shared" 1>&6 +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var" || \ + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action" >&5 +echo "${ECHO_T}$hardcode_action" >&6 if test "$hardcode_action" = relink; then # Fast installation is not supported @@ -4107,9 +8367,33 @@ elif test "$shlibpath_overrides_runpath" = yes || enable_fast_install=needless fi -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +striplib= +old_striplib= +echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + ;; + *) + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + ;; + esac fi if test "x$enable_dlopen" != xyes; then @@ -4127,230 +8411,556 @@ else lt_cv_dlopen_self=yes ;; - cygwin* | mingw* | pw32*) + mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; - *) - echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4138: checking for dlopen in -ldl" >&5 -ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" -cat > conftest.$ac_ext <<EOF -#line 4146 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); - -int main() { -dlopen() -; return 0; } -EOF -if { (eval echo configure:4157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4176: checking for dlopen" >&5 -if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 4181 "configure" -#include "confdefs.h" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define shl_load innocuous_shl_load + /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char dlopen(); below. */ -#include <assert.h> -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); + which can conflict with char shl_load (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ -int main() { +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +#undef shl_load + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) +#if defined (__stub_shl_load) || defined (__stub___shl_load) choke me #else -dlopen(); +char (*f) () = shl_load; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:4204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_dlopen=yes" +int +main () +{ +return f != shl_load; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_dlopen=no" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_shl_load=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi - -if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="dlopen" +echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6 +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for shl_load""... $ac_c" 1>&6 -echo "configure:4222: checking for shl_load" >&5 -if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 4227 "configure" -#include "confdefs.h" -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char shl_load(); below. */ -#include <assert.h> + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load(); + builtin and then its argument prototype would still apply. */ +char shl_load (); +int +main () +{ +shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -int main() { +ac_cv_lib_dld_shl_load=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define dlopen innocuous_dlopen +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef dlopen + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_shl_load) || defined (__stub___shl_load) +#if defined (__stub_dlopen) || defined (__stub___dlopen) choke me #else -shl_load(); +char (*f) () = dlopen; +#endif +#ifdef __cplusplus +} #endif -; return 0; } -EOF -if { (eval echo configure:4250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_shl_load=yes" +int +main () +{ +return f != dlopen; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_shl_load=no" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_dlopen=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6 +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ -if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="shl_load" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6 -echo "configure:4268: checking for dlopen in -lsvld" >&5 -ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else - ac_save_LIBS="$LIBS" + echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" -cat > conftest.$ac_ext <<EOF -#line 4276 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); - -int main() { -dlopen() -; return 0; } -EOF -if { (eval echo configure:4287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_lib_svld_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 +if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 -echo "configure:4306: checking for shl_load in -ldld" >&5 -ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" -cat > conftest.$ac_ext <<EOF -#line 4314 "configure" -#include "confdefs.h" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char shl_load(); - -int main() { -shl_load() -; return 0; } -EOF -if { (eval echo configure:4325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char dld_link (); +int +main () +{ +dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +ac_cv_lib_dld_dld_link=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 +if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" -else - echo "$ac_t""no" 1>&6 fi - + fi - + fi - + fi - + +fi + + fi ;; @@ -4365,26 +8975,26 @@ fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" - echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 -echo "configure:4378: checking whether a program can dlopen itself" >&5 -if eval "test \"`echo '$''{'lt_cv_dlopen_self'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 4388 "configure" +#line 8997 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -4441,17 +9051,23 @@ int main () else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } + else + puts (dlerror ()); exit (status); } EOF - if { (eval echo configure:4449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed @@ -4460,25 +9076,25 @@ EOF fi rm -fr conftest* - -fi -echo "$ac_t""$lt_cv_dlopen_self" 1>&6 +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6 if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 -echo "configure:4472: checking whether a statically linked program can dlopen itself" >&5 -if eval "test \"`echo '$''{'lt_cv_dlopen_self_static'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 4482 "configure" +#line 9097 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -4535,17 +9151,23 @@ int main () else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } + else + puts (dlerror ()); exit (status); } EOF - if { (eval echo configure:4543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; - x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed @@ -4554,10 +9176,10 @@ EOF fi rm -fr conftest* - -fi -echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 +fi +echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi CPPFLAGS="$save_CPPFLAGS" @@ -4578,99 +9200,114 @@ echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 fi -if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6 -echo "configure:4592: checking whether -lc should be explicitly linked in" >&5 - if eval "test \"`echo '$''{'lt_cv_archive_cmds_need_lc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - $rm conftest* - echo 'static int dummy;' > conftest.$ac_ext - - if { (eval echo configure:4599: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_cv_prog_cc_wl - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { (eval echo configure:4612: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; } - then - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi -fi +# Report which library types will actually be built +echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 +test "$can_build_shared" = "no" && enable_shared=no - echo "$ac_t""$lt_cv_archive_cmds_need_lc" 1>&6 +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi ;; - esac -fi -need_lc=${lt_cv_archive_cmds_need_lc-yes} +esac +echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6 -# The second clause should only fire when bootstrapping the +# The else clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then - : -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - test -f Makefile && make "$ltmain" -fi - -if test -f "$ltmain"; then - trap "$rm \"${ofile}T\"; exit 1" 1 2 15 - $rm -f "${ofile}T" - - echo creating $ofile - + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. - for var in echo old_CC old_CFLAGS \ - AR AR_FLAGS CC LD LN_S NM SHELL \ - reload_flag reload_cmds wl \ - pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ - thread_safe_flag_spec whole_archive_flag_spec libname_spec \ - library_names_spec soname_spec \ - RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ - old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ - postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ - old_striplib striplib file_magic_cmd export_symbols_cmds \ - deplibs_check_method allow_undefined_flag no_undefined_flag \ - finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ - hardcode_libdir_flag_spec hardcode_libdir_separator \ + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ - compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + old_postinstall_cmds old_postuninstall_cmds \ + compiler \ + CC \ + LD \ + lt_prog_compiler_wl \ + lt_prog_compiler_pic \ + lt_prog_compiler_static \ + lt_prog_compiler_no_builtin_flag \ + export_dynamic_flag_spec \ + thread_safe_flag_spec \ + whole_archive_flag_spec \ + enable_shared_with_static_runtimes \ + old_archive_cmds \ + old_archive_from_new_cmds \ + predep_objects \ + postdep_objects \ + predeps \ + postdeps \ + compiler_lib_search_path \ + archive_cmds \ + archive_expsym_cmds \ + postinstall_cmds \ + postuninstall_cmds \ + old_archive_from_expsyms_cmds \ + allow_undefined_flag \ + no_undefined_flag \ + export_symbols_cmds \ + hardcode_libdir_flag_spec \ + hardcode_libdir_flag_spec_ld \ + hardcode_libdir_separator \ + hardcode_automatic \ + module_cmds \ + module_expsym_cmds \ + lt_cv_prog_compiler_c_o \ + exclude_expsyms \ + include_expsyms; do case $var in - reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ - old_postinstall_cmds | old_postuninstall_cmds | \ - export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ - extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ + old_archive_cmds | \ + old_archive_from_new_cmds | \ + archive_cmds | \ + archive_expsym_cmds | \ + module_cmds | \ + module_expsym_cmds | \ + old_archive_from_expsyms_cmds | \ + export_symbols_cmds | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ postinstall_cmds | postuninstall_cmds | \ - finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; @@ -4680,14 +9317,29 @@ if test -f "$ltmain"; then esac done - cat <<__EOF__ > "${ofile}T" + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + { echo "$as_me:$LINENO: creating $ofile" >&5 +echo "$as_me: creating $ofile" >&6;} + + cat <<__EOF__ >> "$cfgfile" #! $SHELL -# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # -# Copyright (C) 1996-2000 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 # # This program is free software; you can redistribute it and/or modify @@ -4702,19 +9354,25 @@ if test -f "$ltmain"; then # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. +# A sed program that does not truncate output. +SED=$lt_SED + # Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="sed -e s/^X//" +Xsed="$SED -e 1s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. -if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= # ### BEGIN LIBTOOL CONFIG @@ -4726,18 +9384,27 @@ SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$need_lc - # Whether or not to build static libraries. build_old_libs=$enable_static +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os # An echo program that does not interpret backslashes. echo=$lt_echo @@ -4746,12 +9413,21 @@ echo=$lt_echo AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS -# The default C compiler. -CC=$lt_CC +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler # Is the compiler the GNU C compiler? with_gcc=$GCC +# An ERE matcher. +EGREP=$lt_EGREP + # The linker used to build libraries. LD=$lt_LD @@ -4762,7 +9438,7 @@ LN_S=$lt_LN_S NM=$lt_NM # A symbol stripping program -STRIP=$STRIP +STRIP=$lt_STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD @@ -4784,7 +9460,7 @@ reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. -wl=$lt_wl +wl=$lt_lt_prog_compiler_wl # Object file suffix (normally "o"). objext="$ac_objext" @@ -4792,20 +9468,23 @@ objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. -pic_flag=$lt_pic_flag +pic_flag=$lt_lt_prog_compiler_pic pic_mode=$pic_mode -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_compiler_c_o +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len -# Can we write directly to a .lo ? -compiler_o_lo=$lt_compiler_o_lo +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o -# Must we lock files when doing compilation ? +# Must we lock files when doing compilation? need_locks=$lt_need_locks # Do we need the lib prefix for modules? @@ -4824,10 +9503,10 @@ dlopen_self=$enable_dlopen_self dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. -link_static_flag=$lt_link_static_flag +link_static_flag=$lt_lt_prog_compiler_static # Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_no_builtin_flag +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec @@ -4869,10 +9548,34 @@ archive_expsym_cmds=$lt_archive_expsym_cmds postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method @@ -4892,10 +9595,13 @@ finish_cmds=$lt_finish_cmds finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_global_symbol_pipe +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_global_symbol_to_cdecl +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var @@ -4916,10 +9622,15 @@ hardcode_into_libs=$hardcode_into_libs # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator -# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct @@ -4931,6 +9642,10 @@ hardcode_minus_L=$hardcode_minus_L # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic + # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" @@ -4966,9 +9681,10 @@ include_expsyms=$lt_include_expsyms __EOF__ + case $host_os in aix3*) - cat <<\EOF >> "${ofile}T" + cat <<\EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems @@ -4981,622 +9697,10285 @@ EOF ;; esac - case $host_os in - cygwin* | mingw* | pw32* | os2*) - cat <<'EOF' >> "${ofile}T" - # This is a source program that is used to create dlls on Windows - # Don't remove nor modify the starting and closing comments -# /* ltdll.c starts here */ -# #define WIN32_LEAN_AND_MEAN -# #include <windows.h> -# #undef WIN32_LEAN_AND_MEAN -# #include <stdio.h> -# -# #ifndef __CYGWIN__ -# # ifdef __CYGWIN32__ -# # define __CYGWIN__ __CYGWIN32__ -# # endif -# #endif -# -# #ifdef __cplusplus -# extern "C" { -# #endif -# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -# #ifdef __cplusplus -# } -# #endif -# -# #ifdef __CYGWIN__ -# #include <cygwin/cygwin_dll.h> -# DECLARE_CYGWIN_DLL( DllMain ); -# #endif -# HINSTANCE __hDllInstance_base; -# -# BOOL APIENTRY -# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -# { -# __hDllInstance_base = hInst; -# return TRUE; -# } -# /* ltdll.c ends here */ - # This is a source program that is used to create import libraries - # on Windows for dlls which lack them. Don't remove nor modify the - # starting and closing comments -# /* impgen.c starts here */ -# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. -# -# This file is part of GNU libtool. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# */ -# -# #include <stdio.h> /* for printf() */ -# #include <unistd.h> /* for open(), lseek(), read() */ -# #include <fcntl.h> /* for O_RDONLY, O_BINARY */ -# #include <string.h> /* for strdup() */ -# -# /* O_BINARY isn't required (or even defined sometimes) under Unix */ -# #ifndef O_BINARY -# #define O_BINARY 0 -# #endif -# -# static unsigned int -# pe_get16 (fd, offset) -# int fd; -# int offset; -# { -# unsigned char b[2]; -# lseek (fd, offset, SEEK_SET); -# read (fd, b, 2); -# return b[0] + (b[1]<<8); -# } -# -# static unsigned int -# pe_get32 (fd, offset) -# int fd; -# int offset; -# { -# unsigned char b[4]; -# lseek (fd, offset, SEEK_SET); -# read (fd, b, 4); -# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); -# } -# -# static unsigned int -# pe_as32 (ptr) -# void *ptr; -# { -# unsigned char *b = ptr; -# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); -# } -# -# int -# main (argc, argv) -# int argc; -# char *argv[]; -# { -# int dll; -# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; -# unsigned long export_rva, export_size, nsections, secptr, expptr; -# unsigned long name_rvas, nexp; -# unsigned char *expdata, *erva; -# char *filename, *dll_name; + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + +# Check whether --with-tags or --without-tags was given. +if test "${with_tags+set}" = set; then + withval="$with_tags" + tagnames="$withval" +fi; + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} + else + { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 +echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} + fi + fi + if test -z "$LTCFLAGS"; then + eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in + "") ;; + *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 +echo "$as_me: error: invalid tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 +echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} + { (exit 1); exit 1; }; } + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_flag_spec_ld_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_shlibpath_var_CXX=unsupported +hardcode_automatic_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + $as_unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + $as_unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +compiler_CXX=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' +else + lt_prog_compiler_no_builtin_flag_CXX= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break + ;; + *) + test "$with_gnu_ld" != yes && break + ;; + esac + fi + done + IFS="$lt_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$lt_cv_path_LD" +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 </dev/null` in +*GNU* | *'with BFD'*) + lt_cv_prog_gnu_ld=yes + ;; +*) + lt_cv_prog_gnu_ld=no + ;; +esac +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 +ld_shlibs_CXX=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_CXX=yes + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_CXX=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_CXX='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' ${wl}-bernotok' + allow_undefined_flag_CXX=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX='$convenience' + archive_cmds_need_lc_CXX=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_CXX=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_CXX=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_CXX=no + fi + ;; + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + whole_archive_flag_spec_CXX='' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes ; then + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_CXX=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + ld_shlibs_CXX=no + ;; + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + freebsd* | kfreebsd*-gnu | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + gnu*) + ;; + hpux9*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld_CXX='+b $libdir' + ;; + *) + export_dynamic_flag_spec_CXX='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + *) + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + interix3*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + ;; + linux*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc*) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC*) + # Portland Group C++ compiler + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + ld_shlibs_CXX=no + ;; + openbsd*) + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='${wl}-E' + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + ;; + osf3*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ + $rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + archive_cmds_need_lc_CXX=yes + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. We must also pass each convience library through + # to the system linker between allextract/defaultextract. + # The C++ compiler will combine linker options so we + # cannot just pass the convience library names through + # without $wl. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag_CXX='${wl}-z,text' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + # So that behaviour is only enabled if SCOABSPATH is set to a + # non-empty value in the environment. Most likely only useful for + # creating official distributions of packages. + # This is a hack until libtool officially supports absolute path + # names for shared libraries. + no_undefined_flag_CXX='${wl}-z,text' + allow_undefined_flag_CXX='${wl}-z,nodefs' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + export_dynamic_flag_spec_CXX='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; +esac +echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6 +test "$ld_shlibs_CXX" = no && can_build_shared=no + +GCC_CXX="$GXX" +LD_CXX="$LD" + + +cat > conftest.$ac_ext <<EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +EOF + +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + # The `*' in the case matches for architectures that use `case' in + # $output_verbose_cmd can trigger glob expansion during the loop + # eval without this substitution. + output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"` + + for p in `eval $output_verbose_link_cmd`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX="${prev}${p}" + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX="${prev}${p}" + else + postdeps_CXX="${postdeps_CXX} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX="$p" + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX="$p" + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$rm -f confest.$objext + +# PORTME: override above test on systems where it is broken +case $host_os in +interix3*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + predep_objects_CXX= + postdep_objects_CXX= + postdeps_CXX= + ;; + +solaris*) + case $cc_basename in + CC*) + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + postdeps_CXX='-lCstd -lCrun' + ;; + esac + ;; +esac + + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + +lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_CXX='-qnocommon' + lt_prog_compiler_wl_CXX='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + icpc* | ecpc*) + # Intel C++ + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + pgCC*) + # Portland Group C++ compiler. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fpic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx*) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc*) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + esac + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 + # -# filename = argv[1]; +# Check to make sure the PIC flag actually works. # -# dll = open(filename, O_RDONLY|O_BINARY); -# if (dll < 1) -# return 1; +if test -n "$lt_prog_compiler_pic_CXX"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:11435: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:11439: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works_CXX=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 + +if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac + # -# dll_name = filename; +# Check to make sure the static flag actually works. # -# for (i=0; filename[i]; i++) -# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') -# dll_name = filename + i +1; +wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works_CXX=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works_CXX=yes + fi + else + lt_prog_compiler_static_works_CXX=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6 + +if test x"$lt_prog_compiler_static_works_CXX" = xyes; then + : +else + lt_prog_compiler_static_CXX= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:11539: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:11543: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX="$ltdll_cmds" + ;; + cygwin* | mingw*) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + kfreebsd*-gnu) + link_all_deplibs_CXX=no + ;; + linux*) + link_all_deplibs_CXX=no + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + +echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6 +test "$ld_shlibs_CXX" = no && can_build_shared=no + # -# pe_header_offset = pe_get32 (dll, 0x3c); -# opthdr_ofs = pe_header_offset + 4 + 20; -# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# Do we need to explicitly link libc? # -# if (num_entries < 1) /* no exports */ -# return 1; +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + pic_flag=$lt_prog_compiler_pic_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_CXX=no + else + archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || \ + test -n "$runpath_var_CXX" || \ + test "X$hardcode_automatic_CXX" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_CXX" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && + test "$hardcode_minus_L_CXX" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 +echo "${ECHO_T}$hardcode_action_CXX" >&6 + +if test "$hardcode_action_CXX" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_CXX \ + CC_CXX \ + LD_CXX \ + lt_prog_compiler_wl_CXX \ + lt_prog_compiler_pic_CXX \ + lt_prog_compiler_static_CXX \ + lt_prog_compiler_no_builtin_flag_CXX \ + export_dynamic_flag_spec_CXX \ + thread_safe_flag_spec_CXX \ + whole_archive_flag_spec_CXX \ + enable_shared_with_static_runtimes_CXX \ + old_archive_cmds_CXX \ + old_archive_from_new_cmds_CXX \ + predep_objects_CXX \ + postdep_objects_CXX \ + predeps_CXX \ + postdeps_CXX \ + compiler_lib_search_path_CXX \ + archive_cmds_CXX \ + archive_expsym_cmds_CXX \ + postinstall_cmds_CXX \ + postuninstall_cmds_CXX \ + old_archive_from_expsyms_cmds_CXX \ + allow_undefined_flag_CXX \ + no_undefined_flag_CXX \ + export_symbols_cmds_CXX \ + hardcode_libdir_flag_spec_CXX \ + hardcode_libdir_flag_spec_ld_CXX \ + hardcode_libdir_separator_CXX \ + hardcode_automatic_CXX \ + module_cmds_CXX \ + module_expsym_cmds_CXX \ + lt_cv_prog_compiler_c_o_CXX \ + exclude_expsyms_CXX \ + include_expsyms_CXX; do + + case $var in + old_archive_cmds_CXX | \ + old_archive_from_new_cmds_CXX | \ + archive_cmds_CXX | \ + archive_expsym_cmds_CXX | \ + module_cmds_CXX | \ + module_expsym_cmds_CXX | \ + old_archive_from_expsyms_cmds_CXX | \ + export_symbols_cmds_CXX | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_CXX + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_CXX +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_CXX + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_CXX" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld + + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu + + +archive_cmds_need_lc_F77=no +allow_undefined_flag_F77= +always_export_symbols_F77=no +archive_expsym_cmds_F77= +export_dynamic_flag_spec_F77= +hardcode_direct_F77=no +hardcode_libdir_flag_spec_F77= +hardcode_libdir_flag_spec_ld_F77= +hardcode_libdir_separator_F77= +hardcode_minus_L_F77=no +hardcode_automatic_F77=no +module_cmds_F77= +module_expsym_cmds_F77= +link_all_deplibs_F77=unknown +old_archive_cmds_F77=$old_archive_cmds +no_undefined_flag_F77= +whole_archive_flag_spec_F77= +enable_shared_with_static_runtimes_F77=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +objext_F77=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code=" subroutine t\n return\n end\n" + +# Code to be used in simple link tests +lt_simple_link_test_code=" program t\n end\n" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${F77-"f77"} +compiler=$CC +compiler_F77=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case $host_os in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6 + +echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6 + +GCC_F77="$G77" +LD_F77="$LD" + +lt_prog_compiler_wl_F77= +lt_prog_compiler_pic_F77= +lt_prog_compiler_static_F77= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_static_F77='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_F77='-fno-common' + ;; + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_F77=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_F77=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_F77='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + else + lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_F77='-qnocommon' + lt_prog_compiler_wl_F77='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_F77='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_F77='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + linux*) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-fpic' + lt_prog_compiler_static_F77='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl_F77='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_F77='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl_F77='-Qoption ld ';; + *) + lt_prog_compiler_wl_F77='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl_F77='-Qoption ld ' + lt_prog_compiler_pic_F77='-PIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_F77='-Kconform_pic' + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_can_build_shared_F77=no + ;; + + uts4*) + lt_prog_compiler_pic_F77='-pic' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_F77=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6 + # -# export_rva = pe_get32 (dll, opthdr_ofs + 96); -# export_size = pe_get32 (dll, opthdr_ofs + 100); -# nsections = pe_get16 (dll, pe_header_offset + 4 +2); -# secptr = (pe_header_offset + 4 + 20 + -# pe_get16 (dll, pe_header_offset + 4 + 16)); +# Check to make sure the PIC flag actually works. # -# expptr = 0; -# for (i = 0; i < nsections; i++) -# { -# char sname[8]; -# unsigned long secptr1 = secptr + 40 * i; -# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); -# unsigned long vsize = pe_get32 (dll, secptr1 + 16); -# unsigned long fptr = pe_get32 (dll, secptr1 + 20); -# lseek(dll, secptr1, SEEK_SET); -# read(dll, sname, 8); -# if (vaddr <= export_rva && vaddr+vsize > export_rva) -# { -# expptr = fptr + (export_rva - vaddr); -# if (export_rva + export_size > vaddr + vsize) -# export_size = vsize - (export_rva - vaddr); -# break; -# } -# } +if test -n "$lt_prog_compiler_pic_F77"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_F77=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_F77" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:13127: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:13131: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works_F77=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6 + +if test x"$lt_prog_compiler_pic_works_F77" = xyes; then + case $lt_prog_compiler_pic_F77 in + "" | " "*) ;; + *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; + esac +else + lt_prog_compiler_pic_F77= + lt_prog_compiler_can_build_shared_F77=no +fi + +fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_F77= + ;; + *) + lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" + ;; +esac + # -# expdata = (unsigned char*)malloc(export_size); -# lseek (dll, expptr, SEEK_SET); -# read (dll, expdata, export_size); -# erva = expdata - export_rva; +# Check to make sure the static flag actually works. # -# nexp = pe_as32 (expdata+24); -# name_rvas = pe_as32 (expdata+32); +wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works_F77=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works_F77=yes + fi + else + lt_prog_compiler_static_works_F77=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6 + +if test x"$lt_prog_compiler_static_works_F77" = xyes; then + : +else + lt_prog_compiler_static_F77= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_F77=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:13231: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:13235: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_F77=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag_F77= + enable_shared_with_static_runtimes_F77=no + archive_cmds_F77= + archive_expsym_cmds_F77= + old_archive_From_new_cmds_F77= + old_archive_from_expsyms_cmds_F77= + export_dynamic_flag_spec_F77= + whole_archive_flag_spec_F77= + thread_safe_flag_spec_F77= + hardcode_libdir_flag_spec_F77= + hardcode_libdir_flag_spec_ld_F77= + hardcode_libdir_separator_F77= + hardcode_direct_F77=no + hardcode_minus_L_F77=no + hardcode_shlibpath_var_F77=unsupported + link_all_deplibs_F77=unknown + hardcode_automatic_F77=no + module_cmds_F77= + module_expsym_cmds_F77= + always_export_symbols_F77=no + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_F77= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_F77=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_F77='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_F77= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_F77=no + cat <<EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_F77=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_F77=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_F77='-L$libdir' + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=no + enable_shared_with_static_runtimes_F77=yes + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_F77=no + fi + ;; + + interix3*) + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + export_dynamic_flag_spec_F77='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + link_all_deplibs_F77=no + else + ld_shlibs_F77=no + fi + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_F77=no + cat <<EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs_F77=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + esac + + if test "$ld_shlibs_F77" = no; then + runpath_var= + hardcode_libdir_flag_spec_F77= + export_dynamic_flag_spec_F77= + whole_archive_flag_spec_F77= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=yes + archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_F77=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_F77=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_F77='' + hardcode_direct_F77=yes + hardcode_libdir_separator_F77=':' + link_all_deplibs_F77=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_F77=yes + else + # We have old collect2 + hardcode_direct_F77=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_F77=yes + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_libdir_separator_F77= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_F77=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_F77='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_F77="-z nodefs" + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_F77=' ${wl}-bernotok' + allow_undefined_flag_F77=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_F77='$convenience' + archive_cmds_need_lc_F77=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_F77=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec_F77=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_F77=' ' + allow_undefined_flag_F77=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_F77='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path_F77='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_F77=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag_F77='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_F77=no + hardcode_direct_F77=no + hardcode_automatic_F77=yes + hardcode_shlibpath_var_F77=unsupported + whole_archive_flag_spec_F77='' + link_all_deplibs_F77=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_F77=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + freebsd1*) + ld_shlibs_F77=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # GNU/kFreeBSD uses gcc -shared to do shared libraries. + kfreebsd*-gnu) + archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + link_all_deplibs_F77=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + + hardcode_direct_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld_F77='+b $libdir' + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + ;; + *) + hardcode_direct_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + link_all_deplibs_F77=yes + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + newsos6) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_shlibpath_var_F77=no + ;; + + openbsd*) + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + export_dynamic_flag_spec_F77='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + ;; + *) + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + allow_undefined_flag_F77=unsupported + archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_F77='-rpath $libdir' + fi + hardcode_libdir_separator_F77=: + ;; + + solaris*) + no_undefined_flag_F77=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_shlibpath_var_F77=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; + *) + whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + link_all_deplibs_F77=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_F77='$CC -r -o $output$reload_objs' + hardcode_direct_F77=no + ;; + motorola) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_F77=no + ;; + + sysv4.3*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + export_dynamic_flag_spec_F77='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_F77=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + no_undefined_flag_F77='${wl}-z,text' + archive_cmds_need_lc_F77=no + hardcode_shlibpath_var_F77=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag_F77='${wl}-z,text' + allow_undefined_flag_F77='${wl}-z,nodefs' + archive_cmds_need_lc_F77=no + hardcode_shlibpath_var_F77=no + hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_F77=':' + link_all_deplibs_F77=yes + export_dynamic_flag_spec_F77='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + *) + ld_shlibs_F77=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 +echo "${ECHO_T}$ld_shlibs_F77" >&6 +test "$ld_shlibs_F77" = no && can_build_shared=no + # -# printf ("EXPORTS\n"); -# for (i = 0; i<nexp; i++) -# { -# unsigned long name_rva = pe_as32 (erva+name_rvas+i*4); -# printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i); -# } +# Do we need to explicitly link libc? # -# return 0; -# } -# /* impgen.c ends here */ +case "x$archive_cmds_need_lc_F77" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_F77=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_F77 in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_F77 + pic_flag=$lt_prog_compiler_pic_F77 + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_F77 + allow_undefined_flag_F77= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_F77=no + else + archive_cmds_need_lc_F77=yes + fi + allow_undefined_flag_F77=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6 + ;; + esac + fi + ;; +esac -EOF +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ;; esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "${ofile}T" || (rm -f "${ofile}T"; exit 1) +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; - mv -f "${ofile}T" "$ofile" || \ - (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") - chmod +x "$ofile" +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_F77= +if test -n "$hardcode_libdir_flag_spec_F77" || \ + test -n "$runpath_var_F77" || \ + test "X$hardcode_automatic_F77" = "Xyes" ; then + # We can hardcode non-existant directories. + if test "$hardcode_direct_F77" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && + test "$hardcode_minus_L_F77" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_F77=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_F77=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_F77=unsupported +fi +echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 +echo "${ECHO_T}$hardcode_action_F77" >&6 +if test "$hardcode_action_F77" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_F77 \ + CC_F77 \ + LD_F77 \ + lt_prog_compiler_wl_F77 \ + lt_prog_compiler_pic_F77 \ + lt_prog_compiler_static_F77 \ + lt_prog_compiler_no_builtin_flag_F77 \ + export_dynamic_flag_spec_F77 \ + thread_safe_flag_spec_F77 \ + whole_archive_flag_spec_F77 \ + enable_shared_with_static_runtimes_F77 \ + old_archive_cmds_F77 \ + old_archive_from_new_cmds_F77 \ + predep_objects_F77 \ + postdep_objects_F77 \ + predeps_F77 \ + postdeps_F77 \ + compiler_lib_search_path_F77 \ + archive_cmds_F77 \ + archive_expsym_cmds_F77 \ + postinstall_cmds_F77 \ + postuninstall_cmds_F77 \ + old_archive_from_expsyms_cmds_F77 \ + allow_undefined_flag_F77 \ + no_undefined_flag_F77 \ + export_symbols_cmds_F77 \ + hardcode_libdir_flag_spec_F77 \ + hardcode_libdir_flag_spec_ld_F77 \ + hardcode_libdir_separator_F77 \ + hardcode_automatic_F77 \ + module_cmds_F77 \ + module_expsym_cmds_F77 \ + lt_cv_prog_compiler_c_o_F77 \ + exclude_expsyms_F77 \ + include_expsyms_F77; do -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' + case $var in + old_archive_cmds_F77 | \ + old_archive_from_new_cmds_F77 | \ + archive_cmds_F77 | \ + archive_expsym_cmds_F77 | \ + module_cmds_F77 | \ + module_expsym_cmds_F77 | \ + old_archive_from_expsyms_cmds_F77 | \ + export_symbols_cmds_F77 | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done -# Prevent multiple expansion + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_F77 + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_F77 + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_F77 + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_F77 + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_F77 + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_F77 +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_F77 + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_F77 +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_F77 +archive_expsym_cmds=$lt_archive_expsym_cmds_F77 +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_F77 +module_expsym_cmds=$lt_module_expsym_cmds_F77 + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_F77 + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_F77 + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_F77 + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_F77 + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_F77 + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_F77 + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_F77 + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_F77 + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_F77 + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_F77 + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_F77" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_F77 + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_F77 + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_F77 + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_F77 + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:5190: checking for ANSI C header files" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 else - cat > conftest.$ac_ext <<EOF -#line 5195 "configure" -#include "confdefs.h" -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <float.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5203: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - ac_cv_header_stdc=yes + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + + + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +objext_GCJ=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${GCJ-"gcj"} +compiler=$CC +compiler_GCJ=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +archive_cmds_need_lc_GCJ=no + +old_archive_cmds_GCJ=$old_archive_cmds + + +lt_prog_compiler_no_builtin_flag_GCJ= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' + + +echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15454: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:15458: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + fi -rm -f conftest* +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. -cat > conftest.$ac_ext <<EOF -#line 5220 "configure" -#include "confdefs.h" -#include <string.h> -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" else - rm -rf conftest* - ac_cv_header_stdc=no + : fi -rm -f conftest* fi -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. -cat > conftest.$ac_ext <<EOF -#line 5238 "configure" -#include "confdefs.h" -#include <stdlib.h> -EOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : +lt_prog_compiler_wl_GCJ= +lt_prog_compiler_pic_GCJ= +lt_prog_compiler_static_GCJ= + +echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 + + if test "$GCC" = yes; then + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_static_GCJ='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_GCJ='-fno-common' + ;; + + interix3*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_GCJ=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_GCJ=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_GCJ='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + else + lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case $cc_basename in + xlc*) + lt_prog_compiler_pic_GCJ='-qnocommon' + lt_prog_compiler_wl_GCJ='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + linux*) + case $cc_basename in + icc* | ecc*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-fpic' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl_GCJ='-Qoption ld ';; + *) + lt_prog_compiler_wl_GCJ='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl_GCJ='-Qoption ld ' + lt_prog_compiler_pic_GCJ='-PIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_GCJ='-Kconform_pic' + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_can_build_shared_GCJ=no + ;; + + uts4*) + lt_prog_compiler_pic_GCJ='-pic' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_GCJ=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_GCJ"; then + +echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 +if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - rm -rf conftest* - ac_cv_header_stdc=no + lt_prog_compiler_pic_works_GCJ=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_GCJ" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15722: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:15726: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_pic_works_GCJ=yes + fi + fi + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 + +if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then + case $lt_prog_compiler_pic_GCJ in + "" | " "*) ;; + *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; + esac +else + lt_prog_compiler_pic_GCJ= + lt_prog_compiler_can_build_shared_GCJ=no fi -rm -f conftest* fi +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_GCJ= + ;; + *) + lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" + ;; +esac -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\" +echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6 +if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 5259 "configure" -#include "confdefs.h" -#include <ctype.h> -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } + lt_prog_compiler_static_works_GCJ=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_prog_compiler_static_works_GCJ=yes + fi + else + lt_prog_compiler_static_works_GCJ=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6 + +if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then + : +else + lt_prog_compiler_static_GCJ= +fi + + +echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 +if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_GCJ=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15826: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:15830: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_GCJ=yes + fi + fi + chmod u+w . 2>&5 + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6 + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 + + runpath_var= + allow_undefined_flag_GCJ= + enable_shared_with_static_runtimes_GCJ=no + archive_cmds_GCJ= + archive_expsym_cmds_GCJ= + old_archive_From_new_cmds_GCJ= + old_archive_from_expsyms_cmds_GCJ= + export_dynamic_flag_spec_GCJ= + whole_archive_flag_spec_GCJ= + thread_safe_flag_spec_GCJ= + hardcode_libdir_flag_spec_GCJ= + hardcode_libdir_flag_spec_ld_GCJ= + hardcode_libdir_separator_GCJ= + hardcode_direct_GCJ=no + hardcode_minus_L_GCJ=no + hardcode_shlibpath_var_GCJ=unsupported + link_all_deplibs_GCJ=unknown + hardcode_automatic_GCJ=no + module_cmds_GCJ= + module_expsym_cmds_GCJ= + always_export_symbols_GCJ=no + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_GCJ= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + # Just being paranoid about ensuring that cc_basename is set. + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_GCJ=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_GCJ= + fi + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_GCJ=no + cat <<EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. EOF -if { (eval echo configure:5270: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + + # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_GCJ=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_GCJ=unsupported + # Joseph Beckenbach <jrb3@best.com> says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_GCJ='-L$libdir' + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=no + enable_shared_with_static_runtimes_GCJ=yes + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + interix3*) + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + export_dynamic_flag_spec_GCJ='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_addflag= + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + esac + archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + $echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + link_all_deplibs_GCJ=no + else + ld_shlibs_GCJ=no + fi + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_GCJ=no + cat <<EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs_GCJ=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + esac + + if test "$ld_shlibs_GCJ" = no; then + runpath_var= + hardcode_libdir_flag_spec_GCJ= + export_dynamic_flag_spec_GCJ= + whole_archive_flag_spec_GCJ= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=yes + archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_GCJ=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_GCJ=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_GCJ='' + hardcode_direct_GCJ=yes + hardcode_libdir_separator_GCJ=':' + link_all_deplibs_GCJ=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_GCJ=yes + else + # We have old collect2 + hardcode_direct_GCJ=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_GCJ=yes + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_libdir_separator_GCJ= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_GCJ=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_GCJ='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -fr conftest* +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_GCJ="-z nodefs" + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_GCJ=' ${wl}-bernotok' + allow_undefined_flag_GCJ=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_GCJ='$convenience' + archive_cmds_need_lc_GCJ=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_GCJ=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec_GCJ=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_GCJ=' ' + allow_undefined_flag_GCJ=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_GCJ='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_GCJ=yes + ;; + + darwin* | rhapsody*) + case $host_os in + rhapsody* | darwin1.[012]) + allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_GCJ=no + hardcode_direct_GCJ=no + hardcode_automatic_GCJ=yes + hardcode_shlibpath_var_GCJ=unsupported + whole_archive_flag_spec_GCJ='' + link_all_deplibs_GCJ=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case $cc_basename in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_GCJ=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + freebsd1*) + ld_shlibs_GCJ=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # GNU/kFreeBSD uses gcc -shared to do shared libraries. + kfreebsd*-gnu) + archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + link_all_deplibs_GCJ=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + + hardcode_direct_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + ;; + *) + hardcode_direct_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + link_all_deplibs_GCJ=yes + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + newsos6) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_shlibpath_var_GCJ=no + ;; + + openbsd*) + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + export_dynamic_flag_spec_GCJ='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + ;; + *) + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + allow_undefined_flag_GCJ=unsupported + archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_GCJ='-rpath $libdir' + fi + hardcode_libdir_separator_GCJ=: + ;; + + solaris*) + no_undefined_flag_GCJ=' -z text' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + wlarc='' + archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_shlibpath_var_GCJ=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine linker options so we + # cannot just pass the convience library names through + # without $wl, iff we do not link with $LD. + # Luckily, gcc supports the same syntax we need for Sun Studio. + # Supported since Solaris 2.6 (maybe 2.5.1?) + case $wlarc in + '') + whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; + *) + whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; + esac ;; + esac + link_all_deplibs_GCJ=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_GCJ='$CC -r -o $output$reload_objs' + hardcode_direct_GCJ=no + ;; + motorola) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4.3*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + export_dynamic_flag_spec_GCJ='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_GCJ=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + no_undefined_flag_GCJ='${wl}-z,text' + archive_cmds_need_lc_GCJ=no + hardcode_shlibpath_var_GCJ=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag_GCJ='${wl}-z,text' + allow_undefined_flag_GCJ='${wl}-z,nodefs' + archive_cmds_need_lc_GCJ=no + hardcode_shlibpath_var_GCJ=no + hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator_GCJ=':' + link_all_deplibs_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + *) + ld_shlibs_GCJ=no + ;; + esac + fi + +echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 +echo "${ECHO_T}$ld_shlibs_GCJ" >&6 +test "$ld_shlibs_GCJ" = no && can_build_shared=no + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_GCJ" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_GCJ=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_GCJ in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_GCJ + pic_flag=$lt_prog_compiler_pic_GCJ + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ + allow_undefined_flag_GCJ= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_GCJ=no + else + archive_cmds_need_lc_GCJ=yes + fi + allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 + ;; + esac + fi + ;; +esac + +echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + freebsd*) # from 4.6 on + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix3*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + shlibpath_overrides_runpath=no + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + shlibpath_overrides_runpath=yes + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6 +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi +echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 +hardcode_action_GCJ= +if test -n "$hardcode_libdir_flag_spec_GCJ" || \ + test -n "$runpath_var_GCJ" || \ + test "X$hardcode_automatic_GCJ" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_GCJ" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && + test "$hardcode_minus_L_GCJ" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_GCJ=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_GCJ=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_GCJ=unsupported fi +echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 +echo "${ECHO_T}$hardcode_action_GCJ" >&6 + +if test "$hardcode_action_GCJ" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless fi -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_GCJ \ + CC_GCJ \ + LD_GCJ \ + lt_prog_compiler_wl_GCJ \ + lt_prog_compiler_pic_GCJ \ + lt_prog_compiler_static_GCJ \ + lt_prog_compiler_no_builtin_flag_GCJ \ + export_dynamic_flag_spec_GCJ \ + thread_safe_flag_spec_GCJ \ + whole_archive_flag_spec_GCJ \ + enable_shared_with_static_runtimes_GCJ \ + old_archive_cmds_GCJ \ + old_archive_from_new_cmds_GCJ \ + predep_objects_GCJ \ + postdep_objects_GCJ \ + predeps_GCJ \ + postdeps_GCJ \ + compiler_lib_search_path_GCJ \ + archive_cmds_GCJ \ + archive_expsym_cmds_GCJ \ + postinstall_cmds_GCJ \ + postuninstall_cmds_GCJ \ + old_archive_from_expsyms_cmds_GCJ \ + allow_undefined_flag_GCJ \ + no_undefined_flag_GCJ \ + export_symbols_cmds_GCJ \ + hardcode_libdir_flag_spec_GCJ \ + hardcode_libdir_flag_spec_ld_GCJ \ + hardcode_libdir_separator_GCJ \ + hardcode_automatic_GCJ \ + module_cmds_GCJ \ + module_expsym_cmds_GCJ \ + lt_cv_prog_compiler_c_o_GCJ \ + exclude_expsyms_GCJ \ + include_expsyms_GCJ; do + + case $var in + old_archive_cmds_GCJ | \ + old_archive_from_new_cmds_GCJ | \ + archive_cmds_GCJ | \ + archive_expsym_cmds_GCJ | \ + module_cmds_GCJ | \ + module_expsym_cmds_GCJ | \ + old_archive_from_expsyms_cmds_GCJ | \ + export_symbols_cmds_GCJ | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_GCJ + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_GCJ + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_GCJ + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_GCJ + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_GCJ + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_GCJ +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_GCJ + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_GCJ +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_GCJ +archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_GCJ +module_expsym_cmds=$lt_module_expsym_cmds_GCJ + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_GCJ + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_GCJ + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_GCJ + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_GCJ + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_GCJ + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_GCJ + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_GCJ + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_GCJ + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_GCJ + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_GCJ" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_GCJ + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_GCJ + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_GCJ + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_GCJ + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + RC) + + + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +objext_RC=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +printf "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$rm conftest* + +ac_outfile=conftest.$ac_objext +printf "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$rm conftest* + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${RC-"windres"} +compiler=$CC +compiler_RC=$CC +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + +lt_cv_prog_compiler_c_o_RC=yes + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_RC \ + CC_RC \ + LD_RC \ + lt_prog_compiler_wl_RC \ + lt_prog_compiler_pic_RC \ + lt_prog_compiler_static_RC \ + lt_prog_compiler_no_builtin_flag_RC \ + export_dynamic_flag_spec_RC \ + thread_safe_flag_spec_RC \ + whole_archive_flag_spec_RC \ + enable_shared_with_static_runtimes_RC \ + old_archive_cmds_RC \ + old_archive_from_new_cmds_RC \ + predep_objects_RC \ + postdep_objects_RC \ + predeps_RC \ + postdeps_RC \ + compiler_lib_search_path_RC \ + archive_cmds_RC \ + archive_expsym_cmds_RC \ + postinstall_cmds_RC \ + postuninstall_cmds_RC \ + old_archive_from_expsyms_cmds_RC \ + allow_undefined_flag_RC \ + no_undefined_flag_RC \ + export_symbols_cmds_RC \ + hardcode_libdir_flag_spec_RC \ + hardcode_libdir_flag_spec_ld_RC \ + hardcode_libdir_separator_RC \ + hardcode_automatic_RC \ + module_cmds_RC \ + module_expsym_cmds_RC \ + lt_cv_prog_compiler_c_o_RC \ + exclude_expsyms_RC \ + include_expsyms_RC; do + + case $var in + old_archive_cmds_RC | \ + old_archive_from_new_cmds_RC | \ + archive_cmds_RC | \ + archive_expsym_cmds_RC | \ + module_cmds_RC | \ + module_expsym_cmds_RC | \ + old_archive_from_expsyms_cmds_RC | \ + export_symbols_cmds_RC | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_RC + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# LTCC compiler flags. +LTCFLAGS=$lt_LTCFLAGS + +# A language-specific compiler. +CC=$lt_compiler_RC + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_RC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_RC + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_RC + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_RC +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_RC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_RC +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_RC +archive_expsym_cmds=$lt_archive_expsym_cmds_RC +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_RC +module_expsym_cmds=$lt_module_expsym_cmds_RC + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_RC + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_RC + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_RC + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_RC + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_RC + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_RC + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_RC + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_RC + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_RC + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_RC + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_RC + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_RC" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_RC + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_RC + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_RC + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_RC + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + ;; + + *) + { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 +echo "$as_me: error: Unsupported tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 +echo "$as_me: error: unable to update list of available tagged configurations." >&2;} + { (exit 1); exit 1; }; } + fi +fi + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + + + + + + + + + + + + + + + + + + + if test "x${prefix}" = "xNONE"; then - scriptsdir="${ac_default_prefix}/share/setup-tool-backends/scripts" + scriptsdir="${ac_default_prefix}/share/system-tools-backends-2.0/scripts" + filesdir="${ac_default_prefix}/share/system-tools-backends-2.0/files" else - scriptsdir="${prefix}/share/setup-tool-backends/scripts" + scriptsdir="${prefix}/share/system-tools-backends-2.0/scripts" + filesdir="${prefix}/share/system-tools-backends-2.0/files" fi -trap '' 1 2 15 -cat > confcache <<\EOF +DBUS_SERVICES_DIR="${prefix}/share/dbus-1/services" + + + ac_config_files="$ac_config_files Makefile m4macros/Makefile system-tools-backends-2.0.pc files/Makefile Init/Makefile Network/Makefile Shares/Makefile Time/Makefile Users/Makefile Utils/Makefile SystemToolsBackends.pl org.freedesktop.SystemToolsBackends.service" +cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. # -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. # -EOF +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' fi -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs +LTLIBOBJS=$ac_ltlibobjs -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh -# Generated automatically by configure. +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. # Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# # Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do - case "\$ac_option" in + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by system-tools-backends $as_me 1.9.0, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to <bug-autoconf@gnu.org>." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +system-tools-backends config.status 1.9.0 +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + esac + shift done -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" +ac_configure_extra_args= -trap 'rm -fr `echo " -Makefile -" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS <<EOF +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@PACKAGE@%$PACKAGE%g -s%@VERSION@%$VERSION%g -s%@ACLOCAL@%$ACLOCAL%g -s%@AUTOCONF@%$AUTOCONF%g -s%@AUTOMAKE@%$AUTOMAKE%g -s%@AUTOHEADER@%$AUTOHEADER%g -s%@MAKEINFO@%$MAKEINFO%g -s%@SET_MAKE@%$SET_MAKE%g -s%@CC@%$CC%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@build@%$build%g -s%@build_alias@%$build_alias%g -s%@build_cpu@%$build_cpu%g -s%@build_vendor@%$build_vendor%g -s%@build_os@%$build_os%g -s%@LN_S@%$LN_S%g -s%@OBJEXT@%$OBJEXT%g -s%@EXEEXT@%$EXEEXT%g -s%@ECHO@%$ECHO%g -s%@RANLIB@%$RANLIB%g -s%@STRIP@%$STRIP%g -s%@CPP@%$CPP%g -s%@LIBTOOL@%$LIBTOOL%g -s%@scriptsdir@%$scriptsdir%g +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "m4macros/Makefile" ) CONFIG_FILES="$CONFIG_FILES m4macros/Makefile" ;; + "system-tools-backends-2.0.pc" ) CONFIG_FILES="$CONFIG_FILES system-tools-backends-2.0.pc" ;; + "files/Makefile" ) CONFIG_FILES="$CONFIG_FILES files/Makefile" ;; + "Init/Makefile" ) CONFIG_FILES="$CONFIG_FILES Init/Makefile" ;; + "Network/Makefile" ) CONFIG_FILES="$CONFIG_FILES Network/Makefile" ;; + "Shares/Makefile" ) CONFIG_FILES="$CONFIG_FILES Shares/Makefile" ;; + "Time/Makefile" ) CONFIG_FILES="$CONFIG_FILES Time/Makefile" ;; + "Users/Makefile" ) CONFIG_FILES="$CONFIG_FILES Users/Makefile" ;; + "Utils/Makefile" ) CONFIG_FILES="$CONFIG_FILES Utils/Makefile" ;; + "SystemToolsBackends.pl" ) CONFIG_FILES="$CONFIG_FILES SystemToolsBackends.pl" ;; + "org.freedesktop.SystemToolsBackends.service" ) CONFIG_FILES="$CONFIG_FILES org.freedesktop.SystemToolsBackends.service" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@AMTAR@,$AMTAR,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@EGREP@,$EGREP,;t t +s,@LN_S@,$LN_S,;t t +s,@ECHO@,$ECHO,;t t +s,@AR@,$AR,;t t +s,@ac_ct_AR@,$ac_ct_AR,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@CPP@,$CPP,;t t +s,@CXX@,$CXX,;t t +s,@CXXFLAGS@,$CXXFLAGS,;t t +s,@ac_ct_CXX@,$ac_ct_CXX,;t t +s,@CXXDEPMODE@,$CXXDEPMODE,;t t +s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t +s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t +s,@CXXCPP@,$CXXCPP,;t t +s,@F77@,$F77,;t t +s,@FFLAGS@,$FFLAGS,;t t +s,@ac_ct_F77@,$ac_ct_F77,;t t +s,@LIBTOOL@,$LIBTOOL,;t t +s,@scriptsdir@,$scriptsdir,;t t +s,@filesdir@,$filesdir,;t t +s,@DBUS_SERVICES_DIR@,$DBUS_SERVICES_DIR,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF -EOF -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF -cat >> $CONFIG_STATUS <<EOF +# +# CONFIG_HEADER section. +# -CONFIG_FILES=\${CONFIG_FILES-"Makefile -"} -EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + # Do quote $f, to prevent DOS paths from being IFS'd. + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + rm -f $ac_file + mv $tmp/config.h $ac_file + fi else - ac_dir_suffix= ac_dots= + cat $tmp/config.h + rm -f $tmp/config.h fi +# Compute $ac_file's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $ac_file | $ac_file:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null || +$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X$ac_file : 'X\(//\)[^/]' \| \ + X$ac_file : 'X\(//\)$' \| \ + X$ac_file : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X$ac_file | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'`/stamp-h$_am_stamp_count +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`(dirname "$mf") 2>/dev/null || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`(dirname "$file") 2>/dev/null || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p $dirpart/$fdir + else + as_dir=$dirpart/$fdir + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} + { (exit 1); exit 1; }; }; } -EOF -cat >> $CONFIG_STATUS <<EOF + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF -EOF -cat >> $CONFIG_STATUS <<\EOF +cat >>$CONFIG_STATUS <<\_ACEOF -exit 0 -EOF +{ (exit 0); exit 0; } +_ACEOF chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi echo " Configuration (BACKENDS): - The Backends Will be installed in : ${scriptsdir} - Compiler: ${CC} + The backends will be installed in : ${scriptsdir} + The files will be installed in : ${filesdir} " diff --git a/configure.in b/configure.in index 0106fb6..93f26c1 100644 --- a/configure.in +++ b/configure.in @@ -2,94 +2,48 @@ AC_PREREQ(2.52) dnl ============================================================== dnl Process this file with autoconf to produce a configure script. dnl ============================================================== -AC_INIT(system-tools-backends,1.4.2) +AC_INIT(system-tools-backends,1.9.0) AC_CONFIG_AUX_DIR(.) AC_CONFIG_HEADERS(config.h) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AC_PROG_LIBTOOL -AC_PROG_INTLTOOL([0.29]) - dnl ============================================================== -dnl Set SCRIPTS_DIR, FILES_DIR & LOCALE_DIR +dnl Set SCRIPTS_DIR, FILES_DIR dnl ============================================================== if test "x${prefix}" = "xNONE"; then - scriptsdir="${ac_default_prefix}/share/setup-tool-backends/scripts" - filesdir="${ac_default_prefix}/share/setup-tool-backends/files" - localedir="${ac_default_prefix}/share/locale" + scriptsdir="${ac_default_prefix}/share/system-tools-backends-2.0/scripts" + filesdir="${ac_default_prefix}/share/system-tools-backends-2.0/files" else - scriptsdir="${prefix}/share/setup-tool-backends/scripts" - filesdir="${prefix}/share/setup-tool-backends/files" - localedir="${prefix}/share/locale" + scriptsdir="${prefix}/share/system-tools-backends-2.0/scripts" + filesdir="${prefix}/share/system-tools-backends-2.0/files" fi AC_SUBST(scriptsdir) AC_SUBST(filesdir) -AC_SUBST(localedir) dnl ============================================================== -dnl END: Set SCRIPTS_DIR, FILES_DIR & LOCALE_DIR +dnl END: Set SCRIPTS_DIR, FILES_DIR dnl ============================================================== -GETTEXT_PACKAGE=system-tools-backends -AC_SUBST(GETTEXT_PACKAGE) - -ALL_LINGUAS="ar az bg bn bs ca cs da de el en_CA en_GB es eu fi fr gu hi hr hu id it ja ko lt ms nb ne nl pa pl pt pt_BR ro rw sk sq sr sr@Latn sv ta th tr uk vi xh zh_CN zh_TW" -AM_GLIB_GNU_GETTEXT +DBUS_SERVICES_DIR="${prefix}/share/dbus-1/services" +AC_SUBST(DBUS_SERVICES_DIR) AC_OUTPUT([ Makefile m4macros/Makefile -po/Makefile.in -system-tools-backends.pc +system-tools-backends-2.0.pc files/Makefile -boot-conf -dhcpd-conf -disks-conf -display-conf -font-conf -hardware-conf -internetsharing-conf -memory-conf -mouse-conf -network-conf -package-conf -print-conf -services-conf -shares-conf -time-conf -users-conf -boot-grub.pl -boot-lilo.pl -boot-yaboot.pl -boot.pl -debug.pl -dhcpd.pl -file.pl -filesys.pl -font.pl -general.pl -ishare.pl -media.pl -network.pl -parse.pl -partition.pl -platform.pl -print.pl -process.pl -removable-media.pl -replace.pl -report.pl -service-list.pl -service.pl -share.pl -tokenizer.pl -util.pl -xml.pl -x.pl +Init/Makefile +Network/Makefile +Shares/Makefile +Time/Makefile +Users/Makefile +Utils/Makefile +SystemToolsBackends.pl +org.freedesktop.SystemToolsBackends.service ]) - echo " Configuration (BACKENDS): diff --git a/debug.pl.in b/debug.pl.in deleted file mode 100644 index 1b5b5c1..0000000 --- a/debug.pl.in +++ /dev/null @@ -1,222 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Functions for hacker debug. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -use File::Path; -use File::Copy; - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; - - -%gst_debug_fd_hash = (); - - -sub gst_debug_open_output_file -{ - local *FILE; - my $debug_path = &gst_file_get_debug_path () . "/$gst_name/1/$_[0]"; - - if (!exists $gst_debug_fd_hash{$debug_path}) - { - &gst_debug_rotate_try (); - open (FILE, ">>$debug_path"); - $gst_debug_fd_hash{$debug_path} = *FILE; - } - - return $gst_debug_fd_hash{$debug_path}; -} - -sub gst_debug_close_all -{ - my ($file, @files); - - @files = keys %gst_debug_fd_hash; - foreach $file (@files) - { - &gst_file_close ($gst_debug_fd_hash{$file}); - delete $gst_debug_fd_hash{$file}; - } -} - -sub gst_debug_print_string_to_file -{ - my $debug_file; - - $debug_file = &gst_debug_open_output_file ($_[0]); - print $debug_file $_[1]; -} - -sub gst_debug_print_log_to_file -{ - my ($file, $doc) = @_; - my (@buff, $line, $fd); - - $fd = &gst_debug_open_output_file ($file); - - @buff = split ("\n", $doc); - foreach $line (@buff) - { - print $fd "$line\n"; - } -} - - -sub gst_debug_print_string -{ - if ($gst_debug) { print STDERR $_[0]; } - &gst_debug_print_string_to_file ("debug", $_[0]); -} - - -sub gst_debug_print_line -{ - &gst_debug_print_string ($_[0] . "\n"); -} - - -sub gst_debug_print_indent -{ - my $indent = $_[0]; - my $indent_string = ""; - - $indent_string = " " x $indent; - &gst_debug_print_string ($indent_string); -} - - -sub gst_debug_print_indented_string -{ - my ($indent, @string) = @_; - - &gst_debug_print_indent ($indent); - &gst_debug_print_string (@string); -} - - -sub gst_debug_print_indented_line -{ - my $indent = shift @_; - my @line = @_; - - &gst_debug_print_indent ($indent); - &gst_debug_print_line (@line); -} - - -sub gst_debug_print_struct -{ - foreach $i (@_) - { - &gst_debug_print_struct_r (0, 0, $i); - } -} - - -sub gst_debug_print_struct_r -{ - my ($indent) = $_[0]; - my $is_hash_value = $_[1]; - my $a = $_[2]; - my $type; - my @keys; - my $elem; - my $i; - - $type = ref $a; - - if (!$is_hash_value) { &gst_debug_print_indent ($indent); } - - if ($type eq "SCALAR") - { - &gst_debug_print_line ($$a); - } - elsif ($type eq "ARRAY") - { - &gst_debug_print_line ("[ARRAY]"); - - for ($i = 0; $i <= $#$a; $i++) - { - &gst_debug_print_struct_r ($indent + 1, 0, $$a[$i]); - } - } - elsif ($type eq "HASH") - { - @keys = sort keys (%$a); - - &gst_debug_print_line ("[HASH]"); - - foreach $i (@keys) - { - &gst_debug_print_indented_string ($indent + !$is_hash_value, $i . " -> "); - &gst_debug_print_struct_r ($indent + !$is_hash_value + 1, 1, $$a{$i}); - } - } - else - { - &gst_debug_print_line ($a); - } -} - - -$gst_debug_dir_rotation_was_made = 0; - -sub gst_debug_rotate_try -{ - - my $debug_file = $_[0]; - my $debug_tool_dir = &gst_file_get_debug_path () . "/$gst_name"; - - # If this is the first debug created by this tool on this invocation, - # rotate the debug directories and create a new, empty one. - - if (!$gst_debug_dir_rotation_was_made) - { - my $i; - - $gst_debug_dir_rotation_was_made = 1; - - if (-e "$debug_tool_dir/9") - { - &gst_file_rmtree ("$debug_tool_dir/9", 0, 1); - } - - for ($i = 8; $i; $i--) - { - if (-e "$debug_tool_dir/$i") - { - move ("$debug_tool_dir/$i", "$debug_tool_dir/" . ($i + 1)); - } - } - - &gst_file_create_path ("$debug_tool_dir/1"); - } -} - -1; diff --git a/dhcpd-conf.in b/dhcpd-conf.in deleted file mode 100755 index 4d9af16..0000000 --- a/dhcpd-conf.in +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Dhcpd server configurator. -# -# Copyright (C) 2001 Ximian, Inc. -# -# Authors: Chema Celorio <chema@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/dhcpd.pl$DOTIN"; -} - - -# --- Tool information --- # -$name = "dhcpd"; -$version = "@VERSION@"; -@platforms = ("redhat-7.0", "redhat-7.1"); - -$description =<<"end_of_description;"; - Configure dhcp server parameters -end_of_description; - -# --- XML parsing --- # - -# Scan XML from standard input to an internaltree. -sub xml_parse -{ - my ($file) = @_; - my ($tree, %hash, $elem); - my (%subnets); - - # Scan XML to tree. - - $tree = &gst_xml_scan ($file); - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "networking" tag. - - while ($elem = shift @$tree) - { - if ($elem eq "dhcpd") { &xml_parse_dhcpd (shift @$tree, \%hash); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return (\%hash); -} - -sub xml_parse_dhcpd -{ - my ($tree, $hash) = @_; - my ($elem, %subnets); - - shift @$tree; # Skip attributes. - - while ($elem = shift @$tree) - { - if ($elem eq "installed") { $$hash{"installed"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "configured") { $$hash{"configured"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "active") { $$hash{"active"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "subnet") { &gst_dhcpd_xml_parse_subnet (shift @$tree, \%subnets); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"subnets"} = \%subnets unless scalar keys %subnets == 0; -} - -# --- XML printing --- # -sub gst_dhcpd_print_subnet -{ - my ($h) = @_; - my %ranges, %hosts; - my $range, $hosts; - - &gst_xml_container_enter ("subnet"); - - # Options - &gst_xml_print_hash ($$h{"options"}); - &gst_xml_print_vspace (); - - # Ranges - &gst_xml_print_hash_hash ($$h{"ranges"}, "range"); - &gst_xml_print_vspace (); - - # Hosts - &gst_xml_print_hash_hash ($$h{"hosts"}, "host"); - &gst_xml_print_vspace (); - - &gst_xml_container_leave ("subnet"); - - return; -} - -sub xml_print -{ - my ($h) = @_; - my %subnets; - my $subnet; - my @scalar_keys = qw(installed active); - - &gst_xml_print_begin (); - - &gst_xml_print_scalars ($h, @scalar_keys); - &gst_xml_print_vspace (); - - $subnets = $$h{"subnets"}; - foreach $subnet (keys %$subnets) { - &gst_dhcpd_print_subnet ($$subnets{$subnet}); - &gst_xml_print_vspace (); - } - - &gst_xml_print_end (); - -} - -# Main operations -sub get -{ - my $hash; - - $hash = &gst_dhcpd_conf_get (); - - &gst_report_end (); - &xml_print ($hash); -} - - -sub set -{ - my $hash; - my $res; - - $hash = &xml_parse (); - $res = &gst_dhcpd_conf_set ($hash); - &gst_report_end (); - - if ($res eq -1) { - printf STDERR "An error ocurred while setting configuration\n"; - printf STDERR "Implement error reporting while setting, (or find it)\n"; - } -} - - -# --- Filter config: XML in, XML out --- # -sub filter -{ - my $hash; - - $hash = &xml_parse (); - &gst_report_end (); - &xml_print ($hash); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); - diff --git a/dhcpd.pl.in b/dhcpd.pl.in deleted file mode 100644 index 3aeac44..0000000 --- a/dhcpd.pl.in +++ /dev/null @@ -1,819 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- -# -# Functions for dhcp server configuration -# -# Copyright (C) 2001 Ximian, Inc. -# -# Authors: Chema Celorio <chema@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; -require "$SCRIPTSDIR/service.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/tokenizer.pl$DOTIN"; - -## ------------------------ Get --------------------------------------------- -sub gst_dhcpd_get_host -{ - my ($in, $out) = @_; - my ($mac_address, $next_server, $ip); - my %host; - my $comment = &gst_dhcpd_get_host_comment ($out); - my $host_name = &gst_tokenize_get_token ($in, $out); - - &gst_tokenize_verify_token ($in, "{", $out); - - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { - if ("\}" eq $token) { - last; - } - elsif ("hardware" eq $token) { - &gst_tokenize_verify_token ($in, "ethernet", $out); - $mac_address = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_verify_token ($in, ";", $out); - } - elsif ("fixed-address" eq $token) { - $ip = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_verify_token ($in, ";", $out); - } - elsif ("next-server" eq $token) { - &gst_tokenize_skip_till ($in, ";", $out); - } - else { - &gst_tokenize_warning ("Unexpected token \"$token\""); - &gst_tokenize_skip_till ($in, ";", $out); - } - } - - $host{"host_name"} = $host_name if (defined $host_name); - $host{"mac_address"} = $mac_address if (defined $mac_address); - $host{"next_server"} = $next_server if (defined $next_server); - $host{"ip"} = $ip if (defined $ip); - $host{"comment"} = $comment if (defined $comment); - - return %host; -} - -sub gst_dhcpd_get_range -{ - my ($in, $out) = @_; - my $size = 0; - my @tokens; - my %hash; - my $token; - - # range is tricky because it can contain from 1 to 3 tokens - # - # range a; start = a, end = a, bootp = FALSE - # range a b; start = a, end = b, bootp = FALSE - # range dynamic-bootp a b; start = a, end = b, bootp = TRUE - # range dynamic-bootp a; start = a, end = a, bootp = TRUE - - $token = &gst_tokenize_get_token_till ($in, $out, ";"); - - # bootp for this range ? - $_ = $token; - if (/^dynamic-bootp /) { - $token = $'; # remove dynamic-bootp from token - $hash{"bootp"} = 1; - } else { - $hash{"bootp3"} = 0; - } - - # If it does not contain a whitespace duplicate the value - # since if max is ommited, max = min - $_ = $token; - if (not m/ /) { - $token .= " " . $token - } - - # Get the start and end token - @tokens = split (' ', $token); - $hash{"start"} = $tokens[0]; - $hash{"end"} = $tokens[1]; - my $empty = $tokens[2]; # We should not have any tokens left - - if (defined ($empty)) { - &gst_tokenize_warning ("Unexpected token $empty"); - } - - return %hash; -} - -sub gst_dhcpd_get_subnet -{ - my ($in, $out) = @_; - my %options; - my (%ranges, %j, %r_1); - my (%hosts, %host_1); - - my @known_options = qw(domain-name routers); - my @ignore_options = qw(nis-domain time-offset ntp-servers subnet-mask); - - $options{"ip"} = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_verify_token ($in, "netmask", $out); - $options{"netmask"} = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_verify_token ($in, "{", $out); - - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { -# printf STDERR "Token $token\n"; - if ("option" eq $token) { - my (%h1,%h2); - my $value = &gst_tokenize_get_token ($in, $out); - my $pair = &gst_tokenize_get_token ($in, $out); - $pair =~ s/\"//g; - - # printf STDERR "Value $value\n"; - - if ($value eq "domain-name-servers") { - my $dns_num = 1; - $options{"dns1"}=$pair; - if ("," eq ($token = &gst_tokenize_get_token ($in, $out))) { - $token = &gst_tokenize_get_token ($in, $out); - $options{"dns2"}=$token; - while (";" ne ($token = &gst_tokenize_get_token ($in, $out))){}; - # FIXME -# @$in = (pop @$out, @$in); - } - } - elsif (defined &gst_array_find_index (\@known_options, $value)) { - # printf STDERR "in array\n"; - # remove elements as we read them to avoid duplicates - @known_options = grep ($_ ne $value, @known_options); - $options{$value}=$pair; - &gst_tokenize_verify_token ($in, ";", $out); - } - elsif (defined &gst_array_find_index (\@ignore_options, $value)) { - &gst_tokenize_advance_till ($in, ";", $out); - } - else { - printf STDERR "Unknown option : $value (170)\n"; - if ($token ne ";") { - &gst_tokenize_advance_till ($in, ";", $out); -# &gst_tokenize_verify_token ($in, ";", $out); -# @$in = (pop @$out, @$in); - } - } - } - elsif ("range" eq $token) { - my (%range) = &gst_dhcpd_get_range ($in, $out); - my $name = $range{"start"}; - $ranges{$name} = \%range; - } - elsif ("host" eq $token) { - my (%host) = &gst_dhcpd_get_host ($in, $out); - my $name = $host{"host_name"}; - $hosts{$name}= \%host; - } - elsif ("default-lease-time" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); -# $options{"default-lease-time"}=$token; - $token = &gst_tokenize_get_token ($in, $out); - } - elsif ("max-lease-time" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); -# $options{"max-lease-time"}=$token; - $token = &gst_tokenize_get_token ($in, $out); - } - elsif ("}" eq $token) { - my $resp; - - $resp{"options"}=\%options; - if (scalar (%ranges)) { - $resp{"ranges"}=\%ranges; - } - if (scalar (%hosts) gt 0) { - $resp{"hosts"}=\%hosts; - } - return %resp; - } - else { - &gst_tokenize_warning ("Unexpected token \"$token\" (205)"); - &gst_tokenize_skip_till ($in, ";", $out); - } - } - - return undef; -} - -sub gst_dhcpd_get_subnets -{ - my ($fname) = @_; - my (%subnets); - my $in; - my @out_array = ""; - my $out = \@out_array; - - $in = &gst_tokenize ($fname); - - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { - if ("subnet" eq $token) { - my %subnet = &gst_dhcpd_get_subnet ($in, $out); - my $options = $subnet{"options"}; - my $ip = $$options{"ip"}; - $subnets{$ip} = \%subnet; - } - elsif ("group" eq $token) { - &gst_tokenizer_error ("Groups not supported\n"); - } - elsif ("shared-network" eq $token) { - &gst_tokenizer_error ("Shared networks not supported\n"); - } - } - - return \%subnets; -} - -## ------------------------ XML Parsing -------------------------------------- -sub gst_dhcpd_xml_parse_host -{ - my ($tree, $hosts) = @_; - my (%hash); - - shift @$tree; - - while ($elem = shift @$tree) - { - $hash{$elem} = &gst_xml_get_pcdata (shift @$tree); - } - - $name = $hash{"host_name"}; - $$hosts{$name} = \%hash; -} - -sub gst_dhcpd_xml_parse_range -{ - my ($tree, $hosts) = @_; - my (%hash); - - shift @$tree; - - while ($elem = shift @$tree) - { - $hash{$elem} = &gst_xml_get_pcdata (shift @$tree); - } - - $name = $hash{"start"}; - $$hosts{$name} = \%hash; -} - -sub gst_dhcpd_xml_parse_subnet -{ - my ($tree, $subnets) = @_; - my ($elem, %subnet, %options); - my (%hosts, %ranges); - - shift @$tree; - - while ($elem = shift @$tree) - { - if ($elem eq "ip") { $options{"ip"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "netmask") { $options{"netmask"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "domain-name") { $options{"domain-name"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "dns1") { $options{"dns1"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "dns2") { $options{"dns2"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "routers") { $options{"routers"} = &gst_xml_get_pcdata (shift @$tree); } - - elsif ($elem eq "host") { &gst_dhcpd_xml_parse_host (shift @$tree, \%hosts); } - elsif ($elem eq "range") { &gst_dhcpd_xml_parse_range (shift @$tree, \%ranges); } - - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$subnet{"options"} = \%options unless scalar keys %options == 0; - $$subnet{"hosts"} = \%hosts unless scalar keys %hosts == 0; - $$subnet{"ranges"} = \%ranges unless scalar keys %ranges == 0; - - $name = $options{"ip"}; - - if (not defined ($name)) { - printf STDERR "Fatal error, no ip was provided for a subnet\n"; - printf STDERR "Improve error reporting (well, investigate current methods)\n"; - exit; - } - - $$subnets{$name} = $subnet; - - return; -} - -## ------------------------ Set --------------------------------------------- -sub gst_dhcpd_replace_subnets -{ - my ($file, $old_values, $new_subnets_ref) = @_; - my (%old_subnets, %new_subnets); - my (@remove_list, @add_list, @matching_list); - - %old_subnets = %{$$old_values{"subnets"}}; - %new_subnets = %{$new_subnets_ref}; - - $matching_list = &gst_dhcpd_subnets_match (\%old_subnets, \%new_subnets); - &gst_dhcpd_subnets_match_dump ($matching_list); - - %m = %$matching_list; - foreach $key (keys %m) { - $a=$m{$key}; - &gst_dhcpd_replace_subnet ($file, $key, $m{$key}); - } -} - -sub gst_dhcpd_skip_block -{ - my ($in, $out) = @_; - my $token; - - while (defined ($token = &gst_tokenize_get_token ($in, $out))) { - if ($token eq "}") { - return; - } - if ($token eq "{") { - &gst_dhcpd_skip_block ($in, $out); - } - } - -} - -sub gst_dhcpd_get_host_comment -{ - my ($out) = @_; - my $token, $line, $comment = ""; - - $line = @$out[-2]; - - $_ = $line; - if (/\s*\#/) { - $comment = $'; - chomp ($comment); - $comment =~ s/\s*//; - return $comment; - } - - return undef; -} - -sub gst_dhcpd_add_host -{ - my ($in, $out, $host, $subnet) = @_; - my $ws, $ws2; - - # FIXME, the indentation can be different, found the whitespace neede - # for now, hardcode $ws - $ws = "\t"; - $ws2 = $ws . "\t"; - - # Add the host - &gst_tokenize_append_token ($out, $ws . "\n"); - if (defined ($$host {"comment"})) { - &gst_tokenize_append_token ($out, $ws . "# " . $$host {"comment"} . "\n"); - } - &gst_tokenize_append_token ($out, $ws . "host " . $$host {"host_name"} . " {\n"); - if (defined ($$host {"mac_address"})) { - &gst_tokenize_append_token ($out, $ws2 . "hardware ethernet " . $$host {"mac_address"} . ";\n"); - } - if (defined (my $ip = $$host {"ip"})) { - &gst_tokenize_append_token ($out, $ws2 . "fixed-address " . $$host {"ip"} . ";\n"); - } - &gst_tokenize_append_token ($out, $ws . "}\n"); -} - -sub gst_dhcpd_replace_host -{ - my ($in, $out, $hosts) = @_; - my $hostname; - my $new_values; # array that contains the host information - - $comment = &gst_dhcpd_get_host_comment ($out); - $hostname = &gst_tokenize_get_token ($in, $out); - $new_values = $$hosts{$hostname}; - - # Delete this host ? - if (not defined $new_values) { - &gst_tokenize_undo ($in, $out, 2); # Return the hostname & "host" - $_ = @$out[-1]; - pop (@$out) if (/\s*\#/); # remove the comment ? - $_ = @$out[-1]; - pop (@$out) if (/\s*\n$/); # remove the newline ? - &gst_tokenize_skip_till ($in, "}"); - return; - } - - # Replace the comment (or add it) - my $new_comment = $$new_values{"comment"}; - if (defined ($comment)) { - $$out [-3] =~ s/\#( |)$comment/\# $new_comment/; - } - elsif (defined $new_comment) { - # Insert a comment - &gst_tokenize_undo ($in, $out, 2); - &gst_tokenize_append_token ($out, "\t# " . $new_comment . "\n"); - &gst_tokenize_get_token ($in, $out); - &gst_tokenize_get_token ($in, $out); - } - - &gst_tokenize_verify_token ($in, "{", $out); - - # Flags so that we know if we need to add an element or not - my $hardware_ethernet = 0; - my $fixed_address = 0; - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { - if ("hardware" eq $token) { - my $mac = $$new_values{"mac_address"}; - if ((defined $mac) && ($mac ne "")) { - &gst_tokenize_verify_token ($in, "ethernet", $out); - &gst_tokenize_replace_token ($out, "ethernet"); # clean if broken - &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token ($out, $mac); - &gst_tokenize_verify_token ($in, ";", $out); - } else { - &gst_tokenize_undo ($in, $out, 1); - &gst_tokenize_skip_till ($in, ";"); - } - $hardware_ethernet = 1; - } - elsif ("fixed-address" eq $token) { - my $ip = $$new_values{"ip"}; - if ((defined $ip) && ($ip ne "")) { - &gst_tokenize_get_token ($in, $out); # discard - &gst_tokenize_replace_token ($out, $ip); - &gst_tokenize_verify_token ($in, ";", $out); - } else { - &gst_tokenize_undo ($in, $out, 1); - &gst_tokenize_skip_till ($in, ";"); - } - $fixed_address = 1; - } - elsif ("}" eq $token) { - last; - } - else { - &gst_tokenize_advance_till ($in, ";", $out); - } - } - - &gst_tokenize_undo ($in, $out); - - # Now add items that where not found - my $ws = "\t\t"; - if (($fixed_address eq 0) && (defined (my $ip = $$new_values {"ip"}))) { - &gst_tokenize_append_token ($out, $ws . "fixed-address " . $ip . ";\n"); - } - if (($hardware_ethernet eq 0) && (defined (my $mac = $$new_values {"mac_address"}))) { - &gst_tokenize_append_token ($out, $ws . "hardware ethernet " . $mac . ";\n"); - } - - &gst_tokenize_get_token ($in, $out); - - delete $$hosts{$hostname}; -} - -sub gst_dhcpd_replace_range -{ - my ($in, $out, $ranges) = @_; - my $range; - - # FIXME, Only support one range for now - @ranges_keys = keys %$ranges; - $range = $$ranges{@ranges_keys[0]}; - - if ($$range{"bootp"}) { - &gst_tokenize_append_token ($out, " dynamic-bootp"); - } - &gst_tokenize_append_token ($out, " " . $$range{"start"}); - &gst_tokenize_append_token ($out, " " . $$range{"end"} ); - &gst_tokenize_append_token ($out, ";\n"); - &gst_tokenize_skip_till ($in, ";"); - -} - -sub gst_tokenize_replace_dns -{ - my ($in, $out, $options) = @_; - my $token; - my $dns1 = $$options{"dns1"}; - my $dns2 = $$options{"dns2"}; - - # Remove this item ? - if ($dns1 eq undef && $dns2 eq undef) { - &gst_tokenize_undo ($in, $out, 2); - &gst_tokenize_skip_till ($in, ";"); - &gst_tokenize_undo ($in, $out, 1); - return; - } - - # - # Dns is tricky because the file has a list of servers, our xml has - # dns1 and dns2, maybe we should change the xml ? - # - $token = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token ($out, $dns1); - - $token = &gst_tokenize_get_token ($in, $out); - - # If we already have multiple DNS's - if ($token eq ",") { - $token = &gst_tokenize_get_token ($in, $out); - if (defined $dns2) { - &gst_tokenize_replace_token ($out, $dns2); - &gst_tokenize_verify_token ($in, ";", $out); - } else { - &gst_tokenize_remove_token ($out, 2); # Remove "," and dns2 - &gst_tokenize_skip_till ($in, ";"); - &gst_tokenize_append_token ($out, ";\n"); # skip till ; will skip ; - } - } - # If we only had one server before, do we need to add dns2 ? - elsif (";" eq $token) { - if (defined $dns2) { - my $temp = pop (@$out); - &gst_tokenize_append_token ($out, ", "); - &gst_tokenize_append_token ($out, $dns2); - &gst_tokenize_append_token ($out, $temp); - } - } else { - &gst_tokenize_warning ("Unexpected token $token\n"); - &gst_tokenize_advance_till ($in, ";", $out); - } - - # Reverse the last token which was ";" so that - # we leave it there for _verify ($in, ";",... to pass - &gst_tokenize_undo ($in, $out); - - return; -} - -sub gst_dhcpd_replace_subnet_real -{ - my ($in, $out, $new_values, $subnet) = @_; - my $options, $hosts, $ranges; - my @ignore_options = qw(time-offset ntp-servers); - my @ignore_keywords = qw(default-lease-time max-lease-time); - my $range_replaced = 0; - - $options = $$new_values{"options"}; - $hosts = $$new_values{"hosts"}; - $ranges = $$new_values{"ranges"}; - - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { -# printf STDERR "Token :: -->$token<--\n"; - if ("option" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); -# printf STDERR "Option $token\n"; - if ("domain-name" eq $token || "nis-domain" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token ($out, "\"" . $$options{"domain-name"} . "\""); - } - elsif ("routers" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token ($out, $$options{"routers"}); - } - elsif ("subnet-mask" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token ($out, $$options{"netmask"}); - } - elsif ("domain-name-servers" eq $token) { - &gst_tokenize_replace_dns ($in, $out, $options); - } - elsif (defined &gst_array_find_index (\@ignore_options, $value)) { - &gst_tokenize_advance_till ($in, ";", $out); - &gst_tokenize_undo ($in, $out, 1); - } - else - { - printf STDERR "--- UNKNOWN option : $token\n"; - &gst_tokenize_advance_till ($in, ";", $out); - &gst_tokenize_undo ($in, $out, 1); - } - &gst_tokenize_verify_token ($in, ";", $out); - } - elsif ("netmask" eq $token) { - # This is outside of the `{` - $token = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token ($out, $$options{"netmask"}); - &gst_tokenize_verify_token ($in, "{", $out); - } - elsif ("range" eq $token) { - if (not $range_replaced) { - &gst_dhcpd_replace_range ($in, $out, $ranges); - $range_replaced = 1; - } - } - elsif ("host" eq $token) { - &gst_dhcpd_replace_host ($in, $out, $hosts); - } - elsif (defined &gst_array_find_index (\@ignore_keywords, $value)) { - &gst_tokenize_advance_till ($in, ";", $out); - } - elsif ("}" eq $token) { - last; - } else { - printf STDERR "Unrecognized Token :: -- $token (545)\n"; - &gst_tokenize_advance_till ($in, ";", $out); - } - } - - # What is out, is now our input - &gst_tokenize_undo ($in, $out, 1); - - foreach $key (keys %$hosts) { - &gst_dhcpd_add_host ($in, $out, $$hosts{$key}, $subnet); - } - -} - -sub gst_dhcpd_replace_subnet -{ - my ($file, $subnet, $new_values) = @_; - my $in; - my @out_array = ""; - my $out = \@out_array; - - $in = &gst_tokenize ($file); - - &gst_file_buffer_save ($out, $file . ".1"); - - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { - - if ("subnet" eq $token) { - $token = &gst_tokenize_get_token ($in, $out); - if ($token ne $subnet) { - &gst_tokenize_verify_token ($in, "netmask"); - $token1 = &gst_tokenize_get_token ($in, $out); # 255.255.255.0 - &gst_tokenize_verify_token ($in, "{"); - &gst_dhcpd_skip_block ($in, $out); - } else { - &gst_dhcpd_replace_subnet_real ($in, $out, $new_values, $subnet); - } - } - } - -# &gst_file_buffer_save ($out, $file . ".new"); - &gst_file_buffer_save ($out, $file); -} - -sub gst_dhcpd_subnets_match_dump -{ - my ($ref) = @_; - my %matching_list = %$ref; - -# printf STDERR "\n\nDumping match list\n"; - foreach $needle (keys %matching_list) { - $a = $matching_list{$needle}; -# printf STDERR " Value:$needle Pair:$a\n"; - } -# printf STDERR "\n\n"; - -} - -sub gst_dhcpd_subnets_match -{ - my ($old_subnets_ref, $new_subnets_ref) = @_; - my (%matching_list); - my (%old_subnets, %new_subnets); - - %old_subnets = %$old_subnets_ref; - %new_subnets = %$new_subnets_ref; - - $num_old = scalar keys %old_subnets; - $num_new = scalar keys %new_subnets; - # Here we can write a smart mathing system - # For now do any matching for 1 old 1 new to develop - # the replacing code -# if (($num_old ne 1) || ($num_new) ne 1) { -# printf STDERR "Can only replace 1-1\n"; -# exit; -# } - - @a = keys %old_subnets; - @b = keys %new_subnets; - -# printf STDERR "B zero is ->" . $b[0] . "<-\n"; - - $matching_list {$b[0]} = $new_subnets{$b[0]}; - - return \%matching_list; -} - - -## ------------------------- Parsing tables --------------------------------- - -sub gst_dhcpd_conf_get_parse_table -{ - my %dist_map = - ( - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.0", - ); - - my %dist_tables = - ( - "redhat-7.0" => - { - fn => - { - DHCPD_CONF => "/etc/dhcpd.conf", - DHCPD_SERVICE => "dhcpd", - }, - table => - [ - [ "active", \&gst_service_sysv_get_status, DHCPD_SERVICE ], - [ "installed", \&gst_service_sysv_installed, DHCPD_SERVICE ], - [ "configured", \&gst_file_exists, DHCPD_CONF ], - [ "subnets", \&gst_dhcpd_get_subnets, DHCPD_CONF], - ] - } - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_dhcpd_conf_get -{ - my %dist_attrib; - my $hash; - - %dist_attrib = &gst_dhcpd_conf_get_parse_table (); - - $hash = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - return $hash; -} - -sub gst_dhcpd_conf_get_replace_table -{ - my %dist_map = - ( - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.0", - ); - - my %dist_tables = - ( - "redhat-7.0" => - { - fn => - { - DHCPD_CONF => "/etc/dhcpd.conf", - DHCPD_SERVICE => "dhcpd", - }, - table => - [ - [ "subnets", \&gst_dhcpd_replace_subnets, [DHCPD_CONF, OLD_HASH] ], -# [ "active", \&gst_service_sysv_set_status, [65, DHCPD_SERVICE] ] - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - - -sub gst_dhcpd_conf_set -{ - my ($values_hash) = @_; - my (%dist_attrib, $old_hash); - my $res; - - %dist_attrib = &gst_dhcpd_conf_get_replace_table (); - - $old_hash = &gst_dhcpd_conf_get (); - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash, $old_hash); - - return $res; -} - -1; - diff --git a/disks-conf.in b/disks-conf.in deleted file mode 100755 index 1478990..0000000 --- a/disks-conf.in +++ /dev/null @@ -1,1827 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Simple fixed media configurator. Designed to be architecture- and distribution independent. -# Growing it in order to support the new disk-tool -# -# Copyright (C) 2000-2001 Ximian, Inc. -# Copyright (C) 2003 Alvaro del Castillo -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# Authors: Alvaro del Castillo <acs@barrapunto.com> -# Authors: Carlos Garciía Campos <elkalmail@yahoo.es> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/fstab - -# Running programs affected/used: -# -# fdisk -# mount -# awk (already used in guess_system.sh) -# cat - -# For debuging -# use Data::Dumper; - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/filesys.pl$DOTIN"; - require "$SCRIPTSDIR/partition.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "disks"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", - "redhat-7.1", "mandrake-7.2", "debian-2.2", "debian-woody", "debian-sarge", - "debian-3.1", "suse-7.0", "suse-9.1", "suse-1.0", "unitedlinux-1.0", - "turbolinux-7.0", "rpath"); - -$description =<<"end_of_description;"; - Configures locally mounted partitioned media. -end_of_description; - -$progress_max = 16; - - -# --- System config file locations --- # - -# We list each config file type with as many alternate locations as possible. -# They are tried in array order. First found = used. - -# Right now there's only one entry per array, as I couldn't find any -# typical deviations. - -@fstab_names = ( "/etc/fstab" ); - - -# --- Internal configuration variables --- # - -# Configuration is parsed/read to, and printed/written from, these temporary variables. - -@cf_disks = (); - - -# --- Backend-specific helper subs --- # - -# to filesys -#sub get_media_type -#{ -# my ($dev_clean, $dev_prefix); -# -# ($dev) = @_; -# -# ($dev_clean) = ($dev =~ /^\/dev\/([a-zA-Z0-9]*)$/); -# -# ($dev_prefix) = ($dev_clean =~ /(^[a-z]*)[a-z]/); - -# if ($dev_prefix eq "hd") { -# return ("disk-ide"); -# } elsif ($dev_prefix eq "sd") { -# return ("disk-scsi"); -# { else { -# return ("unknown"); -# } -# } - -sub update_partition -{ - my ($disk, $device, $point, $fs, $options, $check); - my ($listed, $bootable, $detected); - my ($disk_found, $point_found) = (0, 0); - my $label; - my ($start, $end); - - ($disk, $device, $alias, $point, $fs, $options, $check, $size, - $listed, $bootable, $detected, $label, $start, $end) = @_; - - - if ($fs eq "auto") { $fs = ""; } - if ($label eq "") - { - if ($device eq "") { return; } - $label = gst_filesys_ext2_device_to_label ($device); - } - - for ($i = 0; $cf_disks[$i]; $i++) - { - if ($disk eq "" || ($cf_disks[$i])->{device} eq $disk) - { - # Found disk. Now look for partition. - - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) - { - if ($cf_disks[$i]->{partitions}[$j]->{device} eq $device || - ($label ne "") && ($cf_disks[$i]->{partitions}[$j]->{label} eq $label)) - { - # Found partition. - - if ($options ne "") - { - if ($options =~ /noauto/) - { - if (`mount | grep \"$device \"` eq "") { - # TODO: get used swap with the free command - $cf_disks[$i]->{partitions}[$j]->{mounted} = 0; - } - } - else - { - if (`mount | grep \"$device \"` eq "") { - $cf_disks[$i]->{partitions}[$j]->{mounted} = 0; - } else { - $cf_disks[$i]->{partitions}[$j]->{mounted} = 1; - # If the partition is mounted we can show free space - $block_size = $cf_disks[$i]->{block_size}; - $free_space=0; - $free_space = `df --block-size=$block_size $device | grep $device | awk '/\\/dev/ {print \$4}'`; - $cf_disks[$i]->{partitions}[$j]->{free} = $free_space if $free_space; - } - if ($cf_disks[$i]->{partitions}[$j]->{type} eq "swap") { - $cf_disks[$i]->{partitions}[$j]->{mounted} = 1; - } - } - } - - if ($point ne "") { $cf_disks[$i]->{partitions}[$j]->{point} = $point; } - if ($alias ne "") { $cf_disks[$i]->{partitions}[$j]->{alias} = $alias; } - if ($fs) { $cf_disks[$i]->{partitions}[$j]->{type} = $fs; } - if ($listed) { $cf_disks[$i]->{partitions}[$j]->{listed} = 1; } - #if ($bootable) { $cf_disks[$i]->{partitions}[$j]->{bootable} = 1; } - #if ($detected) { $cf_disks[$i]->{partitions}[$j]->{detected} = 1; } - #if ($check) { $cf_disks[$i]->{partitions}[$j]->{check} = 1; } - if ($size) { $cf_disks[$i]->{partitions}[$j]->{size} = $size; } - if ($label) { $cf_disks[$i]->{partitions}[$j]->{label} = $label; } - - $disk_found = 1; - $point_found = 1; last; - } - } - - if (!$point_found && $device) - { - # Make new partition entry. - - my %partition; - - # if ($options =~ /noauto/) { %partition->{mounted} = 0; } - if (`df | grep \"$device \"` eq "") { %partition->{mounted} = 0; } - else - { - %partition->{mounted} = 1; - $block_size = $cf_disks[$i]->{block_size}; - $free_space = 0; - $free_space = `df --block-size=$block_size $device | grep $device | awk '/\\/dev/ {print \$4}'`; - %partition->{free} = $free_space if $free_space; - %partition->{point} = `mount | grep $device | awk '{print \$3}'`; - %partition->{type} = `mount | grep $device | awk '{print \$5}'`; - } - - %partition->{device} = $device; - # we use better the mount info, no fstab info - KaL - if (%partition->{mounted} == 0) { - %partition->{point} = $point; - %partition->{type} = $fs; - } - %partition->{listed} = $listed; - if ($bootable) { %partition->{bootable} = 1; } - if ($detected) { %partition->{detected} = 1; } - if ($check) { %partition->{check} = 1; } - %partition->{size} = $size; - %partition->{label} = $label; - if ($start < $end) { - %partition->{start} = $start; - %partition->{end} = $end; - } - - $bleh = $cf_disks[$i]->{partitions}; - push(@$bleh, \%partition); - - $disk_found = 1; last; - } - } - } - - if (!$disk_found) - { - # Make new disk entry containing this partition. - - my (%disk, %partition); - - if ($options =~ /noauto/) { %partition->{mounted} = 0; } - else { %partition->{mounted} = 1; } - - %partition->{device} = $device; - %partition->{device} = $alias; - %partition->{point} = $point; - %partition->{type} = $fs; - %partition->{listed} = $listed; - #if ($bootable) { %partition->{bootable} = 1; } - #if ($detected) { %partition->{detected} = 1; } - #if ($check) { %partition->{check} = 1; } - %partition->{size} = $size; - %partition->{label} = $label; - if ($start < $end) { - %partition->{start} = $start; - %partition->{end} = $end; - } - - %disk->{device} = $disk; - %disk->{partitions} = []; - - $bleh = %disk->{partitions}; - push(@$bleh, \%partition); - push(@cf_disks, \%disk); - } -} - - -sub get_partition -{ - my ($disk, $device, $label) = @_; - my ($i, $j); - - for ($i = 0; $cf_disks[$i]; $i++) - { - if ($disk eq "" || ($cf_disks[$i])->{device} eq $disk) - { - # Found disk. Now look for partition. - - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) - { - if ($cf_disks[$i]->{partitions}[$j]->{device} eq $device || - ($device eq "" && $cf_disks[$i]->{partitions}[$j]->{label} eq $label)) - { - # Found partition. - - return ($cf_disks[$i]->{partitions}[$j]); - } - } - } - } -} - - -sub get_partition_data -{ - my ($disk, $device, $label); - - ($disk, $device, $label) = @_; - - for ($i = 0; $cf_disks[$i]; $i++) - { - if ($disk eq "" || ($cf_disks[$i])->{device} eq $disk) - { - # Found disk. Now look for partition. - - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) - { - if ($cf_disks[$i]->{partitions}[$j]->{device} eq $device || - ($device eq "" && $cf_disks[$i]->{partitions}[$j]->{label} eq $label)) - { - # Found partition. - - return ($cf_disks[$i]->{partitions}[$j]->{point}, - $cf_disks[$i]->{partitions}[$j]->{type}, - $cf_disks[$i]->{partitions}[$j]->{listed}, - $cf_disks[$i]->{partitions}[$j]->{mounted}, - $cf_disks[$i]->{partitions}[$j]->{bootable}, - $cf_disks[$i]->{partitions}[$j]->{check}, - $cf_disks[$i]->{partitions}[$j]->{label}); - } - } - } - } -} - -sub get_ide_setting -{ - my ($dev_clean, $setting); - - ($dev_clean, $setting) = @_; - - $value = `cat /proc/ide/$dev_clean/settings 2>/dev/null | grep $setting | awk '{print \$2}'`; - - return $value; -} - -sub get_cdrom_settings -{ - my ($device) = @_; - - - if (!sysopen (RD, $device, O_RDONLY|O_NONBLOCK)) { - return; - } - - if ($^O eq 'linux') { - $CDROM_GET_CAPABILITY = 0x5331; - - $CDC_PLAY_AUDIO = 0x100; - $CDC_CD_R = 0x2000; - $CDC_CD_RW = 0x4000; - $CDC_DVD = 0x8000; - $CDC_DVD_R = 0x10000; - $CDC_DVD_RAM = 0x20000; - } - - #foreach $device (@devices) { - - my $drivetype = ioctl (RD, $CDROM_GET_CAPABILITY, 0); - - &update_disk_data ($device, "play-audio", ($drivetype & $CDC_PLAY_AUDIO) ? 1 : 0); - &update_disk_data ($device, "write-cdr", ($drivetype & $CDC_CD_R) ? 1 : 0); - &update_disk_data ($device, "write-cdrw", ($drivetype & $CDC_CD_RW) ? 1 : 0); - &update_disk_data ($device, "read-dvd", ($drivetype & $CDC_DVD) ? 1 : 0); - &update_disk_data ($device, "write-dvdr", ($drivetype & $CDC_DVD_R) ? 1 : 0); - &update_disk_data ($device, "write-dvdram", ($drivetype & $CDC_DVD_RAM) ? 1 : 0); - - close (RD); -} - -sub update_disk_data -{ - my ($disk, $data, $value); - - - ($disk, $data, $value) = @_; - - my $disk_found = 0; - - for ($i = 0; $cf_disks[$i]; $i++) - { - if (($cf_disks[$i])->{device} eq $disk) - { - # Found disk. - $cf_disks[$i]->{$data} = $value; - $disk_found = 1; - last; - } - } - - if (!$disk_found) - { - # Make new disk entry - - my (%disk); - - %disk->{device} = $disk; - %disk->{$data} = $value; - %disk->{partitions} = []; - - push(@cf_disks, \%disk); - } -} - - - - -# --- Configuration file manipulation --- # - - -# /etc/fstab -# -# <device> <mount point> <filesystem> <option,option,...> <dump> <fsck> -# <device> <mount point> <filesystem> <option,option,...> <dump> <fsck> -# ... -# -# Exists: (Presumably everywhere) -# -# Absent: (Presumably nowhere) - -sub read_fstab -{ - my $fstab_file; - local *FSTAB_FILE; - - # Find the file. - - $fstab_file = &gst_file_open_read_from_names(@fstab_names); - if (not $fstab_file) { return; } # We didn't find it. - *FSTAB_FILE = $fstab_file; - - # Parse the file. - - while (<FSTAB_FILE>) - { - my ($disk, $device, $point, $fs, $options, $check, $label); - - @line = split(/[ \n\r\t]+/, $_); - - if ($line[0] eq "") { shift @line; } - if ($line[0] eq "") { next; } - if (&gst_ignore_line($line[0])) { next; } - ($device, $point, $fs, $options, $dump, $check) = @line; - - if ($device =~ /$LABEL=(.*)/) { - $label = $1; - $device = ""; - } else { - $label = ""; - } - - # we want to inform the backend about the swap - if ($fs eq "nfs" || $fs eq "smbfs" || $fs eq "proc" || $fs eq "devpts" || - $fs eq "sysfs" || $fs eq "usbdevfs" || $fs eq "usbfs") { - next; # We can skip these filesystems for sure. - } - - # look for symlinks to manage alias - my $alias = $device; - my $link; - while ($link = readlink ($alias)) { - $alias = $link; - } - - if ($alias ne $device) { - my $temp = $alias; - $alias = $device; - $device = $temp; - # maybe device file is in short format - if (!($device =~ /^\/dev\/.*$/)) { - $device = "/dev/$device"; - } - } else { - # there is no alias - $alias = ""; - } - - if ($point eq "none") { $dir = ""; } - ($disk) = ($device =~ /([a-zA-Z\/]+)/); - - #if ($disk eq "/dev/fd" || ($disk ne "" && $disk eq $device)) { - # next; # Skip floppies and CD-ROMs. - #} - if (($disk eq "/dev/fd") || ($disk eq "/dev/scd")) { - # fd0, scd0 are not partitions - $disk = $device; - } - - if (sysopen (HANDLE, $disk, O_RDONLY|O_NONBLOCK)) { - &update_disk_data ($disk, "present", 1); - close HANDLE; - } else { - &update_disk_data ($disk, "present", 0); - # FIXME removable disk by defualt - &update_disk_data ($disk, "media", "disk"); - } - - - # (Find and update) or (add) our internal disk/partition record. - - for ($i = 0; $cf_disks[$i]; $i++) { - if ($cf_disks[$i]->{device} eq $disk) { - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) { - if ($cf_disks[$i]->{partitions}[$j]->{device} eq $device) { - $type = $cf_disks[$i]->{partitions}[$j]->{type}; - last; - } - } - last; - } - } - - if ($disk eq $device) { - # Disk, not partition, we only want filesystem type, - # mount point and mount options - # we use alias to manage symlinks - &update_disk_data ($disk, "alias", $alias); - &update_disk_data ($disk, "point", $point); - &update_disk_data ($disk, "type", $fs); - #&update_disk_data ($disk, "mount-options", $options); - } elsif (($disk ne "" || $label ne "") && $type ne "empty") { - &update_partition ($disk, $device, $alias, $point, $fs, $options, $check, "", 1, 0, "", $label, 0, 0); - } - } - - close(FILE); -} - -sub write_fstab -{ - my ($ifh, $ofh); - local (*INFILE, *OUTFILE); - - ($ifh, $ofh) = &gst_file_open_filter_write_from_names(@fstab_names); - if (not $ofh) { return; } # No point if we can't write. - *INFILE = $ifh; *OUTFILE = $ofh; - - while (<INFILE>) - { - my ($disk, $device, $point, $fs, $options, $dump, $check, $label); - my ($ipoint, $itype, $icheck, $ilisted, $imounted, $ibootable, $ilabel); - - @line = split(/[ \n\r\t]+/, $_); - - if ($line[0] eq "") { shift @line; } - if ($line[0] eq "") { print OUTFILE; next; } - if (&gst_ignore_line($line[0])) { print OUTFILE; next; } - ($device, $point, $fs, $options, $dump, $check) = @line; - - if ($fs eq "nfs" || $fs eq "smbfs" || $fs eq "proc" || $fs eq "devpts" || - $fs eq "iso9660" || $fs eq "swap" || $device =~ /$\/dev\/fd.*/) - { - print OUTFILE; next; # We can skip these filesystems for sure. - } - - # By now, we know that the "entry" is "interesting". Check if known. - - if ($device =~ /$LABEL=(.*)/) - { - $label = $1; - $device = ""; - $disk = ""; - } - else - { - $label = ""; - ($disk) = ($device =~ /([a-zA-Z\/]+)/); - } - - if ($disk eq "/dev/fd") { print OUTFILE; next; } - - ($ipoint, $itype, $ilisted, $imounted, $ibootable, $icheck, $ilabel) = - &get_partition_data($disk, $device, $label); - - if ($ilisted) - { - # Write record if listedness requested. - - if ($ilabel ne "") - { - print OUTFILE "LABEL=" . $ilabel . " "; - } - else - { - print OUTFILE $device . " "; - } - - if ($ipoint eq "") { print OUTFILE "none "; } - else { print OUTFILE $ipoint . " "; } - - if ($itype eq "") { print OUTFILE "auto "; } - else { print OUTFILE $itype . " "; } - - # Options merging and printing. - - my $prev = 0; - if (!$imounted) { print OUTFILE "noauto"; $prev = 1; } - my @options = ($options =~ /([a-zA-Z0-9=-]+),?/mg); - for $option (@options) - { - # Strip options we handle, keep the rest. - - if ($option eq "auto" || $option eq "noauto" || - $option eq "defaults") { next; } - if ($prev) { print OUTFILE ","; } - print OUTFILE $option; - $prev = 1; - } - - if (!$prev) { print OUTFILE "defaults"; } - - # Leave dump alone. - - print OUTFILE " $dump "; - - # Fsck onboot priority. - - if ($icheck eq "") { $icheck = 0; } - if ($icheck == 1) - { - if ($ipoint eq "/") { print OUTFILE "1\n"; } - else { print OUTFILE "2\n"; } - } - else { print OUTFILE "0\n"; } - - # Indicate that parameters for this partition have been stored. - - my $partition = &get_partition($disk, $device, $label); - %$partition->{stored} = 1; - } - - # Unknown or unlisted-by-request partitions are not written. - } - - # Print the remaining partitions from our internal list. These are - # newly added, and didn't exist in the fstab previously. - - for ($i = 0; $cf_disks[$i]; $i++) - { - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) - { - if ($cf_disks[$i]->{partitions}[$j]->{listed} && - !$cf_disks[$i]->{partitions}[$j]->{stored}) - { - my $part = $cf_disks[$i]->{partitions}[$j]; - - &gst_report ("disks_fstab_add", $cf_disks[$i]->{partitions}[$j]->{device}); - - # Write record. - - print OUTFILE %$part->{device} . " "; - if (%$part->{point} eq "") { print OUTFILE "none "; } - else { print OUTFILE %$part->{point} . " "; } - - if (%$part->{type} eq "") { print OUTFILE "auto "; } - else { print OUTFILE %$part->{type} . " "; } - - # Options printing. - - if (!%$part->{mounted}) { print OUTFILE "noauto "; } - else { print OUTFILE "defaults "; } - - # No dumping by default. - - print OUTFILE " 0 "; - - # Fsck onboot priority. - - if (%$part->{check} == 1) - { - if (%$part->{point} eq "/") { print OUTFILE "1\n"; } - else { print OUTFILE "2\n"; } - } - else { print OUTFILE "0\n"; } - } - } - } - - close OUTFILE; -} - -sub is_ide_scsi -{ - my ($dev) = @_; - - my $line = `cat /proc/cmdline`; - - if ($line && $line ne "") { - if ($line =~ /(.*)$dev=ide-scsi(.*)$/) { - return 1; - } else { - return 0; - } - } else { - return 0; - } -} - -sub scan_ide_bus -{ - my $device = shift; - - if (! opendir (DIR, "/proc/ide/")) { - return; - } - - foreach (readdir (DIR)) { - if ($_ =~ /^hd[a-z]$/) { - if (&is_ide_scsi ($_)) { - next; - } - - if ($device && ($device ne "/dev/$_")) { - next; - } - - my $dma = &get_ide_setting ($_, "using_dma"); - my $model = `cat /proc/ide/$_/model 2>/dev/null`; - my $media = `cat /proc/ide/$_/media 2>/dev/null`; - if ($model ne "") { - &update_disk_data ("/dev/$_", "model", $model); - if ($media =~ /cdrom/) { - &get_cdrom_settings ("/dev/$_"); - } - } - - if ($media ne "") { &update_disk_data ("/dev/$_", "media", $media); } - if ($dma ne "") { &update_disk_data ("/dev/$_", "dma", $dma); } - } - } - closedir (DIR); -} - -sub scan_scsi_bus -{ - my $device = shift; - - if (! `cat /proc/scsi/scsi | grep "Host"`) { - return; - } - - if ($device) { - @files = ( $device ); - } else { - @files = ( "/dev/sda", "/dev/sdb", "/dev/sdc", "/dev/sdd", - "/dev/sde", "/dev/sdf", "/dev/sdg", "/dev/sdh", - "/dev/sdi", "/dev/sdj", "/dev/sdk", "/dev/sdl", - "/dev/sdm", "/dev/sdn", "/dev/sdo", "/dev/sdp", - "/dev/scd0", "/dev/scd1", "/dev/scd2", "/dev/scd3" ); - } - - $SCSI_IOCTL_GET_IDLUN = 0x5382; - $SCSI_IOCTL_GET_BUS_NUMBER = 0x5386; - - my $proc_scsi_file; - local *PROC_SCSI_FILE; - $proc_scsi_file = &gst_file_open_read_from_names ("/proc/scsi/scsi"); - if (not $proc_scsi_file) { return; } - *PROC_SCSI_FILE = $proc_scsi_file; - - my @scsi = (); - for $dev (@files) { - if (sysopen (RD, $dev, O_RDONLY | O_NONBLOCK)) { - my $info; - if (ioctl (RD, $SCSI_IOCTL_GET_IDLUN, $info)) { - my @scsi_info = unpack ("II", $info); - my (%scsi_data); - - %scsi_data->{'device'} = $dev; - %scsi_data->{'id'} = $scsi_info[0] & 0xff; - %scsi_data->{'lun'} = ($scsi_info[0] >> 8) & 0xff; - %scsi_data->{'channel'} = ($scsi_info[0] >> 16) & 0xff; - %scsi_data->{'host'} = (($scsi_info[0] >> 24) & 0xff); - - if (ioctl(RD, $SCSI_IOCTL_GET_BUS_NUMBER, $arg)) { - my @args = unpack ("CCCCCC", $arg); - %scsi_data->{'host'} = $args[0]; - } - - push (@scsi, \%scsi_data); - } - - close (RD); - } - } - - my $vendor; - my $model; - my $media; - my ($host, $channel, $id, $lun); - my $i = 0; - - while (<PROC_SCSI_FILE>) { - my $data = $_; - $data =~ s/^\s*//; - $data =~ s/\s*$//; - @line = split(":", $data); - if ($line[0] eq "Host") { - ($host, $channel, $id, $lun) = ($data =~ /^Host:.*scsi([0-9]+).*Channel:.*([0-9]+).*Id:.*([0-9]+).*Lun:.*([0-9]+).*$/); - - $i = 0; - while ($scsi[$i]) { - #print "DBG: device: " . $scsi[$i]->{'device'} . " host " . $scsi[$i]->{'host'} . " id " . $scsi[$i]->{'id'} . " lun " . $scsi[$i]->{'lun'} . "\n"; - #print "DBG: host $host id $id lun $lun\n"; - if ($scsi[$i]->{'id'} == int ($id) && $scsi[$i]->{'lun'} == int ($lun) && - $scsi[$i]->{'channel'} == int ($channel) && $scsi[$i]->{'host'} == int ($host)) { - last; - } - $i++; - } - } elsif ($line[0] eq "Vendor") { - ($vendor, $model) = ($data =~ /^Vendor:(.*)Model:(.*)Rev:.*$/); - - $vendor =~ s/^\s*//; - $vendor =~ s/\s*$//; - $model =~ s/^\s*//; - $model =~ s/\s*$//; - - if ($scsi[$i]->{'device'}) { &update_disk_data ($scsi[$i]->{'device'}, "model", "$vendor $model");} - } elsif ($line[0] eq "Type") { - if ($data =~ /CD-ROM/) { - $media = "cdrom"; - &get_cdrom_settings ($scsi[$i]->{'device'}); - } elsif ($data =~ /Direct-Access/) { - $media = "disk"; - } - - if ($scsi[$i]->{'device'}) { &update_disk_data ($scsi[$i]->{'device'}, "media", $media);} - } - } - close (PROC_SCSI_FILE); -} - -sub scan_floppy -{ - #FIXME: I don't like it - $floppy = `grep fd /proc/devices | wc -l`; - chomp $floopy; - if ($floppy == 0) { - return; - } elsif ($floppy >= 1) { - $dev="/dev/fd0"; - &update_disk_data ($dev, "media", "floppy"); - } elsif (system ("fdisk /dev/fd1 > /dev/null 2>&1")) { - $dev="/dev/fd1"; - &update_disk_data ($dev, "media", "floppy"); - } -} - -sub get_fs_type -{ - my ($device) = @_; - my ($cmd, $fd, $fstype, $line); - my ($filesys); - - # if mounted get fs - if (&gst_partition_is_mounted ($device)) - { - #$line = `mount | grep "$device"`; - #if ($line ne "") { - # already mounted - ($filesys) = $line =~ /^$device on .* type (.*) .*$/; - if ($filesys) - { - return $filesys; - } - else - { - return "unknown"; - } - } - - # Not already mounted - # Try to mount it - my $ret = &gst_partition_mount_temp ($device); - - #my ($dev) = ($device =~ /\/dev\/(.*)/); - #my $point = "/tmp/disks-conf-$dev"; - - #mkdir ($point); - - #$cmd = "mount $device $point"; - - #$fd = &gst_file_run_pipe_read_with_stderr ($cmd); - - #if (!$fd) { - # my $err = `umount $device`; - #rmdir ($point); - #return "unknown"; - #} - - # Not mounted: not supported or unformatted - #while (<$fd>) { - # if (/not supported/) { -# ($filesys) = ($_ =~ /^mount: fs type (.*) not supported by kernel$/); -# } elsif (/looks like swapspace/) { -# $filesys = "swap"; -# } elsif (/you must specify the filesystem type/) { -# $filesys = "none"; -# } -# } - -# &gst_file_close ($fd); - - if ($ret eq "error") - { - return "unknown"; - } - elsif ($ret =~ /not_supported/) - { - my ($msg) = ($ret =~ /^not_supported::(.*)/); - ($filesys) = ($msg =~ /^mount: fs type (.*) not supported by kernel$/); - return $filesys; - } - elsif ($ret eq "swap") - { - return "swap"; - } - elsif ($ret eq "none") - { - return "none"; - } - - #if ($filesys) { - # rmdir ($point); - #return $filesys; - #} - - # Mounted by me - $line = `mount | grep "$device"`; - if ($line ne "") { - ($filesys) = ($line =~ /^$device on .* type (.*) .*$/); - } - - &gst_partition_umount_temp ($device, $ret); - #my $err = `umount $device`; - #rmdir ($point); - - if ($filesys) { - return $filesys; - } else { - return "unknown"; - } -} - -# --- XML parsing --- # - -sub xml_parse -{ - # Scan XML to tree. - - $tree = &gst_xml_scan; - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the toplevel tag. - - while (@$tree) - { - if ($$tree[0] eq "disks") { &xml_parse_toplevel($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - return($tree); -} - - -sub xml_parse_toplevel -{ - my $tree = $_[0]; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "disk") { &xml_parse_disk($$tree[1]); } - - shift @$tree; - shift @$tree; - } -} - - -sub xml_parse_disk -{ - my %disk; - - my $tree = $_[0]; - shift @$tree; # Skip attributes. - - %disk->{partitions} = []; # Init partition list. - - while (@$tree) - { - if ($$tree[0] eq "device") { %disk->{device} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "size") { %disk->{size} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "partition") - { - my %partition = &xml_parse_partition($$tree[1]); - $bleh = %disk->{partitions}; - push(@$bleh, \%partition); - } - - shift @$tree; shift @$tree; - } - - push(@cf_disks, \%disk); -} - - -sub xml_parse_partition -{ - my %partition; - - my $tree = $_[0]; - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "device") { %partition->{device} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "type") { %partition->{type} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "point") { %partition->{point} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "label") { %partition->{label} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "size") { %partition->{size} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "bootable") { %partition->{bootable} = &xml_parse_state($$tree[1]); } - elsif ($$tree[0] eq "integritycheck") { %partition->{check} = &xml_parse_state($$tree[1]); } - elsif ($$tree[0] eq "mounted") { %partition->{mounted} = &xml_parse_state($$tree[1]); } - elsif ($$tree[0] eq "listed") { %partition->{listed} = &xml_parse_state($$tree[1]); } - elsif ($$tree[0] eq "detected") { %partition->{detected} = &xml_parse_state($$tree[1]); } - - shift @$tree; shift @$tree; - } - - return(%partition); -} - - -sub xml_parse_state -{ - my $tree = $_[0]; - - # Check attribute; 'yes', 'true', 'no', 'false'. - - return(&gst_util_read_boolean($$tree[0]->{state})); -} - - -# --- XML printing --- # - -sub sort_by_media -{ - my %medias = ("disk" => 1, "cdrom" => 2, "floppy" => 3, "" => 4); - - $ia = $a->{media}; - $ia =~ s/^\s*//; - $ia =~ s/\s*$//; - - $ib = $b->{media}; - $ib =~ s/^\s*//; - $ib =~ s/\s*$//; - - if ($ia eq $ib) { - return ($a->{device} gt $b->{device}); - } else { - return (($medias{$ia}) <=> ($medias{$ib})); - } -} - -sub xml_print_common -{ - my ($disk) = @_; - - &gst_xml_print_line ("<device>" . %$disk->{device} . "</device>\n"); - if (%$disk->{alias}) { &gst_xml_print_line ("<alias>" . %$disk->{alias} . "</alias>\n"); } - if (%$disk->{size}) { - # The frontend wants KB - &gst_xml_print_line ("<size>" . %$disk->{size}*(%$disk->{block_size}/1024) . "</size>\n"); - } - if (%$disk->{media}) { &gst_xml_print_line ("<media>" . %$disk->{media} . "</media>\n"); } - if (%$disk->{model}) { &gst_xml_print_line ("<model>" . %$disk->{model} . "</model>\n"); } - &gst_xml_print_state_tag ("present", %$disk->{present}); - if (%$disk->{type}) { &gst_xml_print_line ("<type>" . %$disk->{type} . "</type>\n"); } - if (%$disk->{point}) { &gst_xml_print_line ("<point>" . %$disk->{point} . "</point>\n"); } -} - -sub xml_print_cdrom -{ - my ($disk) = @_; - - &gst_xml_print_state_tag ("play-audio", %$disk->{"play-audio"}); - &gst_xml_print_state_tag ("write-cdr", %$disk->{"write-cdr"}); - &gst_xml_print_state_tag ("write-cdrw", %$disk->{"write-cdrw"}); - &gst_xml_print_state_tag ("read-dvd", %$disk->{"read-dvd"}); - &gst_xml_print_state_tag ("write-dvdr", %$disk->{"write-dvdr"}); - &gst_xml_print_state_tag ("write-dvdram", %$disk->{"write-dvdram"}); -} - -sub xml_print_partitions -{ - my ($disk, $partitions) = @_; - - while (@$partitions) - { - my $partition = $$partitions[0]; - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<partition>\n"); - &gst_xml_enter (); - - &gst_xml_print_line ("<device>" . %$partition->{device} . "</device>\n"); - if (%$partition->{alias}) { &gst_xml_print_line ("<alias>" . %$partition->{alias} . "</alias>\n"); } - if (%$partition->{type}) { &gst_xml_print_line ("<type>" . %$partition->{type} . "</type>\n"); } - if (%$partition->{point}) { &gst_xml_print_line ("<point>" . %$partition->{point} . "</point>\n"); } - if (%$partition->{label}) { &gst_xml_print_line ("<label>" . %$partition->{label} . "</label>\n"); } - if (%$partition->{size}) { - # The frontend wants KB - &gst_xml_print_line ("<size>" . %$partition->{size}*(%$disk->{block_size}/1024) . "</size>\n"); - } - - if (%$partition->{start}) { &gst_xml_print_line ("<start>" . %$partition->{start} . "</start>\n"); } - if (%$partition->{end}) { &gst_xml_print_line ("<end>" . %$partition->{end} . "</end>\n"); } - - #&gst_xml_print_state_tag ("bootable", %$partition->{bootable}); - #&gst_xml_print_state_tag ("integritycheck", %$partition->{check}); - - &gst_xml_print_state_tag ("mounted", %$partition->{mounted}); - if (%$partition->{free}) { - # The frontend wants KB - &gst_xml_print_line ("<free>" . %$partition->{free}*(%$disk->{block_size}/1024) . "</free>\n"); - } - &gst_xml_print_state_tag ("listed", %$partition->{listed}); - #&gst_xml_print_state_tag ("detected", %$partition->{detected}); - - &gst_xml_leave (); - &gst_xml_print_line ("</partition>\n"); - - shift @$partitions; - } -} - -sub xml_print -{ - # print Dumper (@cf_disks); - - &gst_xml_print_begin (); - - &gst_xml_print_line ("<!-- Local fixed media and partitions -->\n"); - &gst_xml_print_vspace (); - - my @disks = sort sort_by_media (@cf_disks); - - while (@disks) - { - if ($disks[0]) - { - my $disk = $disks[0]; - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<disk>\n"); - &gst_xml_enter (); - - &xml_print_common ($disk); - - if (%$disk->{media} =~ /cdrom/) { - &xml_print_cdrom ($disk); - } - if (%$disk->{dma}) { &gst_xml_print_state_tag ("dma", %$disk->{dma}); } - - my $partitions = %$disk->{partitions}; - - &xml_print_partitions ($disk, $partitions); - - &gst_xml_leave (); - &gst_xml_print_line ("</disk>\n"); - &gst_xml_print_vspace (); - } - - shift @disks; - } - - &gst_xml_print_end (); -} - - -# --- Get (read) config --- # - -sub get -{ - setlocale (LC_ALL, "en_US"); - - &scan_ide_bus (); - &scan_scsi_bus (); - &scan_floppy (); - &get_fdisk (); - &read_fstab; - - &gst_report_end (); - &xml_print (); -} - - -# --- Set (write) config --- # - - -sub set_immediate -{ - my $mount_tool; - my $umount_tool; - - $mount_tool = &gst_file_locate_tool("mount"); - $umount_tool = &gst_file_locate_tool("umount"); - - # Count partitions. - - my $i; my $j; - my $num_partitions = 0; - my $num_done = 0; - - for ($i = 0; $cf_disks[$i]; $i++) - { - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) - { - $num_partitions++; - } - } - - # Update mount status. - - if (($mount_tool ne "") && ($umount_tool ne "")) - { - my $i; my $j; - - for ($i = 0; $cf_disks[$i]; $i++) - { - for ($j = 0; $cf_disks[$i]->{partitions}[$j]; $j++) - { - if ($cf_disks[$i]->{partitions}[$j]->{mounted}) - { - &gst_report ("disks_mount", $cf_disks[$i]->{partitions}[$j]->{device}); - system "$mount_tool " . $cf_disks[$i]->{partitions}[$j]->{device} . " " . - $cf_disks[$i]->{partitions}[$j]->{point} . " >/dev/null 2>/dev/null"; - } - else - { - &gst_report ("disks_umount", $cf_disks[$i]->{partitions}[$j]->{device}); - system "$umount_tool " . $cf_disks[$i]->{partitions}[$j]->{device} . " >/dev/null 2>/dev/null"; - } - - $num_done++; - &gst_progress(10 + (80 / ($num_partitions - $num_done + 1))); - } - } - } - else - { - &gst_report ("disks_mount_error"); - } - - &gst_progress(90); -} - - -sub set -{ - &xml_parse (); - - &write_fstab; &gst_progress(10); - - if ($gst_do_immediate) - { - &set_immediate; - } - - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - &xml_parse (); - &gst_report_end (); - &xml_print (); -} - -# --- Test XML file: return to the frontend a fixed XML file --- # -sub test_xml -{ - my ($tool, $file) = @_; - - &gst_report_end (); - &gst_progress(100); - # lazy boy - acs - system ("cat $file"); -} - -#sub msf2lba -#{ -# ($m, $s, $f) = @_; - -# return int (((($m * 60) + $s) * 75 + $f) - 150); -#} - -#sub lba2msf -#{ -# $lba = @_; - -# $lba += 150; -# $lba &= 0xffffff; - -# my $m = int ($lba / (60 * 75)); -# $lba %= (60 * 75); - -# return ($m, int ($lba / 75), int ($lba % 75)); -#} - -sub get_cdrom_disc_info -{ - my ($device, $alias) = @_; - my $cdrom; - - if ($alias eq " ") { undef ($alias); } - - if (!sysopen (RD, $device, O_RDONLY | O_NONBLOCK)) { - $cdrom->{'empty'} = 1; - return $cdrom; - } - - if ($^O eq 'linux') { - $CDS_AUDIO = 100; - $CDS_DATA_1 = 101; - $CDS_DATA_2 = 102; - $CDS_XA_2_1 = 103; - $CDS_XA_2_2 = 104; - $CDS_MIXED = 105; - - $CDROM_DATA_TRACK = 0x04; - $CDROM_LEADOUT = 0xAA; - $CDROM_MSF = 0x02; - - $CDROM_DISC_STATUS = 0x5327; - - $CDROMREADTOCHDR = 0x5305; - $CDROMREADTOCENTRY = 0x5306; - } elsif ($^O =~ /bsd/) { - $CDROMREADTOCHDR = 0x40046304; - $CDROMREADTOCENTRY = 0xc0086305; - } elsif (($^O eq 'solaris') || ($^O eq 'sunos')) { - $CDROMREADTOCHDR = 0x49b; - $CDROMREADTOCENTRY = 0x49c; - } else { - return; - } - - my ($mp, $umount); - my $cdtype; - my $disctype = ioctl (RD, $CDROM_DISC_STATUS, 0); - if ($disctype eq $CDS_AUDIO) { - $cdtype = "audio"; - } elsif ($disctype eq $CDS_DATA_1) { - # Chack if it's a DVD - if (! &gst_partition_is_mounted ($device)) { - $umount = 1; - $mp = &gst_partition_mount_temp ($device); - } else { - $umount = 0; - $mp = &gst_partition_get_mount_point ($device); - } - - if (($mp =~ /^\/.*$/) && (-d $mp)) { - my $audio_ts = "audio_ts"; - my $video_ts = "video_ts"; - if ((-d "$mp/$audio_ts") || (-d "$mp/$video_ts") || - (-d "$mp/" . uc ($audio_ts)) || (-d "$mp/" . uc ($video_ts))) { - $cdtype = "dvd"; - } else { - $cdtype = "data"; - } - } else { - $cdtype = "data"; - } - - if ($umount) { - &gst_partition_umount_temp ($device, $mp); - } - } elsif (($disctype eq $CDS_DATA_2) || ($disctype eq $CDS_XA_2_1) || - ($disctype eq $CDS_XA_2_2)) { - $cdtype = "data"; - } elsif ($disctype eq $CDS_MIXED) { - $cdtype = "mixed"; - } else { - $cdtype = "unknown"; - } - - if (!ioctl (RD, $CDROMREADTOCHDR, $tochdr)) { - $cdrom->{'empty'} = 1; - close (RD); - return $cdrom; - } - - $cdrom->{'empty'} = 0; - - my ($start, $end); - if ($^O =~ /bsd/) { - ($start, $end) = unpack "CC", (substr $tochdr, 2, 2); - } else { - ($start, $end) = unpack "CC", $tochdr; - } - - my @tracks; - - for (my $i = $start; $i <= $end; $i++ ) { - push @tracks, $i; - } - push @tracks, $CDROM_LEADOUT; - - my $min = 0; - my $sec = 0; - my $frame = 0; - my $audio = 0; - my $data = 0; - my $first_data = 0; - my $last_audio = 0; - my $duration = 0; - - foreach (@tracks) { - ioctl (RD, $CDROMREADTOCENTRY, $tocentry = pack ("CCCCCCCCC", $_, 0, $CDROM_MSF, 0, 0, 0, 0)); - my @times = unpack ("CCCCCCCCC", $tocentry); - if ($times[1] & ($CDROM_DATA_TRACK << 4)) { - $data ++; - if ($data eq 1) { - $first_data = $_; - } - } else { - $audio ++; - $last_audio = $_; - } - - my $temp2 = 0; - $temp2 += int ($times[6]); - $temp2 += int ($times[5] * 75); - $temp2 += int ($times[4] * 60 * 75); - - my $temp1 = 0; - $temp1 += $frame; - $temp1 += $sec * 75; - $temp1 += $min * 60 * 75; - - $temp2 -= $temp1; - - my $length_min = int ($temp2 / (60 * 75)); - $temp2 %= (60 * 75); - my $length_sec = int ($temp2 / 75); - my $length_frame = int ($temp2 % 60); - - my $dur = int (($length_min * 60) + $length_sec); - if ($first_data eq $_) { - $dur -= 152; # Mixed CD - } - if ($_ gt 1 && ($last_audio eq $_ || $first_data eq $_)) { - $duration += $dur; - } - - - $min = $times[4]; - $sec = $times[5]; - $frame = $times[6]; - } - - close (RD); - - $min = int ($duration / 60); - $sec = int ($duration % 60); - - # Some corrections - if ($data gt 0 && $audio gt 0) { - $data --; - } elsif ($audio gt 0) { - $audio --; - } else { - $data --; - } - - $cdrom->{'cdtype'} = $cdtype; - if (($cdtype eq "audio") || ($cdtype eq "mixed")) { - $cdrom->{'atracks'} = $audio; - $cdrom->{'duration'} = "$min:$sec"; - $cdrom->{'dtracks'} = $data; - } - - if (($cdtype eq "data") || ($cdtype eq "mixed")) { - if (`mount | grep $device`) { - $cdrom->{'mounted'} = 1; - my ($point) = `mount | grep $device` =~ /^$device on (.*) type .*$/; - if ($point) { $cdrom->{'point'} = $point; } - my ($size) = `df $device | grep $device | awk '/\\/dev/ {print \$2}'`; - if ($size) { $cdrom->{'size'} = $size; } - } else { - $cdrom->{'mounted'} = 0; - # try to get mount point from fstab - if ($device && ($line = `cat /etc/fstab | grep $device`)) { - my @sline = split(/[ \n\r\t]+/, $line); - my $point = $sline[1]; - if ($point) { $cdrom->{'point'} = $point; } - } elsif ($alias && ($line = `cat /etc/fstab | grep $alias`)) { - my @sline = split(/[ \n\r\t]+/, $line); - my ($point) = $sline[1]; - if ($point) { $cdrom->{'point'} = $point; } - } - } - } - - return $cdrom; -} - -sub cdrom_disc_info -{ - my ($tool, $device, $alias) = @_; - my $cdrom; - - $cdrom = &get_cdrom_disc_info ($device, $alias); - &gst_report_end (); - &gst_xml_print_begin ("disc_info"); - &gst_xml_print_state_tag ("empty", %$cdrom->{'empty'}); - if (%$cdrom->{'empty'} == 0) { - &gst_xml_print_line ("<type-content>" . %$cdrom->{'cdtype'} . "</type-content>\n"); - - if (%$cdrom->{'cdtype'} eq "audio" || %$cdrom->{'cdtype'} eq "mixed") { - &gst_xml_print_line ("<audio-tracks>" . %$cdrom->{'atracks'} . "</audio-tracks>\n"); - &gst_xml_print_line ("<duration>" . %$cdrom->{'duration'} . "</duration>\n"); - &gst_xml_print_line ("<data-tracks>" . %$cdrom->{'dtracks'} . "</data-tracks>\n"); - } - - if (%$cdrom->{'cdtype'} eq "data" || %$cdrom->{'cdtype'} eq "mixed") { - &gst_xml_print_state_tag ("mounted", %$cdrom->{'mounted'}); - if (%$cdrom->{'point'}) { &gst_xml_print_line ("<point>" . %$cdrom->{'point'} . "</point>\n"); } - if (%$cdrom->{'size'}) { &gst_xml_print_line ("<size>" . %$cdrom->{'size'} . "</size>\n"); } - } - } - - &gst_xml_print_end ("disc_info"); -} - -sub get_disk_info -{ - my ($device, $present) = @_; - - my $is_present; - - if (sysopen (HANDLE, $device, O_RDONLY|O_NONBLOCK)) { - $is_present = 1; - close HANDLE; - } else { - $is_present = 0; - } - - if ($present) { - # We only want to know if the device is attached - return ($is_present); - } - - for ($i = 0; $cf_disks[$i]; $i++) { - delete ($cf_disks[$i]); - } - - @cf_disks = (); - - $cf_disks[0]->{device} = $device; - $cf_disks[0]->{media} = "disk"; - - &scan_ide_bus ($device); - &scan_scsi_bus ($device); - - &get_fdisk ($device); - &read_fstab; - - return ($is_present, $cf_disks[0]); -} - -sub disk_info -{ - my ($tool, $device, $present) = @_; - - my ($is_present, $disk) = &get_disk_info ($device, $present); - &gst_report_end (); - &gst_xml_print_begin ("disk_info"); - - if ($disk) { - &xml_print_common ($disk); - my $partitions = %$disk->{partitions}; - if ($partitions) { - &xml_print_partitions ($disk, $partitions); - } - } else { - &gst_xml_print_line ("<device>" . $device . "</device>\n"); - &gst_xml_print_state_tag ("present", $is_present); - } - - &gst_xml_print_end ("disk_info"); -} - -# --- Calculates the speed of a device in human readable Kib/sec, Mib/sec, etc.--- # -sub get_dev_speed -{ - my ($device) = @_; - - use IO::Handle; - use Time::HiRes qw( setitimer getitimer ITIMER_REAL ); - - sysopen (HANDLE, $device, O_RDONLY|O_NONBLOCK); - - IO::Handle::sync (HANDLE); - sleep (3); - flush STDOUT; - - setitimer (ITIMER_REAL, (1000.0, 1000.0)); - - $max_iterations = 1024; - $iterations = 0; - ($e11, $e12) = getitimer (ITIMER_REAL); - - do { - ++$iterations; - if (($rc = sysread (HANDLE, $buf, (2 * 1024 * 1024))) != (2 * 1024 * 1024)) { - return; - } - for ($i = 0; $i < (2 * 1024 * 1024); $i += 512) { - $buf[$i] &= 1; - } - ($e21, $e22) = getitimer (ITIMER_REAL); - $elapsed = ($e11 - $e21) + (($e12 - $e22) / 1000000.0); - } while ($elapsed < 3.0 and $iterations < $max_iterations); - - close HANDLE; - - $total = ($iterations * 2) / $elapsed; - - if ($total > 1.0) { # more than 1MiB/s - $total =~ s/^([0-9]+\.[0-9][0-9]).+/$1/; - return "$total MiB/sec"; - } else { - $total *= 1024; - $total =~ s/^([0-9]+\.[0-9][0-9]).+/$1/; - return "$total KiB/sec"; - } -} - -sub dev_speed -{ - my ($tool, $device) = @_; - my ($speed) = &get_dev_speed ($device); - - &gst_report_end (); - &gst_xml_print_begin ("dev_speed"); - &gst_xml_print_pcdata ("speed", $speed) if ($speed ne undef); - &gst_xml_print_end ("dev_speed"); -} - -sub do_mount -{ - my ($device, $typefs, $point, $mounted, $listed) = @_; - - my $error; - - if ($mounted) { - $error = `umount $device 2>&1`; - } else { - if ($listed) { - $error = `mount $device 2>&1`; - } else { - $error = `mount -t $typefs $device $point 2>&1`; - } - } - - return ($error); -} - -sub mount_fs -{ - my ($tool, $device, $media, $typefs, $point, $mounted, $listed, $uid) = @_; - - &gst_report_end (); - &gst_xml_print_begin ("mount"); - - my $error; - - if ($uid == 0 || $mounted == 1) { - # allways umount as root - $error = &do_mount ($device, $typefs, $point, $mounted, $listed); - } else { - # try to mount as the user who launched the frontend - if (fork () == 0) { - POSIX::setuid ($uid); - - my $error; - $error = &do_mount ($device, $typefs, $point, $mounted, $listed); - if ($error ne "") { - &gst_xml_print_line ("<error>" . $error . "</error>\n"); - } - - exit (0); - } else { - wait (); - } - } - - my $is_mounted = `mount | grep \"$device\"`; - if ($is_mounted && $mounted == 1) { - # umount failed - if ($error ne "") { - &gst_xml_print_line ("<error>" . $error . "</error>\n"); - } - $mounted = 1; - } elsif (!$is_mounted && $mounted == 0) { - # mount failed - if ($uid != 0) { - # try again, now as root - $error = &do_mount ($device, $typefs, $point, $mounted, $listed); - if (`mount | grep \"$device\"`) { - # mounted successfully at this time - $mounted = 1; - } else { - # mount failed again - if ($error ne "") { - &gst_xml_print_line ("<error>" . $error . "</error>\n"); - } - $mounted = 0; - } - } else { - if ($error ne "") { - &gst_xml_print_line ("<error>" . $error . "</error>\n"); - } - $mounted = 0; - } - } elsif ($is_mounted && $mounted == 0) { - # mounted successfully - $mounted = 1; - } else { - # umounted successfully - $mounted = 0; - } - - if ($error ne "") { - &gst_xml_print_line ("<error>" . $error . "</error>\n"); - } - - if ($media eq "disk") { - &gst_xml_print_line ("<partition>\n"); - &gst_xml_enter (); - - &gst_xml_print_state_tag ("mounted", $mounted); - - if ($mounted) { - ($point, $typefs) = `mount | grep $device` =~ /^$device on (.*) type (.*) .*$/; - #TODO check block size - #$free = `df --block-size=$block_size $device | grep $device | awk '/\\/dev/ {print \$4}'`; - $free = `df $device | grep $device | awk '/\\/dev/ {print \$4}'`; - } - - if ($typefs) { &gst_xml_print_line ("<typefs>" . $typefs . "</typefs>\n"); } - if ($point ) { &gst_xml_print_line ("<point>" . $point . "</point>\n"); } - if ($free) { &gst_xml_print_line ("<free>" . $free . "</free>\n"); } - - &gst_xml_leave (); - &gst_xml_print_line ("</partition>\n"); - } elsif ($media eq "cdrom") { - &gst_xml_print_line ("<cdrom>\n"); - &gst_xml_enter (); - &get_cdrom_disc_info ($device); - &gst_xml_leave (); - &gst_xml_print_line ("</cdrom>\n"); - } - - &gst_xml_print_end ("mount"); -} - -sub format -{ - my ($tool, $command, $device, $type, $options) = @_; - - &gst_format_partition ($command, $device, $type, $options); - my $typefs = &get_fs_type ($device); - - &gst_report_end (); - &gst_xml_print_begin ("format"); - - if ($typefs ne "none" && $typefs ne "unknown") { - &gst_xml_print_line ("<type>" . $typefs . "</type>\n"); - } else { - # TODO: manage errors - &gst_xml_print_line ("<error> Unknown error</error>\n"); - } - - &gst_xml_print_end ("format"); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "test_xml" => [ \&test_xml, ["test_xml_file"], - "Return a XML file to the frontend." ], - "dev_speed" => [ \&dev_speed, ["device"], - "Return the speed of a device in kb/s" ], - "cdrom_disc_info" => [ \&cdrom_disc_info, ["device", "alias"], - "Return info about the cdrom discs"], - "disk_info" => [ \&disk_info, ["device", "present"], - "Return info about disks"], - "mount" => [ \&mount_fs, ["device", "media", "typefs", "point", "mounted", "listed", "uid"], - "Immediatly mount or umount a given partition"], - "format" => [ \&format, ["command", "device", "type", "options"], - "Format a partition"], -}; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/display-conf.in b/display-conf.in deleted file mode 100644 index 6146d22..0000000 --- a/display-conf.in +++ /dev/null @@ -1,229 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Display configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Tambet Ingo <tambet@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/X11/XF86Config - -# Running programs affected: -# - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/x.pl$DOTIN"; -} - -use File::Copy; -use IO::File; -use POSIX qw(tmpnam); - -# --- Tool information --- # - -$name = "display"; -$version = "@VERSION@"; -@platforms = qw(redhat-6.2 redhat-7.0 redhat-7.1 redhat-7.2 - - mandrake-7.2 mandrake-8.0 - - debian-2.2 debian-woody - - turbolinux-7.0); - -$description =<<"end_of_description;"; - Configures XFree86 version 4. -end_of_description; - -# --- Platform handling --- # - -$standard_locations = -{ - 'XFree3' => '/etc/X11/XF86Config', - 'XFree4' => '/etc/X11/XF86Config-4', -# 'XFree4' => '/home/tambet/XF86Config-4-seth', -}; - -# Most of these (well, all but Red Hat) could, and probably are -# wrong. FIXME -$platmap = -{ - 'redhat-6.0' => $standard_locations, - 'redhat-6.1' => $standard_locations, - 'redhat-6.2' => $standard_locations, - 'redhat-7.0' => $standard_locations, - 'redhat-7.1' => $standard_locations, - 'redhat-7.2' => $standard_locations, - 'debian-2.2' => $standard_locations, - 'debian-woody' => $standard_locations, - 'mandrake-7.2' => $standard_locations, - 'mandrake-8.0' => $standard_locations, - 'suse-7.0' => $standard_locations, - 'turbolinux-7.0' => $standard_locations, -}; - -@display_sections = qw(Device Monitor Screen Display ServerLayout); - -sub distro_file -{ - my $x_version = &x_version (); - my $ver = ($x_version->{'number'} >= 400) ? 'XFree4' : 'XFree3'; - my $tmp = $platmap->{$gst_dist}; - - return $tmp->{$ver}; -} - -# --- XML parsing --- -# Scan XML from standard input to an internal tree. - -sub xml_parse -{ - my $fname = shift; - my ($tree, $hash); - - $tree = &gst_xml_scan ($fname); - - # Find the first interesting value. - while ($$tree[0] eq undef) { - shift @$tree; - } - - while (@$tree) { - if ($$tree[0] eq $name) { $hash = &x_xml_parse ($$tree[1], $hash); } - - shift @$tree; - shift @$tree; - } - - return($hash); -} - -sub xml_print -{ - my $config = shift; - my ($section, $hash); - - &gst_xml_print_begin (); - &gst_xml_print_vspace (); - - foreach $section (keys %$config) { - my ($arrayref) = $$config{$section}; - - foreach $hash (@$arrayref) { - &x_xml_print_section ($hash, $section, \@display_sections); - &gst_xml_print_vspace (); - } - } - - &gst_xml_print_end (); -} - -# Top-level actions. - -sub get -{ - my $config = &x_parse (&distro_file ()); - - &x_config_fix ($config, 1); - - &gst_report_end (); - &xml_print ($config); -} - -sub set -{ - my $config = &x_parse (&distro_file ()); - my $xml_config = &xml_parse (); - &x_config_fix ($xml_config, 0); - - &x_config_set (&distro_file (), $config, $xml_config); - &gst_report_end (); -} - -sub filter -{ - my $config = &xml_parse (); - - &gst_report_end (); - &xml_print ($config); -} - -sub test -{ - my $testX_cmd = "$SCRIPTSDIR/testX"; - my $real_file = &distro_file (); - - my $tmp_file; - do { $tmp_file = tmpnam () } - until my $fh = IO::File->new ($tmp_file, O_RDWR|O_CREAT|O_EXCL); - - copy ($real_file, $tmp_file); - - my $config = &x_parse ($tmp_file); - my $xml_config = &xml_parse (); - &x_config_fix ($xml_config, 0); - - &x_config_set ($tmp_file, $config, $xml_config); - - $res = &gst_file_run ("$testX_cmd --config=$tmp_file"); - unlink ($tmp_file); - - &gst_report_end (); -} - -sub probe -{ - my ($tool, $direct) = @_; - my $cfg_file = &distro_file (); - return unless $cfg_file; - - my $config = &x_parse ($cfg_file); - &x_config_fix ($config, 0); - &x_probe ($cfg_file, $config, $direct); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "test" => [ \&test, [], "Test settings." ], - "probe" => [ \&probe, [ "direct*" ], "Return list of valid standard modelines." ], -}; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/filesys.pl.in b/filesys.pl.in deleted file mode 100644 index c22d130..0000000 --- a/filesys.pl.in +++ /dev/null @@ -1,1115 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Working with filesystems, both local and networked. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; - - -# --- Utilities --- # - -# Merge items in hash B missing in A into A. -sub merge_hashes -{ - my ($ha, $hb) = @_; - my $key; - - foreach $key (keys %$hb) - { - $$ha{$key} = $$hb{$key} if !exists $$ha{$key}; - } -} - -sub gst_filesys_ext2_device_to_label # device -{ - my ($device) = @_; - my $label; - my $fd; - - $fd = &gst_file_run_pipe_read ("e2label $device"); - return undef if $fd eq undef; - $label = <$fd>; - chomp $label; - &gst_file_close ($fd); - - return $label; -} - - -# --- filesys_info; information on a particular filesystem --- # - - -sub gst_filesys_info_new -{ - my $info = {}; - my $opthash = {}; - - $$info{'options'} = $opthash; - return ($info); -} - -# Make a deep copy of a filesys_info struct. -# -# Returns a newly allocated filesys_info, identical to the argument. - -sub gst_filesys_info_dup # filesys_info -{ - my $orig = $_[0]; - my $dup; - my $options = $$orig{'options'}; - - $dup = { %$orig }; - $$dup{'options'} = { %$options }; - - return $dup; -} - -sub gst_filesys_info_match # filesys_info, device, label, uuid, network_host, network_path -{ - my ($info, $device, $label, $uuid, $network_host, $network_path, $point) = @_; - - if (($label && $info->{'label'} eq $label) || - ($uuid && $info->{'uuid'} eq $uuid) || - ($network_host && $network_path && - $info->{'network_host'} eq $network_host && - $info->{'network_path'} eq $network_path) || - ($device && $device ne "none" && $info->{'device'} eq $device) || - ($device eq "none" && $info->{'device'} eq "none" && $point eq $info->{'point'})) - { - return 1; - } - - return 0; -} - -sub gst_filesys_info_settings_to_options -{ - my ($info) = @_; - - if (&gst_filesys_info_get_mounted ($info)) - { - &gst_filesys_info_remove_option ($info, "noauto"); - } - else - { - &gst_filesys_info_set_option ($info, "noauto", ""); - } -} - -sub gst_filesys_info_match_options # filesys_info, filesys_info -{ - my ($info_a, $info_b) = @_; - - if (&gst_filesys_info_print_options ($info_a) eq &gst_filesys_info_print_options ($info_b)) - { - return 1; - } - - return 0; -} - -sub gst_filesys_info_match_data # filesys_info, filesys_info -{ - my ($info_a, $info_b) = @_; - - if (&gst_filesys_info_get_point ($info_a) eq &gst_filesys_info_get_point ($info_b) && - &gst_filesys_info_get_fs ($info_a) eq &gst_filesys_info_get_fs ($info_b) && - &gst_filesys_info_get_dump ($info_a) eq &gst_filesys_info_get_dump ($info_b) && - &gst_filesys_info_get_priority ($info_a) eq &gst_filesys_info_get_priority ($info_b) && - &gst_filesys_info_match_options ($info_a, $info_b)) - { - return 1; - } - - return 0; -} - -# Merge options in B missing in A into A. -sub gst_filesys_info_merge_options -{ - my ($info_a, $info_b) = @_; - my ($opt_a, $opt_b, $key); - - $opt_a = $$info_a{'options'}; - $opt_b = $$info_b{'options'}; - - &merge_hashes ($opt_a, $opt_b); -} - -# Merge stuff in B missing in A into A. -sub gst_filesys_info_merge -{ - my ($info_a, $info_b) = @_; - my $key; - - &merge_hashes ($info_a, $info_b); - &gst_filesys_info_merge_options ($info_a, $info_b); -} - -# Generic set function for filesys_info properties. We need this to -# delete keys if they don't have meaningful values, otherwise an empty -# value could override a perfectly good value in a merge. - -sub gst_filesys_info_set # filesys_info, key, value -{ - my ($filesys_info, $key, $value) = @_; - - if ($value eq "") - { - delete $filesys_info->{$key}; - } - else - { - $filesys_info->{$key} = $value; - } -} - -sub gst_filesys_info_get_device # filesys_info -{ - return $_[0]->{'device'}; -} - -sub gst_filesys_info_set_device # filesys_info, device -{ - &gst_filesys_info_set ($_[0], 'device', $_[1]); -} - -sub gst_filesys_info_get_label # filesys_info -{ - return $_[0]->{'label'}; -} - -sub gst_filesys_info_set_label # filesys_info, label -{ - &gst_filesys_info_set ($_[0], 'label', $_[1]); -} - -sub gst_filesys_info_get_network_host # filesys_info -{ - return $_[0]->{'network_host'}; -} - -sub gst_filesys_info_set_network_host # filesys_info, network_host -{ - my ($info, $host) = @_; - - $host =~ s/^\/+//; - &gst_filesys_info_set ($info, 'network_host', $host); -} - -sub gst_filesys_info_get_network_path # filesys_info -{ - return $_[0]->{'network_path'}; -} - -sub gst_filesys_info_set_network_path # filesys_info, network_path -{ - my ($info, $path) = @_; - - $path = "/" . $path if (!($path =~ /^\//)); - &gst_filesys_info_set ($info, 'network_path', $path); -} - -sub gst_filesys_info_get_uuid # filesys_info -{ - return $_[0]->{'uuid'}; -} - -sub gst_filesys_info_set_uuid # filesys_info, uuid -{ - &gst_filesys_info_set ($_[0], 'uuid', $_[1]); -} - -sub gst_filesys_info_get_point # filesys_info -{ - return $_[0]->{'point'}; -} - -sub gst_filesys_info_set_point # filesys_info, point -{ - &gst_filesys_info_set ($_[0], 'point', $_[1]); -} - -sub gst_filesys_info_get_fs # filesys_info -{ - return $_[0]->{'fs'}; -} - -sub gst_filesys_info_set_fs # filesys_info, fs -{ - &gst_filesys_info_set ($_[0], 'fs', $_[1]); -} - -sub gst_filesys_info_get_dump # filesys_info -{ - return $_[0]->{'dump'} || "0"; -} - -sub gst_filesys_info_set_dump # filesys_info, dump -{ - &gst_filesys_info_set ($_[0], 'dump', $_[1]); -} - -sub gst_filesys_info_get_priority # filesys_info -{ - return $_[0]->{'priority'} || "0"; -} - -sub gst_filesys_info_set_priority # filesys_info, priority -{ - &gst_filesys_info_set ($_[0], 'priority', $_[1]); -} - -sub gst_filesys_info_get_mounted # filesys_info -{ - return $_[0]->{'mounted'}; -} - -sub gst_filesys_info_set_mounted # filesys_info, boolean -{ - &gst_filesys_info_set ($_[0], 'mounted', $_[1]); -} - -sub gst_filesys_info_get_permanent # filesys_info -{ - return $_[0]->{'permanent'}; -} - -sub gst_filesys_info_set_permanent # filesys_info, boolean -{ - &gst_filesys_info_set ($_[0], 'permanent', $_[1]); -} - -sub gst_filesys_info_get_detected # filesys_info -{ - return $_[0]->{'detected'}; -} - -sub gst_filesys_info_set_detected # filesys_info, boolean -{ - &gst_filesys_info_set ($_[0], 'detected', $_[1]); -} - -sub gst_filesys_info_get_option # filesys_info, option -{ - return $_[0]->{'options'}{$_[1]}; -} - -# We can't delete keys with no values here, since most fs options don't -# have values (i.e. they key's presence constitutes a boolean). A value of -# " " (one space) indicates that this entry takes a value (is non-bool), but -# has none. - -sub gst_filesys_info_set_option # filesys_info, option, value -{ - $_[0]->{'options'}{$_[1]} = $_[2]; -} - -sub gst_filesys_info_remove_option # filesys_info, option -{ - delete $_[0]->{'options'}{$_[1]}; -} - -# --- filesys_table; multiple instances of filesys_info --- # - - -sub gst_filesys_table_new -{ - my @array; - return \@array; -} - -# Make a deep copy of a filesys_table struct. -# -# Returns a newly allocated filesys_table, identical to the argument. - -sub gst_filesys_table_dup # filesys_table -{ - my $orig = $_[0]; - my $dup = &gst_filesys_table_new (); - my $i; - - foreach $i (@$orig) - { - &gst_filesys_table_add ($dup, &gst_filesys_info_dup ($i)); - } - - return $dup; -} - -# Add a filesys_info reference to a filesys_table. Note: This function -# does not check for uniqueness, which lets you add several references -# to the same filesys_info. - -sub gst_filesys_table_add # filesys_table, filesys_info -{ - my ($table, $info) = @_; - - push @$table, $info; -} - -# Ensure that a filesys_info reference exists in a filesys_table. If it -# doesn't, it will be added. If it does, no action will be taken. - -sub gst_filesys_table_ensure # filesys_table, filesys_info -{ - my ($table, $info) = @_; - my $i; - - foreach $i (@$table) - { - return if ($i eq $info); - } - - &gst_filesys_table_add ($table, $info); -} - -# Remove a filesys_info reference from a filesys_table. - -sub gst_filesys_table_remove # filesys_table, filesys_info -{ - my ($table, $info) = @_; - my $i; - - if ($info == undef) { return; } - - for ($i = 0; $i < @$table; $i++) - { - if (@$table [$i] eq $info) - { - @$table = (@$table [0 .. $i - 1], @$table [$i + 1 .. @$table - 1]); - return; - } - } - - &gst_debug_print_line ("Entry to remove [" . $info . "] not found in filesys_table."); -} - -# Find and return a reference to a filesys_info in a filesys_table -# matching any of the information provided. - -sub gst_filesys_table_find # filesys_table, device, label, uuid, network_host, network_path -{ - my ($table, $device, $label, $uuid, $network_host, $network_path, $point) = @_; - my $i; - - # Match on high-quality keys. - - foreach $i (@$table) - { - if (($label && $i->{'label'} eq $label) || - ($uuid && $i->{'uuid'} eq $uuid) || - ($network_host && $network_path && - $i->{'network_host'} eq $network_host && - $i->{'network_path'} eq $network_path)) - { - return $i; - } - } - - # Match on low-quality keys. - - if ($device) - { - foreach $i (@$table) - { - if (($device && $device ne "none" && $i->{'device'} eq $device) || - ($device eq "none" && $i->{'device'} eq "none" && $point eq $i->{'point'})) - { - return $i; - } - } - } - - &gst_debug_print_line ("Entry [" . $device . "] not found in filesys_table."); - return undef; -} - -sub gst_filesys_table_find_info_equivalent # filesys_table, filesys_info -{ - my ($table, $info) = @_; - - return &gst_filesys_table_find ($table, &gst_filesys_info_get_device ($info), - &gst_filesys_info_get_label ($info), - &gst_filesys_info_get_uuid ($info), - &gst_filesys_info_get_network_host ($info), - &gst_filesys_info_get_network_path ($info), - &gst_filesys_info_get_point ($info)); -} - -# Merges filesys tables A and B, resolving conflicts by giving priority to A. -# Any entries in A not in B are preserved. This can also be described as -# "salting" one table with another. -# -# Returns a newly allocated table C, which is a superset of A and B. - -sub gst_filesys_table_merge_superset # filesys_table A, filesys_table B -{ - my ($intab_a, $intab_b) = @_; - my ($hash_c, $hash_b, $key); - my $outtab; - - $outtab = &gst_filesys_table_dup ($intab_a); - - foreach $info_b (@$intab_b) - { - my $info_c; - - if ($info_c = &gst_filesys_table_find_info_equivalent ($outtab, $info_b)) - { - &gst_filesys_info_merge ($info_c, $info_b); - } - else - { - $info_c = &gst_filesys_info_dup ($info_b); - &gst_filesys_table_add ($outtab, $info_c); - } - } - - return $outtab; -} - -# Merges filesys tables A and B, resolving conflicts by giving priority to A. -# Any entries not in A are dropped. -# -# Returns a newly allocated table C, which is a subset of A and B. - -sub gst_filesys_table_merge_subset # filesys_table A, filesys_table B -{ - my ($intab_a, $intab_b) = @_; - my ($hash_c, $hash_b, $key); - my $outtab; - - $outtab = &gst_filesys_table_dup ($intab_a); - - foreach $info_b (@$intab_b) - { - my $info_c; - - if ($info_c = &gst_filesys_table_find_info_equivalent ($outtab, $info_b)) - { - &gst_filesys_info_merge ($info_c, $info_b); - } - } - - return $outtab; -} - -# Called to indicate that entries in a filesys table are mounted. - -sub gst_filesys_table_set_mounted_true # filesys_table -{ - my ($table) = @_; - foreach $i (@$table) - { - &gst_filesys_info_set_mounted ($i, 1); - } -} - -# Called to indicate that entries in a filesys table are permanent. - -sub gst_filesys_table_set_permanent_true # filesys_table -{ - my ($table) = @_; - foreach $i (@$table) - { - &gst_filesys_info_set_permanent ($i, 1); - } -} - -# Called to indicate that entries in a filesys table have been detected, -# e.g. by a network or bus scanner, and were not specified in any part of -# the user's configuration. - -sub gst_filesys_table_set_detected_true # filesys_table -{ - my ($table) = @_; - foreach $i (@$table) - { - &gst_filesys_info_set_detected ($i, 1); - } -} - -# --- Parsing --- # - -sub gst_filesys_entry_identify -{ - my ($device, $fs) = @_; - my ($label, $uuid, $network_host, $network_path); - - # <device> expands to "LABEL=<label>", "UUID=<uuid>" or "<device node>". - if ($device =~ /^LABEL=(.*)/i) { $label = $1; $device = ""; } - elsif ($device =~ /^UUID=(.*)/i) { $uuid = $1; $device = ""; } - else - { - # We know only the device node. Try to get label too. - if ($fs eq "ext2" || ($fs eq "auto" && !($device =~ /fd[0-9]$/))) - { - $label = &gst_filesys_ext2_device_to_label ($device); - } - # Network filesystem devices can be separated into remote host and remote path. - elsif ($fs eq "nfs") - { - $device =~ /([^:]+):(.+)/; - $network_host = $1; - $network_path = $2; - $network_path = "/" . $network_path if (!($network_path =~ /^\//)); - $device = ""; - } - elsif ($fs eq "smbfs") - { - $device =~ /[\\\/]*([^\\\/]+)[\\\/]+(.+)/; - $network_host = $1; - $network_path = $2; - $network_path = "/" . $network_path if (!($network_path =~ /^\//)); - $device = ""; - } - } - - return ($device, $label, $uuid, $network_host, $network_path); -} - -sub gst_filesys_entry_identify_info -{ - my ($fsi, $device, $fs) = @_; - my ($label, $uuid, $network_host, $network_path); - - ($device, $label, $uuid, $network_host, $network_path) = &gst_filesys_entry_identify ($device, $fs); - - if ($device) { &gst_filesys_info_set_device ($fsi, $device); } - if ($label) { &gst_filesys_info_set_label ($fsi, $label); } - if ($uuid) { &gst_filesys_info_set_uuid ($fsi, $uuid); } - if ($network_host) { &gst_filesys_info_set_network_host ($fsi, $network_host); } - if ($network_path) { &gst_filesys_info_set_network_path ($fsi, $network_path); } -} - -# Get all instances from fstab-style file. Returns a filesys_table. -# -# This is not done in smaller, atomic funcs that get single options -# per disk device, due to the fact that a device is identified either -# by its label, uuid or device node, and a label can be made to look -# like a device node. For each device, we need to specify the kind of -# key(s) used, and making a special-format string for that (which could -# be passed to option readers) would be a bad hack. - -sub gst_filesys_fstab_parse # filename -{ - my ($file) = @_; - my ($fd, $table); - - $fd = &gst_file_open_read_from_names ($file); - return undef if !$fd; - - $table = &gst_filesys_table_new (); - - while (($_ = &gst_parse_chomp_line_hash_comment ($fd)) != -1) - { - # Each line is in the following format: - # <device> <mount point> <filesystem> <options> <dump flag> <fsck priority> - my @line = split /[ \t]+/, $$_; - next if (@line < 6); - my ($device, $point, $fs, $options, $dump, $fsck) = @line; - - my $fsi = &gst_filesys_info_new (); - &gst_filesys_entry_identify_info ($fsi, $device, $fs); - - # <mount point>, <fs>, <dump flag> and <fsck priority> are verbatim. - &gst_filesys_info_set_point ($fsi, $point); - &gst_filesys_info_set_fs ($fsi, $fs); - &gst_filesys_info_set_dump ($fsi, $dump); - &gst_filesys_info_set_priority ($fsi, $fsck); - - # <options> expands to "<option>[,<option>[,...]]". - my @optlist = split /[,]/, $options; - - foreach $option (@optlist) - { - # <option> expands to "<key>[=<value>]". <key> == "defaults" is ignored. - my ($key, $value) = split /[=]/, $option; - next if ($key eq "" || $key eq "defaults"); - - if ($value eq "" && $option =~ /=/) { $value = " "; } - &gst_filesys_info_set_option ($fsi, $key, $value); - } - - # Link it in. - &gst_filesys_table_add ($table, $fsi); - } - - &gst_file_close ($fd); - return $table; -} - -# Get all instances from 'mount -p' output. Returns a filesys_table. -sub gst_filesys_freebsd_mount_cmd_parse -{ - my ($table, $mount_cmd); - my (@output, $l); - - $table = &gst_filesys_table_new (); - $mount_cmd = &gst_file_locate_tool ("mount"); - @output = (readpipe ("$mount_cmd -p")); - - foreach $l (@output) - { - # Columns are separated by any number of spaces/tabs. - chomp $l; - my @line = split (/[ \t]+/, $l); - - # Each line is in the following format: - # <device> <mount point> <filesystem> <options> <dump flag> <fsck priority> - next if ($#line < 5); - my ($device, $point, $fs, $options, $dump, $fsck) = @line; - - my $fsi = &gst_filesys_info_new (); - &gst_filesys_entry_identify_info ($fsi, $device, $fs); - - # <device> expands to "<device node>" (unlike fstab, which has dev|label|uuid). - # <mount point>, <fs>, <dump flag> and <fsck priority> are verbatim. - &gst_filesys_info_set_device ($fsi, $device); - &gst_filesys_info_set_point ($fsi, $point); - &gst_filesys_info_set_fs ($fsi, $fs); - &gst_filesys_info_set_dump ($fsi, $dump); - &gst_filesys_info_set_priority ($fsi, $fsck); - - # <options> expands to "<option>[,<option>[,...]]". - my @optlist = split (/,/, $options); - - foreach $option (@optlist) - { - # <option> expands to "<key>[=<value>]". <key> == "defaults" is ignored. - my ($key, $value) = split /[=]/, $option; - next if ($key eq "" || $key eq "defaults"); - - $value = " " if ($value eq "" && $option =~ /=/); - &gst_filesys_info_set_option ($fsi, $key, $value); - } - - # Link it in. - &gst_filesys_table_add ($table, $fsi); - } - - return $table; -} - -# Get all instances from mtab-style file. Returns a filesys_table. - -sub gst_filesys_mtab_parse # filename -{ - my ($file) = @_; - my ($fd, $table); - - $fd = &gst_file_open_read_from_names ($file); - return undef if !$fd; - - $table = &gst_filesys_table_new (); - - while (($_ = &gst_parse_chomp_line_hash_comment ($fd)) != -1) - { - # Columns are separated by one, and only one, space. The presence of one or - # more blank values is indicated by a string of several spaces. - my @line = split /[ ]/, $$_; - - # Each line is in the following format: - # <device> <mount point> <filesystem> <options> <dump flag> <fsck priority> - next if (@line < 6); - my ($device, $point, $fs, $options, $dump, $fsck) = @line; - - my $fsi = &gst_filesys_info_new (); - &gst_filesys_entry_identify_info ($fsi, $device, $fs); - - # <device> expands to "<device node>" (unlike fstab, which has dev|label|uuid). - # <mount point>, <fs>, <dump flag> and <fsck priority> are verbatim. - &gst_filesys_info_set_device ($fsi, $device); - &gst_filesys_info_set_point ($fsi, $point); - &gst_filesys_info_set_fs ($fsi, $fs); - &gst_filesys_info_set_dump ($fsi, $dump); - &gst_filesys_info_set_priority ($fsi, $fsck); - - # <options> expands to "<option>[,<option>[,...]]". - my @optlist = split /[,]/, $options; - - foreach $option (@optlist) - { - # <option> expands to "<key>[=<value>]". <key> == "defaults" is ignored. - my ($key, $value) = split /[=]/, $option; - next if ($key eq "" || $key eq "defaults"); - - if ($value eq "" && $option =~ /=/) { $value = " "; } - &gst_filesys_info_set_option ($fsi, $key, $value); - } - - # Link it in. - &gst_filesys_table_add ($table, $fsi); - } - - &gst_file_close ($fd); - return $table; -} - - -# --- Replacing --- # - - -sub gst_filesys_fstab_get_next_entry_line # $infd, $outfd -{ - my ($infd, $outfd) = @_; - - while (<$infd>) - { - # Each line is in the following format: - # <device> <mount point> <filesystem> <options> <dump flag> <fsck priority> - my @line = split /[ \t]+/, $_; - if ($line[0] eq "") { shift @line; } - if (@line < 6 || &gst_ignore_line (@line)) { print $outfd $_; next; } - - return $_; - } - - return undef; -} - -sub gst_filesys_fstab_get_entry_line_fields # line -{ - my ($line) = @_; - - # Remove leading spaces. - $line =~ s/^[ \t]*//; - - # Remove trailing spaces and comments. - $line =~ s/[ \t]*\#.*//; - - return split /[ \t]+/, $line; -} - -sub gst_filesys_fstab_get_entry_line_comments # line -{ -} - -sub gst_filesys_info_print_options # filesys_info -{ - my ($info) = @_; - my $optstring = ""; - my $opthash; - - $opthash = $$info{'options'}; - - for $option (keys (%$opthash)) - { - if ($optstring) { $optstring .= ","; } - $optstring .= $option; - if ($info->{'options'}{$option}) - { - $optstring .= "=" . $info->{'options'}{$option}; - $optstring =~ s/ //; - } - } - - if ($optstring eq "") - { - $optstring = "defaults"; - } - - return $optstring; -} - -sub gst_filesys_info_print_device -{ - my ($info) = @_; - my $device; - - if (&gst_filesys_info_get_label ($info)) - { - $device = "LABEL=" . &gst_filesys_info_get_label ($info); - } - elsif (&gst_filesys_info_get_uuid ($info)) - { - $device = "UUID=" . &gst_filesys_info_get_uuid ($info); - } - elsif (&gst_filesys_info_get_network_host ($info) && - &gst_filesys_info_get_network_path ($info)) - { - if (&gst_filesys_info_get_fs ($info) eq "smbfs") - { - $device = "//" . &gst_filesys_info_get_network_host ($info) - . &gst_filesys_info_get_network_path ($info); - } - else - { - $device = &gst_filesys_info_get_network_host ($info) . ":" . - &gst_filesys_info_get_network_path ($info); - } - } - else - { - $device = &gst_filesys_info_get_device ($info); - } - - return $device; -} - -sub gst_filesys_info_print_entry -{ - my ($info) = @_; - my $line; - - # <device> - - $line = sprintf ("%-23s", &gst_filesys_info_print_device ($info)); - - # <mount point> - - if (&gst_filesys_info_get_point ($info)) - { - $line .= sprintf ("%-24s", (" " . &gst_filesys_info_get_point ($info))) . " "; - } - else - { - $line .= sprintf ("%-24s", (" none")) . " "; - } - - # <filesystem> <options> <dump flag> <fsck priority> - - $line .= sprintf ("%-7s", &gst_filesys_info_get_fs ($info)) . " " . - sprintf ("%-15s", &gst_filesys_info_print_options ($info)) . " " . - &gst_filesys_info_get_dump ($info) . " " . - &gst_filesys_info_get_priority ($info); - - return $line; -} - -sub gst_filesys_fstab_add_entry # filename, filesys_info -{ - my ($file, $info) = @_; - my ($infd, $outfd); - my ($line); - - ($infd, $outfd) = &gst_file_open_filter_write_from_names ($file); - return undef if !$outfd; - - while (<$infd>) { print $outfd $_; } - &gst_file_close ($infd); - - print $outfd &gst_filesys_info_print_entry ($info) . "\n"; - &gst_file_close ($outfd); -} - -sub gst_filesys_fstab_update_entry # filename, filesys_info -{ - my ($file, $info) = @_; - my ($infd, $outfd); - my ($line); - my $replaced = 0; - - ($infd, $outfd) = &gst_file_open_filter_write_from_names ($file); - return undef if !$outfd; - - while ($line = &gst_filesys_fstab_get_next_entry_line ($infd, $outfd)) - { - my ($device, $point, $fs, $options, $dump, $fsck) = &gst_filesys_fstab_get_entry_line_fields ($line); - my ($device, $label, $uuid, $network_host, $network_path) = &gst_filesys_entry_identify ($device, $fs); - - if (!$replaced && &gst_filesys_info_match ($info, $device, $label, $uuid, - $network_host, $network_path, $point)) - { - print $outfd &gst_filesys_info_print_entry ($info) . "\n"; - $replaced = 1; - } - else - { - print $outfd $line; - } - } - - &gst_file_close ($infd); - &gst_file_close ($outfd); -} - -sub gst_filesys_fstab_remove_entry # filename, filesys_info -{ - my ($file, $info) = @_; - my ($infd, $outfd); - my ($line); - - ($infd, $outfd) = &gst_file_open_filter_write_from_names ($file); - return undef if !$outfd; - - while ($line = &gst_filesys_fstab_get_next_entry_line ($infd, $outfd)) - { - my ($device, $point, $fs, $options, $dump, $fsck) = &gst_filesys_fstab_get_entry_line_fields ($line); - my ($device, $label, $uuid, $network_host, $network_path) = &gst_filesys_entry_identify ($device, $fs); - - if (!&gst_filesys_info_match ($info, $device, $label, $uuid, $network_host, $network_path, $point)) - { - print $outfd $line; - } - } - - &gst_file_close ($infd); - &gst_file_close ($outfd); -} - -# Replace instances in fstab-style file. - -sub gst_filesys_fstab_replace # filename, table -{ - my ($file, $table) = @_; - my ($new_table, $old_table); - - $old_table = &gst_filesys_fstab_parse ($file); - $new_table = &gst_filesys_table_dup ($table); - - for $info (@$new_table) - { - my $old_info = &gst_filesys_table_find_info_equivalent ($old_table, $info); - -# print "Looking for entry - "; - if (&gst_filesys_info_get_permanent ($info) && !$old_info) - { -# print "adding.\n"; - &gst_filesys_fstab_add_entry ($file, $info); - } - elsif (!&gst_filesys_info_get_permanent ($info) && $old_info) - { -# print "removing.\n"; - &gst_filesys_fstab_remove_entry ($file, $info); - } - elsif ($old_info && !&gst_filesys_info_match_data ($old_info, $info)) - { -# print "updating.\n"; - &gst_filesys_fstab_update_entry ($file, $info); - } - else - { -# print "found.\n"; - } - } - -# print "---\n"; - - for $old_info (@$old_table) - { -# print "Looking for entry - "; - if (!&gst_filesys_table_find_info_equivalent ($new_table, $old_info)) - { -# print "removing.\n"; - &gst_filesys_fstab_remove_entry ($file, $old_info); - } - else - { -# print "found.\n"; - } - } -} - - -# --- Mounting --- # - - -sub gst_filesys_mount_on -{ - my ($info) = @_; - my ($dev, $point, $fs); - - $dev = &gst_filesys_info_print_device ($info); - $point = &gst_filesys_info_get_point ($info); - - &gst_report_enter (); - &gst_report ("filesys_mount", $dev, $point); - - $fs = &gst_filesys_info_get_fs ($info); - $fs = "auto" if ($fs eq ""); - - if (&gst_file_run ("mount -t " . $fs . " -o " . &gst_filesys_info_print_options ($info) . " " . - $dev . " " . $point)) - { - &gst_report ("filesys_mount_failed", $dev, $point); - } - - &gst_report_leave (); -} - -sub gst_filesys_mount_off -{ - my ($info) = @_; - my ($dev, $point); - - $dev = &gst_filesys_info_print_device ($info); - $point = &gst_filesys_info_get_point ($info); - - &gst_report_enter (); - &gst_report ("filesys_unmount", $dev, $point); - - if (&gst_file_run ("umount -f " . $point)) - { - &gst_report ("filesys_unmount_failed", $dev, $point); - } - - &gst_report_leave (); -} - -sub gst_filesys_mount_sync_all -{ - my ($fstab_file, $mtab_file, $new_table) = @_; - my ($mount_table, $fs_table); - - $fs_table = &gst_filesys_fstab_parse ($fstab_file); - $mount_table = &gst_filesys_mtab_parse ($mtab_file); - - for $info (@$new_table) - { - my $mounted_info = &gst_filesys_table_find_info_equivalent ($mount_table, $info); - - if ($mounted_info && !&gst_filesys_info_get_mounted ($info)) - { - &gst_filesys_mount_off ($mounted_info); - } - elsif (!$mounted_info && &gst_filesys_info_get_mounted ($info)) - { - # If the mount has an fstab entry, we prefer that over the information - # provided by XML. - - my $fs_info = &gst_filesys_table_find_info_equivalent ($fs_table, $info); - - if ($fs_info) - { - &gst_filesys_mount_on ($fs_info); - } - else - { - &gst_filesys_mount_on ($info); - } - } - } -} - - -1; diff --git a/font-conf.in b/font-conf.in deleted file mode 100644 index c3fbb36..0000000 --- a/font-conf.in +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Display configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Tambet Ingo <tambet@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/X11/XF86Config - -# Running programs affected: -# - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/font.pl$DOTIN"; -} - -use Benchmark; - -# --- Tool information --- # - -$name = 'font'; -$version = "@VERSION@"; -@platforms = qw(redhat-6.2 redhat-7.0 redhat-7.1 redhat-7.2 turbolinux-7.0 - mandrake-7.2 mandrake-8.0); - -$description =<<"end_of_description;"; - Configures fonts. -end_of_description; - - -sub xml_print -{ - my $font_list = shift; - - &gst_xml_print_begin (); - &gst_xml_print_vspace (); - - &font_xml_print ($font_list); - - &gst_xml_print_end (); -} - -# Top-level actions. - -sub get -{ - my $font_list = &font_get_all (); - - &gst_report_end (); - &xml_print ($font_list); -} - -sub set -{ - my $font_list = &font_xml_parse (); - - &font_set ($font_list); - &gst_report_end (); -} - -sub filter -{ - my $font_list = &font_xml_parse (); - - &gst_report_end (); - &xml_print ($font_list); -} - -sub test -{ - my ($tool, @dir) = @_; - my $font_list = &font_test (\@dir); - - &gst_report_end (); - &xml_print ($font_list); -} - - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "test" => [ \&test, [ "dir*" ], "Get font information on specified file or directory." ], -}; - - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/font.pl.in b/font.pl.in deleted file mode 100644 index b73736f..0000000 --- a/font.pl.in +++ /dev/null @@ -1,1299 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Common stuff for the ximian-setup-tools backends. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Arturo Espinosa <arturo@ximian.com>, -# Tambet Ingo <tambet@ximian.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -my $SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/service.pl$DOTIN"; - -use File::Copy; -use File::Basename; -use IO::File; -use English; - -my $GST_FONT_DIR = "/usr/share/fonts/gst"; - - -# This code is some experimental stuff that may be useful on the future. -# Commented due to the dependency to the TTF perl module.i -if (0) -{ - -# use Font::TTF::Font; - -sub regexp_cmp_foreach -{ - my ($map, $value) = @_; - my ($key); - - foreach $key (keys %$map) - { - return $$map{$key} if $value =~ /$key/i; - } - - return undef; -} - -# Heuristics to deduct the foundry from a copyright notice. -sub gst_font_info_get_foundry_from_notice -{ - my ($notice) = @_; - my ($ret); - - # Maps from a person (company of physical person) to a foundry. - my %map = - ("hershey" => "hershey", - - # Some of these taken from the X Registry: http://ftp.x.org/pub/DOCS/registry - "copyright.*acorn" => "acorn", - "copyright.*adobe" => "adobe", - " aix " => "aix", # This is IBM, but maybe we'll determine aix foundry this way. - "copyright.*apple" => "apple", - "copyright.*bigelow.*holmes" => "b&h", - "copyright.*bitstream" => "bitstream", - "copyright.*cognition" => "cognition", - "copyright.*cronyx" => "cronyx", - "copyright.*fujitsu" => "fujitsu", - "copyright.*fuji xerox" => "fujixerox", - "copyright.*ipsys" => "ipsys", - "copyright.*metheus" => "metheus", - "copyright.*misc" => "misc", - "copyright.*monotype" => "monotype", - "copyright.*omron" => "omron", - "copyright.*panasonic" => "panasonic", - "copyright.*matsushita" => "panasonic", - "copyright.*sony" => "sony", - "copyright.*urw" => "urw", - - "copyright.*digital equipment" => "dec", - "copyright.*evans.*sutherland" => "eands", - "copyright.*international business machines" => "ibm", - "copyright.*network computing" => "ncd", - "copyright.*sun microsystems" => "sun", - - # Those that may give false positives go last. - "copyright.*dec" => "dec", - "copyright.*ibm" => "ibm", - "copyright.*ncd" => "ncd", - "copyright.*sun" => "sun", - "copyright.*microsoft" => "microsoft" - ); - - # first aptempt: match sth like "Copyright 1987-1990 as an unpublished work by Bitstream" - $ret = ®exp_cmp_foreach (\%map, $notice); - return $ret if $ret ne undef; - - # Give up: use misc. - return "misc"; -} - -sub gst_font_info_get_setwidth_from_label -{ - my ($label) = @_; - my ($ret); - - # FIXME: find cases for "semicondensed" and others. - my %map = - ("narrow" => "condensed"); - - - $ret = ®exp_cmp_foreach (\%map, $label); - return $ret if $ret ne undef; - - # The default value. - return "normal"; -} - -sub gst_font_info_deduct_extras -{ - my ($info) = @_; - - $$info{"foundry"} = &gst_font_info_get_foundry_from_notice ($$info{"notice"}); - $$info{"setwidth"} = &gst_font_info_get_setwidth_from_label ($$info{"label"}); - $$info{"weight"} = " $$info{weight} "; - $$info{"weight"} =~ s/[ \t]+/ /g; - - # Solve "Oblique" fonts. - if (!$$info{"weight"} =~ / Italic /) - { - if ($$info{"angle"} < 0.0) - { - $$info{"weight"} .= "Oblique "; - } - elsif ($$info{"angle"} > 0.0) - { - $$info{"weight"} .= "ReverseOblique "; - } - } -} - -# buff is an array with one line of text per entry. -sub gst_font_info_get_from_afm_buff -{ - my ($buff) = @_; - my ($line, $key, $value, %info); - - my %map = - ("FontName" => "name", - "FullName" => "label", - "FamilyName" => "family", - "Weight" => "weight", - "IsFixedPitch" => "fixed", - "Notice" => "notice", - "ItalicAngle" => "angle", - "CharacterSet" => "charset", - ); - - foreach $line (@$buff) - { - ($key, $value) = split ("[ \t]+", $line, 2); - chomp $value; - last if $key eq "StartCharMetrics"; - $info{$map{$key}} = $value if exists $map{$key}; - } - - &gst_font_info_deduct_extras (\%info); - - return \%info; -} - -sub gst_font_info_get_from_afm_str -{ - my ($str) = @_; - my (@buff); - - @buff = split ('\n', $str); - - return &gst_font_info_get_from_afm_buff (\@buff); -} - -sub gst_font_info_get_from_afm -{ - my ($file) = @_; - local *AFM; - my (@buff, $info); - - open AFM, $file; - @buff = (<AFM>); - close AFM; - - $info = &gst_font_info_get_from_afm_buff (\@buff); - $$info{"file"} = $file; - $$info{"file"} =~ s/.*\///; - - return $info; -} - -sub gst_font_info_get_from_ttf2pt1 -{ - my ($file) = @_; - my ($key, $value, @buff, $info); - my $fd; - - $fd = &gst_file_run_pipe_read ("ttf2pt1 -A $file -"); - @buff = <$fd>; - &gst_file_close ($fd); - - $info = &gst_font_info_get_from_afm_buff (\@buff); - $$info{"file"} = $file; - $$info{"file"} =~ s/.*\///; - - return $info; -} - -sub namerec_value -{ - my ($table, $idx) = @_; - my ($ms, $apple, $uni); - - # As documented in http://fonts.apple.com/TTRefMan/RM06/Chap6name.html - # Get the Unicode (0) value, trying any semantic. - $uni = $ {$$table[$idx]}[0]; - if ($uni) - { - my $i; - - # FIXME: dunno if we are following the way the structure comes built. - $uni = $$uni[0]; - for ($i = 0; $i < 4; $i++) - { - return $$uni{$i} if $$uni{$i} ne undef; - } - } - - # Get the Microsoft (3) value, western encoding (1033). - $ms = $ {$ {$ {$$table[$idx]}[3]}[1]}{"1033"}; - return $ms if $ms ne undef; - - # Get the Apple (1) value, Roman encoding (0). - $apple = $ {$ {$ {$$table[$idx]}[1]}[0]}{"0"}; - return $apple if $apple ne undef; -} - -sub gst_font_info_get_from_ttf -{ - my ($file) = @_; - my ($font, $t, $post, %info); - - $font = Font::TTF::Font->open($file); - return undef if !$font; - - $post = $$font{"post"}->read; - $t = $$font{"name"}->read; - $t = $$t{"strings"}; - - # As documented in http://fonts.apple.com/TTRefMan/RM06/Chap6name.html - $info{"name"} = &namerec_value ($t, 6); - $info{"label"} = &namerec_value ($t, 4); - $info{"family"} = &namerec_value ($t, 1); - $info{"weight"} = &namerec_value ($t, 2); - $info{"notice"} = &namerec_value ($t, 0); - $info{"angle"} = $$post{"italicAngle"}; - $info{"fixed"} = $$post{"isFixedPitch"}? "true": "false"; - - $info{"file"} = $file; - $info{"file"} =~ s/.*\///; - - &gst_font_info_deduct_extras (\%info); - - $font->DESTROY; - - return \%info; -} - -sub gst_font_info_to_fontdir -{ - my ($info) = @_; - my ($line, $i); - my (%map); - my ($weight, $slant, $addstyle, $pitch, $charmap); - - $i = $info; - - %map = (" Light " => "light", - " Regular " => "regular", - " Roman " => "medium", - " Normal " => "medium", - " Medium " => "medium", - " Book " => "book", - " DemiBold " => "demibold", - " Demi " => "demibold", - " Bold " => "bold", - " Black " => "black"); - $weight = ®exp_cmp_foreach (\%map, $$i{"weight"}); - - %map = (" Italic " => "i", - " ReverseItalic " => "ri", - " Oblique " => "o", - " ReverseOblique" => "ro"); - $slant = ®exp_cmp_foreach (\%map, $$i{"weight"}); - $slant = "r" if $slant eq undef; - - # No way to know addstyle for now. - $addstyle = ""; - $pitch = ($$i{"fixed"} eq "false")? "p" : "m"; - # FIXME: no way to tell charactermap. Should use X encodings in get funcs - # or see how ttmkfdir takes care of this. - $charmap = "-"; - - # We're using 0's because we assume we are dealing with scalable fonts. - return "$$i{file} -$$i{foundry}-$$i{family}-$weight-$slant-$$i{setwidth}-$addstyle-0-0-0-0-$pitch-0-$charmap"; -} - -} # if (0) - - -use strict; - - -# XFS Config - -my $xfs_boolean = { - 'parse' => \&xfs_parse_boolean, - }; - -my $xfs_cardinal = { - 'parse' => \&xfs_parse_cardinal, - }; - -my $xfs_string = { - 'parse' => \&xfs_parse_string, - }; - -my $xfs_string_list = { - 'parse' => \&xfs_parse_string_list, - }; - -my $xfs_resol_list = { - 'parse' => \&xfs_parse_string_list, - }; - -my $xfs_trans_type = { - 'parse' => \&xfs_parse_string, - }; - -my $xfs_table = { - 'catalogue' => $xfs_string_list, - 'alternate-servers' => $xfs_string_list, - 'client-limit' => $xfs_cardinal, - 'clone-self' => $xfs_boolean, - 'default-point-size' => $xfs_cardinal, - 'default-resolutions' => $xfs_resol_list, - 'error-file' => $xfs_string, - 'no-listen' => $xfs_trans_type, - 'port' => $xfs_cardinal, - 'use-syslog' => $xfs_boolean, - 'deferglyphs' => $xfs_string, - }; - -# XFS boolean - -sub xfs_parse_boolean -{ - my $val = shift; - my $buf = shift; - - unless ($val eq 'on' || $val eq 'off') - { - # TODO: Give error; - return; - } - - return $val; -} - - -# XFS cardinal (integer) - -sub xfs_parse_cardinal -{ - my $val = shift; - my $buf = shift; - - unless ($val =~ /^\d+$/) - { - # TODO: Give error; - return; - } - - return $val; -} - - -# XFS string - -sub xfs_parse_string -{ - my $val = shift; - my $buf = shift; - - # TODO: Dunno what do check here -# unless ($val =~ /^\d+$/) -# { - # TODO: Give error; -# return; -# } - - return $val; -} - -# XFS string list - -sub xfs_parse_string_list -{ - my $val = shift; - my $buf = shift; - my $last; - my $list = []; - - while (1) - { - $val =~ s/\s+$//; - $val =~ s/^\s+//; - - $last++ unless $val =~ s/,$//; - if ($val) - { - my @tmp = split (/[ \t]*,[ \t]*/, $val); - push @$list, @tmp; - } - else - { - # TODO: Give error; - last; - } - shift @$buf; - last if $last; - $val = $$buf[0]; - } - - return $list; -} - -sub xfs_parse -{ - my $fname = shift; - $fname = $fname || '/etc/X11/fs/config'; - my $config = {}; - return unless $fname; - - my $buf = &gst_file_buffer_load ($fname); - return unless $buf; - - while (@$buf) - { - my $line = shift @$buf; - next if &gst_ignore_line ($line); - - chomp ($line); - my ($kw, $val) = split (/[ \t]*=[ \t]*/, $line, 2); - if (exists ($xfs_table->{$kw})) - { - my $func = $xfs_table->{$kw}{'parse'}; - my $val = &$func ($val, $buf); - if ($val) - { - $config->{$kw} = $val; - } - else - { - # TODO: Give error; - 1; - } - } - else - { - # TODO: report error; - 1; - } - } - - return $config; -} - - -################################ -# # -# MAIN PROGRAM # -# # -################################ - -BEGIN { - &gst_report_table ({ - 'font_install_success' => ['info', _('Font [%s] installed successfully.')], - 'font_install_fail' => ['warn', _('File [%s] not installed.')], - 'font_remove_success' => ['info', _('Font [%s] removed successfully.')], - 'font_dir_update_success' => ['info', _('Font dir [%s] updated successfully.')], - 'font_dir_update_fail' => ['warn', _('Couldn\'t update font dir [%s].')], - - 'font_list' => ['info', _('[%s] fonts read successfully.')], - - }); -} - -my $cmd = 'gnome-font-install'; - -my $GNOME_PRINT_DATADIR; -my $GNOME_PRINT_SYSCONFDIR; - -open (FD, "$cmd --dir 2>&1 |"); -if (FD) -{ - my @output = (<FD>); - close (FD); - - foreach (@output) - { - if (/^\$DATADIR=(.*)/) { $GNOME_PRINT_DATADIR = $1; next; } - if (/^\$SYSCONFDIR=(.*)/) { $GNOME_PRINT_SYSCONFDIR = $1; next; } - } -} - -unless ($GNOME_PRINT_DATADIR || $GNOME_PRINT_SYSCONFDIR) -{ - print ("Can't find gnome-print's \$DATADIR or \$SYSCONFDIR.\n"); - return; -} - -my $font_map = { - 'name' => [], - 'get' => [], - 'set' => [], -}; - -# Gets a hash of all fonts we currently support. -# Hash keys are name of modules, values are lists of fonts. -sub font_list -{ - my $names = $font_map->{'name'}; - my $list = $font_map->{'get'}; - my $fonts = {}; - - for (my $i = 0; $i < scalar @$list; $i++) - { - my $func = $$list[$i]; - - &gst_report ("font_list", $$names[$i]); - - my $tmp = &$func (); - $fonts->{$$names[$i]} = $tmp if $tmp; - } - - return $fonts; -} - - -# Returns a hash of all fonts. -# Unifies different systems, abstracts font systems. -sub font_get_all -{ - my %font_list; - my $fonts = &font_list (); - - foreach my $system (keys %$fonts) - { - my $tmp_fonts = $fonts->{$system}; - %font_list = (%font_list, %$tmp_fonts); - } - - return \%font_list; -} - -# Takes two arguments with lists of fonts. -# Returns two lists with unique items from passed lists. -sub font_lists_compare -{ - my $sys_fonts = shift; - my $xml_fonts = shift; - - # Make a copy of xml_fonts. - my %fonts_copy = %$xml_fonts; - - my %del; - my %add; - - # Build list of removals - foreach my $key (keys (%$sys_fonts)) - { - if (exists $fonts_copy{$key}) - { - delete $fonts_copy{$key}; - } - else - { - $del{$key} = $sys_fonts->{$key}; - } - } - - # Build list of additions - %add = %fonts_copy; - - return (\%del, \%add); -} - -# Returns true if file should be copied. -sub font_file_copy_need -{ - my $path = shift; - - # Can we be a bit smarter? - return if ($path =~ /\/usr\//); - - return 1; -} - -# Copy new font files to our fonts dir. -# Pass a fontslist as single argument and modifies it's file locations. -sub font_file_copy -{ - my $add = shift; - return unless $add; - - foreach (keys %$add) - { - my $font = $add->{$_}; - next unless exists $font->{'name'}; - - my $type = $font->{'format'}; - foreach my $file (@{$font->{'file'}}) - { - my $path = $file->{'path'}; - next unless &font_file_copy_need ($path); - - my $new_path = "$GST_FONT_DIR/$type/"; - &gst_file_create_path ($new_path, 0755) unless (-d $new_path); - $new_path .= lc (basename ($path)); - - unless (-f $new_path) - { - # FIXME: Report. - copy ($path, $new_path); - } - $file->{'path'} = $new_path; - } - } -} - -# -sub font_file_del -{ - my $del = shift; - return unless $del; - - foreach (keys %$del) - { - my $font = $del->{$_}; - - # FIXME: Report. - foreach my $file (@{$font->{'file'}}) - { - # unlink $file->{'path'} if (-f $file->{'path'}); - } - } -} - -# -sub font_set -{ - my $xml_fonts = shift; - return unless $xml_fonts; - return unless ref ($xml_fonts) eq 'HASH'; - - my $names = $font_map->{'name'}; - my $get_functions = $font_map->{'get'}; - my $set_functions = $font_map->{'set'}; - - for (my $i = 0; $i < scalar @$names; $i++) - { - my $get = $$get_functions[$i]; - my $set = $$set_functions[$i]; - - my $sys_fonts = &$get (); - my ($del, $add) = &font_lists_compare ($sys_fonts, $xml_fonts); - &font_file_copy ($add); - &$set ($del, $add); - &font_file_del ($del); - } -} - -# Pass list of fonts, prints out XML -sub font_xml_print -{ - my $fonts = shift; - - foreach (keys %$fonts) - { - my $font = $fonts->{$_}; - - &gst_xml_print_line ("<font format=\"$font->{format}\" name=\"$font->{name}\" version=\"$font->{version}\"" . - " familyname=\"$font->{familyname}\" speciesname=\"$font->{speciesname}\"" . - " psname=\"$font->{psname}\" weight=\"$font->{weight}\" italicangle=\"$font->{italicangle}\">"); - - &gst_xml_enter (); - foreach my $file (@{$font->{'file'}}) - { - &gst_xml_print_line ("<file type=\"$file->{type}\" path=\"$file->{path}\"" . - " size=\"$file->{size}\" mtime=\"$file->{mtime}\"/>"); - } - &gst_xml_leave (); - &gst_xml_print_line ("</font>"); - } -} - -# Just a dumb wrapper due to fact that we are using gnome-print's XML. -sub font_xml_parse -{ - my $fname = shift; - return &gp_parse ($fname); -} - -sub font_test -{ - my $dir = shift || return; - - # FIXME: Report. - my $fonts = &gp_invoke (join (" ", @$dir), 0) if scalar @$dir; - return $fonts; -} - - -################################ -# # -# MODULES # -# # -################################ - -# Each 'module' should register itself in their own BEGIN {} block. It should add -# a name of the module and 2 function references -# to $font_map global variable: get and set. - - -################################ -# # -# Gnome-print module. # -# # -################################ - -# Module info: -# This is THE MODULE since we use gnome-print's -# XML format to interact with frontend. - -# Register. -push @{$font_map->{'name'}}, 'Gnome-print'; -push @{$font_map->{'get'}}, \&gp_read_fontmaps; -push @{$font_map->{'set'}}, \&gp_font_set; - - -sub gp_run -{ - my $dir = shift; - my $user = shift; - my $set = shift; - $user = $user ? "--user " : "--dynamic "; - $set = $set ? "" : "--clean --target - "; - - my $command = "gnome-font-install --debug --recursive -a $GNOME_PRINT_DATADIR/gnome/fonts/adobe-urw.font " . - $set . $user . $dir; - - open (FD, "$command 2>&1 |"); - if (FD) - { - my @output = (<FD>); - close (FD); - return \@output; - } - - # TODO: Give error; - return; -} - -sub gp_parse_xml -{ - my $data = shift; - my $toplevel; - - my $xml = shift @$data; - while (@$data) - { - my $tag = shift @$data; - unless ($toplevel) - { - $toplevel = $1 if $tag =~ /<(\S+)/; - } - - last if $tag =~ /<\/$toplevel[ \t]+/; - - $xml .= $tag; - } - return &gp_parse ($xml); -} - -sub gp_run_collect -{ - my $data = shift; - my $xml; - - return unless ($data || scalar @$data < 1); - - while (@$data) - { - local $_ = $$data[0]; - - if (/<\?xml version/) { $xml = &gp_parse_xml ($data); }; - # TODO: Add parser for all output messages and report them. - - shift @$data; - } - - return $xml; -} - -sub gp_invoke -{ - my $dir = shift || '/'; - my $set = shift; - my $user = $UID; # Used as a boolean here, we care only for root (uid 0, false) or other (!0, true). - - my $proc = &gst_process_fork (\&gp_run, $dir, $user, $set); - &gst_process_list_check_ready (60, $proc); - my $list = &gst_process_result_collect ($proc, \&gp_run_collect); - - return $list; -} - - -# gnome-font-installer output's (XML) parser. - - -sub gp_parse_font -{ - my $font_list = shift; - my $tree = shift; - my $font; - - $font = shift @$tree; - while (@$tree) - { - my $tag = shift @$tree; - my $data = shift @$tree; - - $font->{$tag} = [] unless exists $font->{$tag}; - push @{$font->{$tag}}, $$data[0]; - } - - $font_list->{$font->{'name'}} = $font; -} - - -sub gp_parse -{ - my $fname = shift; - my $font_list = {}; - - my $tree = &gst_xml_scan ($fname); - - if ($$tree[0] eq 'fontmap') - { - $tree = $$tree[1]; - unless (&gst_xml_get_attribute ($tree, 'version') >= 2) - { - # TODO: report - &gst_debug_print_line ("gp_parse: File '$fname' fontmap version should be 2.0 or higher."); - return; - } - } - - elsif ($$tree[0] eq 'font') - { - # shift @$tree; - $tree = $$tree[1]; - } - - else - { - # TODO: report - &gst_debug_print_line ("gp_parse: File '$fname' doesn't seem to be fontmap file."); - return; - } - - shift @$tree; - while (@$tree) - { - my $tag = shift @$tree; - unless ($tag eq 'font') - { - # TODO: report - next; - } - - &gp_parse_font ($font_list, shift @$tree); - } - - return $font_list; -} - -# Read gnome-print's fontmap files: -# $HOME/.gnome/fonts (user) -# $SYSCONFDIR/gnome/fonts (dynamic) -# $DATADIR/gnome/fonts (static) -sub gp_read_fontmaps -{ - my $fontmap = 'gnome-print.fontmap'; - my $home = $ENV{'HOME'}; - - # FIXME: There are couple of hardcoded ones too. - my @dirs = ("$home/.gnome/fonts", "$GNOME_PRINT_SYSCONFDIR/gnome/fonts", "$GNOME_PRINT_DATADIR/gnome/fonts"); - - # FIXME: Report. - my %gp_fonts; - foreach my $dir (@dirs) - { - my @files; - push @files, "$dir/$fontmap"; - opendir(DIR, $dir); - foreach my $file (grep { /\.fontmap$/ } readdir(DIR)) - { - next if $file eq $fontmap; - push @files, "$dir/$file"; - } - closedir(DIR); - - foreach (@files) - { - my $font_ref = &gp_parse ($_) if (-f $_); - next unless scalar keys %$font_ref; - %gp_fonts = (%gp_fonts, %$font_ref); - } - } - - return \%gp_fonts; -} - -sub gp_font_set -{ - my $del = shift; - my $add = shift; - my @list; - - # FIXME: Report. - - # FIXME: Delete - - foreach (keys %$add) - { - my $font = $add->{$_}; - next unless exists $font->{'file'}; - - foreach my $file (@{$font->{'file'}}) - { - push @list, $file->{'path'}; - } - } - &gp_invoke (join (" ", @list), 1) if scalar @list; -} - - - -################################ -# # -# xfs module. # -# # -################################ - -# Module info: -# This module is distro and version specific. Some xfs implementations (older?) -# doesn't have truetype support. - -# Register. -#push @{$font_map->{'name'}}, 'xfs'; -#push @{$font_map->{'get'}}, \&x_read_fonts; -#push @{$font_map->{'set'}}, \&gp_font_install; - - -sub xfs_get_fontpath -{ - my $cmd = &gst_file_locate_tool ('chkfontpath'); - return unless $cmd; - - my $fh = IO::File->new ("$cmd |"); - return unless $fh; - - my @output = <$fh>; - $fh->close; - - my @fonts; - foreach (@output) - { - my $path = $1 if (/^\d+: (.+)$/); - $path =~ s/:unscaled$//; - push @fonts, $path if $path; - } - - return \@fonts; -} - -# Adds new fontpath to XFS -# Before calling it make sure it's really needed. -sub xfs_add_fontpath -{ - my $paths = shift || return; - my $cmd = &gst_file_locate_tool ('chkfontpath'); - - foreach my $path (@$paths) - { - &gst_file_run ("$cmd -a $path"); - } -} - -sub xfs_reload -{ - &gst_service_sysv_restart (90, 'xfs'); -} - - -################################ -# # -# XFree module. # -# # -################################ - -# Module info: -# Depends on: -# Gnome-print module -# xfs module - -# Register. -push @{$font_map->{'name'}}, 'XFree'; -push @{$font_map->{'get'}}, \&x_read_fonts; -push @{$font_map->{'set'}}, \&x_font_set; - - -sub x_fontpath_get -{ - my $cmd = &gst_file_locate_tool ('xset'); - return unless $cmd; - - my $output = &gst_file_run_backtick ("$cmd q"); - return unless $output; - - $output = $1 if $output =~ /Font Path:\n\s+(.+)/; - unless ($output) - { - &gst_debug_print_line ("x_fontpath_get: Couldn't find 'Font Path' from 'xset q' output."); - return; - } - - my @tmp = split (/[ \t]*,[ \t]*/, $output); - my $fonts = []; - foreach (@tmp) - { - if (/^unix\/:/) - { - my $xfs_fonts = &xfs_get_fontpath (); - push @$fonts, @$xfs_fonts; - } - else - { - push @$fonts, $_; - } - } - - return $fonts; -} - -sub x_fontpath_add -{ - my $new_paths = shift || return; - my $old_paths = &x_fontpath_get (); - my (@path, %seen); - - @seen{@$old_paths} = (); # Tricky perl to build a lookup table. - foreach my $item (@$new_paths) - { - push @path, $item unless (exists $seen{$item}); - } - - # Now we have a list of new paths, let's add them - # FIXME: Where do we add it? xfs? xftt? current x server fontpath? XF86Config? - - &xfs_add_fontpath (\@path); -} - -sub x_fonts_refresh -{ - &xfs_reload (); - &gst_file_run ("xset fp rehash"); -} - -sub x_fonts_dir_parse -{ - my $path = shift; - return unless $path; - my $file = shift || 'fonts.dir'; - - my $fh = IO::File->new ("$path/$file"); - return unless $fh; - - # Known font suffixes - my @suffixlist = qw (.afm .pfm .pfa .pfb .ttf); - - my $fonts; - while (<$fh>) - { - next if /^\d+\s+$/; # Probably the first line, showing the number of fonts. - - if (/^(\S+) (\S+)/) - { - my $f = basename ($1, @suffixlist); - $fonts->{"$path/$f.*"} = undef; - } - } - - $fh->close (); - return $fonts; -} - -# Not used. -sub x_fonts_dir_modify -{ - # Don't delete it, I have some plans with it. - my $del = shift; - my $add = shift; - my $path = shift; - return unless $path; - my $file = shift || 'fonts.dir'; - - my $buf = &gst_file_buffer_load ("$path/$file"); - return unless $buf; - - # Find files which are to be removed - my @del_files; - foreach my $font (@$del) - { - foreach my $file (@{$font->{'path'}}) - { - push @del_files, $file; - } - } - - for (my $i = 1; $i < scalar @$buf; $i++) - { - my $line = $$buf[$i]; - my ($fname, $xname) = split ('/ /', $line); - - if (&gst_item_is_in_list ($fname, @del_files)) - { - $line = ''; - $$buf[0]--; - } - } - - &gst_file_buffer_save ($buf, $file); - - # Add: - # Bad bad hack, FIXME. - my $cmd = "type1inst -nolog -q -d " . - "$GST_FONT_DIR/type1/"; - &gst_file_run ($cmd); - - $cmd = &gst_file_locate_tool ('ttmkfdir'); - &gst_file_run ("$cmd -d $GST_FONT_DIR/truetype/ -o $GST_FONT_DIR/truetype/fonts.scale"); -} - -sub x_get_fonts -{ - my $x_font_path = &x_fontpath_get (); - return unless $x_font_path; - - # FIXME: Report. - - my %x_fonts; - foreach (@$x_font_path) - { - my $fonts = &x_fonts_dir_parse ($_); - next unless scalar keys %$fonts; - %x_fonts = (%x_fonts, %$fonts); - } - - return \%x_fonts; -} - -sub x_read_fonts -{ - my $x_font_paths = &x_get_fonts (); - return unless $x_font_paths || scalar @$x_font_paths > 1; - - return &gp_invoke (join (" ", keys (%$x_font_paths)), 0); -} - -# Maybe it should be common function: -# Scans font_list and returns list of different directories -# these fotns are in. -sub x_font_dirs -{ - my $font_list = shift; - my $dirlist = []; - my %seen = (); - - foreach my $font (@$font_list) - { - foreach my $file (@{$font->{'file'}}) - { - my $item = dirname ($file->{'path'}); - push @$dirlist, $item unless $seen{$item}++; # It's a kinda magic! No wait, it's just perl :) - } - } - - return $dirlist; -} - -sub x_add_font -{ - my $add = shift; - my $type1_tool = &gst_file_locate_tool ("$SCRIPTSDIR/type1inst"); - my $true_tool = &gst_file_locate_tool ("ttmkfdir"); - my $true_tool2 = &gst_file_locate_tool ("mkfontdir"); - my $tmp; - - my $type1 = []; - my $true = []; - - my $path = []; - - foreach (keys %$add) - { - my $font = $add->{$_}; - - if ($font->{'format'} eq 'type1') { push @$type1, $font; } - elsif ($font->{'format'} eq 'truetype') { push @$true, $font; } - - else { &gst_debug_print_line ("x_add_font: unknonw font type: $font->{format}.") } - } - - # Install type1 fonts. - $tmp = &x_font_dirs ($type1); - push @$path, @$tmp if $tmp; - foreach my $dir (@$tmp) - { - &gst_file_run ("$type1_tool -q -d $dir"); - } - - # Install TrueType fonts. - $tmp = &x_font_dirs ($true); - push @$path, @$tmp if $tmp; - foreach my $dir (@$tmp) - { - &gst_file_run ("$true_tool -d $dir -o $dir/fonts.scale"); - &gst_file_run ("$true_tool2 $dir"); - } - - &x_fontpath_add ($path); -} - -sub x_font_set -{ - my $del = shift; - my $add = shift; - - return unless ($del && $add); - return if (scalar (keys (%$del)) == 0 && - scalar (keys (%$add)) == 0); - - # FIXME: Report. - - &x_add_font ($add); - - #FIXME: $del - - &x_fonts_refresh (); -} - - -1; diff --git a/gen-reportcode-list.sh b/gen-reportcode-list.sh deleted file mode 100755 index a0cf1c9..0000000 --- a/gen-reportcode-list.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh - -echo Backends - report codes -echo ======================= - -for i in *.pl.in *-conf.in -do - name=`echo $i | cut -d - -f 1` - let j=`echo $name | wc -c` - cap=`echo $name | cut -c 1 | tr a-z A-Z` - name=$cap`echo $name | cut -c 2-64` - - echo - echo - echo $name - - while let j=$[j - 1] - do - echo -n - - done - - echo - echo - - grep gst_report_info $i | sed "s/.*gst_report_info *[(] *//" | \ - sed "s/, *\"/ /" | sed "s/\" *[)]\;.*//" | \ - ( while read line; - do - if test x = x`echo $line | cut -d ' ' -f 1 | sed s/[0-9]//g` - then - code=$[200 + `echo $line | cut -d ' ' -f 1`] - desc=`echo $line | cut -d ' ' -f 2-` - else - code="2??" - desc=$line - fi - echo $code $desc - done ) | sort - - grep gst_report_warning $i | sed "s/.*gst_report_warning *[(] *//" | \ - sed "s/, *\"/ /" | sed "s/\" *[)]\;.*//" | \ - ( while read line; - do - if test x = x`echo $line | cut -d ' ' -f 1 | sed s/[0-9]//g` - then - code=$[300 + `echo $line | cut -d ' ' -f 1`] - desc=`echo $line | cut -d ' ' -f 2-` - else - code="3??" - desc=$line - fi - echo $code $desc - done ) | sort - - grep gst_report_error $i | sed "s/.*gst_report_error *[(] *//" | \ - sed "s/, *\"/ /" | sed "s/\" *[)]\;.*//" | \ - ( while read line; - do - if test x = x`echo $line | cut -d ' ' -f 1 | sed s/[0-9]//g` - then - code=$[400 + `echo $line | cut -d ' ' -f 1`] - desc=`echo $line | cut -d ' ' -f 2-` - else - code="4??" - desc=$line - fi - echo $code $desc - done ) | sort - - grep gst_report_fatal $i | sed "s/.*gst_report_fatal *[(] *//" | \ - sed "s/, *\"/ /" | sed "s/\" *[)]\;.*//" | \ - ( while read line; - do - if test x = x`echo $line | cut -d ' ' -f 1 | sed s/[0-9]//g` - then - code=$[500 + `echo $line | cut -d ' ' -f 1`] - desc=`echo $line | cut -d ' ' -f 2-` - else - code="5??" - desc=$line - fi - echo $code $desc - done ) | sort -done diff --git a/guess_system.sh b/guess_system.sh deleted file mode 100755 index e1b5871..0000000 --- a/guess_system.sh +++ /dev/null @@ -1,1121 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 -# Free Software Foundation, Inc. -# -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Written by Per Bothner <bothner@cygnus.com>. -# The master version of this file is at the FSF in /home/gd/gnu/lib. -# Please send patches to <autoconf-patches@gnu.org>. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit system type (host/target name). -# -# Only a few systems have been added to this list; please add others -# (but try to keep the structure clean). -# - -# Use $HOST_CC if defined. $CC may point to a cross-compiler -if test x"$CC_FOR_BUILD" = x; then - if test x"$HOST_CC" != x; then - CC_FOR_BUILD="$HOST_CC" - else - if test x"$CC" != x; then - CC_FOR_BUILD="$CC" - else - CC_FOR_BUILD=cc - fi - fi -fi - - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 8/24/94.) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15 - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <<EOF >$dummy.s - .globl main - .ent main -main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-cbm-sysv4 - exit 0;; - amiga:NetBSD:*:*) - echo m68k-cbm-netbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - arm32:NetBSD:*:*) - echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - SR2?01:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - atari*:NetBSD:*:*) - echo m68k-atari-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - sun3*:NetBSD:*:*) - echo m68k-sun-netbsd${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:NetBSD:*:*) - echo m68k-apple-netbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - macppc:NetBSD:*:*) - echo powerpc-apple-netbsd${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i?86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - sed 's/^ //' << EOF >$dummy.c - #include <sys/systemcfg.h> - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:4) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` - if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=4.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - sed 's/^ //' << EOF >$dummy.c - #include <stdlib.h> - #include <unistd.h> - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - rm -f $dummy.c $dummy - esac - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - sed 's/^ //' << EOF >$dummy.c - #include <unistd.h> - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i?86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} - exit 0 ;; - CRAY*T3E:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F300:UNIX_System_V:*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - F301:UNIX_System_V:*:*) - echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` - exit 0 ;; - hp3[0-9][05]:NetBSD:*:*) - echo m68k-hp-netbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - i?86:BSD/386:*:* | i?86:BSD/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - if test -x /usr/bin/objformat; then - if test "elf" = "`/usr/bin/objformat`"; then - echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` - exit 0 - fi - fi - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:NetBSD:*:*) - echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - *:Linux:*:*) - - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - ld_help_string=`cd /; ld --help 2>&1` - ld_supported_emulations=`echo $ld_help_string \ - | sed -ne '/supported emulations:/!d - s/[ ][ ]*/ /g - s/.*supported emulations: *// - s/ .*// - p'` - case "$ld_supported_emulations" in - *ia64) - echo "${UNAME_MACHINE}-unknown-linux" - exit 0 - ;; - i?86linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 - ;; - i?86coff) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 - ;; - sparclinux) - echo "${UNAME_MACHINE}-unknown-linux-gnuaout" - exit 0 - ;; - armlinux) - echo "${UNAME_MACHINE}-unknown-linux-gnuaout" - exit 0 - ;; - elf32arm*) - echo "${UNAME_MACHINE}-unknown-linux-gnu" - exit 0 - ;; - armelf_linux*) - echo "${UNAME_MACHINE}-unknown-linux-gnu" - exit 0 - ;; - m68klinux) - echo "${UNAME_MACHINE}-unknown-linux-gnuaout" - exit 0 - ;; - elf32ppc) - # Determine Lib Version - cat >$dummy.c <<EOF -#include <features.h> -#if defined(__GLIBC__) -extern char __libc_version[]; -extern char __libc_release[]; -#endif -main(argc, argv) - int argc; - char *argv[]; -{ -#if defined(__GLIBC__) - printf("%s %s\n", __libc_version, __libc_release); -#else - printf("unkown\n"); -#endif - return 0; -} -EOF - LIBC="" - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy | grep 1\.99 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f $dummy.c $dummy - echo powerpc-unknown-linux-gnu${LIBC} - exit 0 - ;; - esac - - if test "${UNAME_MACHINE}" = "alpha" ; then - sed 's/^ //' <<EOF >$dummy.s - .globl main - .ent main - main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - LIBC="" - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - - objdump --private-headers $dummy | \ - grep ld.so.1 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 - elif test "${UNAME_MACHINE}" = "mips" ; then - cat >$dummy.c <<EOF -#ifdef __cplusplus - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __MIPSEB__ - printf ("%s-unknown-linux-gnu\n", argv[1]); -#endif -#ifdef __MIPSEL__ - printf ("%sel-unknown-linux-gnu\n", argv[1]); -#endif - return 0; -} -EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - else - # Either a pre-BFD a.out linker (linux-gnuoldld) - # or one that does not give us useful --help. - # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. - # If ld does not provide *any* "supported emulations:" - # that means it is gnuoldld. - echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" - test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - - case "${UNAME_MACHINE}" in - i?86) - VENDOR=pc; - ;; - *) - VENDOR=unknown; - ;; - esac - # Determine whether the default compiler is a.out or elf - cat >$dummy.c <<EOF -#include <features.h> -#ifdef __cplusplus - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); -#endif - return 0; -} -EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - fi ;; -# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions -# are messed up and put the nodename in both sysname and nodename. - i?86:DYNIX/ptx:4*:*) - echo i386-sequent-sysv4 - exit 0 ;; - i?86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i?86:*:5:7*) - # Fixed at (any) Pentium or better - UNAME_MACHINE=i586 - if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then - echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} - fi - exit 0 ;; - i?86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL - elif /bin/uname -X 2>/dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - pc:*:*:*) - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes <hewes@openmarket.com>. - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:*:6*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-qnx-qnx${UNAME_VERSION} - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -cat >$dummy.c <<EOF -#ifdef _SEQUENT_ -# include <sys/types.h> -# include <sys/utsname.h> -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include <sys/param.h> - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -#if !defined (ultrix) - printf ("vax-dec-bsd\n"); exit (0); -#else - printf ("vax-dec-ultrix\n"); exit (0); -#endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -#echo '(Unable to guess system type)' 1>&2 - -exit 1 diff --git a/hardware-conf.in b/hardware-conf.in deleted file mode 100755 index 4b4e7d7..0000000 --- a/hardware-conf.in +++ /dev/null @@ -1,880 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Hardware configurator. -# Designed to be architecture- and distribution independent. -# -# Version 0.0.1 - copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Bradford Hovinen <hovinen@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/conf.modules /etc/X11/XF86Config /etc/isapnp.conf /dev/* - -# Running programs affected/used: -# -# /sbin/modprobe /sbin/rmmod /sbin/depmod /bin/uname /sbin/mknod -# /bin/&setserial - -# Other files used for information: -# -# /proc/devices /proc/cpuinfo /proc/ioports /proc/interrupts /proc/dma -# /proc/modules /proc/bus/pci/* /proc/ide/* /proc/scsi/* - - -# Note: -# -# This backend program is just the tip of the iceberg -- there are -# many, many more parts to this under the hood. We're probably going -# to have to institute a system whereby there exist multiple -# configuration scriptlets in a particular directory, one for each -# class of hardware (e.g., IDE devices, video cards, serial ports), -# so that the user can install configuration scripts for new -# hardware types easily. - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "hardware"; -$version = "@VERSION@"; - -$description =<<"end_of_description;"; - Configures hardware. -end_of_description; - - -# --- System config file locations --- # - -# We list each config file type with as many alternate locations as possible. -# They are tried in array order. First found = used. - -@conf_modules_names = ( "/etc/conf.modules", "/etc/modules.conf" ); -@XF86Config_names = ( "/etc/X11/XF86Config" ); - -# --- Internal configuration variables --- # - -# Configuration is parsed/read to, and printed/written from, these -# temporary variables. - -# Hash of hardware devices, keyed by kernel identifier -# Each entry is a hash with the following data: -# -# id - kernel-level identifier (e.g. ide0, psaux, eth0, etc.) -# type - type of device: `Serial Port', `Video Adaptor', etc. -# vendor - self-explanatory -# model - ditto -# driver - kernel module or XFree86 driver, if any -# bus - connection - ISA, PCI, IDE, SCSI, USB, etc. -# {id,target,etc} - identifying characteristics on connection -# io - I/O port(s) used (array, if any) -# irq - IRQ(s) used (array, if any) -# dma - DMA channel(s) used (array, if any) -# ...and any other defining characteristics, according to the type -# of device - -%cf_hardware = (); - -# Hash of modules listed in /etc/conf.modules, indexed by module name -# (or alias). Each entry contains the following data: -# -# module - module name -# options - hash of module options as parsed from the options line - -%cf_modules = (); - -# Hash of items from /etc/isapnp.conf, indexed by something or other - -%cf_isapnp = (); - -# Array of devices referred to in XF86Config. Each entry is a hash -# that has the device type, the driver, the XF86Config options and the -# XF86Config identifier - -%cf_xf86config = (); - -# Array of I/O port allocations. Each entry is a hash with the keys -# low, high, and device. - -@cf_ioports = (); - -# Hash of IRQ allocations. Maps IRQ numbers to arrays of devices - -%cf_irq = (); - -# Hash of DMA allocations. Maps DMA channel numbers to devices - -%cf_dma = (); - -# Array of serial ports. Entries are just UARTs - -@cf_serial = (); - -# Array of parallel ports. Entries are hashes containing the IRQ, DMA, -# and modes - -@cf_parallel = (); - -# Array of IDE controllers. Entries are just empty arrays for now - -@cf_ide = (); - -# Array of SCSI controllers. Entries are just empty arrays for now - -@cf_scsi = (); - -# Array of NICs. Entries are hashes with the id and the MAC address - -@cf_nic = (); - - -# --- XML parsing --- # - - -# Scan XML from standard input to an internal tree. - -sub xml_parse - { - # Scan XML to tree. - - $tree = &gst_xml_scan; - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "networking" tag. - - while (@$tree) - { - if ($$tree[0] eq "memory") { &xml_parse_memory($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - return($tree); - } - - -# <memory>...</memory> - -sub xml_parse_memory - { - my $tree = $_[0]; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "swapdev") - { - push @cf_swapinfo, &xml_parse_swapinfo ($$tree[1]); - } - - shift @$tree; - shift @$tree; - } - } - - -# <swap-device>...</swap-device> - -sub xml_parse_swapinfo - { - my $tree = $_[0]; - my $node; - my $entry = {}; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq 'device') - { - $entry->{device} = &gst_xml_get_word ($$tree[1]); - } - elsif ($$tree[0] eq 'enabled') - { - $node = $$tree[1]; - $entry->{enabled} = &gst_util_read_boolean ($$node[0]->{state}); - } - elsif ($$tree[0] eq 'priority') - { - $entry->{priority} = &gst_xml_get_word ($$tree[1]); - } - elsif ($$tree[0] eq 'size') - { - $entry->{size} = &gst_xml_get_word ($$tree[1]); - } - elsif ($$tree[0] eq 'isfile') - { - $node = $$tree[1]; - $entry->{is_file} = &gst_util_read_boolean ($$node[0]->{state}); - } - elsif ($$tree[0] eq 'isnew') - { - $node = $$tree[1]; - $entry->{is_new} = &gst_util_read_boolean ($$node[0]->{state}); - } - - shift @$tree; - shift @$tree; - } - - return $entry; - } - - -# --- XML printing --- # - - -sub xml_print - { - print "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n"; - print "<!DOCTYPE memory []>\n\n"; - print "<hardware>\n"; - &gst_xml_enter (); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<!-- Configuration starts here -->\n"); - &gst_xml_print_vspace (); - - foreach $entry (@cf_hardware) - { - &gst_xml_print_line ("<device id='$entry->{id}'>\n"); - - LOOP: while (($key, $value) = each %$entry) - { - next if $key eq 'id'; - next if $key eq 'io'; - - SWITCH: - { - $_ = $key; - /^ports/ && do - { - &gst_xml_enter; - foreach $range (@$value) - { - &gst_xml_print_line ("<io low='$range->{low}' high='$range->{high}'/>\n"); - } - last SWITCH; - }; - /^interrupts/ && do - { - foreach $number (@$value) - { - &gst_xml_print_line ("<interrupt number='$number'/>\n"); - } - last SWITCH; - }; - /^dma/ && do - { - foreach $channel (@$value) - { - &gst_xml_print_line ("<dma channel='$channel'/>\n"); - } - last SWITCH; - }; - /^modes/ && do - { - foreach $mode (@$value) - { - &gst_xml_print_line ("<mode>$mode</mode>\n"); - } - last SWITCH; - }; - (/^id/ || /^io/ || /^irq/) && next LOOP; - - &gst_xml_print_line ("<$key>$value</$key>\n"); - &gst_xml_leave; - } - } - - &gst_xml_print_line ("</device>\n"); - &gst_xml_print_vspace (); - } - - &gst_xml_print_line ("<!-- End of configuration -->\n"); - &gst_xml_print_vspace (); - - &gst_xml_leave (); - print "</hardware>\n"; - } - - -# --- Get (read) config --- # - -############################################################################### -# Reading and parsing configuration files, running programs to &get -# configuration info, etc. -############################################################################### - -# This is going to choke when one tries to run it on a conf.modules -# with conditionals. Hopefully no one will try to do that until I -# implement that feature. - -sub read_conf_modules - { - local (*CONF_MODULES_FILE); - my (%real_names); - - *CONF_MODULES_FILE = &gst_file_open_read_from_names (@conf_modules_names); - - LINE: while (<CONF_MODULES_FILE>) - { - /^alias\s+([^\s]+)\s+([^\s]+)\n$/ && do - { - next LINE if $cf_modules{$1}; # Already exists???? - $cf_modules{$1} = - { 'module' => $2, 'options' => $cf_modules{$2}->{options} }; - $real_names{$2} = $1; - delete $cf_modules{$2}; - next LINE; - }; - /^options\s+([^\s]+)\s+(.*)\n$/ && do - { - $module_name = $1; - $module_name = $real_names{$1} if defined $real_names{$1}; - $cf_modules{$module_name}->{options} = { split /\s+|=/, $2 }; - next LINE; - }; - } - - close CONF_MODULES_FILE; - } - -sub read_isapnp_conf - { - } - -# Section handlers - -sub handle_input_device - { - my ($entry); - - $entry->{type} = 'input-device'; - - while (<XF86CONFIG_FILE>) - { - s/\s*#.*\n$//g; # Strip out comments - next if not length; - last if /EndSection/; - - /Identifier\s+\"([^\"]+)\"/ && do { $entry->{name} = $1; }; - /Driver\s+\"([^\"]+)\"/ && do { $entry->{driver} = $1; }; - /Option\s+\"([^\"]+)\"\s+\"([^\"])\"/ && do - { $entry->{$1} = [ split /\s+/, $2 ]; }; - } - - return $entry; - } - -sub read_XF86Config - { - local (*XF86CONFIG_FILE); - my ($entry); - - my (%section_handler_table) = - ( 'InputDevice' => \&handle_input_device ); - - *XF86CONFIG_FILE = &gst_file_open_read_from_names (@XF86Config_names); - - while (<XF86CONFIG_FILE>) - { - s/\s*#.*\n$//g; # Strip out comments - next if not length; - - if (/Section\s+\"([^\"]+)\"/) - { - push @cf_xf86config, &{$section_handler_table{$1}} - if exists $section_handler_table{$1}; - } - } - - close XF86CONFIG_FILE; - } - -# Read I/O port allocation - -sub read_proc_ioports - { - local (*IOPORTS_FILE); - my ($entry); - - open IOPORTS_FILE, "/proc/ioports"; - - while (<IOPORTS_FILE>) - { - $entry = {}; - ($low, $high, $entry->{device}) = - /\A([0-9a-f]{4})-([0-9a-f]{4}) : (.+)\n/; - - $entry->{low} = hex $low; - $entry->{high} = hex $high; - - push @cf_ioports, $entry; - } - - close IOPORTS_FILE; - } - -# Read IRQ allocation - -sub read_proc_interrupts - { - local (*IRQ_FILE); - my ($irq, $device); - - open IRQ_FILE, "/proc/interrupts"; - - while (<IRQ_FILE>) - { - ($irq, $device) = - /^\s+(\d+):\s+\d+\s+[a-zA-Z\-]+\s+(.+)\n/; - $cf_irq{$irq} = [split /, /, $device] - if defined $irq; - } - - close IRQ_FILE; - } - -# Read DMA allocation - -sub read_proc_dma - { - local (*DMA_FILE); - my ($channel, $device); - - open DMA_FILE, "/proc/interrupts"; - - while (<DMA_FILE>) - { - ($channel, $device) = - /\A\s+(\d+):\s+(.+)\Z/; - $cf_dma{$channel} = [split /, /, $device]; - } - - close DMA_FILE; - } - -# Read PCI bus device information - -sub read_proc_pci - { - } - -# Read IDE information - -sub read_proc_ide - { - local (*CONTROLLER_DIR); - - opendir CONTROLLER_DIR, "/proc/ide"; - - if (*CONTROLLER_DIR) - { - foreach $i (readdir (CONTROLLER_DIR)) - { - next if not $i =~ /ide(\d+)/; - $cf_ide[$1] = { 'id' => "ide$1" }; - } - } - - closedir (CONTROLLER_DIR); - } - -# Read SCSI information - -sub read_proc_scsi - { - } - -# Read parallel port information - -sub read_proc_parport - { - my ($entry, $line); - local (*PARPORT_DIR); - - opendir PARPORT_DIR, "/proc/parport"; - return if !PARPORT_DIR; - - foreach $i (readdir (PARPORT_DIR)) - { - next if not $i =~ /\d+/; - $entry = {'id' => "parport$i"}; - - open PARPORT_FILE, "/proc/parport/$i/hardware"; - - LINE: while (<PARPORT_FILE>) - { - /^base:[\s]+(0x[0-9a-f]+)/ && do { $entry->{io} = [$1]; next LINE; }; - /^irq:[\s]+(none|[0-9]+)/ && do { $entry->{irq} = [$1] if $1 ne 'none'; next LINE; }; - /^dma:[\s]+(none|[0-9]+)/ && do { $entry->{dma} = [$1] if $1 ne 'none'; next LINE; }; - /^modes:[\s]+([\d\w,]+)/ && do { $entry->{modes} = [split /,/, $1]; next LINE; }; - } - - push @cf_parallel, $entry; - - close PARPORT_FILE; - } - - closedir PARPORT_DIR; - } - -# Find all serial ports by running &setserial -g on /dev/ttyS* - -sub get_serial_ports - { - my ($entry, $line); - - foreach $i ('/dev/ttyS0', '/dev/ttyS1', '/dev/ttyS2', '/dev/ttyS3') - { - $line = `&setserial -g $i`; - $entry = {}; - ($entry->{id}, $entry->{uart}, $port, $irq) = - ($line =~ /\/dev\/(ttyS[0-9]+), UART: ([0-9A-Za-z]+), Port: (0x[0-9a-f]+), IRQ: ([0-9]+)/); - next if $entry->{uart} eq 'unknown'; - - $entry->{type} = 'Serial Port'; - $entry->{io} = [hex $port]; - $entry->{irq} = [$irq]; - push @cf_serial, $entry; - } - } - -# Find all network interfaces by running /sbin/ifconfig - -sub get_network_interfaces -{ - my ($fd); - - $fd = &gst_file_run_pipe_read ("ifconfig -a"); - - while (<$fd>) - { - if (/^([\w\d]+)/) - { - next if $1 eq 'lo'; - $entry = { 'id' => $1 }; - /HWaddr (([A-F\d]{2}:){5}[A-F\d]{2})/ && do { $entry->{macaddr} = $1; }; - /Link encap:(\w+|(\w+\s)+\w+)/ && do { $entry->{type} = $1; }; - push @cf_nic, $entry; - } - } - - &gst_file_close ($fd); -} - -# Find the record in the io ports list that contains a given I/O -# port. Check to make sure it actually matches the given device. - -sub find_port_record - { - my ($port, $device) = @_; - - foreach $entry (@cf_ioports) - { - if ($port >= $entry->{low} and $port <= $entry->{high}) - { - $entry->{error} = 1 if $device && $device ne $entry->{device}; - return $entry; - } - } - - return undef; - } - -# Combine all the hardware configuration into one `master list', -# finding any descrepencies and reporting them - -sub combine - { - my (%hardware); - my ($index); - my (@words) = ('Primary', 'Secondary', 'Tertiary', 'Quaternary'); - - $index = 0; - - foreach $entry (@cf_serial) - { - next if not $entry->{id}; - - $hardware{$entry->{id}} = - { - 'type' => "Serial port", - 'id' => $entry->{id}, - 'ports' => [ &find_port_record ($entry->{io}->[0], $entry->{id}) ], - 'interrupts' => $entry->{irq}, - 'name' => "$words[$index] serial port" - }; - - $index++; - } - - $index = 0; - - foreach $entry (@cf_parallel) - { - next if not $entry->{id}; - - $hardware{$entry->{id}} = - { - 'type' => "Parallel port", - 'id' => $entry->{id}, - 'ports' => [ &find_port_record ($entry->{io}->[0], $entry->{id}) ], - 'interrupts' => $entry->{irq}, - 'name' => "$words[$index] parallel port" - }; - - $index++; - } - - $index = 0; - - foreach $controller (@cf_ide) - { - next if not $controller->{id}; - - $entry = - { - 'type' => "Disk controller", - 'id' => $controller->{id}, - 'ports' => [], - 'interrupts' => [], - 'name' => "$words[$index] IDE disk controller" - }; - - $hardware{$entry->{id}} = $entry; - $index++; - } - - $index = 0; - - foreach $nic (@cf_nic) - { - next if not $nic->{id}; - - $entry = - { - 'type' => "Network interface card", - 'id' => $nic->{id}, - 'subtype' => $nic->{type}, - 'macaddr' => $nic->{macaddr}, - 'ports' => [], - 'interrupts' => [], - 'dma' => [], - 'name' => "$words[$index] network interface card", - }; - - $hardware{$entry->{id}} = $entry; - $index++; - } - - $index_kbd = 0; - $index_mouse = 0; - - foreach $device (@cf_xf86config) - { - if ($device->{driver} eq 'keyboard') - { - $entry = - { - 'type' => "Keyboard", - 'id' => "XFree86:$device->{name}", - 'driver' => $device->{driver}, - 'name' => "$words[$index_kbd] keyboard" - } - } - elsif ($device->{driver} eq 'mouse') - { - next; - } - - $hardware{$entry->{id}} = $entry; - $index_kbd++; - $index_mouse++; - } - - foreach $entry (@cf_ioports) - { - &gst_push_unique ($hardware{$entry->{device}}->{ports}, $entry) - if exists $hardware{$entry->{device}}; - } - - while (($irq, $devices) = each %cf_irq) - { - foreach $device (@$devices) - { - &gst_push_unique ($hardware{$device}->{interrupts}, $irq) - if exists $hardware{$device}; - } - } - - while (($channel, $devices) = each %cf_dma) - { - foreach $device (@$devices) - { - &gst_push_unique ($hardware{$device}->{dma}, $channel) - if exists $hardware{$device}; - } - } - - @cf_hardware = values %hardware; - } - -sub get - { - if ($gst_verbose) - { - print STDERR "Getting system configuration, generating XML output.\n"; - } - - if ($gst_verbose) { print STDERR "Getting swap entries.\n"; } - - # For each basic type of device, read all the information about it - # from all the different sources. FIXME: Perhaps we should read in - # some commonly-used files, like conf.modules and /proc/* first. - - # We're going to replace this with a more extensible, modular - # system soon, but for now, we'll just hardcode everything. - - &read_conf_modules; - &read_isapnp_conf; - &read_XF86Config; - &read_proc_ioports; - &read_proc_interrupts; - &read_proc_dma; - &read_proc_pci; - &read_proc_ide; - &read_proc_scsi; - &read_proc_parport; - &get_serial_ports; - &get_network_interfaces; - - &combine; - - if ($gst_verbose) { print STDERR "Printing XML.\n"; } - &xml_print (); - } - - -# --- Set (write) config --- # - - - -sub set - { - if ($gst_verbose) - { - print STDERR "Setting system configuration from XML input.\n"; - } - - if ($gst_verbose) { print STDERR "Parsing XML.\n"; } - &xml_parse (); - - if ($gst_do_immediate) - { - if ($gst_verbose) - { - print STDERR - "Changing running configuration via local utilities.\n"; - } -# Set configuration here - } - } - - -# --- Filter config: XML in, XML out --- # - - -sub filter - { - &xml_parse (); - &xml_print (); - } - - -# --- Main --- # - -# Process options. - -while (@ARGV) - { - if ($ARGV[0] eq "--get" || $ARGV[0] eq "-g") { &gst_set_operation("get"); } - elsif ($ARGV[0] eq "--set" || $ARGV[0] eq "-s") { &gst_set_operation("set"); } - elsif ($ARGV[0] eq "--filter" || $ARGV[0] eq "-f") { &gst_set_operation("filter"); } - elsif ($ARGV[0] eq "--help" || $ARGV[0] eq "-h") { print STDERR $Usage; exit(0); } - elsif ($ARGV[0] eq "--prefix" || $ARGV[0] eq "-p") - { - if ($gst_prefix ne "") - { - print STDERR "Error: You may specify --prefix only once.\n\n"; - print STDERR $Usage; exit(1); - } - - $gst_prefix = $ARGV[1]; - - if ($gst_prefix eq "") - { - print STDERR "Error: You must specify an argument to the --prefix option.\n\n"; - print STDERR $Usage; exit(1); - } - - shift @ARGV; # For the argument. - } - elsif ($ARGV[0] eq "--disable-immediate") { $gst_do_immediate = 0; } - elsif ($ARGV[0] eq "--verbose" || $ARGV[0] eq "-v") { $gst_verbose = 1; } - else - { - print STDERR "Error: Unrecognized option '$ARGV[0]'.\n\n"; - print STDERR $Usage; exit(1); - } - - shift @ARGV; - } - - -# Do our thing. - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/internetsharing-conf.in b/internetsharing-conf.in deleted file mode 100755 index 6b9a770..0000000 --- a/internetsharing-conf.in +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Time configurator. Designed to be architecture- and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Chema Celorio <chema@ximian.com> -# Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/ishare.pl$DOTIN"; - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "internetsharing"; -$version = "@VERSION@"; -@platforms = ("redhat-7.0", "redhat-7.1", "redhat-7.2", - - "mandrake-7.2", - - "debian-2.2", "debian-woody"); - -$description =<<"end_of_description;"; - Sets up firewall rules for a basic internet sharing (masq) - network. -end_of_description; - - -# --- XML parsing --- # - -# Scan XML from standard input to an internal tree. - -sub xml_parse -{ - my ($tree, %hash, $elem); - - # Scan XML to tree. - - $tree = &gst_xml_scan (); - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "networking" tag. - - while ($elem = shift @$tree) - { - if ($elem eq "internetsharing") { &xml_parse_internetsharing (shift @$tree, \%hash); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return (\%hash); -} - - -sub xml_parse_internetsharing -{ - my ($tree, $hash) = @_; - my ($elem, %interface); - - shift @$tree; # Skip attributes. - - while ($elem = shift @$tree) - { - if ($elem eq "fwrules") { $$hash{"fwrules"} = &xml_parse_fwrules (shift @$tree); } - elsif ($elem eq "dhcp") { $$hash{"dhcp"} = &xml_parse_dhcp (shift @$tree); } - elsif ($elem eq "interface") { &gst_network_xml_parse_interface (shift @$tree, \%interface); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"interface"} = \%interface unless scalar keys %interface == 0; -} - - -sub xml_parse_fwrules -{ - my ($tree) = @_; - my ($elem, $hash, $landevs); - - $hash = {}; - $landevs = []; - shift @$tree; # Skip attributes. - - while ($elem = shift @$tree) - { - if ($elem eq "tools") { $$hash{"tools"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "kerneltool") { $$hash{"kerneltool"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "configured") { $$hash{"configured"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "forwarding") { $$hash{"forwarding"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "masquerading") { $$hash{"masquerading"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "overwrite") { $$hash{"overwrite"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "active") { $$hash{"active"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "landev") { push @$landevs, &gst_xml_get_pcdata (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"landev"} = $landevs; - - return $hash; -} - - -sub xml_parse_dhcp -{ - my ($tree) = @_; - my ($elem, $hash, $devs); - - $hash = {}; - $devs = []; - shift @$tree; # Skip attributes. - - while ($elem = shift @$tree) - { - if ($elem eq "installed") { $$hash{"installed"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "configured") { $$hash{"configured"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "overwrite") { $$hash{"overwrite"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "active") { $$hash{"active"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "dev") { push @$devs, &gst_xml_get_pcdata (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"dev"} = $devs; - - return $hash; -} - - -# --- XML printing --- # - - -sub xml_print -{ - my ($h) = @_; - - &gst_xml_print_begin (); - &gst_xml_print_hash ($$h{"fwrules"}, "fwrules"); - &gst_xml_print_hash ($$h{"dhcp"}, "dhcp"); - &gst_xml_print_hash_hash ($$h{"interface"}, "interface"); - &gst_xml_print_end (); -} - -# Main operations - -sub get -{ - my $hash; - - $hash = &gst_ishare_conf_get (); - - &gst_report_end (); - &xml_print ($hash); -} - - -sub get_interfaces -{ - my $hash; - - $hash = &gst_network_interfaces_get (); - - &gst_report_end (); - &gst_xml_print_begin (); - &gst_xml_print_hash_hash ($hash, "interface"); - &gst_xml_print_end (); -} - - -sub set -{ - my $hash; - - $hash = &xml_parse (); - &gst_ishare_conf_set ($hash); - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - my $hash; - - $hash = &xml_parse (); - &gst_report_end (); - &xml_print ($hash); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "get_interfaces" => [ \&get_interfaces, [], "Get the interface tags only." ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); - diff --git a/ishare.pl.in b/ishare.pl.in deleted file mode 100644 index 353f6e0..0000000 --- a/ishare.pl.in +++ /dev/null @@ -1,526 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Functions for internet sharing setup. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/service.pl$DOTIN"; -require "$SCRIPTSDIR/network.pl$DOTIN"; - - -sub gst_ishare_ipchains_configured -{ - my ($tools, $kerneltool) = @_; - my ($ret, $fd, $val); - - if ($tools && $kerneltool) - { - $fd = &gst_file_run_pipe_read ("ipchains-save"); - if ($fd ne undef) - { - $ret = 0; - while ($val = <$fd>) - { - if ($val =~ /^-A forward.*MASQ$/) - { - $ret = 1; - last; - } - } - - &gst_file_close ($fd); - } - } - - return $ret; -} - - -sub gst_ishare_fwrules_get_ipchains -{ - &gst_ishare_get_linux22_forward_support (\%hash); - &gst_ishare_get_linux22_forward_support_active (\%hash); - - return \%hash; -} - - -sub gst_ishare_ipchains_save -{ - my ($ipchains_conf, $interface, $landevs, $overwrite) = @_; - my ($fd, $dev, $landev, $network, $netmask); - my (@buff, $line); - - return 0 if !$overwrite; - - $fd = &gst_file_run_pipe_read ("ipchains-save"); - @buff = (<$fd>); - &gst_file_close ($fd); - - foreach $line (@buff) - { - $line = "" if $line =~ /^-A forward.*MASQ$/; - } - - foreach $landev (@$landevs) - { - $dev = $$interface{$landev}; - $netmask = $$dev{"netmask"}; - $network = &gst_network_ipv4_calc_subnet ($$dev{"address"}, $netmask); - push @buff, "-A forward -s $network/$netmask -d 0.0.0.0/0.0.0.0 -j MASQ\n"; - } - - &gst_file_buffer_clean (\@buff); - return &gst_file_buffer_save (\@buff, $ipchains_conf); -} - - -sub gst_ishare_dhcp_set_devs -{ - my ($linux_conf, $overwrite, $dev) = @_; - - if ($overwrite) { - return &gst_replace_join_first_array - ($linux_conf, "DHCP.interface", " ", " ", $dev); - } - - return 0; -} - - -sub gst_ishare_dhcp_conf_add_interface -{ - my ($buff, $address, $netmask, $hwaddr) = @_; - my ($network, $broadcast, $min, $max, $hostname); - - $hostname = &gst_file_run_backtick ("hostname"); - chomp $hostname; - $hostname = "server" if $hostname eq ""; - - $min = $network = &gst_network_ipv4_calc_subnet ($address, $netmask); - $max = $broadcast = &gst_network_ipv4_calc_bcast ($address, $netmask); - - $max =~ s/([0-9]+)$//; - $max .= $1 - 1; - - $min =~ s/([0-9]+)$//; - $min .= $1 + 1; - - push @$buff, "subnet $network netmask $netmask {\n\n"; - push @$buff, "\toption routers $address;\n"; - push @$buff, "\toption subnet-mask $netmask;\n\n"; - push @$buff, "\trange dynamic-bootp $min $max;\n\n"; - push @$buff, "\tdefault-lease-time 21600;\n"; - push @$buff, "\tmax-lease-time 43200;\n\n"; - push @$buff, "\thost $hostname {\n"; - push @$buff, "\t\thardware ethernet $hwaddr;\n"; - push @$buff, "\t\tfixed-address $address;\n"; - push @$buff, "\t}\n"; - push @$buff, "}\n\n"; -} - - -sub gst_ishare_dhcp_set_conf -{ - my ($dhcpd_conf, $overwrite, $interface, $devs) = @_; - my ($dev, $iface); - my (@buff, $info); - - return 0 if !$overwrite; - - $info = &gst_network_interfaces_get_info (); - - foreach $dev (@$devs) - { - $iface = $$interface{$dev}; - - &gst_ishare_dhcp_conf_add_interface (\@buff, $$iface{"address"}, $$iface{"netmask"}, - $ {$$info{$$iface{"dev"}}}{"hwaddr"}); - } - - &gst_file_buffer_clean (\@buff); - &gst_file_buffer_save (\@buff, $dhcpd_conf); -} - - -sub gst_ishare_conf_get -{ - my %dist_attrib; - my $hash; - - %dist_attrib = &gst_ishare_conf_get_parse_table (); - - $hash = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - return $hash; -} - - -sub gst_ishare_fwrules_get -{ - my %dist_attrib; - my $hash; - - %dist_attrib = &gst_ishare_fwrules_get_parse_table (); - - $hash = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - return $hash; -} - - -sub gst_ishare_dhcp_get -{ - my %dist_attrib; - my $hash; - - %dist_attrib = &gst_ishare_dhcp_get_parse_table (); - - $hash = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - return $hash; -} - - -sub gst_ishare_conf_set -{ - my ($values_hash) = @_; - my (%dist_attrib, $old_hash); - - %dist_attrib = &gst_ishare_conf_get_replace_table (); - - $old_hash = &gst_network_conf_get (); - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash, $old_hash); - - return $res; -} - - -sub gst_ishare_fwrules_set -{ - my ($interface, $values_hash) = @_; - my (%dist_attrib, $old_hash); - - %dist_attrib = &gst_ishare_fwrules_get_replace_table (); - - $$values_hash{"interface"} = $interface; - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash, $old_hash); - delete $$values_hash{"interface"}; - - return $res; -} - - -sub gst_ishare_dhcp_set -{ - my ($interface, $values_hash) = @_; - my (%dist_attrib, $old_hash); - - %dist_attrib = &gst_ishare_dhcp_get_replace_table (); - - $$values_hash{"interface"} = $interface; - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash, $old_hash); - delete $$values_hash{"interface"}; - - return $res; -} - - -sub gst_ishare_conf_get_parse_table -{ - my %dist_map = - ( - "redhat-7.0" => "mandrake-7.2", - "redhat-7.1" => "mandrake-7.2", - "redhat-7.2" => "mandrake-7.2", - "mandrake-7.2" => "mandrake-7.2", - "debian-2.2" => "mandrake-7.2", - "debian-woody" => "mandrake-7.2" - ); - - my %dist_tables = - ( - "mandrake-7.2" => - { - fn => {}, - table => - [ - [ "interface", \&gst_network_interfaces_get ], - [ "fwrules", \&gst_ishare_fwrules_get ], - [ "dhcp", \&gst_ishare_dhcp_get ], - ] - } - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_ishare_fwrules_get_parse_table -{ - my %dist_map = - ( - "redhat-7.0" => "mandrake-7.2", - "redhat-7.1" => "mandrake-7.2", - "redhat-7.2" => "mandrake-7.2", - "mandrake-7.2" => "mandrake-7.2", - "debian-2.2" => "mandrake-7.2", - "debian-woody" => "mandrake-7.2" - ); - - my %dist_tables = - ( - "mandrake-7.2" => - { - fn => - { - PROC_IPCHAINS => "/proc/net/ip_fwchains", - PROC_FORWARD => "/proc/sys/net/ipv4/ip_forward", - PROC_MASQ => "/proc/net/ip_masquerade" - }, - table => - [ - [ "tools", \&gst_file_tool_installed, "ipchains" ], - [ "kerneltool", \&gst_file_exists, PROC_IPCHAINS ], - [ "configured", \&gst_ishare_ipchains_configured, "%tools%", "%kerneltool%" ], - [ "forwarding", \&gst_file_exists, PROC_FORWARD ], - [ "masquerading", \&gst_file_exists, PROC_MASQ ], - [ "active", \&gst_parse_kw, PROC_FORWARD, "1" ] - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_ishare_dhcp_get_parse_table -{ - my %dist_map = - ( - "redhat-7.0" => "mandrake-7.2", - "redhat-7.1" => "mandrake-7.2", - "redhat-7.2" => "mandrake-7.2", - "mandrake-7.2" => "mandrake-7.2", - "debian-2.2" => "debian-2.2", - "debian-woody" => "debian-2.2" - ); - - my %dist_tables = - ( - "mandrake-7.2" => - { - fn => - { - DHCPD_CONF => "/etc/dhcpd.conf", - DHCPD_SERVICE => "dhcpd", - LINUX_CONF => "/etc/conf.linuxconf" - }, - table => - [ - [ "installed", \&gst_service_sysv_installed, DHCPD_SERVICE ], - [ "configured", \&gst_file_exists, DHCPD_CONF ], - [ "active", \&gst_service_sysv_get_status, DHCPD_SERVICE ], - [ "dev", \&gst_parse_split_first_array, LINUX_CONF, "DHCP.interface", - "[ \t]+", "[ \t]+" ], - ] - }, - "debian-2.2" => - { - fn => - { - DHCPD_CONF => "/etc/dhcpd.conf", - DHCPD_SERVICE => "dhcp", - }, - table => - [ - [ "installed", \&gst_service_sysv_installed, DHCPD_SERVICE ], - [ "configured", \&gst_file_exists, DHCPD_CONF ], - [ "active", \&gst_service_sysv_get_status, DHCPD_SERVICE ], - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_ishare_conf_get_replace_table -{ - my %dist_map = - ( - "redhat-7.0" => "mandrake-7.2", - "redhat-7.1" => "mandrake-7.2", - "redhat-7.2" => "mandrake-7.2", - "mandrake-7.2" => "mandrake-7.2", - "debian-2.2" => "mandrake-7.2", - "debian-woody" => "mandrake-7.2" - ); - - my %dist_tables = - ( - "mandrake-7.2" => - { - fn => {}, - table => - [ - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "fwrules", \&gst_ishare_fwrules_set, "%interface%" ], - [ "dhcp", \&gst_ishare_dhcp_set, "%interface%" ] - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_ishare_fwrules_get_replace_table -{ - my %dist_map = - ( - "redhat-7.0" => "mandrake-7.2", - "redhat-7.1" => "mandrake-7.2", - "redhat-7.2" => "mandrake-7.2", - "mandrake-7.2" => "mandrake-7.2", - "debian-2.2" => "debian-2.2", - "debian-woody" => "debian-2.2" - ); - - my %dist_tables = - ( - "mandrake-7.2" => - { - fn => - { - IPCHAINS_CONF => "/etc/sysconfig/ipchains", - IPCHAINS_SERVICE => "ipchains", - PROC_FORWARD => "/proc/sys/net/ipv4/ip_forward", - SYSCONFIG_NETWORK => "/etc/sysconfig/network" - }, - table => - [ - [ "active", \&gst_replace_line_first, PROC_FORWARD ], - [ "active", \&gst_replace_sh_bool, SYSCONFIG_NETWORK, "FORWARD_IPV4" ], - [ "overwrite", \&gst_ishare_ipchains_save, IPCHAINS_CONF, "%interface%", "%landev%" ], - [ "active", \&gst_service_sysv_force_status, [8, IPCHAINS_SERVICE] ], - ] - }, - "debian-2.2" => - { - fn => - { - IPCHAINS_CONF => "/etc/network/ipchains", - IPCHAINS_SERVICE => "setup-tools-ipchains", - PROC_FORWARD => "/proc/sys/net/ipv4/ip_forward", - NETWORK_OPTIONS => "/etc/network/options" - }, - table => - [ - [ "active", \&gst_replace_sh_bool, NETWORK_OPTIONS, "ip_forward" ], - [ "active", \&gst_replace_line_first, PROC_FORWARD ], - [ "active", \&gst_service_sysv_install_script, IPCHAINS_SERVICE, "debian_ipchains" ], - [ "overwrite", \&gst_ishare_ipchains_save, IPCHAINS_CONF, "%interface%", "%landev%" ], - [ "active", \&gst_service_sysv_force_status, [5, IPCHAINS_SERVICE] ], - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_ishare_dhcp_get_replace_table -{ - my %dist_map = - ( - "redhat-7.0" => "mandrake-7.2", - "redhat-7.1" => "mandrake-7.2", - "redhat-7.2" => "mandrake-7.2", - "mandrake-7.2" => "mandrake-7.2", - "debian-2.2" => "debian-2.2", - "debian-woody" => "debian-2.2" - ); - - my %dist_tables = - ( - "mandrake-7.2" => - { - fn => - { - DHCPD_CONF => "/etc/dhcpd.conf", - DHCPD_SERVICE => "dhcpd", - LINUX_CONF => "/etc/conf.linuxconf" - }, - table => - [ - [ "dev", \&gst_ishare_dhcp_set_devs, LINUX_CONF, "%overwrite%" ], - [ "dev", \&gst_ishare_dhcp_set_conf, DHCPD_CONF, "%overwrite%", "%interface%" ], - [ "active", \&gst_service_sysv_set_status, [65, DHCPD_SERVICE] ] - ] - }, - "debian-2.2" => - { - fn => - { - DHCPD_CONF => "/etc/dhcpd.conf", - DHCPD_SERVICE => "dhcp", - }, - table => - [ - [ "dev", \&gst_ishare_dhcp_set_conf, DHCPD_CONF, "%overwrite%", "%interface%" ], - [ "active", \&gst_replace_sh_bool, "/etc/init.d/dhcpd", "run_dhcpd", "1", "0" ], - [ "active", \&gst_service_sysv_set_status, [20, DHCPD_SERVICE] ] - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} diff --git a/m4macros/.cvsignore b/m4macros/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/m4macros/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/media.pl.in b/media.pl.in deleted file mode 100644 index 50ee528..0000000 --- a/media.pl.in +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Detect, list and manipulate local media devices. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; - - -# gst_media_get_ide_device_from_proc -# -# Read IDE device specs for a single device from constructed /proc subdir and -# a couple of other places. - -sub gst_media_get_ide_device_from_proc -{ - my ($path) = "/proc/ide/$_[0]/$_[1]"; - my (%device); - - %device->{"device"} = $_[1]; - %device->{"type"} = "ide"; - %device->{"media"} = &gst_parse_line_first ("$path/media"); - %device->{"model"} = &gst_parse_line_first ("$path/model"); - %device->{"cache"} = &gst_parse_line_first ("$path/cache"); - %device->{"capacity"} = &gst_parse_line_first ("$path/capacity"); - %device->{"driver"} = (split ' ', &gst_parse_line_first ("$path/driver")) [0]; - - # TODO: We need a detailed list of media types that can occur, and what - # special handling they need. Currently recognized are: disk, cdrom. - # - # Currently, everything that's not a disk is removable. - - if (%device->{"media"} eq "disk") - { - %device->{"is_removable"} = 0; - - # Disk devices can't be mounted and don't have file systems. Their - # partitions can and do, however. - - # TODO: Partition information gathered in a sub-hash. - } - else # (%device->{"media"} eq "cdrom") - { - %device->{"is_removable"} = 1; - - %device->{"point_listed"} = &gst_parse_split_first_str ("/etc/fstab", "/dev/$_[1]", "[ \t]+"); - %device->{"point_actual"} = &gst_parse_split_first_str ("/etc/mtab", "/dev/$_[1]", "[ \t]+"); - %device->{"fs_listed"} = (&gst_parse_split_all ("/etc/fstab", "/dev/$_[1]", "[ \t]+")) -> [1]; - %device->{"fs_actual"} = (&gst_parse_split_all ("/etc/mtab", "/dev/$_[1]", "[ \t]+")) -> [1]; - - if (%device->{"point_actual"}) - { - %device->{"is_mounted"} = 1; - } - else - { - %device->{"is_mounted"} = 0; - } - } - - return %device; -} - - -# gst_media_get_list_from_proc -# -# Scan /proc files for media devices, and return a list of hashes. - -sub gst_media_get_list_from_proc -{ - local (*PROC_IDE_DIR, *PROC_IDE_CHANNEL_DIR); - my (@devices); - - if (!(stat ("/proc"))) { return undef; } - - # IDE devices. - - if (!(opendir (PROC_IDE_DIR, "/proc/ide"))) { return undef; } - - foreach $ide_entry (readdir (PROC_IDE_DIR)) - { - if ($ide_entry =~ /ide[0-9]/) - { - if (!(opendir (PROC_IDE_CHANNEL_DIR, "/proc/ide/$ide_entry"))) { next; } - - foreach $ide_channel_entry (readdir (PROC_IDE_CHANNEL_DIR)) - { - # NOTE: This is just checking if the entry is a directory. I have a - # feeling it's more portable than stat(). - - if ($ide_channel_entry eq "." || $ide_channel_entry eq ".." || - !(opendir (PROC_IDE_DEVICE, "/proc/ide/$ide_entry/$ide_channel_entry"))) - { - next; - } - - closedir (PROC_IDE_DEVICE); - - my %device = &gst_media_get_ide_device_from_proc ($ide_entry, $ide_channel_entry); - if (%device) - { - push @devices, \%device; - } - } - } - } - - return @devices; -} - - -# gst_media_get_list -# -# Return a list of hashes describing the media devices present -# on this machine. - -sub gst_media_get_list -{ - my @devices; - - @devices = &gst_media_get_list_from_proc(); - return @devices; -} - - -# gst_media_xml_print -# -# Given a media hash-list, prints the media inside a <media> tag -# pair, using current indent levels. - -sub gst_media_xml_print -{ - my @devices = @_; - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<media>\n"); - &gst_xml_enter (); - - for $dev (@devices) - { - &gst_xml_print_vspace (); - &gst_xml_print_line ("<device>\n"); - &gst_xml_enter (); - &gst_xml_print_line ("<name>" . $dev->{"device"} . "</name>\n"); - &gst_xml_print_line ("<type>" . $dev->{"media"} . "</type>\n"); - &gst_xml_print_line ("<interface>" . $dev->{"type"} . "</interface>\n"); - &gst_xml_print_line ("<driver>" . $dev->{"driver"} . "</driver>\n"); - &gst_xml_print_line ("<model>" . $dev->{"model"} . "</model>\n"); - - if ($dev->{"media"} ne "disk") - { - &gst_xml_print_vspace (); - if ($dev->{"point_listed"}) - { - &gst_xml_print_line ("<point_listed>" . $dev->{"point_listed"} . "</point_listed>\n"); - } - - gst_xml_print_state_tag ("mounted", $dev->{"is_mounted"}); - } - - &gst_xml_leave (); - &gst_xml_print_line ("</device>\n"); - &gst_xml_print_vspace (); - } - - &gst_xml_leave (); - &gst_xml_print_line ("</media>\n"); - &gst_xml_print_vspace (); -} - - -# gst_media_xml_parse -# -# - -sub gst_media_xml_parse -{ -} diff --git a/memory-conf.in b/memory-conf.in deleted file mode 100755 index ab4c897..0000000 --- a/memory-conf.in +++ /dev/null @@ -1,588 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Memory configurator. -# Designed to be architecture- and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Bradford Hovinen <hovinen@ximian.com>, Tambet Ingo <tambet@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/fstab /proc/meminfo - -# Running programs affected/used: -# -# swapon swapoff mkswap fdisk dd - -# --- Common stuff --- # - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; -} - - -$DEBUG = 1; # 1 == command; no debug. 2 == no commands, just report. 3 == report and command. - -# --- Tool information --- # - -$name = "memory"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", - "redhat-7.1", "redhat-7.2", - - "mandrake-7.2", - - "debian-2.2", "debian-woody", - - "suse-7.0", "turbolinux-7.0"); - -$description =<<"end_of_description;"; -Configures main and swap memory. -end_of_description; - -$progress_max = 3; - - -# --- System config file locations --- # - -# We list each config file type with as many alternate locations as possible. -# They are tried in array order. First found = used. - -@fstab_names = ( "/etc/fstab" ); -@meminfo_names = ( "/proc/meminfo" ); - -# Where are the tools? - -$cmd_swapon = &gst_file_locate_tool ("swapon"); -$cmd_swapoff = &gst_file_locate_tool ("swapoff"); -$cmd_mkswap = &gst_file_locate_tool ("mkswap"); -$cmd_dd = &gst_file_locate_tool ("dd"); - - -# --- Internal configuration variables --- # - -# Configuration is parsed/read to, and printed/written from, these temporary variables. - -@cf_swapinfo = (); -@cf_partition = (); -@cf_memory = (); - - -# --- XML scanning --- # - -sub xml_parse -{ - # Scan XML to tree. - - $tree = &gst_xml_scan; - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "memory" tag. - - while (@$tree) - { - if ($$tree[0] eq "memory") { &xml_parse_memory($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - return($tree); -} - - -# <memory>...</memory> - -sub xml_parse_memory -{ - my $tree = $_[0]; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "swapdev") - { - push @cf_swapinfo, &xml_parse_swapinfo ($$tree[1]); - } - - shift @$tree; - shift @$tree; - } -} - - -# <swap-device>...</swap-device> - -sub xml_parse_swapinfo -{ - my $tree = $_[0]; - my $node; - my $entry = {}; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq 'device') - { - $entry->{device} = &gst_xml_get_word ($$tree[1]); - } - elsif ($$tree[0] eq 'enabled') - { - $node = $$tree[1]; - $entry->{enabled} = &gst_util_read_boolean ($$node[0]->{state}); - } - elsif ($$tree[0] eq 'priority') - { - $entry->{priority} = &gst_xml_get_word ($$tree[1]); - } - elsif ($$tree[0] eq 'size') - { - $entry->{size} = &gst_xml_get_size ($$tree[1]); - } - elsif ($$tree[0] eq 'isfile') - { - $node = $$tree[1]; - $entry->{is_file} = &gst_util_read_boolean ($$node[0]->{state}); - } - elsif ($$tree[0] eq 'isnew') - { - $node = $$tree[1]; - $entry->{is_new} = &gst_util_read_boolean ($$node[0]->{state}); - } - - shift @$tree; - shift @$tree; - } - - return $entry; -} - -# --- XML printing --- # - - -sub xml_print -{ - &gst_xml_print_begin (); - - foreach $entry (@cf_memory) { - &gst_xml_print_line ("<memsize>$entry->{MemTotal}</memsize>\n"); - &gst_xml_print_line ("<swapsize>$entry->{SwapTotal}</swapsize>\n"); - } - - &gst_xml_print_vspace (); - - foreach $entry (@cf_partition) { - &gst_xml_print_line ("<partition>\n"); - &gst_xml_enter; - &gst_xml_print_line ("<device>$entry->{device}</device>\n"); - &gst_xml_print_line ("<size>$entry->{size}</size>\n"); - &gst_xml_leave; - &gst_xml_print_line ("</partition>\n"); - } - - &gst_xml_print_vspace (); - - foreach $entry (@cf_swapinfo) { - &gst_xml_print_line ("<swapdev>\n"); - &gst_xml_enter; - &gst_xml_print_line ("<device>$entry->{device}</device>\n"); - &gst_xml_print_line ("<enabled state='", - &gst_print_boolean_yesno ($entry->{enabled}), - "'/>\n"); - &gst_xml_print_line ("<priority>$entry->{priority}</priority>\n"); - &gst_xml_print_line ("<isfile state='", - &gst_print_boolean_truefalse ($entry->{is_file}), - "'/>\n"); - &gst_xml_print_line ("<size>$entry->{size}</size>\n"); - &gst_xml_print_line ("<isnew state='", - &gst_print_boolean_truefalse ($entry->{is_new}), - "'/>\n"); - &gst_xml_leave; - &gst_xml_print_line ("</swapdev>\n\n"); - } - - &gst_xml_print_end (); -} - - -# --- Get (read) config --- # - -sub get_memory -{ - my (@meminfo); - my ($totmem); - my ($totswap); - my $ifh; - local *FILE; - - $ifh = &gst_file_open_read_from_names(@meminfo_names); - if (not $ifh) { return; } # We didn't find it. - *FILE = $ifh; - - @meminfo = <FILE>; - close FILE; - - foreach $entry (@meminfo) - { - if ($entry =~ /^MemTotal:(\s+)(\w+)/) - { - $totmem = sprintf ("%.1fMB", $2 / 1024); # In Mb, integer - } - elsif ($entry =~ /^SwapTotal:(\s+)(\w+)/) - { - $totswap = sprintf ("%.1fMB", $2 / 1024); - } - } - - push @cf_memory, { - "MemTotal" => $totmem, - "SwapTotal" => $totswap - }; -} - - -sub get_fdisk -{ - # Okay, so this is strictly not portable either. Patches welcome. - - my @check_devs = ( "/dev/hda", "/dev/hdb", "/dev/hdc", "/dev/hdd", - - "/dev/sda", "/dev/sdb", "/dev/sdc", "/dev/sdd", - "/dev/sde", "/dev/sdf", - - "/dev/eda", "/dev/edb", "/dev/edc", "/dev/edd", - - "/dev/xda", "/dev/xdb" ); - - for $dev (@check_devs) - { - my ($disk, $device, $point, $fs, $options, $check, $size, $bootable, $fd); - - &gst_report ("disks_partition_probe", $dev); - - $fd = &gst_file_run_pipe_read ("fdisk -l $dev"); - while (<$fd>) - { - if (/^\/dev/) - { - @line = split(/[ \n\r\t]+/, $_); - - $device = $line[0]; shift @line; - ($disk) = ($device =~ /([a-zA-Z\/]+)/); - - shift @line; shift @line; # Start and end clusters. - - ($size) = ($line[0] =~ /([0-9]+)/); - $size = sprintf ("%.1fMB", $size / 1024); - shift @line; - - if ($line[0] ne "82") { next; } # Not Swap - else - { - push @cf_partition, { - "device" => $device, - "size" => $size - }; - } - - - } - } - &gst_file_close ($fd); - - &gst_report ("disks_size_query", $dev); - -# open(FDISK_HD, "$fdisk_tool -s $dev 2>/dev/null |"); -# ($size) = (<FDISK_HD> =~ /([0-9]+)/); -# if ($size eq "") { next; } -# close(FDISK_HD); - - } -} - - - -sub get_swap_size -{ - my ($device) = $_[0]; - my ($is_file) = $_[1]; - my ($size) = 0; - - if ($is_file && -f $device) - { - # Is file, &get file size. - my (@stats) = stat($device); - $size = $stats[7]; # size in stat structure. - $size = $size /1024 / 1024; # Size from bytes to Mb. - $size .= "MB"; - } - elsif ($is_file == 0) - { - my $fd; - - # Is partition, &get size. - $fd = &gst_file_run_pipe_read ("fdisk -s $device"); - while (<$fd>) - { - if (/^\w+/) - { - $size = sprintf("%.1fMB", $_ / 1024); #size from Kb to Mb - } - } - &gst_file_close ($fd); - } - - return $size; -} - - -sub get_swap_entries -{ - my $fstab_file; - local *FSTAB_FILE; - - $fstab_file = &gst_file_open_read_from_names (@fstab_names); - if (!$fstab_file) { return; } - *FSTAB_FILE = $fstab_file; - - while (<FSTAB_FILE>) - { - my ($device, $mount_pt, $type, $options, $fs_freq, $fs_passno) = split; - my (@option_list) = split /\,/, $options; - my ($priority) = -1; - my ($enabled); - my ($size); - my ($is_new) = 0; - my ($is_file) = 1; - - next if $type ne 'swap'; - - &gst_report ("memory_swap_found", $device); - - if ($device =~ /^\#(.*)/) - { - $device = $1; - $enabled = 0; - } - else - { - $enabled = 1; - } - - if ($device =~ /^(\#?)\/dev\//) - { - $is_file = 0; - } - - $size = &get_swap_size($device, $is_file); - - foreach $item (@option_list) - { - my ($key, $value) = split /\=/, $item; - - $priority = $value if $key eq 'pri'; - } - - push @cf_swapinfo, { - "device" => $device, - "enabled" => $enabled, - "priority" => $priority, - "is_file" => $is_file, - "size" => $size, - "is_new" => $is_new - }; - } -} - - -sub get -{ - &gst_report ("memory_swap_probe"); - - &get_memory; &gst_print_progress(); - &get_fdisk; &gst_print_progress(); - &get_swap_entries; &gst_print_progress(); - - &gst_report_end (); - &xml_print (); -} - - -# --- Set (write) config --- # - -sub setup_swap_files -{ - my $command; - - $command = "$cmd_swapoff -a"; # To make sure removed swap spaces &get removed - &gst_file_run ($command); - - my $num_done = 0; - - foreach $entry (@cf_swapinfo) - { - if ($entry->{is_new}) - { - if ($entry->{is_file}) - { - my ($size) = $entry->{size}; - $size =~ tr/MB$//d; # Remove Mb from the end - $size *= 1024; # Make it to Kb - - $command = "$cmd_dd if=/dev/null of=$entry->{device} bs=1024 count=$size"; - &gst_file_run ($command); - } - - $command = "$cmd_mkswap $entry->{device} >/dev/null 2>/dev/null"; - &gst_file_run ($command); - } - - elsif ($entry->{is_file}) - { - my ($size) = $entry->{size}; - $size =~ tr/MB$//d; # Remove Mb from the end - $size *= 1024; # Make it to Kb - - if ($size != $entry->{size}) - { - $command = "$cmd_dd if=/dev/zero of=$entry->{device} bs=1024 count=$size"; - &gst_file_run ($command); - - $command = "$cmd_mkswap $entry->{device} >/dev/null 2>/dev/null"; - &gst_file_run ($command); - } - } - - if ($entry->{priority} == -1) - { - $priority = ""; - } - else - { - $priority = "-p $entry->{priority}"; - } - - if ($entry->{enabled}) - { - $command = "$cmd_swapon $entry->{device} $priority >/dev/null 2>/dev/null"; - &gst_file_run ($command); - } - - $num_done++; - &gst_progress(90 / ($#cf_swapinfo - $num_done + 2)); - } -} - -sub set_swap_entries -{ - my ($fstab_in_file, $fstab_out_file); - local (*FSTAB_IN_FILE, *FSTAB_OUT_FILE); - my (@lines); - my ($priority_str); - - ($fstab_in_file, $fstab_out_file) = - &gst_file_open_filter_write_from_names (@fstab_names); - if (!$fstab_out_file) { return; } - *FSTAB_IN_FILE = $fstab_in_file; *FSTAB_OUT_FILE = $fstab_out_file; - - while (<FSTAB_IN_FILE>) - { - my ($device, $mount_pt, $type, $options, $fs_freq, $fs_passno) = - split /\s+/; - - print FSTAB_OUT_FILE if $type ne 'swap'; - } - - foreach $entry (@cf_swapinfo) - { - if ($entry->{priority} >= 0) - { - $priority_str = sprintf "pri=%-11u", $entry->{priority}; - } - else - { - $priority_str = "defaults "; - } - - print FSTAB_OUT_FILE "#" if !$entry->{enabled}; - printf FSTAB_OUT_FILE - "%-23s swap swap %s 0 0\n", - $entry->{device}, - $priority_str; - } - - close FSTAB_FILE; -} - - -sub set -{ - &xml_parse (); - - if ($gst_do_immediate) - { - &setup_swap_files; - } - - &set_swap_entries; - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - &xml_parse (); - &gst_report_end (); - &xml_print (); -} - - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/mouse-conf.in b/mouse-conf.in deleted file mode 100644 index a3c5d28..0000000 --- a/mouse-conf.in +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Pointing Device configurator : Manage your mouse etc -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Ravi Pratap <ravi@che.iitm.ac.in> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/X11/XF86Config - -# Running programs affected: -# -# /etc/X11/X - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/parse.pl$DOTIN"; -#require "$SCRIPTSDIR/mouse.pl$DOTIN"; -} - - -# -- Tool information --- # - -$name = "mouse"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", - "redhat-7.0", "redhat-7.1", "redhat-7.2", "turbolinux-7.0"); - -$description =<<"end_of_desc;"; - Configures Pointing Tool Device -end_of_desc; - -@conf_files = ("/etc/X11/XF86Config"); - -# Helper functions - -sub gst_mouse_conf_get -{ - my %hash; - my $config_file; - local *CONFIG_FILE; - - $config_file = &gst_file_open_read_from_names (@conf_files); - if (not $config_file) { return; } - *CONFIG_FILE = $config_file; - - while (<CONFIG_FILE>) { - chomp; - - # We're only interested in the pointer section - - next if (/^\#/ || /^$/); - last if (/Pointer/); - } - - while (<CONFIG_FILE>) { - my ($a, $b); - - chomp; - next if (/^\#/ || /^$/); - last if (/EndSection/); - - ($a, $b) = split (" ", $_, 2); - - if ($b) { $hash{"$a"} = $b; } - else { $hash{"$a"} = "on"; } - } - - return \%hash; - -} - - -sub xml_print () -{ - my $h = $_[0]; - my @tags = ('Protocol', 'Device', 'BaudRate', 'SampleRate', 'Emulate3Buttons', 'Emulate3Timeout', 'ChordMiddle'); - my $i; - - &gst_xml_print_begin (); - - while ($i = shift @tags) { - if (exists $$h{$i} && $$h{$i} eq "on") { gst_xml_print_line ("<$i/>\n"); } - elsif (exists $$h{$i}) { gst_xml_print_line ("<$i>$$h{$i}</$i>\n"); } - } - - &gst_xml_print_end (); -} - - - - -# The main stuff - -# --- Write new configuration to file --- # - -sub set -{ - print "Not implemented yet! \n"; - - &gst_report_end (); - -} - - -# --- Get configuration from file --- # - -sub get -{ - my $hash; - - $hash = &gst_mouse_conf_get (); - - &xml_print ($hash); - &gst_report_end (); - -} - - -# --- Filter config: XML in, XML out --- # - -sub filter -{ - print "Not implemented yet! \n"; - - &gst_report_end (); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/network-conf.in b/network-conf.in deleted file mode 100755 index 822ee03..0000000 --- a/network-conf.in +++ /dev/null @@ -1,638 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Network configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# Michael Vogt <mvo@debian.org> (Debian Support) -# Arturo Espinosa <arturo@ximian.com> -# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/resolv.conf -# /etc/host.conf -# /etc/hosts -# /etc/sysconfig/network -# /etc/rc.config -# /etc/smb.conf - -# Running programs affected: -# -# smbd -# nmbd -# ifconfig: check current interfaces and activate/deactivate. - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/network.pl$DOTIN"; -} - -# --- Tool information --- # - -$name = "network"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", "redhat-7.1", - "redhat-7.2", "redhat-8.0", "redhat-9", - "openna-1.0", - "mandrake-7.1", "mandrake-7.2", "mandrake-9.0", "mandrake-9.1", "mandrake-9.2", - "mandrake-10.0", "mandrake-10.1","mandrake-10.2", "mandriva-2006.0", "mandriva-2006.1", - "yoper-2.2", - "blackpanther-4.0", - "debian-2.2", "debian-3.0", "debian-sarge", - "ubuntu-5.04", "ubuntu-5.10", "ubuntu-6.04", - "suse-7.0", "suse-9.0", "suse-9.1", - "turbolinux-7.0", "fedora-1", "fedora-2", "fedora-3", "fedora-4", "rpath", - "pld-1.0", "pld-1.1", "pld-1.99", - "conectiva-9", "conectiva-10", - "vine-3.0", "vine-3.1", - "ark", - "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0", - "gentoo", "vlos-1.2", "freebsd-5", "freebsd-6"); - -$description =<<"end_of_description;"; - Configures all network parameters and interfaces. -end_of_description; - -$progress_max = 10; - -$profile_file = "profiles.xml"; - - -# --- XML parsing --- - -# Scan XML from standard input to an internal tree. -sub xml_parse -{ - my ($tree, %hash, $elem); - # Scan XML to tree. - - $tree = &gst_xml_scan (); - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "network" tag. - - while ($elem = shift @$tree) - { - if ($elem eq "network") { &xml_parse_network (shift @$tree, \%hash); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return(\%hash); -} - -# <network>...</network> - -sub push_unique -{ - my ($arr, $val) = @_; - my $i; - - foreach $i (@$arr) - { - return if $i eq $val; - } - - push @$arr, $val; -} - -sub xml_parse_network -{ - my ($tree, $hash) = @_; - my ($elem); - my (@searchdomain, @nameserver, @order, %statichost, %interface, %dialing); - - shift @$tree; # Skip attributes. - - while ($elem = shift @$tree) - { - if ($elem eq "auto") { $$hash{"auto"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "hostname") { $$hash{"hostname"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "gateway") { $$hash{"gateway"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "gatewaydev") { $$hash{"gatewaydev"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "domain") { $$hash{"domain"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "workgroup") { $$hash{"workgroup"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "smbdesc") { $$hash{"smbdesc"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "name") { $$hash{"name"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "description") { $$hash{"description"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "winsserver") { $$hash{"winsserver"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "winsuse") { $$hash{"winsuse"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "smbuse") { $$hash{"smbuse"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "hostmatch") { $$hash{"hostmatch"} = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "nameserver") { &push_unique (\@nameserver, &gst_xml_get_pcdata (shift @$tree)); } - elsif ($elem eq "searchdomain") { &push_unique (\@searchdomain, &gst_xml_get_pcdata (shift @$tree)); } - elsif ($elem eq "order") { push (@order, &gst_xml_get_pcdata (shift @$tree)); } - elsif ($elem eq "statichost") { &xml_parse_statichost (shift @$tree, \%statichost); } - elsif ($elem eq "interface") { &gst_network_xml_parse_interface (shift @$tree, \%interface); } - elsif ($elem eq "dialing") { &xml_parse_dialing (shift @$tree, \%dialing); } - elsif ($elem eq "dialinstalled") { shift @$tree; } - elsif ($elem eq "smbinstalled") { shift @$tree; } - elsif ($elem eq "smartdhcpcd") { shift @$tree; } - elsif ($elem eq "gwdevunsup") { shift @$tree; } - elsif ($elem eq "wireless_device") { shift @$tree; } - elsif ($elem eq "profiledb") { &xml_parse_profiledb (shift @$tree, $hash); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"order"} = \@order unless $#order < 0; - $$hash{"searchdomain"} = \@searchdomain unless $#searchdomain < 0; - $$hash{"nameserver"} = \@nameserver unless $#nameserver < 0; - $$hash{"statichost"} = \%statichost unless scalar keys %statichost == 0; - $$hash{"interface"} = \%interface unless scalar keys %interface == 0; - $$hash{"dialing"} = \%dialing unless scalar keys %dialing == 0; -} - -# <network><statichost>...</statichost></network> -sub xml_parse_statichost -{ - my ($tree, $statichost) = @_; - my ($ip, @alias, $elem); - - shift @$tree; - - while ($elem = shift @$tree) - { - if ($elem eq "ip") { $ip = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "alias") { push(@alias, &gst_xml_get_pcdata (shift @$tree)); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - # common regexp for IPv4 and IPv6 - if ($ip =~ /([0-9a-fA-F\.:])+/) - { - $$statichost{$ip} = \@alias; - } -} - -sub xml_parse_dialing -{ - my ($tree, $dialing) = @_; - my (%hash, $name, $elem); - - shift @$tree; - - while ($elem = shift @$tree) - { - $hash{$elem} = &gst_xml_get_pcdata (shift @$tree); - } - - $name = $hash{"name"}; - $$dialing{$name} = \%hash; -} - -# couple of functions for fixing profiles format -sub fix_profile_modem_iface -{ - my ($configuration, $section, $dialing) = @_; - my ($s, $key, %h); - - foreach $s (keys %$dialing) - { - if ($s eq $section) - { - $h = $$dialing{$s}; - - foreach $key (keys %$h) - { - $$configuration{$key} = $$h{$key}; - } - } - } -} - -sub fix_profile_interface_format -{ - my ($interface, $dialing) = @_; - my (%configuration, $key, $section); - - return if (exists $$interface{"configuration"}); - - foreach $key (keys %$interface) - { - if ($key !~ /^(dev|enabled|hwaddr)$/) - { - if ($key eq 'wvsection') - { - &fix_profile_modem_iface (\%configuration, $$interface{$key}, $dialing); - $configuration{"section"} = $$interface{$key}; - } - else - { - $dest_key = $key; - $configuration{$key} = $$interface{$key}; - } - - delete $$interface{$key}; - } - } - - $$interface{"type"} = &gst_network_get_interface_type ($$interface{"dev"}); - - if (%configuration) - { - $$interface{"configuration"} = \%configuration; - } -} - -sub fix_profile_format -{ - my ($hash) = @_; - my ($interfaces, $dialing, $iface); - - $interfaces = $$hash{"interface"}; - $dialing = $$hash{"dialing"}; - - foreach $iface (keys %$interfaces) - { - &fix_profile_interface_format ($$interfaces{$iface}, $dialing); - } -} - -sub xml_parse_profile -{ - my ($tree, $hash) = @_; - my (%profile); - - &xml_parse_network ($tree, \%profile); - - # We've got to translate the old profiles format - &fix_profile_format (\%profile); - - push @{$hash->{"profiledb"}{"profile"}}, \%profile; -} - -sub xml_parse_profiledb -{ - my ($tree, $hash) = @_; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "profile") { &xml_parse_profile ($$tree[1], $hash); } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } -} - -# --- XML printing --- # - -sub xml_print_configuration -{ - my ($h) = @_; - my @scalar_keys = - qw(auto hostname gateway gatewaydev gwdevunsup domain - hostmatch workgroup smbdesc winsserver winsuse smbuse - smartdhcpcd smbinstalled dialinstalled name); - my @array_keys = - qw(nameserver searchdomain order); - - # Hostname, domain, search domains, nameservers. - - &gst_xml_print_scalars ($h, @scalar_keys); - &gst_xml_print_arrays ($h, @array_keys); - &network_xml_print_statichost ($h); - - &xml_print_interfaces ($$h{"interface"}); -} - -sub xml_print_profiledb -{ - my ($h) = @_; - - &gst_xml_print_vspace (); - - &gst_xml_print_line ("<profiledb>\n"); - &gst_xml_enter (); - foreach $i (@{$$h{"profiledb"}{"profile"}}) - { - gst_xml_print_line ("<profile>\n"); - gst_xml_enter (); - - &xml_print_configuration ($i); - - gst_xml_leave (); - gst_xml_print_line ("</profile>\n"); - } - gst_xml_leave (); - gst_xml_print_line ("</profiledb>\n"); -} - -sub xml_print_interfaces -{ - my ($h) = @_; - my ($dev, $type); - - foreach $dev (keys %$h) - { - if ($$h{$dev}{"type"}) - { - $type = $$h{$dev}{"type"}; - delete $$h{$dev}{"type"}; - } - else - { - $type = &gst_network_get_interface_type ($dev); - } - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<interface type='$type'>"); - &gst_xml_enter (); - &gst_xml_print_hash ($$h{$dev}); - - &gst_xml_leave (); - &gst_xml_print_line ("</interface>"); - } -} - -sub xml_print -{ - my ($h) = @_; - - &gst_xml_print_begin (); - - &xml_print_configuration ($h); - &xml_print_profiledb ($h); - - &gst_xml_print_end (); -} - - -# Reading profiles -sub read_profiledb -{ - my ($hash) = @_; - my ($path); - my ($tree); - - $path = gst_file_get_data_path () . "/" . $main::tool->{"name"} . "/"; - chmod (0755, $path); - chmod (0644, $path . $profile_file); - - $tree = &gst_xml_scan ($path . $profile_file, $tool); - if ($tree && scalar @$tree) - { - if ($$tree[0] eq 'profiledb') - { - xml_parse_profiledb ($$tree[1], $hash); - } - else - { - gst_report ('xml_unexp_tag', $$tree[0]); - } - } -} - -# Writing profiles -sub write_profiledb -{ - my ($hash) = @_; - my $profiledb = $hash->{'profiledb'}; - my $path = &gst_file_get_data_path () . "/" . $main::tool->{'name'} . "/"; - chmod (0755, $path); - - if ($profiledb) { - # Write our profiles. - my $fh = &gst_file_open_write_from_names ($path . $profile_file); - if ($fh) - { - local *STDOUT = $fh; - &xml_print_profiledb ($hash); - close ($fh); - - delete $hash->{'profiledb'}; - } - } - else - { - gst_file_remove ($path . $profile_file); - } - - chmod (0644, $path . $profile_file); -} - - -# Top-level actions. -sub get -{ - my $hash; - - # network interface stuff - $hash = &gst_network_conf_get (); - &read_profiledb (\%$hash); - &gst_network_ensure_loopback ($hash); - - &gst_report_end (); - &xml_print ($hash); -} - - -sub set -{ - my $hash; - - $hash = &xml_parse (); - &write_profiledb ($hash); - &gst_network_conf_set ($hash); - &gst_report_end (); -} - -sub set_profile -{ - my ($tool, $profile_name) = @_; - my ($hash, $profiles, $profile); - - &read_profiledb (\%$hash); - $profiles = $$hash{"profiledb"}{"profile"}; - - foreach $profile (@$profiles) - { - if ($$profile{"name"} eq $profile_name) - { - &gst_network_conf_set ($profile); - } - } - - &gst_report_end (); -} - -sub save_profiles -{ - my $hash; - - $hash = &xml_parse (); - &write_profiledb ($hash); - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - my $hash; - - $hash = &xml_parse (); - &gst_report_end (); - &xml_print ($hash); -} - -sub enable_iface -{ - my ($tool, $iface, $enabled) = @_; - my (%dist_attrib, $iface_set); - my %hash = ("configuration" => {"file" => $iface}); - - %dist_attrib = &gst_network_get_interface_replace_table (); - $iface_set = $dist_attrib{"iface_set"}; - &$iface_set (\%hash, undef, $enabled, 1); - - # small hack for ensuring that the interface is really down - # when messing ifup/ifdown/ifconfig calls - if ($enabled == 0) - { - gst_file_run ("ifconfig $iface down"); - &drop_dhcp_connection ($iface); - &drop_pppd_connection ($iface); - } - - # Don't forget to do gst_end when the reports are over! - &gst_report_end (); - # XML output would come here, but this directive returns no XML. -} - -sub enable_iface_with_config -{ - my ($tool) = @_; - my ($tree, $hash, $ret, $str); - - # Scan XML to tree. - $tree = &gst_xml_scan (); - - if (shift @$tree eq "interface") - { - $hash = &gst_network_xml_parse_interface (shift @$tree); - } - - $ret = &gst_network_enable_iface_with_config ($hash); - &gst_report_end (); - - &gst_xml_print_begin ("enable-iface"); - &gst_xml_print_pcdata ("success", ($ret == 0) ? "1" : "0"); - &gst_xml_print_end ("enable-iface"); -} - -sub list_ifaces -{ - my ($tool) = @_; - my ($ifaces, $iface, @arr); - - $ifaces = &gst_network_interfaces_get_info (); - - foreach $iface (keys %$ifaces) - { - push @arr, $$ifaces{$iface}; - } - - &gst_report_end (); - &gst_xml_print_begin ("network-ifaces"); - &gst_xml_print_structure (\@arr, "interface"); - &gst_xml_print_end ("network-ifaces"); -} - -sub detect_modem -{ - my ($tool) = @_; - my ($device); - - $device = &gst_network_autodetect_modem (); - &gst_report_end (); - - &gst_xml_print_begin ("network-modem-device"); - &gst_xml_print_pcdata ("device", $device) if ($device ne undef); - &gst_xml_print_end ("network-modem-device"); -} - -sub detect_essids -{ - my ($tool, $iface) = @_; - my (@essids); - - $essids = &gst_network_detect_essids ($iface); - &gst_report_end (); - - &gst_xml_print_begin ("essids"); - &gst_xml_print_structure ($essids, "network"); - &gst_xml_print_end ("essids"); -} - -sub set_gateway -{ - my ($tool, $iface, $address) = @_; - - &gst_network_route_set_default_gw ($iface, $address); - &gst_report_end (); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "list_ifaces" => [ \&list_ifaces, [], - "List interfaces and active/inactive status." ], - "save_profiles" => [ \&save_profiles, [], "Save the profiles list" ], - "set_profile" => [ \&set_profile, [ "profile_name" ], - "Set a profile as the default configuration" ], - "enable_iface" => [ \&enable_iface, [ "interface", "enabled" ], - "Immediatly enable or disable a given interface. " . - "interface is the file tag value, enabled is 1 or 0." ], - "enable_iface_with_config" => [ \&enable_iface_with_config, [], - "Enable an interface with a given configuration" ], - "detect_modem" => [ \&detect_modem, [], "Detects the modem device." ], - "detect_essids" => [ \&detect_essids, [ "interface" ], "Detects active wireless networks" ], - "set_gateway" => [ \&set_gateway, [ "interface", "address" ], "Sets the default gateway" ] -}; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/network.pl.in b/network.pl.in deleted file mode 100644 index 58589e1..0000000 --- a/network.pl.in +++ /dev/null @@ -1,6535 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Common network stuff for the ximian-setup-tools backends. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# Arturo Espinosa <arturo@ximian.com> -# Michael Vogt <mvo@debian.org> - Debian 2.[2|3] support. -# David Lee Ludwig <davidl@wpi.edu> - Debian 2.[2|3] support. -# Grzegorz Golawski <grzegol@pld-linux.org> - PLD support -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -use Socket; - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; -require "$SCRIPTSDIR/service.pl$DOTIN"; -require "$SCRIPTSDIR/util.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; -require "$SCRIPTSDIR/process.pl$DOTIN"; - - -# Shared XML printing function -sub network_xml_print_statichost -{ - my ($h) = $_[0]; - my ($statichost, $i, $j, $val); - - &gst_xml_print_vspace (); - foreach $i (keys %{$$h{"statichost"}}) - { - $statichost = $ {$$h{"statichost"}}{$i}; - &gst_xml_container_enter ("statichost"); - $val = &gst_xml_quote ($i); - &gst_xml_print_pcdata ("ip", $val); - foreach $j (@$statichost) - { - $val = &gst_xml_quote ($j); - &gst_xml_print_pcdata ("alias", $val); - } - &gst_xml_container_leave ("statichost"); - } -} - -sub gst_network_get_linux_wireless_ifaces -{ - my ($fd, $line); - my (@ifaces, $command); - - $command = &gst_file_get_cmd_path ("iwconfig"); - open $fd, "$command |"; - return @ifaces if $fd eq undef; - - while (<$fd>) - { - if (/^([a-zA-Z0-9]+)[\t ].*$/) - { - push @ifaces, $1; - } - } - - &gst_file_close ($fd); - - &gst_report_leave (); - return \@ifaces; -} - -sub gst_network_get_freebsd_wireless_ifaces -{ - my ($fd, $line, $iface); - my (@ifaces, $command); - - $command = &gst_file_get_cmd_path ("iwconfig"); - open $fd, "$command |"; - return @ifaces if $fd eq undef; - - while (<$fd>) - { - if (/^([a-zA-Z]+[0-9]+):/) - { - $iface = $1; - } - - if (/media:.*wireless.*/i) - { - push @ifaces, $iface; - } - } - - &gst_file_close ($fd); - &gst_report_leave (); - - return \@ifaces; -} - -# Returns an array with the wireless devices found -sub gst_network_get_wireless_ifaces -{ - my ($plat) = $$tool{"system"}; - - return &gst_network_get_linux_wireless_ifaces if ($plat eq "Linux"); - return &gst_network_get_freebsd_wireless_ifaces if ($plat eq "FreeBSD"); -} - -# set of functions for enabling an interface -sub gst_network_config_wireless -{ - my ($hash, $dev, $command_iwconfig, $command_ifconfig) = @_; - my ($essid, $key, $command); - - $essid = $$hash{"configuration"}{"essid"}; - $key = $$hash{"configuration"}{"key"}; - $key_type = $$hash{"configuration"}{"key_type"}; - - if ($essid) - { - $command = $command_iwconfig if ($$tool{"system"} eq "Linux"); - $command = $command_ifconfig if ($$tool{"system"} eq "FreeBSD"); - - $command .= " $dev"; - $command .= " essid '$essid'" if ($essid); - - if ($key) - { - $key = &gst_network_get_full_key ($key, $key_type); - $command .= " key '$key'"; - } - else - { - $command .= " key off"; - } - - &gst_file_run ($command); - } -} - -sub gst_network_enable_iface -{ - my ($hash, $dev, $command_ifconfig) = @_; - my ($address, $netmask, $bootproto, $remote_address); - - $address = $$hash{"configuration"}{"address"}; - $netmask = $$hash{"configuration"}{"netmask"}; - $bootproto = $$hash{"configuration"}{"bootproto"}; - $remote_address = $$hash{"configuration"}{"remote_address"}; - - if ($bootproto eq "dhcp") - { - if (&gst_file_locate_tool ("dhclient3")) - { - $command = "dhclient3 -pf /var/run/dhclient.$dev.pid $dev"; - } - elsif (&gst_file_locate_tool ("dhclient")) - { - $command = "dhclient -pf /var/run/dhclient.$dev.pid -e $dev"; - } - else - { - $command = "dhcpcd -n $dev"; - } - } - else - { - $command = $command_ifconfig; - $command .= " $dev"; - $command .= " $address" if ($address); - $command .= " netmask $netmask" if ($netmask); - $command .= " dstaddr $remote_address" if ($remote_address); - $command .= " up"; - } - - return &gst_file_run ($command); -} - -sub gst_network_get_chat_file -{ - my ($hash) = @_; - my ($volume, $phone_number, $external_line, $dial_command); - my ($dial, $tmp_file, $filename, $arr); - - $volume = $$hash{"configuration"}{"volume"}; - $phone_number = $$hash{"configuration"}{"phone_number"}; - $external_line = $$hash{"configuration"}{"external_line"}; - $dial_command = $$hash{"configuration"}{"dial_command"}; - - $filename = gst_file_get_temp_name ("network-admin-chat-script-XXXXXXXXX"); - $tmp_file = "/tmp/$filename"; - - $dial = $dial_command; - $dial .= $external_line . "W" if ($external_line); - $dial .= $phone_number; - - &gst_network_create_pppscript ($tmp_file); - chmod (0600, $tmp_file); - &gst_replace_chat ($tmp_file, "atd[tp][0-9wW]+", $dial); - &gst_network_set_modem_volume ($tmp_file, $volume); - - - return $tmp_file; -} - -sub gst_network_enable_modem -{ - my ($hash, $dev, $command_pppd, $command_chat) = @_; - my ($config, $chat_file, $command, $ret); - - $config = $$hash{"configuration"}; - $chat_file = &gst_network_get_chat_file ($hash); - - $command = $command_pppd; - $command .= " " . $$config{"serial_port"}; - $command .= " debug" if ($$config{"debug"}); - $command .= ($$config{"noauth"}) ? " noauth" : " auth"; - $command .= ($$config{"persist"}) ? " persist" : " nopersist"; - $command .= ($$config{"serial_hwctl"}) ? " crtscts" : " nocrtscts"; - $command .= ($$config{"set_default_gw"}) ? " defaultroute" : " nodefaultroute"; - $command .= " usepeerdns" if ($$config{"update_dns"}); - $command .= " user " . $$config{"login"}; - $command .= " connect \'$command_chat -v -f $chat_file\'"; - - $ret = &gst_file_run ($command); - - return $ret; -} - -sub gst_network_enable_isdn -{ - my ($hash, $dev, $command_pppd) = @_; - my ($config, $command); - - $config = $$hash{"configuration"}; - - $command = $command_pppd; - $command .= " debug" if ($$config{"debug"}); - $command .= ($$config{"noauth"}) ? " noauth" : " auth"; - $command .= ($$config{"persist"}) ? " persist" : " nopersist"; - $command .= ($$config{"serial_hwctl"}) ? " crtscts" : " nocrtscts"; - $command .= ($$config{"set_default_gw"}) ? " defaultroute" : " nodefaultroute"; - $command .= " usepeerdns" if ($$config{"update_dns"}); - $command .= " sync plugin userpass.so ipcp-accept-local ipcp-accept-remote"; - $command .= " plugin capiplugin.so"; - $command .= " /dev/null"; - $command .= " user " . $$config{"login"}; - $command .= " number " . $$config{"phone_number"}; - - return &gst_file_run ($command); -} - -sub drop_dhcp_connection -{ - my ($dev) = @_; - &gst_process_kill_by_pidfile ("dhclient.$dev.pid"); - &gst_process_kill_by_pidfile ("/etc/dhcpc/dhcpcd-$dev.pid"); -} - -sub drop_pppd_connection -{ - my ($dev) = @_; - &gst_process_kill_by_pidfile ("$dev.pid"); -} - -sub gst_network_enable_iface_with_config -{ - my ($hash) = @_; - my ($command_ifconfig, $command_iwconfig); - my ($command_pppd, $command_chat); - my ($dev, $command, $ret); - - $command_ifconfig = "ifconfig"; - $command_iwconfig = "iwconfig"; - $command_pppd = "pppd"; - $command_chat = gst_file_locate_tool ("chat"); - - $dev = $$hash{"dev"}; - - $command = "$command_ifconfig $dev down"; - $ret = &gst_file_run ($command); - - &drop_dhcp_connection ($dev); - &drop_pppd_connection ($dev); - - if (exists ($$hash{"configuration"})) - { - if (exists ($$hash{"configuration"}{"phone_number"})) - { - $login = $$hash{"configuration"}{"login"}; - $pw = $$hash{"configuration"}{"password"}; - - &gst_network_set_pap_passwd ("/etc/ppp/pap-secrets", $login, $pw); - &gst_network_set_pap_passwd ("/etc/ppp/chap-secrets", $login, $pw); - - if (&gst_network_check_pppd_plugin ("capiplugin")) - { - $ret = &gst_network_enable_isdn ($hash, $dev, $command_pppd); - } - else - { - $ret = &gst_network_enable_modem ($hash, $dev, $command_pppd, $command_chat); - } - } - else - { - # if it's a wireless interface, put first the essid - &gst_network_config_wireless ($hash, $dev, $command_iwconfig, $command_ifconfig); - $ret = &gst_network_enable_iface ($hash, $dev, $command_ifconfig); - } - } - - return $ret; -} - -# Tries to detect modem in a closed list of devices -sub gst_network_autodetect_modem -{ - my (@arr); - - if ($$tool{"system"} eq "Linux") - { - @arr = ("/dev/modem", "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3"); - - $pid = `pidof pppd 2>/dev/null`; - - if ($pid =~ /\d/) { - return; - } - } - elsif ($$tool{"system"} eq "FreeBSD") - { - @arr = ("/dev/modem", "/dev/cuaa0", "/dev/cuaa1", "/dev/cuaa2", "/dev/cuaa3"); - } - - foreach $tty (@arr) { - $temp = `pppd lcp-max-configure 1 nodetach noauth nocrtscts $tty connect \"chat -t1 \'\' AT OK\" 2>/dev/null`; - - if ($temp =~ /established/) { - return $tty; - } - } -} - -# Parse <interface>...</interface>. Put here so it can be shared with internetsharing. -sub gst_network_xml_parse_interface_config -{ - my ($tree) = @_; - my (%config); - - shift @$tree; - - while ($elem = shift @$tree) - { - $config{$elem} = &gst_xml_get_pcdata (shift @$tree); - } - - return \%config; -} - -sub gst_network_xml_parse_interface -{ - my ($tree, $interface) = @_; - my (%hash, $aux, $dev, $elem); - - shift @$tree; - - while ($elem = shift @$tree) - { - if ($elem eq "configuration") - { - $aux = &gst_network_xml_parse_interface_config (shift @$tree); - $hash{$elem} = $aux if ($aux ne undef); - } - else - { - $hash{$elem} = &gst_xml_get_pcdata (shift @$tree); - } - } - - if (($hash{"configuration"} ne undef) && - ($hash{"configuration"}{"file"} ne undef)) - { - $dev = $hash{"configuration"}{"file"}; - } - else - { - $dev = &gst_network_get_file (\%hash); - $hash{"configuration"}{"file"} = $dev if ($hash{"configuration"} ne undef); - } - - $$interface{$dev} = \%hash; - return \%hash; -} - -# Expects something like "132.248.10.2" and returns 4 bytes. -sub gst_network_ipv4_str2vec -{ - my ($str) = @_; - - return pack ('C4', split ('\.', $str)); -} - -# Converse -sub gst_network_ipv4_vec2str -{ - my ($vec) = @_; - - return join ('.', unpack ('C4', $vec)); -} - -# Gets the subnet, in bitmap. -sub gst_network_ipv4_calc_subnet_vec -{ - my ($addr, $mask) = @_; - my ($addrvec, $maskvec); - - $addrvec = &gst_network_ipv4_str2vec ($addr); - $maskvec = &gst_network_ipv4_str2vec ($mask); - - return $addrvec & $maskvec; -} - -# What you're looking for. -sub gst_network_ipv4_calc_subnet -{ - my ($addr, $mask) = @_; - - return &gst_network_ipv4_vec2str (&gst_network_ipv4_calc_subnet_vec); -} - -# The broadcast, bitmap. -sub gst_network_ipv4_calc_bcast_vec -{ - my ($addr, $mask) = @_; - - $addrvec = &gst_network_ipv4_str2vec ($addr); - $maskvec = &gst_network_ipv4_str2vec ($mask); - - return $addrvec | ~$maskvec; -} - -# And this returning the quad-dot notation. -sub gst_network_ipv4_calc_bcast -{ - my ($addr, $mask) = @_; - - return &gst_network_ipv4_vec2str (&gst_network_ipv4_calc_bcast_vec); -} - - -# Selects a ping command, which must ping just twice, with -# one second interval, returning numeric IPs to the given -# broadcast address. -sub gst_network_get_broadcast_ping_cmd -{ - my ($bcast) = @_; - my ($tool_ping); - - my %cmd_map = - ( - "debian-2.2" => "ping -c 2 -i 1 -n $bcast", - "redhat-6.2" => "ping -c 2 -i 1 -n -b $bcast" - ); - my %dist_map = - ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-6.2", - "redhat-8.0" => "redhat-6.2", - "redhat-9" => "redhat-6.2", - "openna-1.0" => "redhat-6.2", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - "ubuntu-5.10" => "debian-2.2", - "ubuntu-6.04" => "debian-2.2", - "mandrake-7.1" => "debian-2.2", - "mandrake-7.2" => "debian-2.2", - "mandrake-9.0" => "debian-2.2", - "mandrake-9.1" => "debian-2.2", - "mandrake-9.2" => "debian-2.2", - "mandrake-10.0" => "debian-2.2", - "mandrake-10.1" => "redhat-6.2", - "mandrake-10.2" => "redhat-6.2", - "mandriva-2006.0" => "redhat-6.2", - "mandriva-2006.1" => "redhat-6.2", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "debian-2.2", - "suse-7.0" => "debian-2.2", - "suse-9.0" => "redhat-6.2", - "suse-9.1" => "redhat-6.2", - "pld-1.0" => "redhat-6.2", - "pld-1.1" => "redhat-6.2", - "pld-1.99" => "redhat-6.2", - "conectiva-9" => "debian-2.2", - "conectiva-10" => "debian-2.2", - "fedora-1" => "redhat-6.2", - "fedora-2" => "redhat-6.2", - "fedora-3" => "redhat-6.2", - "fedora-4" => "redhat-6.2", - "rpath" => "redhat-6.2", - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - "ark" => "redhat-6.2", - "slackware-9.1.0" => "redhat-6.2", - "slackware-10.0.0" => "redhat-6.2", - "slackware-10.1.0" => "redhat-6.2", - "slackware-10.2.0" => "redhat-6.2", - "gentoo" => "debian-2.2", - "vlos-1.2" => "debian-2.2", - "freebsd-5" => "debian-2.2", - "freebsd-6" => "debian-2.2", - ); - - return $cmd_map{$dist_map{$gst_dist}}; -} - - -# Run ping, taking what looks like the replying host addresses, return -# colon-sepparated (:) string. To be used with gst_process_fork. -sub gst_network_ping_broadcast_call -{ - my ($bcast) = @_; - my ($cmd, %hosts, $fd); - - $cmd = &gst_network_get_broadcast_ping_cmd ($bcast); - $fd = &gst_file_run_pipe_read ($cmd); - return undef if $fd eq undef; - while (<$fd>) - { - if (/([0-9.]+):?[ \t]+icmp_seq/) - { - # If it already exists, it is the second count, and we can return then. - last if exists $hosts{$1}; - $hosts{$1} = 1 ; - } - } - &gst_file_close ($fd); - - return join (':', keys (%hosts)); -} - - -# Return an array of IPs of the hosts in all the adjacent local networks. -sub gst_network_find_hosts -{ - my ($iface, $ifaces, $dev, $hosts_str, @hosts, $proc, @procs); - - $ifaces = &gst_network_interfaces_get_info (); - - foreach $dev (keys %$ifaces) - { - $iface = $$ifaces{$dev}; - if ($$iface{"active"} && exists $$iface{"bcast"}) - { - push @procs, &gst_process_fork (\&gst_network_ping_broadcast_call, $$iface{"bcast"}); - } - } - - &gst_process_list_check_ready (3, \@procs); - - foreach $proc (@procs) - { - if ($$proc{"ready"}) - { - sysread ($$proc{"fd"}, $hosts_str, 4096); - push @hosts, split (':', $hosts_str); - } - } - - return @hosts; -} - - -# like, &gst_network_lookup_address_block ("132.248.10.2") returns 'dns2.unam.mx' -# but watch it: it will block until libc timeouts or a result is found. If -# nothing found, returns the address. -sub gst_network_lookup_address_block -{ - my ($addr) = @_; - my $name; - - $name = (gethostbyaddr (&gst_network_ipv4_str2vec ($addr), AF_INET))[0]; - return $addr if length ($name) == 0; - return $name; -} - - -# To be called from gst_process_fork by the child. -sub gst_network_address_lookup_call -{ - my ($addr) = @_; - - return &gst_network_lookup_address_block ($addr); -} - - -# Fork a lookup process for every passed address, return ref to -# array with info on every proc. -sub gst_network_lookup_address_start -{ - my (@addrs) = @_; - my ($addr, $proc, @procs); - - # Fork a lookup for every address. - foreach $addr (@addrs) - { - $proc = &gst_process_fork (\&gst_network_address_lookup_call, $addr); - $$proc{"addr"} = $addr; - push @procs, $proc; - } - - return \@procs; -} - -# Take a ref to a list of forked lookup processes, -# and collect the information from those ready. -sub gst_network_lookup_address_collect -{ - my ($procs) = @_; - my ($name, @names, $proc); - - # For every process, if the "ready" flag is on, read info. - # Else, populate with the given address. Then kill child and wait for it to die. - foreach $proc (@$procs) - { - if ($$proc{"ready"}) - { - sysread ($$proc{"fd"}, $name, 4096); - push @names, $name; - } - else - { - push @names, $$proc{"addr"}; - } - &gst_process_kill ($proc); - } - - return @names; -} - - -# like, &gst_network_lookup_address (10, "132.248.10.2", "132.248.29.8") returns -# 'dns2.unam.mx', 'sphinx.nuclecu.unam.mx' after 10 seconds, in the worst case. -# If any of the given addresses is not resolved before timeout, the address will -# be returned as its name. Timeout of 0 or undef blocks. -# Timeout may be a decimal (0.5, half a second). You can split this process in -# two, so you can collect the information at the last moment, giving more time for -# the lookups to take place. Use the two functions above for this, as shown here. -sub gst_network_lookup_address -{ - my ($timeout, @addrs) = @_; - my $procs; - - $procs = &gst_network_lookup_address_start (@addrs); - &gst_process_list_check_ready ($timeout, $procs); - return &gst_network_lookup_address_collect ($procs); -} - - -# This code is not under the portable table style because it is supposed to -# depend on wvdial. -sub gst_network_dialing_get -{ - my %vars = - ( - "Inherits" => "inherits", - "Modem" => "device", - "Baud" => "speed", - "Init1" => "init1", - "Init2" => "init2", - "Phone" => "phone", - "Username" => "login", - "Password" => "password", - "Dial Command" => "dialcmd", - "SetVolume" => "volume", - "Stupid mode" => "stupid", - "Auto Reconnect" => "persist", - "Force Address" => "address", - "Auto DNS" => "update_dns", - "Check Def Route" => "set_default_gw", - "GST Device" => "gst_dev", - "Dial Command" => "dial_command" - ); - my %title2type = - ( - "Dialer (.*)" => "dialer", - "Modem(.*)" => "modem" - ); - - my ($file) = @_; - my (%ret, @sections); - my ($i, $j, $name, $val); - - &gst_report_enter (); - &gst_report ("network_dialing_get"); - - @sections = &gst_parse_ini_sections ($file); - foreach $i (@sections) - { - my %hash; - - $hash{"type"} = "unknown"; - foreach $j (keys %title2type) - { - if ($i =~ /$j/) - { - $hash{"name"} = $1; - $hash{"type"} = $title2type{$j}; - } - } - - $ret{$hash{"name"}} = \%hash; - - foreach $j (keys %vars) - { - $val = &gst_parse_ini ($file, $i, $j); - $hash{$vars{$j}} = $val if ($val ne undef); - } - - # we add the volume label, it's not a line in the wvdial config, - # it's a hayes command in the init2 string, it can be ATM0 or ATL[1-3] - if ($hash{"init2"} =~ /M0/) - { - $hash{"volume"} = 0; - } - elsif ($hash{"init2"} =~ /L[1-3]/) - { - $hash{"init2"} =~ /.*L([1-3]).*/; - $volume = ($1); - $hash{"volume"} = $volume; - } - else - { - $hash{"volume"} = 3; - } - - # add the external line access number - if ($hash{"phone"} =~ /(^.*)[wW]/) - { - $hash{"external_line"} = $1; - $hash{"phone"} =~ s/^.*[wW]//; - } - } - - &gst_report_leave (); - return \%ret; -} - -# returns interface type depending on it's interface name -# types_cache is a global var for caching interface types -sub gst_network_get_interface_type -{ - my ($dev) = @_; - my (@wireless_ifaces, $wi, $type); - - return $types_cache{$dev} if (exists $types_cache{$dev}); - - #check whether interface is wireless - $wireless_ifaces = &gst_network_get_wireless_ifaces (); - foreach $wi (@$wireless_ifaces) - { - if ($dev eq $wi) - { - $types_cache{$dev} = "wireless"; - return $types_cache{$dev}; - } - } - - if ($dev =~ /^(ppp|tun)/) - { - # check whether the proper plugin exists - if (&gst_network_check_pppd_plugin ("capiplugin")) - { - $types_cache{$dev} = "isdn"; - } - else - { - $types_cache{$dev} = "modem"; - } - } - elsif ($dev =~ /^(eth|dc|ed|bfe|em|fxp|bge|de|xl|ixgb|txp|vx|lge|nge|pcn|re|rl|sf|sis|sk|ste|ti|tl|tx|vge|vr|wb|cs|ex|ep|fe|ie|lnc|sn|xe|le|an|awi|wi|ndis|wlaue|axe|cue|kue|rue|fwe|nve)[0-9]/) - { - $types_cache{$dev} = "ethernet"; - } - elsif ($dev =~ /^irlan[0-9]/) - { - $types_cache{$dev} = "irlan"; - } - elsif ($dev =~ /^plip[0-9]/) - { - $types_cache{$dev} = "plip"; - } - elsif ($dev =~ /^lo[0-9]?/) - { - $types_cache{$dev} = "loopback"; - } - - return $types_cache{$dev}; -} - -sub gst_network_freebsd_interfaces_get_info -{ - my ($dev, %ifaces, $fd); - - &gst_report_enter (); - &gst_report ("network_iface_active_get"); - - $fd = &gst_file_run_pipe_read ("ifconfig"); - return {} if $fd eq undef; - - while (<$fd>) - { - chomp; - if (/^([^ \t:]+):.*(<.*>)/) - { - $dev = $1; - $ifaces{$dev}{"dev"} = $dev; - $ifaces{$dev}{"enabled"} = 1 if ($2 =~ /[<,]UP[,>]/); - } - - s/^[ \t]+//; - if ($dev) - { - $ifaces{$dev}{"hwaddr"} = $1 if /ether[ \t]+([^ \t]+)/i; - $ifaces{$dev}{"addr"} = $1 if /inet[ \t]+([^ \t]+)/i; - $ifaces{$dev}{"mask"} = $1 if /netmask[ \t]+([^ \t]+)/i; - $ifaces{$dev}{"bcast"} = $1 if /broadcast[ \t]+([^ \t]+)/i; - } - } - - &gst_file_close ($fd); - &gst_report_leave (); - return \%ifaces; -} - -sub gst_network_linux_interfaces_get_info -{ - my ($dev, %ifaces, $fd); - - &gst_report_enter (); - &gst_report ("network_iface_active_get"); - - $fd = &gst_file_run_pipe_read ("ifconfig -a"); - return {} if $fd eq undef; - - while (<$fd>) - { - chomp; - if (/^([^ \t:]+)/) - { - $dev = $1; - $ifaces{$dev}{"enabled"} = 0; - $ifaces{$dev}{"dev"} = $dev; - } - - s/^[ \t]+//; - if ($dev) - { - $ifaces{$dev}{"hwaddr"} = $1 if /HWaddr[ \t]+([^ \t]+)/i; - $ifaces{$dev}{"addr"} = $1 if /addr:([^ \t]+)/i; - $ifaces{$dev}{"mask"} = $1 if /mask:([^ \t]+)/i; - $ifaces{$dev}{"bcast"} = $1 if /bcast:([^ \t]+)/i; - $ifaces{$dev}{"enabled"} = 1 if /^UP[ \t]/i; - } - } - - &gst_file_close ($fd); - &gst_report_leave (); - return \%ifaces; -} - -sub gst_network_interfaces_get_info -{ - my (%ifaces); - - $ifaces = &gst_network_linux_interfaces_get_info if ($$tool{"system"} eq "Linux"); - $ifaces = &gst_network_freebsd_interfaces_get_info if ($$tool{"system"} eq "FreeBSD"); - - foreach $dev (keys %$ifaces) - { - #$$ifaces{$dev}{"enabled"} = 0 if $$ifaces{$dev}{"addr"} eq undef; - $$ifaces{$dev}{"type"} = &gst_network_get_interface_type ($dev); - - #delete unknown ifaces - if ($$ifaces{$dev}{"type"} eq undef) - { - delete $$ifaces{$dev}; - } - } - - return $ifaces; -} - -sub gst_network_active_interfaces_get -{ - my $fd; - my @ret = (); - - &gst_report_enter (); - &gst_report ("network_iface_active_get"); - - $fd = &gst_file_run_pipe_read ("ifconfig"); - return undef if $fd eq undef; - - while (<$fd>) - { - chomp; - s/:? .*//; - next if /^$/; - push @ret, $_; - } - - &gst_file_close ($fd); - - &gst_report_leave (); - return @ret; -} - -sub gst_network_freebsd5_active_interfaces_get -{ - my ($fd, @ret); - - &gst_report_enter (); - &gst_report ("network_iface_active_get"); - - $fd = &gst_file_run_pipe_read ("ifconfig"); - return undef if ($fd eq undef); - - while (<$fd>) - { - chomp; - if (/^([\w\d]*):.*[<,]UP[,>]/) - { - push @ret, $1; - } - } - - &gst_file_close ($fd); - &gst_report_leave (); - - return @ret; -} - -sub gst_network_suse70_active_interfaces_get -{ - my (@devs, $dev, @ret, $num); - - @devs = &gst_network_active_interfaces_get (); - - foreach $dev (@devs) - { - if ($dev ne "lo") - { - $num = &gst_network_suse70_parse_iface_num ("$gst_prefix/etc/rc.config", $dev); - push @ret, $num if $num != -1; - } - } - - return @ret; -} - -sub gst_network_interface_active -{ - my ($search_iface, $proc) = @_; - my @ifaces; - - &gst_report_enter (); - &gst_report ("network_iface_is_active", $search_iface); - - @ifaces = &$proc (); - while ($ifaces[0] ne "") - { - return 1 if (shift (@ifaces) eq $search_iface); - } - - &gst_report_leave (); - return 0; -} - -sub gst_network_interface_ensure_broadcast_and_network -{ - my ($iface) = @_; - - if (exists $$iface{"netmask"} && - exists $$iface{"address"}) - { - if (! exists $$iface{"broadcast"}) - { - $$iface{"broadcast"} = &gst_network_ipv4_calc_bcast ($$iface{"address"}, $$iface{"netmask"}); - } - - if (! exists $$iface{"network"}) - { - $$iface{"network"} = &gst_network_ipv4_calc_subnet ($$iface{"address"}, $$iface{"netmask"}); - } - } -} - -sub gst_network_sysconfig_dir_ifaces_get_existing -{ - my ($dir) = @_; - my (@ret, $i, $name); - local *IFACE_DIR; - - if (opendir IFACE_DIR, "$gst_prefix/$dir") - { - foreach $i (readdir (IFACE_DIR)) - { - push @ret, $1 if ($i =~ /^ifcfg-(.+)$/); - } - - closedir (IFACE_DIR); - } - - return \@ret; -} - -sub gst_network_sysconfig_rh62_ifaces_get_existing -{ - return @{&gst_network_sysconfig_dir_ifaces_get_existing ("/etc/sysconfig/network-scripts")}; -} - -sub gst_network_sysconfig_rh72_ifaces_get_existing -{ - my ($ret); - - # This syncs /etc/sysconfig/network-scripts and /etc/sysconfig/networking - &gst_file_run ("redhat-config-network-cmd"); - - $ret = &gst_network_sysconfig_dir_ifaces_get_existing - ("/etc/sysconfig/networking/profiles/default"); - - &gst_arr_merge ($ret, - &gst_network_sysconfig_dir_ifaces_get_existing - ("/etc/sysconfig/networking/devices")); - - return @$ret; -} - -sub gst_network_debian_ifaces_get_existing -{ - my (@ret, @stanzas, $stanza); - - @stanzas = &gst_parse_interfaces_stanzas ("$gst_prefix/etc/network/interfaces", "iface"); - - foreach $stanza (@stanzas) - { - if ($$stanza[1] eq "inet") - { - push @ret, $$stanza[0]; - } - } - - return @ret; -} - -sub gst_network_suse70_ifaces_get_existing -{ - my $file = "$gst_prefix/etc/rc.config"; - my ($i, $dev, @ret, $fd); - - $fd = &gst_file_open_read_from_names ($file); - return @ret if !$fd; - - while ($i = <$fd>) - { - if ($i =~ /^[ \t]*NETDEV_([0-9]+)=/) - { - push @ret, $1 if &gst_parse_sh ($file, "NETDEV_$1") ne ""; - } - } - - &gst_file_close ($fd); - return @ret; -} - -sub gst_network_suse90_ifaces_get_existing -{ - return @{&gst_network_sysconfig_dir_ifaces_get_existing ("/etc/sysconfig/network")}; -} - -sub gst_network_sysconfig_pld10_ifaces_get_existing -{ - return @{&gst_network_sysconfig_dir_ifaces_get_existing ("/etc/sysconfig/interfaces")}; -} - -sub gst_network_slackware91_ifaces_get_existing -{ - my $file = "/etc/rc.d/rc.inet1.conf"; - my $pppscript = "/etc/ppp/pppscript"; - my ($fd, $i, @ret); - - $fd = &gst_file_open_read_from_names ($file); - return @ret if !$fd; - - while ($i = <$fd>) - { - if ($i =~ /^[ \t]*(IPADDR|USE_DHCP)\[([0-9]+)\][ \t]*=[ \t]*"(.*)"/) - { - push @ret, "eth$2" if ($3 ne ""); - } - } - - &gst_file_close ($fd); - - if (&gst_file_exists ($pppscript)) - { - push @ret, "ppp0"; - } - - return @ret; -} - -sub gst_network_gentoo_ifaces_get_existing -{ - my $file = "/etc/conf.d/net"; - my ($fd, $i, @ret, $ppp); - - $fd = &gst_file_open_read_from_names ($file); - return @ret if !$fd; - - while ($i = <$fd>) - { - if ($i =~ /^config_([a-zA-Z0-9]*)[ \t]*=/) - { - push @ret, $1; - } - } - - #now the PPP ifaces - foreach $ppp (</etc/conf.d/net.*>) - { - $ppp =~ s#^/etc/conf.d/net\.##; - push @ret, $ppp if ($ppp =~ /^ppp[0-9]$/); - } - - return @ret; -} - -sub gst_network_freebsd_ifaces_get_existing -{ - my $file = "/etc/rc.conf"; - my ($fd, $i, @ret); - - $fd = &gst_file_open_read_from_names ($file); - return @ret if !$fd; - - while ($i = <$fd>) - { - if ($i =~ /^ifconfig_(.*)[ \t]*=/) - { - push @ret, $1; - } - } - - return @ret; -} - -sub gst_network_suse70_parse_iface_num -{ - my ($file, $dev) = @_; - my ($i, $ret); - - foreach $i (&gst_network_suse70_ifaces_get_existing ()) - { - $ret = &gst_parse_sh ($file, "NETDEV_$i"); - return $i if $ret eq $dev; - } - - &gst_debug_print_string ("\n\nWarning: gst_network_suse70_parse_iface_num: num for $dev not found.\n\n"); - return -1; -} - -sub gst_network_suse70_parse_iface_auto -{ - my ($file, $iface, $key) = @_; - my ($val, $i); - - $val = &gst_parse_sh_split ($file, $key, "[ \t]+"); - - foreach $i (@$val) - { - return 1 if $i eq "_$iface"; - } - - return 0; -} - -sub gst_network_suse70_replace_iface_auto -{ - my ($file, $iface, $key, $value) = @_; - my ($val, $i, $found, @ret); - - $val = &gst_parse_sh_split ($file, $key, "[ \t]+"); - - foreach $i (@$val) - { - $found = 1 if $i eq "_$iface"; - push @ret, $i unless ($i eq "_$iface" && !$value); - } - - return 0 if ($found == $value); - push @ret, "_$iface" if (!$found && $value); - - return &gst_replace_sh ($file, $key, join (" ", @ret)); -} - -sub gst_network_suse70_parse_iface_sh -{ - my ($file, $iface, $key) = @_; - my ($val, $num); - - return &gst_parse_sh ($file, "${key}_$iface"); -} - -sub gst_network_suse70_replace_iface_sh -{ - my ($file, $iface, $key, $value) = @_; - my ($val, $num); - - return &gst_replace_sh ($file, "${key}_$iface", $value); -} - -sub gst_network_suse70_get_ifconfig_arg -{ - my ($file, $iface, $key) = @_; - my ($val); - - $val = &gst_network_suse70_parse_iface_sh ($file, $iface, "IFCONFIG"); - $val =~ /[ \t]+$key[ \t]+([^ \t]+)/; - return $1; -} - -sub gst_network_suse70_set_ifconfig_arg -{ - my ($file, $iface, $key, $value) = @_; - my ($val); - - $val = &gst_network_suse70_parse_iface_sh ($file, $iface, "IFCONFIG"); - - return 0 if $val =~ /^dhcpclient$/ || $val =~ /^bootp$/; - - if (! ($val =~ s/([ \t]+$key[ \t]+)[^ \t]+/$1$value/)) - { - $val =~ s/[ \t]+up$//; - $val .= " " if $val =~ /[^ \t]$/; - $val .= "$key $value up"; - } - - return &gst_network_suse70_replace_iface_sh ($file, $iface, "IFCONFIG", $val); -} - -sub gst_network_suse70_set_ifconfig_ip -{ - my ($file, $iface, $value) = @_; - - $val = &gst_network_suse70_parse_iface_sh ($file, $iface, "IFCONFIG"); - - return 0 if $val =~ /^dhcpclient$/ || $val =~ /^bootp$/; - - if (! ($val =~ s/^[0-9\.]+([ \t])/$value$1/)) - { - $val = "$value $val"; - $val =~ s/[ \t]+/ /; - } - - return &gst_network_suse70_replace_iface_sh ($file, $iface, "IFCONFIG", $val); -} - -sub gst_network_get_new_dialing_dev -{ - my ($dial_hash, $type) = @_; - my ($dial, $dev, $maxdev); - - $maxdev = -1; - foreach $dial (keys %$dial_hash) - { - $dev = $ {$$dial_hash{$dial}}{"gst_dev"}; - if ($dev ne "") - { - if ($dev =~ s/^$type//) - { - $maxdev = $dev if $dev > $maxdev; - } - } - } - - $maxdev ++; - return "$type$maxdev"; -} - -sub gst_network_dial2iface -{ - my ($dial_hash, $name) = @_; - my ($dial, %iface, $i); - - my %map = ("address" => "address", - "update_dns" => "update_dns", - "login" => "login", - "password" => "password", - "serial_port" => "device", - "serial_speed" => "speed", - "set_default_gw" => "set_default_gw", - "persist" => "persist", - "phone_number" => "phone", - "dev" => "gst_dev" - ); - - $dial = $$dial_hash{$name}; - if ($$dial{"gst_dev"} eq "") - { - $$dial{"gst_dev"} = "ppp0"; - # = &gst_network_get_new_dialing_dev ($dial_hash, "ppp"); - } - else - { - $iface{"enabled"} = &gst_network_interface_active ($$dial{"gst_dev"}, - \&gst_network_active_interfaces_get)? 1: 0; - } - - foreach $i (keys %map) - { - $iface{$i} = $$dial{$map{$i}} if exists $$dial{$map{$i}}; - } - - $iface{"file"} = $iface{"name"} = $iface{"section"} = $name; - $iface{"update_dns"} = 1 if ($iface{"update_dns"} eq ""); - $iface{"set_default_gw"} = 1 if ($iface{"set_default_gw"} eq ""); - - return \%iface; -} - -sub gst_network_iface2dial -{ - my ($dial_hash, $iface) = @_; - my ($dial, $i); - - my %map = ("address" => "address", - "update_dns" => "update_dns", - "device" => "serial_port", - "speed" => "serial_speed", - "set_default_gw" => "set_default_gw", - "persist" => "persist", - "gst_dev" => "dev" - ); - - $dial = $$dial_hash{$$iface{"name"}}; - - foreach $i (keys %map) - { - $$dial{$i} = $$iface{$map{$i}} if exists $$iface{$map{$i}}; - } - - $$dial{"type"} = "dialer"; -} - -sub gst_network_suse70_get_ppp -{ - my ($dial, $iface) = @_; - my ($d); - - foreach $d (keys %$dial) - { - $$iface{$d} = &gst_network_dial2iface ($dial, $d); - } - - return $iface; -} - -sub gst_network_suse70_set_ppp -{ - my ($wvfile, $dial, $iface) = @_; - my ($d, $i, @ppp_devs, $section); - - foreach $d (keys %$iface) - { - $i = $$iface{$d}; - if ($$i{"dev"} =~ /^ppp/) - { - my ($tmp, $wv, $name); - - push @ppp_devs, $i; - - # This takes care of connection name changes. - $wv = $$i{"section"}; - $name = $$i{"name"}; - - if ($wv ne $name) - { - $tmp = $$dial{$wv}; - delete $$dial{$wv}; - $$tmp{"name"} = $name; - $$dial{$name} = $tmp; - } - - # Then merges interface with dialing. - &gst_network_iface2dial ($dial, $i); - } - } - - # Delete any wvdial sections that are no longer present as ifaces. - OUTER: foreach $d (keys %$dial) - { - foreach $i (@ppp_devs) - { - next OUTER if $$i{"name"} eq $ {$$dial{$d}}{"name"}; - } - - # Don't delete the defaults: that's not very polite. - delete $$dial{$d} unless $ {$$dial{$d}}{"name"} eq "Defaults"; - } - - return 0; -} - -sub gst_network_suse70_ppp_iface_activate -{ - my ($name, $enabled); - my ($wvdial_dod, $tool_ifconfig, @paths); - - @paths = &gst_service_sysv_get_paths (); - $wvdial_dod = $paths[1] . "/wvdial.dod"; - $tool_ifconfig = &gst_file_locate_tool ("ifconfig"); - - if ($enabled) - { - &gst_debug_print_string ("\n\nifup ppp iface $name\n\n"); - return -1 if &gst_file_run_bg ("$wvdial_dod start \"$name\""); - } - else - { - # Hmm... you'd better not have more than one ppp connection active: - # this is the only SuSE way of doing it. - &gst_debug_print_string ("\n\nifdown ppp iface $name\n\n"); - return -1 if &gst_file_run ("$wvdial_dod stop"); - } - - return 0; -} - -sub gst_network_suse70_activate_ppp -{ - my ($iface) = @_; - my ($d, $i); - - foreach $d (keys %$iface) - { - $i = $$iface{$d}; - if ($$i{"dev"} =~ /^ppp/ && (! $$i{"enabled"})) - { - &gst_network_suse70_ppp_iface_activate ($$i{"name"}, 0); - # deleted, so interfaces_set doesn't handle them. - delete $$iface{$d}; - } - } - - foreach $d (keys %$iface) - { - $i = $$iface{$d}; - if ($$i{"dev"} =~ /^ppp/ && $$i{"enabled"}) - { - &gst_network_suse70_ppp_iface_activate ($$i{"name"}, 1); - delete $$iface{$d}; - } - } - - return 0; -} - -sub gst_network_slackware91_create_pppgo -{ - my ($pppgo) = "/usr/sbin/ppp-go"; - my ($contents, $pppd, $chat); - local *FILE; - - if (!&gst_file_exists ($pppgo)) - { - $pppd = &gst_file_locate_tool ("pppd"); - $chat = &gst_file_locate_tool ("chat"); - - # create a simple ppp-go from scratch - # this script is based on the one that's created by pppsetup - $contents = "killall -INT pppd 2>/dev/null \n"; - $contents .= "rm -f /var/lock/LCK* /var/run/ppp*.pid \n"; - $contents .= "( $pppd connect \"$chat -v -f /etc/ppp/pppscript\") || exit 1 \n"; - $contents .= "exit 0 \n"; - - &gst_file_buffer_save ($contents, $pppgo); - chmod 0777, "$gst_prefix/$pppgo"; - } -} - -sub gst_network_get_modem_volume -{ - my ($file) = @_; - my ($volume); - - $volume = &gst_parse_chat ($file, "AT.*(M0|L[1-3])"); - - return 3 if ($volume eq undef); - - $volume =~ s/^[ml]//i; - return $volume; -} - -sub gst_network_set_modem_volume_string -{ - my ($file, $key, $volume) = @_; - my ($vol); - - if ($volume == 0) { $vol = "ATM0" } - elsif ($volume == 1) { $vol = "ATL1" } - elsif ($volume == 2) { $vol = "ATL2" } - else { $vol = "ATL3" } - - return &gst_replace_sh ($file, $key, $vol); -} - -sub gst_network_set_modem_volume -{ - my ($file, $volume) = @_; - my $line; - - $line = &gst_parse_chat ($file, "AT([^DZ][a-z0-9&]+)"); - $line =~ s/(M0|L[1-3])//g; - - if ($volume == 0) { $line .= "M0"; } - elsif ($volume == 1) { $line .= "L1"; } - elsif ($volume == 2) { $line .= "L2"; } - else { $line .= "L3"; } - - return &gst_replace_chat ($file, "AT([^DZ][a-z0-9&]+)", $line); -} - -sub gst_network_create_pppscript -{ - my ($pppscript) = @_; - my ($contents); - - if (!&gst_file_exists ($pppscript)) - { - # create a template file from scratch - $contents = 'TIMEOUT 60' . "\n"; - $contents .= 'ABORT ERROR' . "\n"; - $contents .= 'ABORT BUSY' . "\n"; - $contents .= 'ABORT VOICE' . "\n"; - $contents .= 'ABORT "NO CARRIER"' . "\n"; - $contents .= 'ABORT "NO DIALTONE"' . "\n"; - $contents .= 'ABORT "NO DIAL TONE"' . "\n"; - $contents .= 'ABORT "NO ANSWER"' . "\n"; - $contents .= '"" "ATZ"' . "\n"; - $contents .= '"" "AT&FH0"' . "\n"; - $contents .= 'OK-AT-OK "ATDT000000000"' . "\n"; - $contents .= 'TIMEOUT 75' . "\n"; - $contents .= 'CONNECT' . "\n"; - - &gst_file_buffer_save ($contents, $pppscript); - } -} - -sub gst_network_create_isdn_options -{ - my ($file) = @_; - - if (!&gst_file_exists ($file)) - { - &gst_file_copy_from_stock ("general_isdn_ppp_options", $file); - } -} - -sub gst_network_check_pppd_plugin -{ - my ($plugin) = @_; - my ($version, $output); - - $version = &gst_file_run_backtick ("pppd --version", 1); - $version =~ s/.*version[ \t]+//; - chomp $version; - - return 0 if !version; - return &gst_file_exists ("/usr/lib/pppd/$version/$plugin.so"); -} - -sub gst_network_gentoo_parse_gateway -{ - my ($file, $iface) = @_; - my ($str); - - $str = &gst_parse_confd_net ($file, "routes_$iface"); - - if ($str =~ /default[ \t]+(via|gw)[ \t]+([0-9\.\:]*)/) - { - return $2; - } -} - -sub gst_network_interfaces_get -{ - my (%dist_attrib, %config_hash, %hash, %fn); - my (@config_ifaces, $iface, $dev); - my ($dist, $value, $file, $proc); - my ($i, $j); - my ($modem_settings); - - $hash = &gst_network_interfaces_get_info (); - %dist_attrib = &gst_network_get_interface_parse_table (); - %fn = %{$dist_attrib{"fn"}}; - $proc = $dist_attrib{"ifaces_get"}; - @ifaces = &$proc (); - - # clear unneeded hash elements - foreach $i (keys %$hash) - { - delete $$hash{$i}{"addr"}; - delete $$hash{$i}{"bcast"}; - delete $$hash{$i}{"mask"}; - } - - foreach $i (@ifaces) - { - foreach $j (keys (%fn)) - { - $ {$dist_attrib{"fn"}}{$j} = &gst_parse_expand ($fn{$j}, "iface", $i); - } - - $iface = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - &gst_network_interface_ensure_broadcast_and_network ($iface); - $$iface{"file"} = $i if ($$iface{"file"} eq undef); - - $dev = $$iface{"dev"}; - delete $$iface{"dev"}; - - if (exists $$hash{$dev}) - { - $$hash{$dev}{"configuration"} = $iface; - } - elsif (($dev eq "ppp0") || ($dev eq "tun0")) - { - $modem_settings = $iface; - } - } - - # only show PPP and ISDN devices if pppd exists - # and they aren't configured yet - $dev = "ppp0" if ($$tool{"system"} eq "Linux"); - $dev = "tun0" if ($$tool{"system"} eq "FreeBSD"); - - if (!exists $$hash{$dev} && &gst_file_locate_tool ("pppd")) - { - $$hash{$dev}{"dev"} = $dev; - $$hash{$dev}{"enabled"} = 0; - $$hash{$dev}{"type"} = &gst_network_get_interface_type ($dev); - $$hash{$dev}{"configuration"} = $modem_settings if ($modem_settings); - } - - return \%$hash; -} - -sub gst_network_conf_get -{ - my %dist_attrib; - my $hash; - - %dist_attrib = &gst_network_get_parse_table (); - - $hash = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - return $hash; -} - -sub gst_network_rh_get_smb_desc -{ - my ($file, $section, $var, $hostname) = @_; - my $val; - - $val = &gst_parse_ini ($file, $section, $var); - if (($val =~ /^Samba Server/) && ($hostname ne undef)) - { - return $hostname; - } - - return $val; -} - -sub gst_network_rh62_get_file -{ - my ($iface) = @_; - my ($pre, $i, $dev); - - $dev = $$iface{"dev"}; - $pre = "$gst_prefix/etc/sysconfig/network-scripts/ifcfg-"; - - return $dev if ! -e "$pre$dev"; - - $dev =~ s/[0-9]*$//; - - $i = 0; - $i ++ while (-e "$pre$dev$i"); - - return "$dev$i"; -} - -sub gst_network_rh72_get_file -{ - my ($iface) = @_; - my ($pre, $i, $dev); - - $dev = $$iface{"dev"}; - $pre = "$gst_prefix/etc/sysconfig/networking/devices/ifcfg-"; - - return $dev if ! -e "$pre$dev"; - - $i = 0; - $i ++ while (-e "$pre$dev.$i"); - - return "$dev.$i"; -} - -sub gst_network_deb22_get_file -{ - my ($iface) = @_; - - return $$iface{"dev"}; -} - -sub gst_network_suse70_get_file -{ - my ($i, $file); - - $file = "$gst_prefix/etc/rc.config"; - - $i = 0; - $i ++ while (&gst_parse_sh ($file, "NETDEV_$i") ne ""); - - return $i; -} - -sub gst_network_pld10_get_file -{ - my ($iface) = @_; - my ($pre, $i, $dev); - - $dev = $$iface{"dev"}; - $pre = "$gst_prefix/etc/sysconfig/interfaces/ifcfg-"; - - return $dev if ! -e "$pre$dev"; - - $dev =~ s/[0-9]*$//; - - $i = 0; - $i ++ while (-e "$pre$dev$i"); - - return "$dev$i"; -} - -sub gst_network_get_file -{ - my ($iface) = @_; - my $proc; - - my %dist_map = - ( - "redhat-6.0" => \&gst_network_rh62_get_file, - "redhat-6.1" => \&gst_network_rh62_get_file, - "redhat-6.2" => \&gst_network_rh62_get_file, - "redhat-7.0" => \&gst_network_rh62_get_file, - "redhat-7.1" => \&gst_network_rh62_get_file, - "redhat-7.2" => \&gst_network_rh72_get_file, - "redhat-8.0" => \&gst_network_rh72_get_file, - "redhat-9" => \&gst_network_rh72_get_file, - "openna-1.0" => \&gst_network_rh62_get_file, - "mandrake-7.2" => \&gst_network_rh62_get_file, - "mandrake-7.1" => \&gst_network_rh62_get_file, - "mandrake-9.0" => \&gst_network_rh62_get_file, - "mandrake-9.1" => \&gst_network_rh62_get_file, - "mandrake-9.2" => \&gst_network_rh62_get_file, - "mandrake-10.0" => \&gst_network_rh62_get_file, - "mandrake-10.1" => \&gst_network_rh62_get_file, - "mandrake-10.2" => \&gst_network_rh62_get_file, - "mandriva-2006.0" => \&gst_network_rh62_get_file, - "mandriva-2006.1" => \&gst_network_rh62_get_file, - "yoper-2.2" => \&gst_network_rh62_get_file, - "blackpanther-4.0" => \&gst_network_rh62_get_file, - "conectiva-9" => \&gst_network_rh62_get_file, - "conectiva-10" => \&gst_network_rh62_get_file, - "debian-2.2" => \&gst_network_deb22_get_file, - "debian-3.0" => \&gst_network_deb22_get_file, - "debian-sarge" => \&gst_network_deb22_get_file, - "ubuntu-5.04" => \&gst_network_deb22_get_file, - "ubuntu-5.10" => \&gst_network_deb22_get_file, - "ubuntu-6.04" => \&gst_network_deb22_get_file, - "suse-7.0" => \&gst_network_suse70_get_file, - "suse-9.0" => \&gst_network_deb22_get_file, - "suse-9.1" => \&gst_network_deb22_get_file, - "turbolinux-7.0" => \&gst_network_rh62_get_file, - "pld-1.0" => \&gst_network_pld10_get_file, - "pld-1.1" => \&gst_network_pld10_get_file, - "pld-1.99" => \&gst_network_pld10_get_file, - "fedora-1" => \&gst_network_rh72_get_file, - "fedora-2" => \&gst_network_rh72_get_file, - "fedora-3" => \&gst_network_rh72_get_file, - "fedora-4" => \&gst_network_rh72_get_file, - "rpath" => \&gst_network_rh72_get_file, - "vine-3.0" => \&gst_network_rh62_get_file, - "vine-3.1" => \&gst_network_rh62_get_file, - "ark" => \&gst_network_rh62_get_file, - "slackware-9.1.0" => \&gst_network_deb22_get_file, - "slackware-10.0.0" => \&gst_network_deb22_get_file, - "slackware-10.1.0" => \&gst_network_deb22_get_file, - "slackware-10.2.0" => \&gst_network_deb22_get_file, - "gentoo" => \&gst_network_deb22_get_file, - "freebsd-5" => \&gst_network_deb22_get_file, - "freebsd-6" => \&gst_network_deb22_get_file, - ); - - $proc = $dist_map{$gst_dist}; - - return &$proc ($iface) if $proc; - - # FIXME: should make us bail. - &gst_debug_print_string ("\n\nWarning: No network_get_file proc for dist $gst_dist.\n\n"); - return undef; -} - -sub gst_network_get_gateway_data -{ - my ($fd, $gateway, $dev); - - $fd = &gst_file_run_pipe_read ("route -n"); - while (<$fd>) - { - if (/^0\.0\.0\.0[\t ]+([^\t ]+).*[ \t]([a-zA-Z0-9]*)/) - { - $gateway = $1; - $dev = $2; - last; - } - } - - &gst_file_close ($fd); - return ($gateway, $dev); -} - -sub gst_network_get_default_gatewaydev -{ - my ($gateway, $dev) = &gst_network_get_gateway_data (); - - return $dev; -} - -sub gst_network_get_default_gateway -{ - my ($gateway, $dev) = &gst_network_get_gateway_data (); - - return $gateway; -} - -sub gst_network_route_set_default_gw -{ - my ($gatewaydev, $gateway) = @_; - my ($tool_route, $curr_gateway, $curr_gatewaydev, $fd); - - # Just in case. This means that no static gateway is needed. - return if $gateway eq ""; - - $fd = &gst_file_run_pipe_read ("route -n"); - while (<$fd>) - { - if (/^0\.0\.0\.0[ \t]+([0-9.]+) /) - { - $curr_gateway = $1; - if ($gatewaydev ne "") - { - /([a-z0-9]+)$/; - $curr_gatewaydev = $1; - } - - last; - } - } - &gst_file_close ($fd); - - if (($curr_gateway ne $gateway) || - ($curr_gatewaydev ne $gatewaydev)) - { - &gst_file_run ("route del default gw $curr_gateway"); - &gst_file_run ("route add default gw $gateway $gatewaydev"); - } -} - -sub gst_network_run_hostname -{ - my ($hostname) = @_; - - &gst_report_enter (); - &gst_report ("network_hostname_set", $hostname); - &gst_file_run ("hostname $hostname"); - &gst_report_leave (); -} - -sub gst_network_dialing_get_section_name -{ - my ($dial) = @_; - - my %type2title = - ( - "dialer" => "Dialer ", - "modem" => "Modem ", - "unknown" => "" - ); - - return $type2title{$$dial{"type"}} . $$dial{"name"}; -} - -sub gst_network_dialing_set -{ - my ($file, $old_hash, $values_hash) = @_; - my %vars = - ( - "inherits" => "Inherits", - "device" => "Modem", - "speed" => "Baud", - "init1" => "Init1", - "init2" => "Init2", - "phone" => "Phone", - "login" => "Username", - "password" => "Password", - "dialcmd" => "Dial Command", - "setvol" => "SetVolume", - "stupid" => "Stupid mode", - "persist" => "Auto Reconnect", - "address" => "Force Address", - "update_dns" => "Auto DNS", - "set_default_gw" => "Check Def Route", - "gst_dev" => "GST Device", - "dial_command" => "Dial Command" - ); - - my (%hash, $section); - my $ret; - my ($i, $j); - - &gst_report_enter (); - &gst_report ("network_dialing_set"); - &gst_file_run ("wvdialconf $gst_prefix/$file") if (!-e "$gst_prefix/$file"); - - # Remove those that are in old, but not in values. - $old_hash = $$old_hash{"dialing"}; - OUTER: foreach $i (keys %$old_hash) - { - foreach $j (keys %$values_hash) - { - next OUTER if ($j eq $i) && ($ {$$values_hash{$j}}{"type"} eq $ {$$old_hash{$i}}{"type"}); - } - - $section = gst_network_dialing_get_section_name ($$old_hash{$i}); - $ret = -1 if &gst_replace_remove_ini_section ($file, $section); - } - - # Now save the current stuff. - foreach $i (keys %$values_hash) - { - %hash = %{$$values_hash{$i}}; - - $section = gst_network_dialing_get_section_name (\%hash); - delete $hash{"type"}; - delete $hash{"name"}; - - # if init1 doesnt exist add one with ATZ - if (!$hash{"init1"}) - { - $hash{"init1"} = "ATZ"; - } - - # add the volume settings to init2 - if ($hash{"init2"} !~ /^(AT)/) - { - $hash{"init2"} = "AT"; - } - $hash {"init2"} =~ s/L[1-3]//; - $hash {"init2"} =~ s/M[0-2]//; - if ($hash{"volume"} == 0) - { - $hash{"init2"} .= "M0"; - } - else - { - $volume = $hash{"volume"}; - $hash {"init2"} .= "L$volume"; - } - delete $hash {"volume"}; - - # join again the "external_line" and "phone" tags - if ($hash{"external_line"} ne undef) - { - $hash{"phone"} = $hash{"external_line"} . "W" . $hash{"phone"}; - delete $hash{"external_line"}; - } - - foreach $j (keys %hash) - { - $ret = -1 if &gst_replace_ini ($file, $section, $vars{$j}, $hash{$j}); - } - } - - &gst_report_leave (); - - chmod (0600, $file) if !$ret; - - return $ret; -} - -# This works for all systems that have ifup/ifdown scripts. -sub gst_network_rh62_interface_activate_by_dev -{ - my ($dev, $enabled) = @_; - - &gst_report_enter (); - - if ($enabled) - { - &gst_report ("network_iface_activate", $dev); - return -1 if &gst_file_run ("ifup $dev"); - } - else - { - &gst_report ("network_iface_deactivate", $dev); - return -1 if &gst_file_run ("ifdown $dev"); - } - - &gst_report_leave (); - - return 0; -} - -sub gst_network_rh62_interface_activate -{ - my ($hash, $old_hash, $enabled, $force) = @_; - my $dev; - - if ($force || &gst_network_interface_changed ($hash, $old_hash)) - { - if (exists $$hash{"configuration"}{"file"}) - { - $dev = $$hash{"configuration"}{"file"}; - } - else - { - $dev = $$hash{"dev"}; - } - - &gst_network_rh62_interface_activate_by_dev ($dev, $enabled); - } -} - -sub gst_network_suse9_interface_activate -{ - my ($hash, $old_hash, $enabled, $force) = @_; - my ($iface, $dev); - - if ($force || &gst_network_interface_changed ($hash, $old_hash)) - { - if (exists $$hash{"configuration"}{"file"}) - { - $iface = $$hash{"configuration"}{"file"}; - $dev = &gst_network_suse9_get_dev_name ($iface); - } - else - { - $dev = $$hash{"dev"}; - } - - &gst_network_rh62_interface_activate_by_dev ($dev, $enabled); - } -} - -sub gst_network_suse70_interface_activate_by_dev -{ - my ($dev, $enabled) = @_; - my ($network, @paths); - - @paths = &gst_service_sysv_get_paths (); - $network = $paths[1] . "/network"; - - &gst_report_enter (); - - if ($enabled) - { - &gst_report ("network_iface_deactivate", $hash{"dev"}); - return -1 if &gst_file_run_bg ("$network start $dev"); - } - else - { - &gst_report ("network_iface_activate", $hash{"dev"}); - return -1 if &gst_file_run ("$network stop $dev"); - } - - &gst_report_leave (); - - return 0; -} - -sub gst_network_suse70_interface_activate -{ - my ($hash, $old_hash, $enabled, $force) = @_; - - if ($force || &gst_network_interface_changed ($hash, $old_hash)) - { - &gst_network_rh62_interface_activate_by_dev ($$hash{"dev"}, $enabled); - } -} - -sub gst_network_slackware91_interface_activate_by_dev -{ - my ($dev, $enabled) = @_; - my ($address, $netmask, $gateway); - my ($file) = "/etc/rc.d/rc.inet1.conf"; - my ($ret) = 0; - - &gst_report_enter (); - - if ($enabled) - { - &gst_report ("network_iface_activate", $dev); - - if ($dev =~ /^ppp/) - { - $ret = &gst_file_run ("ppp-go"); - } - else - { - if (&gst_parse_rcinet1conf_bool ($file, $dev, USE_DHCP)) - { - # Use DHCP - $ret = &gst_file_run ("dhclient $dev"); - } - else - { - $address = &gst_parse_rcinet1conf ($file, $dev, "IPADDR"); - $netmask = &gst_parse_rcinet1conf ($file, $dev, "NETMASK"); - $gateway = &gst_network_get_gateway ($file, "GATEWAY", $address, $netmask); - - $ret = &gst_file_run ("ifconfig $dev $address netmask $netmask up"); - - # Add the gateway if necessary - if ($gateway ne undef) - { - &gst_file_run ("route add default gw $gateway"); - } - } - } - } - else - { - &gst_report ("network_iface_deactivate", $dev); - - $ret = &gst_file_run ("ifconfig $dev down") if ($dev =~ /^eth/); - $ret = &gst_file_run ("ppp-off") if ($dev =~ /^ppp/); - } - - &gst_report_leave (); - return -1 if ($ret != 0); - return 0; -} - -sub gst_network_slackware91_interface_activate -{ - my ($hash, $old_hash, $enabled, $force) = @_; - my $dev = $$hash{"configuration"}{"file"}; - - if ($force || &gst_network_interface_changed ($hash, $old_hash)) - { - &gst_network_slackware91_interface_activate_by_dev ($dev, $enabled); - } -} - -sub gst_network_gentoo_interface_activate_by_dev -{ - my ($dev, $enabled) = @_; - my $file = "/etc/init.d/net.$dev"; - my $action = ($enabled == 1)? "start" : "stop"; - - return &gst_file_run ("$file $action"); -} - -sub gst_network_gentoo_interface_activate -{ - my ($hash, $old_hash, $enabled, $force) = @_; - my $dev = $$hash{"configuration"}{"file"}; - - if ($force || &gst_network_interface_changed ($hash, $old_hash)) - { - &gst_network_gentoo_interface_activate_by_dev ($dev, $enabled); - } -} - -sub gst_network_freebsd_interface_activate_by_dev -{ - my ($hash, $enabled) = @_; - my ($dev) = $$hash{"configuration"}{"file"}; - my ($startif) = "/etc/start_if.$dev"; - my ($file) = "/etc/rc.conf"; - my ($command, $dhcp_flags, $defaultroute, $fd); - - if ($enabled) - { - # Run the /etc/start_if.$dev commands - $fd = &gst_file_open_read_from_names ($startif); - - while (<$fd>) - { - `$_`; - } - - &gst_file_close ($fd); - $command = &gst_parse_sh ($file, "ifconfig_$dev"); - - # Bring up the interface - if ($command =~ /DHCP/i) - { - $dhcp_flags = &gst_parse_sh ($file, "dhcp_flags"); - &gst_file_run ("dhclient $dhcp_flags $dev"); - } - else - { - &gst_file_run ("ifconfig $dev $command"); - } - - # Add the default route - $default_route = &gst_parse_sh ($file, "defaultrouter"); - &gst_file_run ("route add default $default_route") if ($default_route !~ /^no$/i); - } - else - { - &gst_file_run ("ifconfig $dev down"); - } -} - -sub gst_network_freebsd_interface_activate -{ - my ($hash, $old_hash, $enabled, $force) =@_; - - if ($force || &gst_network_interface_changed ($hash, $old_hash)) - { - &gst_network_freebsd_interface_activate_by_dev ($hash, $enabled); - } -} - -sub gst_network_remove_pap_entry -{ - my ($file, $login) = @_; - my ($i, $buff); - - &gst_report_enter (); - &gst_report ("network_remove_pap", $file, $login); - - $buff = &gst_file_buffer_load ($file); - - foreach $i (@$buff) - { - $i = "" if ($i =~ /^[ \t]*$login[ \t]/); - } - - &gst_file_buffer_clean ($buff); - &gst_report_leave (); - return &gst_file_buffer_save ($buff, $file); -} - -sub gst_network_rh62_interface_delete -{ - my ($old_hash) = @_; - my $dev = $$old_hash{"configuration"}{"file"}; - my $file = "$gst_prefix/etc/sysconfig/network-scripts/ifcfg-$dev"; - my $login; - - &gst_network_rh62_interface_activate_by_dev ($dev, 0); - - $login = $old_hash{"configuration"}{"login"}; - if ($login ne "") - { - &gst_network_remove_pap_entry ("/etc/ppp/pap-secrets", $login); - &gst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login); - } - - &gst_file_remove ($file); -} - -sub gst_network_rh72_interface_delete -{ - my ($old_hash) = @_; - my ($dev, $login); - - $filedev = $$old_hash{"configuration"}{"file"}; - $dev = $$old_hash{"dev"}; - $login = $$old_hash{"configuration"}{"login"}; - - &gst_network_rh62_interface_activate_by_dev ($filedev, 0); - - if ($login ne "") - { - &gst_network_remove_pap_entry ("/etc/ppp/pap-secrets", $login); - &gst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login); - } - - &gst_file_remove ("$gst_prefix/etc/sysconfig/networking/devices/ifcfg-$filedev"); - &gst_file_remove ("$gst_prefix/etc/sysconfig/networking/profiles/default/ifcfg-$filedev"); - &gst_file_remove ("$gst_prefix/etc/sysconfig/network-scripts/ifcfg-$dev"); - - &gst_file_run ("redhat-config-network-cmd"); -} - -sub gst_network_deb22_interface_delete -{ - my ($old_hash) = @_; - my $dev = $$old_hash{"dev"}; - - &gst_network_rh62_interface_activate_by_dev ($dev, 0); - &gst_replace_interfaces_iface_stanza_delete ("$gst_prefix/etc/network/interfaces", $dev); - - $login = $old_hash{"configuration"}{"login"}; - if ($login ne "") - { - &gst_network_remove_pap_entry ("/etc/ppp/pap-secrets", $login); - &gst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login); - } -} - -sub gst_network_suse70_interface_delete -{ - my ($old_hash) = @_; - my $dev = $$old_hash{"configuration"}{"file"}; - my $file = "$gst_prefix/etc/rc.config"; - my $login; - - &gst_network_suse70_interface_activate_by_dev ($$old_hash{"dev"}, 0); - -# Commented until I know what to do with ppp connections. -# $login = $old_hash{"login"}; -# if ($login ne "") -# { -# &gst_network_remove_pap_entry ("/etc/ppp/pap-secrets", $login); -# &gst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login); -# } - - &gst_replace_sh ($file, "IPADDR_$dev", ""); - &gst_replace_sh ($file, "NETDEV_$dev", ""); - &gst_replace_sh ($file, "IFCONFIG_$dev", ""); -} - -sub gst_network_suse90_interface_delete -{ - my ($old_hash) = @_; - my $file = $$old_hash{"configuration"}{"file"}; - my $provider = &gst_parse_sh ("$gst_prefix/etc/sysconfig/network/ifcfg-$file", PROVIDER); - my $dev = &gst_network_suse9_get_dev_name ($file); - - &gst_network_rh62_interface_activate_by_dev ($dev, 0); - - &gst_file_remove ("$gst_prefix/etc/sysconfig/network/ifroute-$file"); - &gst_file_remove ("$gst_prefix/etc/sysconfig/network/ifcfg-$file"); - &gst_file_remove ("$gst_prefix/etc/sysconfig/network/providers/$provider"); -} - -sub gst_network_pld10_interface_delete -{ - my ($old_hash) = @_; - my $dev = $$old_hash{"configuration"}{"file"}; - my $file = "$gst_prefix/etc/sysconfig/interfaces/ifcfg-$dev"; - my $login; - - &gst_network_rh62_interface_activate_by_dev ($dev, 0); - - $login = $old_hash{"configuration"}{"login"}; - if ($login ne "") - { - &gst_network_remove_pap_entry ("/etc/ppp/pap-secrets", $login); - &gst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login); - } - - &gst_file_remove ($file); -} - -sub gst_network_slackware91_interface_delete -{ - my ($old_hash) = @_; - my $rcinetconf = "$gst_prefix/etc/rc.d/rc.inet1.conf"; - my $rcinet = "$gst_prefix/etc/rc.d/rc.inet1"; - my $pppscript = "$gst_prefix/etc/ppp/pppscript"; - my $dev = $$old_hash {"dev"}; - - # remove ifup/ppp-go at startup if existing - &gst_network_slackware91_set_auto ($rcinet, $dev); - - if ($dev =~ /^eth/) - { - # empty the values - &gst_replace_rcinet1conf ($rcinetconf, $dev, "IPADDR", ""); - &gst_replace_rcinet1conf ($rcinetconf, $dev, "NETMASK", ""); - &gst_replace_rcinet1conf ($rcinetconf, $dev, "USE_DHCP", ""); - &gst_replace_rcinet1conf ($rcinetconf, $dev, "DHCP_HOSTNAME", ""); - } - elsif ($dev =~ /^ppp/) - { - &gst_file_remove ($pppscript); - } -} - -sub gst_network_gentoo_interface_delete -{ - my ($old_hash) = @_; - my ($dev) = $$old_hash {"dev"}; - my ($gateway) = $$old_hash {"configuration"}{"gateway"}; - my ($initfile) = "$gst_prefix/etc/init.d/net.$dev"; - my ($netconf); - - # bring down the interface and remove from init - &gst_service_gentoo_set_status ($initfile, 1, 0); - - if ($dev =~ /^ppp/) - { - $netconf = "/etc/conf.d/net.$dev"; - gst_file_remove ($netconf); - } - else - { - $netconf = "/etc/conf.d/net"; - &gst_replace_sh ($netconf, "config_$dev", ""); - } -} - -sub gst_network_freebsd_interface_delete -{ - my ($old_hash) = @_; - my ($dev) = $$old_hash{"dev"}; - my ($startif) = "/etc/start_if.$dev"; - my ($file) = "/etc/rc.conf"; - my ($pppconf) = "/etc/ppp/ppp.conf"; - my ($buff, $line_no, $end_line_no, $i); - - &gst_file_run ("ifconfig $dev down"); - - if ($dev =~ /^tun[0-9]+/) - { - # Delete the ppp.conf section - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - - $buff = &gst_file_buffer_load ($pppconf); - - $line_no = &gst_parse_pppconf_find_stanza ($buff, $section); - $end_line_no = &gst_parse_pppconf_find_next_stanza ($buff, $line_no + 1); - $end_line_no = scalar @$buff + 1 if ($end_line_no == -1); - $end_line_no--; - - for ($i = $line_no; $i <= $end_line_no; $i++) - { - delete $$buff[$i]; - } - - &gst_file_buffer_clean ($buff); - &gst_file_buffer_save ($buff, $pppconf); - } - - &gst_replace_sh ($file, "ifconfig_$dev", ""); - &gst_file_remove ($startif); -} - -sub gst_network_interface_changed -{ - my ($iface, $iface_old) = @_; - - delete $$iface{"type"}; - delete $$iface_old{"type"}; - return !&gst_util_struct_eq ($iface, $iface_old); -} - -# silly function for leveling the configuration hash -# with the interface hash -sub level_interface_hash -{ - my ($hash) = @_; - my (%config, $i); - - $config = $$hash{"configuration"}; - - foreach $i (keys %$config) - { - $$hash{$i} = $$config{$i}; - } -} - -sub gst_network_interface_set -{ - my ($dev, $values_hash, $old_hash) = @_; - my (%dist_attrib, %fn); - my ($proc, $i, $res); - - &gst_report_enter (); - &gst_report ("network_iface_set", $dev); - %dist_attrib = &gst_network_get_interface_replace_table (); - $proc = $dist_attrib{"iface_set"}; - %fn = %{$dist_attrib{"fn"}}; - - level_interface_hash (\%$values_hash); - level_interface_hash (\%$old_hash); - - foreach $i (keys (%fn)) - { - $ {$dist_attrib{"fn"}}{$i} = &gst_parse_expand ($fn{$i}, "iface", $dev); - } - - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash, $old_hash); - - # if success saving the settings for the interface, set up immediatly. - &$proc ($values_hash, $old_hash, $$values_hash{"enabled"}, 0) if !$res; - - &gst_report_leave (); - - return $res; -} - -sub gst_network_interfaces_set -{ - my ($old_hash, $values_hash) = @_; - my (%dist_attrib, @ifaces, %fn); - my ($value, $proc); - my ($i, $j); - my ($tmp, $res); - my ($delete_proc, $set_proc); - my ($was_active); - - &gst_report_enter (); - &gst_report ("network_ifaces_set"); - - %dist_attrib = &gst_network_get_interface_replace_table (); - $old_hash = $$old_hash{"interface"}; - - $delete_proc = $dist_attrib{"iface_delete"}; - $set_proc = $dist_attrib{"iface_set"}; - - foreach $i (keys %$values_hash) - { - # delete it if it's no longer configured - if (exists $$old_hash{$i}{"configuration"} && - not exists $$values_hash{$i}{"configuration"}) - { - &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); - &$delete_proc ($$old_hash{$i}); - } - elsif (exists $$values_hash{$i}{"configuration"}) - { - if (&gst_network_interface_changed ($$values_hash{$i}, $$old_hash{$i})) - { - $was_active = $$values_hash{$i}{"enabled"}; - - &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 0, 1); - $tmp = &gst_network_interface_set ($i, $$values_hash{$i}, $$old_hash{$i}); - $res = $tmp if !$res; - - if ($was_active == 1) - { - &$set_proc ($$values_hash{$i}, $$old_hash{$i}, 1, 1); - } - } - } - } - - &gst_report_leave (); - return $res; -} - -sub gst_network_conf_set -{ - my $values_hash = $_[0]; - my $old_hash; - my %dist_attrib; - - $old_hash = &gst_network_conf_get (); - - &gst_network_ensure_loopback ($values_hash, $old_hash); - - %dist_attrib = &gst_network_get_replace_table (); - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash, $old_hash); - return $res; -} - -sub gst_network_get_pap_passwd -{ - my ($file, $login) = @_; - my (@arr, $passwd); - - $login = '"?' . $login . '"?'; - &gst_report_enter (); - &gst_report ("network_get_pap_passwd", $login, $file); - $arr = &gst_parse_split_first_array ($file, $login, "[ \t]+", "[ \t]+"); - - $passwd = $$arr[1]; - &gst_report_leave (); - - $passwd =~ s/^\"([^\"]*)\"$/$1/; - - return $passwd; -} - -sub gst_network_set_pap_passwd -{ - my ($file, $login, $passwd) = @_; - my ($line); - - $login = '"' . $login . '"'; - $passwd = '"'. $passwd . '"'; - $line = "* $passwd"; - - return &gst_replace_split ($file, $login, "[ \t]+", $line); -} - -# These functions do not honour the file nor call directives. -sub gst_network_get_ppp_options_re -{ - my ($file, $re) = @_; - my ($fd, @res); - - &gst_report_enter (); - &gst_report ("network_get_ppp_option", &gst_replace_regexp_to_separator ($re), $file); - $fd = &gst_file_open_read_from_names ("$file"); - &gst_report_leave (); - return undef if !$fd; - - while (($_ = &gst_parse_chomp_line_hash_comment ($fd)) != -1) - { - $_ = $$_; - - if (/$re/) - { - return $1; - } - } - - return undef; -} - -sub gst_network_set_ppp_options_re -{ - my ($file, $re, $value) = @_; - my ($buff, $line, $replaced, $ret); - my ($pre_space, $post_comment); - - &gst_report_enter (); - &gst_report ("network_set_ppp_option", &gst_replace_regexp_to_separator ($re), $file); - - $buff = &gst_file_buffer_load ($file); - - foreach $line (@$buff) - { - $pre_space = $post_comment = ""; - chomp $line; - $pre_space = $1 if $line =~ s/^([ \t]+)//; - $post_comment = $1 if $line =~ s/([ \t]*\#.*)//; - - if ($line =~ /$re/) - { - $line = "$value\n"; - $replaced = 1; - last; - } - - $line = $pre_space . $line . $post_comment . "\n"; - } - - push @$buff, "$value\n" if !$replaced; - - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); - return $ret; -} - -sub gst_network_set_ppp_options_connect -{ - my ($file, $value) = @_; - my $ret; - - &gst_report_enter (); - &gst_report ("network_set_ppp_connect", $file); - $ret = &gst_network_set_ppp_options_re ($file, "^connect", "connect \"/usr/sbin/chat -v -f $value\""); - &gst_report_leave (); - return $ret; -} - -sub gst_network_get_ppp_options_unsup -{ - my ($file) = @_; - my ($fd, $line, $res, $re); - my @known_options = ("usepeerdns", "mtu", "mru", "user", "/dev/[^ \t]+", "[0-9]+", - "defaultroute", "debug", "persist", "escape", "crtscts", "connect", - "remotename", "hide-password", "noauth", "noipdefault", "ipparam", "name \".*\""); - - $res = ""; - &gst_report_enter (); - &gst_report ("network_get_ppp_unsup", $file); - $fd = &gst_file_open_read_from_names ("$file"); - &gst_report_leave (); - return undef if !$fd; - - GET_LINE: while (($line = &gst_parse_chomp_line_hash_comment ($fd)) != -1) - { - $_ = $$line; - next if /^[ \t]*$/; - - foreach $re (@known_options) - { - next GET_LINE if /^$re/; - } - - $res .= "$_ "; - } - - chop $res; - - return $res; -} - -sub gst_network_set_ppp_options_unsup -{ - my ($file, $value) = @_; - my ($buff, $line, $re, $ret); - my ($pre_space, $post_comment); - my @known_options = ("usepeerdns", "mtu", "mru", "user", "/dev/[^ \t]+", "[0-9]+", - "defaultroute", "debug", "persist", "escape", "crtscts", "connect", - "remotename", "hide-password", "noauth", "noipdefault", "ipparam", "name \".*\""); - - # The options in the last row are those that are on by default in pppd and we don't handle, - # so we ignore them, as they are set implicitly if not specified. - - &gst_report_enter (); - &gst_report ("network_set_ppp_unsup", $file); - $buff = &gst_file_buffer_load ($file); - - GET_LINE: foreach $line (@$buff) - { - $pre_space = $post_comment = ""; - $pre_space = $1 if $line =~ s/^([ \t]+)//; - $post_comment = $1 if $line =~ s/([ \t]*\#.*)//; - - foreach $re (@known_options) - { - next GET_LINE if $line =~ /^$re/; - } - $line = $pre_space . $post_comment . "\n"; - $line = "" if $line =~ /^[ \t]*$/; - } - - $value =~ s/[ \t]+([^0-9])/\n$1/g; - push @$buff, $value . "\n"; - - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); - return $ret; -} - -sub gst_network_rh62_parse_bootproto -{ - my ($file, $key) = @_; - my %rh62_to_proto_name = - ( - "bootp" => "bootp", - "dhcp" => "dhcp", - "none" => "none" - ); - my $ret; - - $ret = &gst_parse_sh ($file, $key); - - if (!exists $rh62_to_proto_name{$ret}) - { - &gst_report ("network_bootproto_unsup", $file, $ret); - $ret = "none"; - } - return $rh62_to_proto_name{$ret}; -} - -sub gst_network_rh62_replace_bootproto -{ - my ($file, $key, $value) = @_; - my %proto_name_to_rh62 = - ( - "bootp" => "bootp", - "dhcp" => "dhcp", - "none" => "none" - ); - - return &gst_replace_sh ($file, $key, $proto_name_to_rh62{$value}); -} - -sub gst_network_deb22_parse_bootproto -{ - my ($file, $iface) = @_; - my (@stanzas, $stanza, $method, $bootproto); - my %debian_to_proto_name = - ( - "bootp" => "bootp", - "dhcp" => "dhcp", - "loopback" => "none", - "ppp" => "none", - "static" => "none" - ); - - &gst_report_enter (); - @stanzas = &gst_parse_interfaces_stanzas ($file, "iface"); - - foreach $stanza (@stanzas) - { - if (($$stanza[0] eq $iface) && ($$stanza[1] eq "inet")) - { - $method = $$stanza[2]; - last; - } - } - - if (exists $debian_to_proto_name {$method}) - { - $bootproto = $debian_to_proto_name {$method}; - } - else - { - $bootproto = "none"; - &gst_report ("network_bootproto_unsup", $method, $iface); - } - - &gst_report_leave (); - return $bootproto; -} - -sub gst_network_deb22_replace_bootproto -{ - my ($file, $iface, $value) = @_; - my (@stanzas, $stanza, $method, $bootproto); - my %proto_name_to_debian = - ( - "bootp" => "bootp", - "dhcp" => "dhcp", - "loopback" => "loopback", - "ppp" => "ppp", - "none" => "static" - ); - - my %dev_to_method = - ( - "lo" => "loopback", - "ppp" => "ppp", - "ippp" => "ppp" - ); - - foreach $i (keys %dev_to_method) - { - $value = $dev_to_method{$i} if $iface =~ /^$i/; - } - - return &gst_replace_interfaces_stanza_value ($file, $iface, 2, $proto_name_to_debian{$value}); -} - -sub gst_network_slackware91_parse_bootproto -{ - my ($file, $iface) = @_; - - if (&gst_parse_rcinet1conf_bool ($file, $iface, USE_DHCP)) - { - return "dhcp" - } - else - { - return "none"; - } -} - -sub gst_network_slackware91_replace_bootproto -{ - my ($file, $iface, $value) = @_; - - if ($value eq "dhcp") - { - &gst_replace_rcinet1conf ($file, $iface, USE_DHCP, "yes"); - } - else - { - &gst_replace_rcinet1conf ($file, $iface, USE_DHCP); - } -} - -sub gst_network_suse70_parse_bootproto -{ - my ($file, $iface) = @_; - my ($ret); - my %suse70_to_proto_name = - ( - "bootp" => "bootp", - "dhcpclient" => "dhcp" - ); - - $ret = &gst_network_suse70_parse_iface_sh ($file, $iface, "IFCONFIG"); - if (!exists $suse70_to_proto_name {$ret}) - { - &gst_report ("network_bootproto_unsup", $iface, $ret); - return "none"; - } - - return $suse70_to_proto_name {$ret}; -} - -sub gst_network_suse70_replace_bootproto -{ - my ($file, $iface, $value) = @_; - my ($ret, $val); - my %proto_name_to_suse70 = - ( - "bootp" => "bootp", - "dhcp" => "dhcpclient", - "none" => "" - ); - - $val = $proto_name_to_suse70{$value}; - return &gst_network_suse70_replace_iface_sh ($file, $iface, "IFCONFIG", $val); -} - -sub gst_network_pld10_parse_bootproto -{ - my ($file, $key) = @_; - my %pld10_to_proto_name = - ( - "bootp" => "bootp", - "dhcp" => "dhcp", - "pump" => "pump", - "none" => "none" - ); - my $ret; - - $ret = &gst_parse_sh ($file, $key); - - if (!exists $pld10_to_proto_name{$ret}) - { - &gst_report ("network_bootproto_unsup", $file, $ret); - $ret = "none"; - } - return $pld10_to_proto_name{$ret}; -} - -sub gst_network_pld10_replace_bootproto -{ - my ($file, $key, $value) = @_; - my %proto_name_to_pld10 = - ( - "bootp" => "bootp", - "dhcp" => "dhcp", - "pump" => "pump", - "none" => "none" - ); - - return &gst_replace_sh ($file, $key, $proto_name_to_pld10{$value}); -} - -sub gst_network_parse_bootproto -{ - my ($file, $key) = @_; - - return "dhcp" if (&gst_parse_sh ($file, $key) =~ /dhcp/i); - return "bootp" if (&gst_parse_sh ($file, $key) =~ /bootp/i); - return "none"; -} - -sub gst_network_suse90_replace_bootproto -{ - my ($file, $key, $value) = @_; - my %proto_name_to_suse90 = - ( - "dhcp" => "dhcp", - "bootp" => "bootp", - "static" => "none", - ); - - return &gst_replace_sh ($file, $key, $proto_name_to_suse90{$value}); -} - -sub gst_network_gentoo_parse_bootproto -{ - my ($file, $dev) = @_; - - return "dhcp" if (&gst_parse_confd_net ($file, "config_$dev") =~ /dhcp/i); - return "none"; -} - -sub gst_network_gentoo_replace_bootproto -{ - my ($file, $dev, $value) = @_; - - return if ($dev =~ /^ppp/); - - return &gst_replace_confd_net ($file, "config_$dev", "dhcp") if ($value ne "none"); - - # replace with a fake IP address, I know it's a hack - return &gst_replace_confd_net ($file, "config_$dev", "0.0.0.0"); -} - -sub gst_network_freebsd5_replace_bootproto -{ - my ($file, $dev, $value) = @_; - - return &gst_replace_sh ($file, "ifconfig_$dev", "dhcp") if ($value ne "none"); - return &gst_replace_sh ($file, "ifconfig_$dev", ""); -} - -sub gst_network_pump_iface_supported -{ - my ($iface) = @_; - my ($dev); - my @devs = qw(eth wlan plip irlan); - - foreach $dev (@devs) - { - return 1 if $iface =~ /^$dev/; - } - - return 0; -} - -sub gst_network_parse_pppconf -{ - my ($pppconf, $startif, $iface, $key) = @_; - my ($section); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - return undef if ($section eq undef); - - return &gst_parse_pppconf ($pppconf, $section, $key); - } -} - -sub gst_network_parse_pppconf_bool -{ - my ($pppconf, $startif, $iface, $key) = @_; - my ($section); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - return undef if ($section eq undef); - - return &gst_parse_pppconf_bool ($pppconf, $section, $key); - } -} - -sub gst_network_parse_pppconf_re -{ - my ($pppconf, $startif, $iface, $key, $re) = @_; - my ($section); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - return undef if ($section eq undef); - - return &gst_parse_pppconf_re ($pppconf, $section, $key, $re); - } -} - -sub gst_network_replace_pppconf -{ - my ($pppconf, $startif, $iface, $key, $val) = @_; - my ($section); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - &gst_replace_pppconf ($pppconf, $section, $key, $val); - } -} - -sub gst_network_replace_pppconf_bool -{ - my ($pppconf, $startif, $iface, $key, $val) = @_; - my ($section); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - &gst_replace_pppconf_bool ($pppconf, $section, $key, $val); - } -} - -sub gst_network_replace_pppconf_route -{ - my ($pppconf, $startif, $iface, $key, $val) = @_; - my ($section); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - &gst_replace_pppconf_common ($pppconf, $section, $key, - ($val == 1)? "add default HISADDR" : undef); - } -} - -sub gst_network_replace_pppconf_dial_command -{ - my ($pppconf, $startif, $iface, $val) = @_; - my ($section, $dial); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - $dial = &gst_parse_pppconf ($pppconf, $section, "dial"); - $dial =~ s/ATD[TP]/$val/; - - &gst_replace_pppconf ($pppconf, $section, "dial", $dial); - } -} - -sub gst_network_replace_pppconf_volume -{ - my ($pppconf, $startif, $iface, $val) = @_; - my ($section, $dial, $vol, $pre, $post); - - if ($iface =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - $dial = &gst_parse_pppconf ($pppconf, $section, "dial"); - - if ($dial =~ /(.*AT[^ \t]*)([ML][0-3])(.* OK .*)/i) - { - $pre = $1; - $post = $3; - } - elsif ($dial =~ /(.*AT[^ \t]*)( OK .*)/i) - { - $pre = $1; - $post = $2; - } - - if ($val == 0) - { - $vol = "M0"; - } - else - { - $vol = "L$val"; - } - - $dial = $pre . $vol . $post; - &gst_replace_pppconf ($pppconf, $section, "dial", $dial); - } -} - -sub gst_network_get_freebsd5_ppp_persist -{ - my ($startif, $iface) = @_; - my ($val); - - if ($iface =~ /^tun[0-9]+/) - { - $val = &gst_parse_startif ($startif, "ppp[ \t]+\-(auto|ddial)[ \t]+"); - - return 1 if ($val eq "ddial"); - return 0; - } - - return undef; -} - -sub gst_network_pump_get_nodns -{ - my ($file, $iface, $bootproto) = @_; - - return undef if (!&gst_network_pump_iface_supported ($iface)); - - return &gst_parse_pump_get_iface_kw_not ($file, $iface, "nodns"); -} - -sub gst_network_pump_set_nodns -{ - my ($file, $iface, $bootproto, $value) = @_; - - return 0 if $bootproto ne "dhcp"; - return 0 if (!&gst_network_pump_iface_supported ($iface)); - - return &gst_replace_pump_iface_kw_not ($file, $iface, "nodns", $value); -} - -sub gst_network_debian_parse_remote_address -{ - my ($file, $iface) = @_; - my ($str, @tuples, $tuple, @res); - - &gst_report_enter (); - &gst_report ("network_get_remote", $iface); - - @tuples = &gst_parse_interfaces_option_tuple ($file, $iface, "up", 1); - - &gst_report_leave (); - - foreach $tuple (@tuples) - { - @res = $$tuple[1] =~ /[ \t]+pointopoint[ \t]+([^ \t]+)/; - return $res[0] if $res[0]; - } - - return undef; -} - -sub gst_network_debian_replace_remote_address -{ - my ($file, $iface, $value) = @_; - my ($ifconfig, $ret); - - &gst_report_enter (); - &gst_report ("network_set_remote", $iface); - - $ifconfig = &gst_file_locate_tool ("ifconfig"); - - $ret = &gst_replace_interfaces_option_str ($file, $iface, "up", "$ifconfig $iface pointopoint $value"); - &gst_report_leave (); - return $ret; -} - -sub gst_network_debian_woody_get_auto_by_stanza -{ - my ($file, $iface) = @_; - my (@stanzas, $stanza, $i); - - @stanzas = &gst_parse_interfaces_stanzas ($file, "auto"); - - foreach $stanza (@stanzas) - { - foreach $i (@$stanza) - { - return $stanza if $i eq $iface; - } - } - - return undef; -} - -sub gst_network_debian_woody_get_auto -{ - my ($file, $iface) = @_; - - return (&gst_network_debian_woody_get_auto_by_stanza ($file, $iface) ne undef)? 1 : 0; -} - -sub gst_network_debian_woody_set_auto -{ - my ($file, $iface, $value) = @_; - my ($buff, $line_no, $found); - - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); - $line_no = 0; - - while (($found = &gst_replace_interfaces_get_next_stanza ($buff, \$line_no, "auto")) != -1) - { - if ($value) - { - if ($$buff[$line_no] =~ /[ \t]$iface([\# \t\n])/) - { - return &gst_file_buffer_save ($buff, $file); - } - } - else - { - # I'm including the hash here, although the man page says it's not supported. - last if $$buff[$line_no] =~ s/[ \t]$iface([\# \t\n])/$1/; - } - - $line_no ++; - } - - if ($found == -1) - { - if ($value) - { - &gst_replace_interfaces_auto_stanza_create ($buff, $iface); - } - } - else - { - if ($value) - { - chomp $$buff[$line_no]; - $$buff[$line_no] .= " $iface\n"; - } - $$buff[$line_no] =~ s/auto[ \t]*$//; - } - - return &gst_file_buffer_save ($buff, $file); -} - -# looks for eth_up $eth_iface_number -sub gst_network_slackware91_get_auto -{ - my ($file, $rclocal, $iface) = @_; - my ($search) = 0; - my ($buff); - - if ($iface =~ /^eth/) - { - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); - - $iface =~ s/eth//; - - foreach $i (@$buff) - { - if ($i =~ /^[ \t]*'start'\)/) - { - $search = 1; - } - elsif (($i =~ /^[ \t]*;;/) && ($search == 1)) - { - return 0; - } - elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1)) - { - return 1 if ($1 == $iface); - } - } - - return 0; - } - elsif ($iface =~ /^ppp/) - { - return &gst_parse_kw ($rclocal, "ppp-go"); - } -} - -# adds or deletes eth_up $eth_iface_number -sub gst_network_slackware91_set_auto -{ - my ($file, $rclocal, $iface, $active) = @_; - my ($search) = 0; - my ($nline) = 0; - my ($buff, $sline); - - if ($iface =~ /^eth/) - { - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); - - $iface =~ s/eth//; - - foreach $i (@$buff) - { - if ($i =~ /^[ \t]*('start'\)|\*\))/) - { - # if the line is 'start') or *), begin the search - $search = 1; - } - elsif (($i =~ /^[ \t]*gateway_up/) && ($search == 1)) - { - # save the line in which we're going to save the eth_up stuff - $sline = $nline; - } - elsif (($i =~ /^[ \t]*(;;|esac)/) && ($search == 1)) - { - # we've arrived to the end of the case, if we wanted to - # add the iface, now it's the moment - $$buff[$sline] = "\teth_up $iface\n" . $$buff[$sline] if ($active == 1); - $search = 0; - } - elsif (($i =~ /^[ \t]*eth_up (\S+)/) && ($search == 1)) - { - if ($1 == $iface) - { - delete $$buff[$nline] if ($active == 0); - $search = 0; - } - } - - $nline++; - } - - return &gst_file_buffer_save ($buff, $file); - } - elsif ($iface =~ /^ppp/) - { - return &gst_replace_kw ($rclocal, "ppp-go", $active); - } -} - -# finds out if a interface is active at boot time -sub gst_network_freebsd5_get_auto -{ - my ($file, $defaults_file, $iface) = @_; - my ($val); - - $val = &gst_parse_sh ($file, "network_interfaces"); - $val = &gst_parse_sh ($defaults_file, "network_interfaces") if ($val eq undef); - - return 1 if ($val eq "auto"); - return 1 if ($val =~ /$iface/); - return 0; -} - -sub gst_network_freebsd5_set_auto -{ - my ($file, $iface, $active) = @_; - my ($val); - - $val = &gst_parse_sh ($file, "network_interfaces"); - $val = &gst_file_run_backtick ("ifconfig -l") if ($val =~ /auto/); - $val .= " "; - - if ($active && ($val !~ /$iface /)) - { - $val .= $iface; - } - elsif (!$active && ($val =~ /$iface /)) - { - $val =~ s/$iface //; - } - - # Trim the string - $val =~ s/^[ \t]*//; - $val =~ s/[ \t]*$//; - - &gst_replace_sh ($file, "network_interfaces", $val); -} - -sub gst_network_suse90_get_auto -{ - my ($file, $key) = @_; - my ($ret); - - $ret = &gst_parse_sh ($file, $key); - - return 1 if ($ret =~ /^onboot$/i); - return 0; -} - -sub gst_network_suse90_set_auto -{ - my ($file, $key, $enabled) = @_; - my ($ret); - - if($enabled) - { - return &gst_replace_sh($file, $key, "onboot"); - } - else - { - return &gst_replace_sh($file, $key, "manual"); - } -} - -# Return IP address or netmask, depending on $what -sub gst_network_pld10_get_ipaddr -{ - my ($file, $key, $what) = @_; - my ($ipaddr, $netmask, $ret, $i); - my @netmask_prefixes = (0, 128, 192, 224, 240, 248, 252, 254, 255); - - $ipaddr = &gst_parse_sh($file, $key); - return undef if $ipaddr eq ""; - - if($ipaddr =~ /([^\/]*)\/([[:digit:]]*)/) - { - $netmask = $2; - return undef if $netmask eq ""; - - if($what eq "address") - { - return $1; - } - - for($i = 0; $i < int($netmask/8); $i++) - { - $ret .= "255."; - } - - $ret .= "$netmask_prefixes[$b%8]." if $netmask < 32; - - for($i = int($netmask/8) + 1; $i < 4; $i++) - { - $ret .= "0."; - } - - chop($ret); - return $ret; - } - return undef; -} - -# Writes IP address or netmask, depending in $what, to $file -sub gst_network_pld10_set_ipaddr -{ - my ($file, $key, $what, $value) = @_; - my %prefixes = - ( - "0" => 0, - "128" => 1, - "192" => 2, - "224" => 3, - "240" => 4, - "248" => 5, - "252" => 6, - "254" => 7, - "255" => 8 - ); - my ($ipaddr, $netmask); - - $ipaddr = &gst_parse_sh($file, $key); - return undef if $ipaddr eq ""; - - if($what eq "address") - { - $ipaddr =~ s/.*\//$value\//; - } - else - { - if($value =~ /([[:digit:]]*).([[:digit:]]*).([[:digit:]]*).([[:digit:]]*)/) - { - $netmask = $prefixes{$1} + $prefixes{$2} + $prefixes{$3} + $prefixes{$4}; - $ipaddr =~ s/\/[[:digit:]]*/\/$netmask/; - } - } - - return &gst_replace_sh($file, $key, $ipaddr); -} - -# FIXME: this function isn't IPv6-aware -# it checks if a IP address is in the same network than another -sub gst_network_is_ip_in_same_network -{ - my ($address1, $address2, $netmask) = @_; - my (@add1, @add2, @mask); - my ($i); - - return 0 if (($address1 eq undef) || - ($address2 eq undef) || - ($netmask eq undef)); - - @add1 = split (/\./, $address1); - @add2 = split (/\./, $address2); - @mask = split (/\./, $netmask); - - for ($i = 0; $i < 4; $i++) - { - $add1[$i] += 0; - $add2[$i] += 0; - $mask[$i] += 0; - - return 0 if (($add1[$i] & $mask[$i]) != ($add2[$i] & $mask[$i])); - } - - return 1; -} - -# function that gets a gateway device from the gateway address -sub gst_network_get_gateway_dev_from_address -{ - my ($interface, $gateway) = @_; - my ($address, $netmask, $key); - - foreach $key (keys %$interface) - { - $address = $$interface{$key}{"address"}; - $netmask = $$interface{$key}{"netmask"}; - - return $$interface{$key}{"dev"} if (&gst_network_is_ip_in_same_network ($address, $gateway, $netmask)); - } - - return undef; -} - -sub gst_network_get_plip_gateway -{ - my ($file, $key, $remote_address) = @_; - my ($gateway); - - $gateway = &gst_parse_sh ($file, $key); - - return $gateway if ($gateway eq $remote_address); -} - -sub gst_network_get_gateway -{ - my ($file, $key, $address, $netmask) = @_; - my ($gateway); - - return undef if ($address eq undef); - - $gateway = &gst_parse_sh ($file, $key); - - return $gateway if &gst_network_is_ip_in_same_network ($address, $gateway, $netmask); - return undef; -} - -sub gst_network_suse90_get_gateway -{ - my ($file, $address, $netmask) = @_; - my ($gateway) = &gst_parse_split_first_array_pos ($file, "default", 0, "[ \t]+", "[ \t]+"); - - return $gateway if &gst_network_is_ip_in_same_network ($address, $gateway, $netmask); - return undef; -} - -sub gst_network_suse90_get_plip_gateway -{ - my ($file, $remote_address) = @_; - my ($gateway) = &gst_parse_split_first_array_pos ($file, "default", 0, "[ \t]+", "[ \t]+"); - - return $gateway if ($gateway eq $remote_address); - return undef; -} - -sub gst_network_suse90_replace_gateway -{ - my ($file, $dev, $address, $netmask, $value) = @_; - - - return &gst_replace_split ($file, "default", "[ \t]+", "$value \- $dev") if &gst_network_is_ip_in_same_network ($address, $value, $netmask); -# return &gst_replace_split ($file, "default", "[ \t]+", "$value \- $dev") ; - return undef; - -} - - -# runs a function if the interface is of type $type -sub gst_network_check_type -{ - my ($iface) = shift @_; - my ($type) = shift @_; - my ($func) = shift @_; - my ($t); - - $t = &gst_network_get_interface_type ($iface); - - if ($t =~ "^$type") - { - &$func (@_); - } -} - -# creates files neccesary for gentoo ifaces -sub gst_network_gentoo_create_files -{ - my ($dev) = @_; - my ($init) = "/etc/init.d/net.$dev"; - my ($conf) = "/etc/conf.d/net.$dev"; - my ($backup) = "/etc/conf.d/net.ppp0.gstbackup"; - - if ($dev =~ /ppp/) - { - &gst_file_copy ("/etc/init.d/net.ppp0", $init) if (!&gst_file_exists ($init)); - - # backup the ppp config file - &gst_file_copy ("/etc/conf.d/net.ppp0", $backup) if (!&gst_file_exists ($backup)); - &gst_file_copy ($backup, $conf) if (!&gst_file_exists ($conf)); - } - else - { - &gst_file_copy ("/etc/init.d/net.eth0", $init) if (!&gst_file_exists ($init)); - } - - chmod 0755, "$gst_prefix/$init"; -} - -# we need this function because essid can be multiword, and thus it can't be in rc.conf -sub gst_network_freebsd5_replace_essid -{ - my ($file, $startif, $iface, $essid) = @_; - - if ($essid =~ /[ \t]/) - { - # It's multiword - &gst_file_buffer_save ("ifconfig $iface ssid \"$essid\"", $startif); - &gst_replace_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", ""); - } - else - { - &gst_replace_sh_re ($file, "ifconfig_$iface", "ssid[ \t]+([^ \t]*)", " ssid $essid"); - } -} - -sub gst_network_freebsd_create_ppp_startif -{ - my ($startif, $iface, $dev, $persist) = @_; - my ($section); - - if ($dev =~ /^tun[0-9]+/) - { - $section = &gst_parse_startif ($startif, "ppp[ \t]+\-[^ \t]+[ \t]+([^ \t]+)"); - $section = $dev if ($section eq undef); - - return &gst_file_buffer_save ("ppp -ddial $section", $startif) if ($persist eq 1); - return &gst_file_buffer_save ("ppp -auto $section", $startif); - } -} - -# Functions for parsing provider file in suse 9.X -sub gst_network_suse90_parse_provider_file_func -{ - my ($provider, $key, $func) = @_; - my ($path) = "/etc/sysconfig/network/providers/"; - - return &$func ("$path/$provider", $key); -} - -sub gst_network_suse90_parse_provider_file -{ - my ($provider, $key) = @_; - return &gst_network_suse90_parse_provider_file_func ($provider, $key, \&gst_parse_sh); -} - -sub gst_network_suse90_parse_provider_file_bool -{ - my ($provider, $key) = @_; - return &gst_network_suse90_parse_provider_file_func ($provider, $key, \&gst_parse_sh_bool); -} - -# Functions for replacing in provider file in SuSE 9.X -sub gst_network_suse90_replace_provider_file_func -{ - my ($provider, $key, $value, $func) = @_; - my ($path) = "/etc/sysconfig/network/providers/"; - - return &$func ("$path/$provider", $key, $value); -} - -sub gst_network_suse90_replace_provider_file -{ - my ($provider, $key, $value) = @_; - #make sure the function is called only by modem - if ($provider =~ /ppp/) - { - return &gst_network_suse90_replace_provider_file_func ($provider, $key, $value, \&gst_replace_sh); - } -} - -sub gst_network_suse90_replace_provider_file_bool -{ - my ($provider, $key, $value) = @_; - #make sure the function is called only by modem - if ($provider =~ /ppp/) - { - return &gst_network_suse90_replace_provider_file_func ($provider, $key, $value, \&gst_replace_sh_bool); - } -} - -sub gst_network_suse9_get_dev_name -{ - my ($iface) = @_; - my ($ifaces, $dev, $hwaddr, $d); - my ($dev); - - $dev = &gst_parse_sh ("/var/run/sysconfig/if-$iface", "interface"); - - if ($dev eq undef) - { - $fd = &gst_file_run_backtick ("getcfg-interface $iface"); - } - - if ($dev eq undef) - { - # Those are the last cases, we make rough guesses - if ($iface =~ /-pcmcia-/) - { - # it's something like wlan-pcmcia-0 - $dev =~ s/-pcmcia-//; - } - elsif ($iface =~ /-id-([a-fA-F0-9\:]*)/) - { - # it's something like eth-id-xx:xx:xx:xx:xx:xx, which is the NIC MAC - $hwaddr = $1; - $ifaces = &gst_network_interfaces_get_info (); - - foreach $d (keys %$ifaces) - { - if ($hwaddr eq $$ifaces{$d}{"hwaddr"}) - { - $dev = $d; - last; - } - } - } - } - - if ($dev eq undef) - { - # We give up, take $iface as $dev - $dev = $iface; - } - - return $dev; -} - -sub gst_network_detect_essids -{ - my ($iface) = @_; - my ($fd, @arr, $encrypted); - - # some wireless cards need to be up before scanning - &gst_file_run ("ifconfig $iface up"); - $fd = &gst_file_run_pipe_read ("iwlist $iface scanning"); - return undef if (!$fd); - - while (<$fd>) - { - if (/^[ \t]*Encryption key:([^ \t\n]+)/) - { - $encrypted = ($1 eq "off") ? 0 : 1; - } - elsif (/^[ \t]*ESSID\:"(.+)"/) - { - push @arr, {"essid" => $1, - "encrypted" => $encrypted }; - } - } - - return \@arr; -} - -sub gst_network_get_wep_key_type -{ - my ($func) = shift @_; - my ($val); - - $val = &$func (@_); - - return undef if (!$val); - return "ascii" if ($val =~ /^s\:/); - return "hexadecimal"; -} - -sub gst_network_get_wep_key -{ - my ($func) = shift @_; - my ($val); - - $val = &$func (@_); - $val =~ s/^s\://; - - return $val; -} - -sub gst_network_get_full_key -{ - my ($key, $key_type) = @_; - - if ($key_type eq "ascii") - { - $key = "s:" . $key; - } - - return $key; -} - -sub gst_network_set_wep_key_type -{ - my ($key, $key_type, $func); - - # seems kind of hackish, but we want to use distro - # specific saving functions, so we need to leave - # the args as variable as possible - $func = shift @_; - $key_type = pop @_; - $key = pop @_; - - push @_, &gst_network_get_full_key ($key, $key_type); - &$func (@_); -} - -# Set dist_map for your distro to "" if you don't want -# loopback ensuring. See suse-7.0 entry for example. -sub gst_network_ensure_loopback_interface -{ - my ($interface) = @_; - my $dev; - my %dist_map = - ( - "redhat-5.2" => "lo", - "redhat-6.0" => "lo", - "redhat-6.1" => "lo", - "redhat-6.2" => "lo", - "redhat-7.0" => "lo", - "redhat-7.1" => "lo", - "redhat-7.2" => "lo", - "redhat-8.0" => "lo", - "redhat-9" => "", - "openna-1.0" => "lo", - "mandrake-7.1" => "lo", - "mandrake-7.2" => "lo", - "mandrake-9.0" => "lo", - "mandrake-9.1" => "lo", - "mandrake-9.2" => "lo", - "mandrake-10.0" => "lo", - "mandrake-10.1" => "lo", - "mandrake-10.2" => "lo", - "mandriva-2006.0" => "lo", - "mandriva-2006.1" => "lo", - "yoper-2.2" => "lo", - "blackpanther-4.0" => "lo", - "conectiva-9" => "lo", - "conectiva-10" => "lo", - "debian-2.2" => "lo", - "debian-3.0" => "lo", - "debian-sarge" => "lo", - "ubuntu-5.04" => "lo", - "ubuntu-5.10" => "lo", - "ubuntu-6.04" => "lo", - "suse-7.0" => "", - "suse-9.0" => "", - "suse-9.1" => "", - "turbolinux-7.0" => "lo", - "pld-1.0" => "lo", - "pld-1.1" => "lo", - "pld-1.99" => "lo", - "fedora-1" => "", - "fedora-2" => "", - "fedora-3" => "", - "fedora-4" => "", - "rpath" => "", - "vine-3.0" => "lo", - "vine-3.1" => "lo", - "ark" => "lo", - "slackware-9.1.0" => "", - "slackware-10.0.0" => "", - "slackware-10.1.0" => "", - "slackware-10.2.0" => "", - "gentoo" => "", - "vlos-1.2" => "", - "freebsd-5" => "", - "freebsd-6" => "", - ); - - $dev = $dist_map {$gst_dist}; - - return if $dev eq ""; - - if (!exists $$interface{$dev}) - { - my %iface = ( - "auto" => 1, - "user" => 0, - "dev" => "lo", - "address" => "127.0.0.1", - "netmask" => "255.0.0.0", - "broadcast" => "127.255.255.255", - "network" => "127.0.0.0", - "bootproto" => "none", - "enabled" => 1, - "update_dns" => 0 - ); - - $$interface{$dev} = \%iface; - &gst_network_interface_set ($dev, \%iface); - } - elsif (! $ {$$interface{$dev}}{"enabled"}) - { - $ {$$interface{$dev}}{"enabled"} = 1; - &gst_network_interface_set ($dev, $$interface{$dev}); - } -} - -sub gst_network_statichost_add_alias -{ - my ($localhost, $alias) = @_; - my $i; - - foreach $i (@$localhost) - { - return if ($i eq $alias); - } - - push @$localhost, $alias; -} - -sub gst_network_statichost_remove_alias -{ - my ($localhost, $alias) = @_; - my $i; - - for ($i = 0; $i < @$localhost; $i++) { - if ($$localhost[$i] eq $alias) - { - delete $$localhost[$i]; - return; - } - } -} - -sub gst_network_ensure_loopback_statichost -{ - my ($statichost, $hostname, $old_hostname, $lo_ip) = @_; - my $i; - - if (exists $$statichost{$lo_ip}) - { - my $localhost = $$statichost{$lo_ip}; - &gst_network_statichost_remove_alias ($localhost, $old_hostname) if ($old_hostname); - &gst_network_statichost_add_alias ($localhost, $hostname); - } - else - { - $$statichost{$lo_ip} = [ ("localhost", "localhost.localdomain", $hostname) ]; - } -} - -sub get_network_get_lo_ip -{ - my ($statichost) = @_; - - foreach $i (keys %$statichost) - { - return $i if ($i =~ /^127\./); - } - - return "127.0.0.1"; -} - -sub gst_network_ensure_loopback -{ - my $values_hash = $_[0]; - my $old_values_hash = $_[1]; - my $interface = $$values_hash{"interface"}; - my $hostname = $$values_hash{"hostname"}; - my $statichost = $$values_hash{"statichost"}; - my $lo_ip = &get_network_get_lo_ip ($statichost); - - # needed for replacing hostname safely - my $old_hostname = $$old_values_hash{"hostname"}; - - &gst_report_enter (); - &gst_report ("network_ensure_lo"); - - &gst_network_ensure_loopback_statichost ($statichost, $hostname, $old_hostname, $lo_ip); - &gst_network_ensure_loopback_interface ($interface, $lo_ip); - - &gst_report_leave (); -} - -sub gst_network_get_parse_table -{ - my %dist_map = - ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.0", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-7.2", - "redhat-9" => "redhat-7.2", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "redhat-7.0", - "mandrake-9.1" => "redhat-7.0", - "mandrake-9.2" => "redhat-7.0", - "mandrake-10.0" => "redhat-7.0", - "mandrake-10.1" => "redhat-7.0", - "mandrake-10.2" => "redhat-7.0", - "mandriva-2006.0" => "redhat-7.0", - "mandriva-2006.1" => "redhat-7.0", - "yoper-2.2" => "redhat-7.0", - "blackpanther-4.0" => "redhat-7.0", - "conectiva-9" => "redhat-7.0", - "conectiva-10" => "redhat-7.0", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - "ubuntu-5.10" => "debian-2.2", - "ubuntu-6.04" => "debian-2.2", - "suse-7.0" => "suse-7.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-7.0", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "redhat-7.0", - "vine-3.1" => "redhat-7.0", - "ark" => "redhat-7.0", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_tables = - ( - "redhat-6.2" => - { - fn => - { - SYSCONFIG_NW => "/etc/sysconfig/network", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_parse_sh, SYSCONFIG_NW, HOSTNAME ], - [ "gateway", \&gst_parse_sh, SYSCONFIG_NW, GATEWAY ], - [ "gatewaydev", \&gst_parse_sh, SYSCONFIG_NW, GATEWAYDEV ], - [ "userifacectl", \&gst_parse_trivial, 1 ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "smb" ], - [ "smartdhcpcd", \&gst_file_tool_installed, "pump" ], - [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], - [ "interface", \&gst_network_interfaces_get ] - ] - }, - - "redhat-7.0" => - { - fn => - { - SYSCONFIG_NW => "/etc/sysconfig/network", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_parse_sh, SYSCONFIG_NW, HOSTNAME ], - [ "gateway", \&gst_parse_sh, SYSCONFIG_NW, GATEWAY ], - [ "gatewaydev", \&gst_parse_sh, SYSCONFIG_NW, GATEWAYDEV ], - [ "userifacectl", \&gst_parse_trivial, 1 ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "smb" ], - [ "smartdhcpcd", \&gst_file_tool_installed, "pump" ], - [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], - [ "interface", \&gst_network_interfaces_get ] - ] - }, - - "redhat-7.2" => - { - fn => - { - SYSCONFIG_NW => ["/etc/sysconfig/networking/profiles/default/network", - "/etc/sysconfig/networking/network", - "/etc/sysconfig/network"], - RESOLV_CONF => ["/etc/sysconfig/networking/profiles/default/resolv.conf", - "/etc/resolv.conf"], - HOST_CONF => "/etc/host.conf", - HOSTS => ["/etc/sysconfig/networking/profiles/default/hosts", - "/etc/hosts"], - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf", - }, - table => - [ - [ "hostname", \&gst_parse_sh, SYSCONFIG_NW, HOSTNAME ], - [ "gateway", \&gst_parse_sh, SYSCONFIG_NW, GATEWAY ], - [ "gatewaydev", \&gst_parse_sh, SYSCONFIG_NW, GATEWAYDEV ], - [ "userifacectl", \&gst_parse_trivial, 1 ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "smb" ], - [ "smartdhcpcd", \&gst_file_tool_installed, "pump" ], - [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], - [ "interface", \&gst_network_interfaces_get ] - ] - }, - - "debian-2.2" => - { - fn => - { - OPTIONS => "/etc/network/options", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - HOSTNAME => "/etc/hostname", - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_parse_line_first, HOSTNAME ], - [ "gateway", \&gst_network_get_default_gateway ], - [ "gatewaydev", \&gst_network_get_default_gatewaydev ], -# [ "gwdevunsup", \&gst_parse_trivial, 1 ], -# [ "userifacectl", \&gst_parse_trivial, 0 ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_parse_split_all_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_parse_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "samba" ], - [ "smartdhcpcd", \&gst_file_tool_installed, "pump" ], - [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], - [ "interface", \&gst_network_interfaces_get ] - ] - }, - - "suse-7.0" => - { - fn => - { - RC_CONFIG => "/etc/rc.config", - ROUTE_CONF => "/etc/route.conf", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_parse_sh_get_hostname, RC_CONFIG, FQHOSTNAME ], - [ "gateway", \&gst_parse_split_first_str, ROUTE_CONF, "default", "[ \t]+" ], - [ "gateway", \&gst_parse_split_first_str, ROUTE_CONF, "0.0.0.0", "[ \t]+" ], - [ "gwdevunsup", \&gst_parse_trivial, 1 ], - [ "userifacectl", \&gst_parse_trivial, 0 ], - [ "domain", \&gst_parse_sh_get_domain, RC_CONFIG, FQHOSTNAME ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], -# This was to take the values from SuSEConfig, but a better solution is to get -# the configuration from /etc/resolv.conf and then replace in rc.config, so those -# files stay in sync. -# [ "nameserver", \&gst_parse_sh_split, RC_CONFIG, NAMESERVER, "[ \t]+" ], -# [ "searchdomain", \&gst_parse_sh_split, RC_CONFIG, SEARCHLIST, "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_parse_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "smb" ], - [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], - [ "interface_tmp", \&gst_network_interfaces_get ], - [ "interface", \&gst_network_suse70_get_ppp, "%dialing%", "%interface_tmp%" ], - ] - }, - - "suse-9.0" => - { - fn => - { - ROUTE_CONF => "/etc/sysconfig/network/routes", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - HOSTNAME => "/etc/HOSTNAME", - SMB_CONF => "/etc/samba/smb.conf", - }, - table => - [ - [ "hostname", \&gst_parse_fq_hostname, HOSTNAME ], - [ "domain", \&gst_parse_fq_domain, HOSTNAME ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_get_status, "smb" ], - [ "smbinstalled", \&gst_service_installed, "smb" ], - [ "dialinstalled", \&gst_parse_trivial, 1 ], - [ "interface", \&gst_network_interfaces_get ], - [ "gateway", \&gst_parse_split_first_array_pos, ROUTE_CONF, "default", 0, "[ \t]+", "[ \t]+" ], - [ "gatewaydev", \&gst_network_get_gateway_dev_from_address, "%interface%", "%gateway%" ], - ] - }, - - "pld-1.0" => - { - fn => - { - SYSCONFIG_NW => "/etc/sysconfig/network", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/smb/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_parse_sh, SYSCONFIG_NW, HOSTNAME ], - [ "gateway", \&gst_parse_sh, SYSCONFIG_NW, GATEWAY ], - [ "gatewaydev", \&gst_parse_sh, SYSCONFIG_NW, GATEWAYDEV ], - [ "userifacectl", \&gst_parse_trivial, 1 ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "smb" ], - [ "smartdhcpcd", \&gst_file_tool_installed, "pump" ], - [ "dialinstalled", \&gst_file_tool_installed, "wvdial" ], - [ "interface", \&gst_network_interfaces_get ] - ] - }, - - "slackware-9.1.0" => - { - fn => - { - RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - HOSTNAME => "/etc/HOSTNAME", - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_parse_fq_hostname, HOSTNAME ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "order", \&gst_parse_split_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_parse_split_first_bool, HOST_CONF, "multi", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_installed, "/etc/rc.d/rc.samba" ], - [ "dialinstalled", \&gst_parse_trivial, 1 ], - [ "interface", \&gst_network_interfaces_get ], - [ "gateway", \&gst_parse_sh, RC_INET_CONF, GATEWAY ], - [ "gatewaydev", \&gst_network_get_gateway_dev_from_address, "%interface%", "%gateway%" ], - ] - }, - - "gentoo" => - { - fn => - { - HOSTNAME => "/etc/conf.d/hostname", - DOMAINNAME => "/etc/conf.d/domainname", - NET => "/etc/conf.d/net", - RESOLV_CONF => "/etc/resolv.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/samba/smb.conf" - }, - table => - [ - [ "hostname", \&gst_parse_sh, HOSTNAME, "HOSTNAME" ], - [ "domain", \&gst_parse_sh, DOMAINNAME, "DNSDOMAIN" ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_gentoo_get_status, "samba" ], - [ "smbinstalled", \&gst_service_installed, "samba" ], - [ "dialinstalled", \&gst_parse_trivial, 1 ], - [ "gateway", \&gst_network_get_default_gateway ], - [ "gatewaydev", \&gst_network_get_default_gatewaydev ], - [ "interface", \&gst_network_interfaces_get ], - ] - }, - - "freebsd-5" => - { - fn => - { - RC_CONF => "/etc/rc.conf", - RESOLV_CONF => "/etc/resolv.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/usr/local/etc/smb.conf" - }, - table => - [ - [ "hostname", \&gst_parse_sh_re, RC_CONF, hostname, "^([^\.]*)\." ], - [ "domain", \&gst_parse_split_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_parse_split_all_unique_hash_comment, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_parse_split_first_array_unique, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "statichost", \&gst_parse_split_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_parse_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_network_rh_get_smb_desc, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_parse_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_parse_ini_bool, SMB_CONF, "global", "wins support" ], - [ "dialinstalled", \&gst_parse_trivial, 1 ], - [ "smbinstalled", \&gst_service_installed, "samba" ], - [ "smbuse", \&gst_service_rcng_get_status, "smbd" ], - [ "interface", \&gst_network_interfaces_get ], - [ "gateway", \&gst_parse_sh, RC_CONF, defaultrouter ], - [ "gatewaydev", \&gst_network_get_gateway_dev_from_address, "%interface%", "%gateway%" ], - ] - }, - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_network_get_interface_parse_table -{ - my %dist_map = - ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-8.0", - "redhat-9" => "redhat-8.0", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "mandrake-9.0", - "mandrake-9.1" => "mandrake-9.0", - "mandrake-9.2" => "mandrake-9.0", - "mandrake-10.0" => "mandrake-9.0", - "mandrake-10.1" => "mandrake-9.0", - "mandrake-10.2" => "mandrake-9.0", - "mandriva-2006.0" => "mandrake-9.0", - "mandriva-2006.1" => "mandrake-9.0", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "mandrake-9.0", - "conectiva-9" => "conectiva-9", - "conectiva-10" => "conectiva-9", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - "ubuntu-5.04" => "debian-3.0", - "ubuntu-5.10" => "debian-3.0", - "ubuntu-6.04" => "debian-3.0", - "suse-7.0" => "suse-7.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-6.2", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "vine-3.0", - "vine-3.1" => "vine-3.0", - "ark" => "vine-3.0", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_tables = - ( - "redhat-6.2" => - { - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], - [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MTU ]], - [ "mru", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MRU ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PAPNAME ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, LINESPEED ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, DEFROUTE ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - ] - }, - - "redhat-7.2" => - { - ifaces_get => \&gst_network_sysconfig_rh72_ifaces_get_existing, - fn => - { - IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", - "/etc/sysconfig/networking/devices/ifcfg-#iface#", - "/etc/sysconfig/network-scripts/ifcfg-#iface#"], - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_parse_sh, IFCFG, NAME ], -# [ "name", \&gst_parse_trivial, IFACE ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], - [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_parse_sh, IFCFG, ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, IFCFG, KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, IFCFG, KEY ]], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], - [ "section", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MTU ]], - [ "mru", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MRU ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PAPNAME ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPOPTIONS ], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&gst_parse_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, "%dev%", -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "redhat-8.0" => - { - ifaces_get => \&gst_network_sysconfig_rh72_ifaces_get_existing, - fn => - { - IFCFG => ["/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", - "/etc/sysconfig/networking/devices/ifcfg-#iface#", - "/etc/sysconfig/network-scripts/ifcfg-#iface#"], - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_parse_sh, IFCFG, NAME ], -# [ "name", \&gst_parse_trivial, IFACE ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], - [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_parse_sh, IFCFG, WIRELESS_ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], - [ "section", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MTU ]], - [ "mru", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MRU ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PAPNAME ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPOPTIONS ], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&gst_parse_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, "%dev%", -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "vine-3.0" => - { - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_parse_sh, IFCFG, NAME ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], - [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_parse_sh, IFCFG, ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, IFCFG, KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, IFCFG, KEY ]], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], - [ "section", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MTU ]], - [ "mru", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MRU ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PAPNAME ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPOPTIONS ], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&gst_parse_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "mandrake-9.0" => - { - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_parse_sh, IFCFG, NAME ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], - [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_parse_sh, IFCFG, WIRELESS_ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], - [ "section", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MTU ]], - [ "mru", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MRU ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PAPNAME ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, LINESPEED ]], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPOPTIONS ], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&gst_parse_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "conectiva-9" => - { - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_parse_sh, IFCFG, NAME ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], - [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_parse_sh, IFCFG, WIRELESS_ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], - [ "section", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, WVDIALSECT ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PEERDNS ]], - [ "mtu", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MTU ]], - [ "mru", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MRU ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PAPNAME ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, MODEMPORT ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, LINESPEED ]], - [ "ppp_options", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh, IFCFG, PPPOPTIONS ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, DEFROUTE ]], -# [ "debug", \&gst_parse_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, PERSIST ]], - [ "serial_escapechars", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ]], - [ "serial_hwctl", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ]], - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_parse_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "debian-2.2" => - { - ifaces_get => \&gst_network_debian_ifaces_get_existing, - fn => - { - INTERFACES => "/etc/network/interfaces", - IFACE => "#iface#", - CHAT => "/etc/chatscripts/%section%", - PPP_OPTIONS => "/etc/ppp/peers/%section%", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ -# [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "dev", \&gst_parse_trivial, IFACE ], - [ "bootproto", \&gst_network_deb22_parse_bootproto, [INTERFACES, IFACE]], - [ "auto", \&gst_parse_interfaces_option_kw_not, [INTERFACES, IFACE], "noauto" ], -# [ "name", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "name" ], - [ "address", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "address" ], - [ "netmask", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], - [ "broadcast", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "broadcast" ], - [ "network", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "network" ], - [ "gateway", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], - [ "essid", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "wireless[_-]essid" ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]], - [ "remote_address", \&gst_network_debian_parse_remote_address, [INTERFACES, IFACE]], - [ "section", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "provider" ], - [ "update_dns", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "usepeerdns" ]], - [ "noauth", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "noauth" ]], - [ "mtu", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], - [ "mru", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], - [ "serial_port", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], - [ "serial_speed", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], - [ "login", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^login \"?([^\"]*)\"?" ]], - [ "password", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "ppp_options", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], - [ "set_default_gw", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "defaultroute" ]], - [ "debug", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "debug" ]], - [ "persist", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "persist" ]], - [ "serial_escapechars", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], - [ "serial_hwctl", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "crtscts" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "atd[^0-9]([0-9*#]*)[wW]" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "atd.*[ptwW]([0-9, -]+)" ]], - [ "dial_command", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "(atd[tp])[0-9, -w]+" ]], - [ "volume", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_modem_volume, CHAT ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - ] - }, - - # Basicly the same as debian-2.2, but the "auto" option changes. - "debian-3.0" => - { - ifaces_get => \&gst_network_debian_ifaces_get_existing, - fn => - { - INTERFACES => "/etc/network/interfaces", - IFACE => "#iface#", - CHAT => "/etc/chatscripts/%section%", - PPP_OPTIONS => "/etc/ppp/peers/%section%", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - }, - table => - [ -# [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "dev", \&gst_parse_trivial, IFACE ], - [ "bootproto", \&gst_network_deb22_parse_bootproto, [INTERFACES, IFACE]], - [ "auto", \&gst_network_debian_woody_get_auto, [INTERFACES, IFACE]], -# [ "name", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "name" ], - [ "address", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "address" ], - [ "netmask", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], - [ "broadcast", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "broadcast" ], - [ "network", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "network" ], - [ "gateway", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], - [ "essid", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "wireless[_-]essid" ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_interfaces_option_str, INTERFACES, IFACE, "wireless[_-]key1?" ]], - [ "remote_address", \&gst_network_debian_parse_remote_address, [INTERFACES, IFACE]], - [ "section", \&gst_parse_interfaces_option_str, [INTERFACES, IFACE], "provider" ], - [ "update_dns", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_kw, PPP_OPTIONS, "usepeerdns" ]], - [ "noauth", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_kw, PPP_OPTIONS, "noauth" ]], - [ "mtu", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], - [ "mru", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], - [ "serial_port", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], - [ "serial_speed", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], - [ "login", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^user \"?([^\"]*)\"?" ]], - [ "password", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "ppp_options", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], - [ "set_default_gw", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_kw, PPP_OPTIONS, "defaultroute" ]], - [ "debug", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_kw, PPP_OPTIONS, "debug" ]], - [ "persist", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_parse_kw, PPP_OPTIONS, "persist" ]], - [ "serial_escapechars", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], - [ "serial_hwctl", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "crtscts" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "atd[^0-9]([0-9*#]*)[wW]" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "isdn", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^number[ \t]+(.+)[wW]" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "isdn", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^number.*[wW \t](.*)" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "atd.*[ptwW]([0-9, -]+)" ]], - [ "dial_command", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "(atd[tp])[0-9, -w]+" ]], - [ "volume", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_modem_volume, CHAT ]], -# [ "enabled", \&gst_network_interface_active, IFACE, -# \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - ] - }, - - "suse-7.0" => - { - ifaces_get => \&gst_network_suse70_ifaces_get_existing, - fn => - { - IFCFG => "/etc/rc.config", - IFACE => "#iface#" - }, - table => - [ - [ "bootproto", \&gst_network_suse70_parse_bootproto, [IFCFG, IFACE] ], - [ "auto", \&gst_network_suse70_parse_iface_auto, [IFCFG, IFACE], NETCONFIG ], - [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "name", \&gst_network_suse70_parse_iface_sh, [IFCFG, IFACE], GST_IFACE_NAME ], - [ "dev", \&gst_network_suse70_parse_iface_sh, [IFCFG, IFACE], NETDEV ], - [ "address", \&gst_network_suse70_parse_iface_sh, [IFCFG, IFACE], IPADDR ], - [ "netmask", \&gst_network_suse70_get_ifconfig_arg, [IFCFG, IFACE], netmask ], - [ "broadcast", \&gst_network_suse70_get_ifconfig_arg, [IFCFG, IFACE], broadcast ], -# [ "network", \&gst_parse_trivial, 0 ], # not supported. -# [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], # not supported - [ "remote_address", \&gst_network_suse70_get_ifconfig_arg, [IFCFG, IFACE], pointopoint ], - [ "enabled", \&gst_network_interface_active, IFACE, - \&gst_network_suse70_active_interfaces_get ], - [ "enabled", \&gst_parse_trivial, 0 ] - ] - }, - - "suse-9.0" => - { - ifaces_get => \&gst_network_suse90_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network/ifcfg-#iface#", - ROUTE_CONF => "/etc/sysconfig/network/routes", - IFACE => "#iface#" - }, - table => - [ - [ "dev", \&gst_network_suse9_get_dev_name, IFACE ], -# [ "enabled", \&gst_network_interface_active, "%dev%", \&gst_network_active_interfaces_get ], - [ "auto", \&gst_network_suse90_get_auto, IFCFG, STARTMODE ], - [ "bootproto", \&gst_network_parse_bootproto, IFCFG, BOOTPROTO ], - [ "address", \&gst_parse_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_parse_sh, IFCFG, NETMASK ], - [ "remote_address", \&gst_parse_sh, IFCFG, REMOTE_IPADDR ], - [ "essid", \&gst_parse_sh, IFCFG, WIRELESS_ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, IFCFG, WIRELESS_KEY ]], - [ "gateway", \&gst_network_suse90_get_gateway, ROUTE_CONF, "%address%", "%netmask%" ], - [ "gateway", \&gst_network_suse90_get_plip_gateway, ROUTE_CONF, "%remote_address%" ], - # Modem stuff goes here - [ "serial_port", \&gst_parse_sh, IFCFG, MODEM_DEVICE ], - [ "serial_speed", \&gst_parse_sh, IFCFG, SPEED ], - [ "mtu", \&gst_parse_sh, IFCFG, MTU ], - [ "mru", \&gst_parse_sh, IFCFG, MRU ], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPD_OPTIONS ], - [ "dial_command", \&gst_parse_sh, IFCFG, DIALCOMMAND ], - [ "external_line", \&gst_parse_sh, IFCFG, DIALPREFIX ], - [ "section", \&gst_parse_sh, IFCFG, PROVIDER ], - [ "volume", \&gst_parse_sh_re, IFCFG, INIT8, "AT.*[ml]([0-3])" ], - [ "login", \&gst_network_suse90_parse_provider_file, "%section%", USERNAME ], - [ "password", \&gst_network_suse90_parse_provider_file, "%section%", PASSWORD ], - [ "phone_number", \&gst_network_suse90_parse_provider_file, "%section%", PHONE ], - [ "dns1", \&gst_network_suse90_parse_provider_file, "%section%", DNS1 ], - [ "dns2", \&gst_network_suse90_parse_provider_file, "%section%", DNS2 ], - [ "update_dns", \&gst_network_suse90_parse_provider_file_bool, "%section%", MODIFYDNS ], - [ "persist", \&gst_network_suse90_parse_provider_file_bool, "%section%", PERSIST ], - [ "stupid", \&gst_network_suse90_parse_provider_file_bool, "%section%", STUPIDMODE ], - [ "set_default_gw", \&gst_network_suse90_parse_provider_file_bool, "%section%", DEFAULTROUTE ], - ] - }, - - "pld-1.0" => - { - ifaces_get => \&gst_network_sysconfig_pld10_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/interfaces/ifcfg-#iface#", - CHAT => "/etc/sysconfig/interfaces/data/chat-#iface#", - IFACE => "#iface#", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_pld10_parse_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_parse_sh_bool, IFCFG, ONBOOT ], -# [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_parse_sh, IFCFG, DEVICE ], - [ "dev", \&gst_parse_sh, IFCFG, DEVICE ], - [ "address", \&gst_network_pld10_get_ipaddr, IFCFG, IPADDR, "address" ], - [ "netmask", \&gst_network_pld10_get_ipaddr, IFCFG, IPADDR, "netmask" ], -# [ "broadcast", \&gst_parse_sh, IFCFG, BROADCAST ], -# [ "network", \&gst_parse_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], - [ "remote_address", \&gst_parse_sh, IFCFG, REMIP ], -# [ "update_dns", \&gst_network_pump_get_nodns, PUMP, "%dev%", "%bootproto%" ], -# [ "dns1", \&gst_parse_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_parse_sh, IFCFG, DNS2 ], - [ "update_dns", \&gst_parse_sh_bool, IFCFG, PEERDNS ], - [ "mtu", \&gst_parse_sh, IFCFG, MTU ], - [ "mru", \&gst_parse_sh, IFCFG, MRU ], - [ "login", \&gst_parse_sh, IFCFG, PAPNAME ], - [ "password", \&gst_network_get_pap_passwd, PAP, "%login%" ], - [ "password", \&gst_network_get_pap_passwd, CHAP, "%login%" ], - [ "serial_port", \&gst_parse_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_parse_sh, IFCFG, LINESPEED ], -# [ "ppp_options", \&gst_parse_sh, IFCFG, PPPOPTIONS ], -# [ "section", \&gst_parse_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_parse_sh_bool, IFCFG, DEFROUTE ], -# [ "debug", \&gst_parse_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_parse_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_parse_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_parse_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_parse_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], -# [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], -# [ "enabled", \&gst_parse_trivial, 0 ] - ] - }, - "slackware-9.1.0" => - { - ifaces_get => \&gst_network_slackware91_ifaces_get_existing, - fn => - { - RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", - RC_INET => "/etc/rc.d/rc.inet1", - RC_LOCAL => "/etc/rc.d/rc.local", - IFACE => "#iface#", - WIRELESS => "/etc/pcmcia/wireless.opts", - PPP_OPTIONS => "/etc/ppp/options", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - CHAT => "/etc/ppp/pppscript", - }, - table => - [ - [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "dev", \&gst_parse_trivial, IFACE ], - [ "address", \&gst_parse_rcinet1conf, [RC_INET_CONF, IFACE], IPADDR ], - [ "netmask", \&gst_parse_rcinet1conf, [RC_INET_CONF, IFACE], NETMASK ], - [ "gateway", \&gst_network_get_gateway, RC_INET_CONF, GATEWAY, "%address%", "%netmask%" ], - [ "auto", \&gst_network_slackware91_get_auto, [RC_INET, RC_LOCAL, IFACE]], - [ "bootproto", \&gst_network_slackware91_parse_bootproto, [RC_INET_CONF, IFACE]], - [ "essid", \&gst_parse_wireless_opts, [ WIRELESS, IFACE ], \&gst_network_get_wireless_ifaces, ESSID ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_wireless_opts, WIRELESS, IFACE, \&gst_network_get_wireless_ifaces, KEY ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_wireless_opts, WIRELESS, IFACE, \&gst_network_get_wireless_ifaces, KEY ]], - [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], - # Modem stuff - [ "update_dns", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "usepeerdns" ]], - [ "noauth", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "noauth" ]], - [ "mtu", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], - [ "mru", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], - [ "serial_port", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], - [ "serial_speed", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], - [ "login", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_re, PPP_OPTIONS, "^name \"?([^\"]*)\"?" ]], - [ "password", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_pap_passwd, CHAP, "%login%" ]], - [ "ppp_options", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_ppp_options_unsup, PPP_OPTIONS ]], - [ "set_default_gw", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "defaultroute" ]], - [ "debug", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "debug" ]], - [ "persist", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "persist" ]], - [ "serial_escapechars", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_split_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], - [ "serial_hwctl", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_kw, PPP_OPTIONS, "crtscts" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "atd[^0-9]*([0-9*#]*)[wW]" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "atd.*[ptw]([0-9, -]+)" ]], - [ "dial_command", \&gst_network_check_type, [IFACE, "modem", \&gst_parse_chat, CHAT, "(atd[tp])[0-9, -w]+" ]], - [ "volume", \&gst_network_check_type, [IFACE, "modem", \&gst_network_get_modem_volume, CHAT ]], - ] - }, - - "gentoo" => - { - ifaces_get => \&gst_network_gentoo_ifaces_get_existing, - fn => - { - NET => "/etc/conf.d/net", - PPPNET => "/etc/conf.d/net.#iface#", - INIT => "net.#iface#", - IFACE => "#iface#", - WIRELESS => "/etc/conf.d/wireless", - }, - table => - [ - [ "auto", \&gst_service_gentoo_get_service_status, INIT, "default" ], - [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "dev", \&gst_parse_trivial, IFACE ], - [ "address", \&gst_parse_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ], - [ "netmask", \&gst_parse_confd_net_re, NET, "config_%dev%", "netmask[ \t]+([0-9\.]*)" ], - [ "remote_address", \&gst_parse_confd_net_re, NET, "config_%dev%", "dest_address[ \t]+([0-9\.]*)" ], -# [ "gateway", \&gst_parse_sh_re, NET, "gateway", "%dev%/([0-9\.\:]*)" ], - [ "gateway", \&gst_network_gentoo_parse_gateway, [ NET, IFACE ]], - [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_active_interfaces_get ], - [ "bootproto", \&gst_network_gentoo_parse_bootproto, [ NET, IFACE ]], - [ "essid", \&gst_parse_sh, WIRELESS, "essid_%dev%" ], - [ "key_type", \&gst_network_get_wep_key_type, [ \&gst_parse_sh, WIRELESS, "key_%essid%" ]], - [ "key", \&gst_network_get_wep_key, [ \&gst_parse_sh, WIRELESS, "key_%essid%" ]], - # modem stuff - [ "update_dns", \&gst_parse_sh_bool, PPPNET, PEERDNS ], - [ "mtu", \&gst_parse_sh, PPPNET, MTU ], - [ "mru", \&gst_parse_sh, PPPNET, MRU ], - [ "serial_port", \&gst_parse_sh, PPPNET, MODEMPORT ], - [ "serial_speed", \&gst_parse_sh, PPPNET, LINESPEED ], - [ "login", \&gst_parse_sh, PPPNET, USERNAME ], - [ "password", \&gst_parse_sh, PPPNET, PASSWORD ], - [ "ppp_options", \&gst_parse_sh, PPPNET, PPPOPTIONS ], - [ "set_default_gw", \&gst_parse_sh_bool, PPPNET, DEFROUTE ], - [ "debug", \&gst_parse_sh_bool, PPPNET, DEBUG ], - [ "persist", \&gst_parse_sh_bool, PPPNET, PERSIST ], - [ "serial_escapechars", \&gst_parse_sh_bool, PPPNET, ESCAPECHARS ], - [ "serial_hwctl", \&gst_parse_sh_bool, PPPNET, HARDFLOWCTL ], - [ "external_line", \&gst_parse_sh_re, PPPNET, NUMBER, "^([0-9*#]*)wW" ], - [ "phone_number", \&gst_parse_sh_re, PPPNET, NUMBER, "w?([0-9]*)\$" ], - [ "volume", \&gst_parse_sh_re, PPPNET, INITSTRING, "^at.*[ml]([0-3])" ], - ] - }, - - "freebsd-5" => - { - ifaces_get => \&gst_network_freebsd_ifaces_get_existing, - fn => - { - RC_CONF => "/etc/rc.conf", - RC_CONF_DEFAULT => "/etc/defaults/rc.conf", - STARTIF => "/etc/start_if.#iface#", - PPPCONF => "/etc/ppp/ppp.conf", - IFACE => "#iface#", - }, - table => - [ - [ "auto", \&gst_network_freebsd5_get_auto, [RC_CONF, RC_CONF_DEFAULT, IFACE ]], - [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "dev", \&gst_parse_trivial, IFACE ], - # we need to double check these values both in the start_if and in the rc.conf files, in this order - [ "address", \&gst_parse_startif, STARTIF, "inet[ \t]+([0-9\.]+)" ], - [ "address", \&gst_parse_sh_re, RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)" ], - [ "netmask", \&gst_parse_startif, STARTIF, "netmask[ \t]+([0-9\.]+)" ], - [ "netmask", \&gst_parse_sh_re, RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)" ], - [ "remote_address", \&gst_parse_startif, STARTIF, "dest_address[ \t]+([0-9\.]+)" ], - [ "remote_address", \&gst_parse_sh_re, RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)" ], - [ "essid", \&gst_parse_startif, STARTIF, "ssid[ \t]+(\".*\"|[^\"][^ ]+)" ], - [ "essid", \&gst_parse_sh_re, RC_CONF, "ifconfig_%dev%", "ssid[ \t]+([^ ]*)" ], - # this is for plip interfaces - [ "gateway", \&gst_network_get_plip_gateway, RC_CONF, "defaultrouter", "%remote_address%" ], - [ "gateway", \&gst_network_get_gateway, RC_CONF, "defaultrouter", "%address%", "%netmask%" ], - [ "enabled", \&gst_network_interface_active, IFACE, \&gst_network_freebsd5_active_interfaces_get ], - [ "bootproto", \&gst_network_parse_bootproto, RC_CONF, "ifconfig_%dev%" ], - # Modem stuff - [ "serial_port", \&gst_network_parse_pppconf, [ PPPCONF, STARTIF, IFACE ], "device" ], - [ "serial_speed", \&gst_network_parse_pppconf, [ PPPCONF, STARTIF, IFACE ], "speed" ], - [ "mtu", \&gst_network_parse_pppconf, [ PPPCONF, STARTIF, IFACE ], "mtu" ], - [ "mru", \&gst_network_parse_pppconf, [ PPPCONF, STARTIF, IFACE ], "mru" ], - [ "login", \&gst_network_parse_pppconf, [ PPPCONF, STARTIF, IFACE ], "authname" ], - [ "password", \&gst_network_parse_pppconf, [ PPPCONF, STARTIF, IFACE ], "authkey" ], - [ "update_dns", \&gst_network_parse_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "dns" ], - [ "set_default_gw", \&gst_network_parse_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ], - [ "external_line", \&gst_network_parse_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "phone", "[ \t]+([0-9]+)[wW]" ], - [ "phone_number", \&gst_network_parse_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "phone", "[wW]?([0-9]+)[ \t]*\$" ], - [ "dial_command", \&gst_network_parse_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "dial", "(ATD[TP])" ], - [ "volume", \&gst_network_parse_pppconf_re, [ PPPCONF, STARTIF, IFACE ], "dial", "AT.*[ml]([0-3]) OK " ], - [ "persist", \&gst_network_get_freebsd5_ppp_persist, [ STARTIF, IFACE ]], - ] - }, - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_network_get_replace_table -{ - my %dist_map = - ( - "redhat-5.2" => "redhat-5.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.0", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-7.2", - "redhat-9" => "redhat-7.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "redhat-7.0", - "mandrake-9.1" => "redhat-7.0", - "mandrake-9.2" => "redhat-7.0", - "mandrake-10.0" => "redhat-7.0", - "mandrake-10.1" => "redhat-7.0", - "mandrake-10.2" => "redhat-7.0", - "mandriva-2006.0" => "redhat-7.0", - "mandriva-2006.1" => "redhat-7.0", - "yoper-2.2" => "redhat-7.0", - "blackpanther-4.0" => "redhat-7.0", - "conectiva-9" => "redhat-7.0", - "conectiva-10" => "redhat-7.0", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - "ubuntu-5.10" => "debian-2.2", - "ubuntu-6.04" => "debian-2.2", - "suse-7.0" => "suse-7.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-7.0", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "redhat-7.0", - "vine-3.1" => "redhat-7.0", - "ark" => "redhat-7.0", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_tables = - ( - "redhat-6.2" => - { - fn => - { - SYSCONFIG_NW => "/etc/sysconfig/network", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "auto", \&gst_replace_sh_bool, SYSCONFIG_NW, NETWORKING ], - [ "hostname", \&gst_replace_sh, SYSCONFIG_NW, HOSTNAME ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_replace_sh, SYSCONFIG_NW, GATEWAY], - [ "gatewaydev", \&gst_replace_sh, SYSCONFIG_NW, GATEWAYDEV], - [ "domain", \&gst_replace_sh, SYSCONFIG_NW, DOMAIN], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_set_status, 91, "smb", "%smbuse%" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ] - ] - }, - - "redhat-7.0" => - { - fn => - { - SYSCONFIG_NW => "/etc/sysconfig/network", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "auto", \&gst_replace_sh_bool, SYSCONFIG_NW, NETWORKING ], - [ "hostname", \&gst_replace_sh, SYSCONFIG_NW, HOSTNAME ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_replace_sh, SYSCONFIG_NW, GATEWAY], - [ "gatewaydev", \&gst_replace_sh, SYSCONFIG_NW, GATEWAYDEV], - [ "domain", \&gst_replace_sh, SYSCONFIG_NW, DOMAIN], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_set_status, 91, "smb", "%smbuse%" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ] - ] - }, - - "redhat-7.2" => - { - fn => - { - SYSCONFIG_NW => ["/etc/sysconfig/networking/profiles/default/network", - "/etc/sysconfig/networking/network", - "/etc/sysconfig/network"], - RESOLV_CONF => ["/etc/sysconfig/networking/profiles/default/resolv.conf", - "/etc/resolv.conf"], - HOST_CONF => "/etc/host.conf", - HOSTS => ["/etc/sysconfig/networking/profiles/default/hosts", - "/etc/hosts"], - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "auto", \&gst_replace_sh_bool, SYSCONFIG_NW, NETWORKING ], - [ "hostname", \&gst_replace_sh, SYSCONFIG_NW, HOSTNAME ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_replace_sh, SYSCONFIG_NW, GATEWAY], - [ "gatewaydev", \&gst_replace_sh, SYSCONFIG_NW, GATEWAYDEV], - [ "domain", \&gst_replace_sh, SYSCONFIG_NW, DOMAIN], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_set_status, 91, "smb", "%smbuse%" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ] - ] - }, - - "debian-2.2" => - { - fn => - { - OPTIONS => "/etc/network/options", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - HOSTNAME => "/etc/hostname", - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_replace_line_first, HOSTNAME ], - [ "hostname", \&gst_network_run_hostname ], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_set_status, 91, "samba" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ] - ] - }, - - "suse-7.0" => - { - fn => - { - RC_CONFIG => "/etc/rc.config", - ROUTE_CONF => "/etc/route.conf", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/smb.conf", - WVDIAL => "/etc/wvdial.conf", - SUSECONFIG => "SuSEconfig" - }, - table => - [ - [ "hostname", \&gst_replace_sh_set_hostname, RC_CONFIG, FQHOSTNAME ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_replace_join_first_str, ROUTE_CONF, "default", "[ \t]+" ], - [ "gateway", \&gst_replace_join_first_str, ROUTE_CONF, "0.0.0.0", "[ \t]+" ], - [ "domain", \&gst_replace_sh_set_domain, RC_CONFIG, FQHOSTNAME ], - [ "nameserver", \&gst_replace_sh_join, RC_CONFIG, NAMESERVER, "[ \t]+" ], - [ "searchdomain", \&gst_replace_sh_join, RC_CONFIG, SEARCHLIST, "[ \t]+" ], -# Remove /etc/resolv.conf so SuSEconfig sets the new values. - [ "searchdomain", \&gst_file_remove, RESOLV_CONF ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_set_status, 20, "smb", "%smbuse%" ], - [ "interface", \&gst_network_suse70_set_ppp, [WVDIAL, "%dialing%"] ], -# We're calling this sepparated cuz we are going to call wvdial to activate. - [ "interface", \&gst_network_suse70_activate_ppp ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "_always_", \&gst_file_run, SUSECONFIG ], - ] - }, - - "suse-9.0" => - { - fn => - { - ROUTE_CONF => "/etc/sysconfig/network/routes", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - HOSTNAME => "/etc/HOSTNAME", - SMB_CONF => "/etc/samba/smb.conf", - }, - table => - [ - [ "hostname", \&gst_replace_fq_hostname, HOSTNAME, "%hostname%", "%domain%" ], - [ "hostname", \&gst_network_run_hostname ], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_suse_set_status, "smb" ], - [ "gateway", \&gst_replace_join_first_str, ROUTE_CONF, "default", "[ \t]+", "%gateway% - -" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - ] - }, - - "pld-1.0" => - { - fn => - { - SYSCONFIG_NW => "/etc/sysconfig/network", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/smb/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "auto", \&gst_replace_sh_bool, SYSCONFIG_NW, NETWORKING ], - [ "hostname", \&gst_replace_sh, SYSCONFIG_NW, HOSTNAME ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_replace_sh, SYSCONFIG_NW, GATEWAY], - [ "gatewaydev", \&gst_replace_sh, SYSCONFIG_NW, GATEWAYDEV], -# [ "domain", \&gst_replace_sh, SYSCONFIG_NW, DOMAIN], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_sysv_set_status, 91, "smb", "%smbuse%" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ] - ] - }, - "slackware-9.1.0" => - { - fn => - { - RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", - RESOLV_CONF => "/etc/resolv.conf", - HOST_CONF => "/etc/host.conf", - HOSTS => "/etc/hosts", - HOSTNAME => "/etc/HOSTNAME", - SMB_CONF => "/etc/samba/smb.conf", - WVDIAL => "/etc/wvdial.conf" - }, - table => - [ - [ "hostname", \&gst_replace_fq_hostname, HOSTNAME, "%hostname%", "%domain%" ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_replace_rcinet1conf_global, RC_INET_CONF, GATEWAY ], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "order", \&gst_replace_join_first_array, HOST_CONF, "order", "[ \t]+", ",[ \t]*" ], - [ "hostmatch", \&gst_replace_join_first_bool, HOST_CONF, "multi", "[ \t]+", "on", "off" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_bsd_set_status, "/etc/rc.d/rc.samba" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ], - [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ] - ] - }, - - "gentoo" => - { - fn => - { - HOSTNAME => "/etc/conf.d/hostname", - DOMAINNAME => "/etc/conf.d/domainname", - NET => "/etc/conf.d/net", - RESOLV_CONF => "/etc/resolv.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/etc/samba/smb.conf" - }, - table => - [ - [ "hostname", \&gst_replace_sh, HOSTNAME, "HOSTNAME" ], - [ "hostname", \&gst_network_run_hostname ], - [ "gateway", \&gst_network_route_set_default_gw, "%gatewaydev%" ], - [ "domain", \&gst_replace_sh, DOMAINNAME, "DNSDOMAIN" ], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_gentoo_set_status, "samba", 1 ], - # first set the gateway to something like "eth0", then add the IP address like "eth0/1.1.1.1" -# [ "gatewaydev", \&gst_replace_sh, NET, gateway ], -# [ "gateway", \&gst_replace_sh_re, NET, gateway, "\/[0-9\.]*\$", "/%gateway%" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ] - ] - }, - - "freebsd-5" => - { - fn => - { - RC_CONF => "/etc/rc.conf", - RESOLV_CONF => "/etc/resolv.conf", - HOSTS => "/etc/hosts", - SMB_CONF => "/usr/local/etc/smb.conf" - }, - table => - [ - [ "hostname", \&gst_replace_sh, RC_CONF, "hostname", "%hostname%.%domain%" ], - [ "hostname", \&gst_network_run_hostname, "%hostname%.%domain%" ], - [ "domain", \&gst_replace_join_first_str, RESOLV_CONF, "domain", "[ \t]+" ], - [ "nameserver", \&gst_replace_join_all, RESOLV_CONF, "nameserver", "[ \t]+" ], - [ "searchdomain", \&gst_replace_join_first_array, RESOLV_CONF, "search", "[ \t]+", "[ \t]+" ], - [ "statichost", \&gst_replace_join_hash, HOSTS, "[ \t]+", "[ \t]+" ], - [ "workgroup", \&gst_replace_ini, SMB_CONF, "global", "workgroup" ], - [ "smbdesc", \&gst_replace_ini, SMB_CONF, "global", "server string", "%hostname%" ], - [ "winsserver", \&gst_replace_ini, SMB_CONF, "global", "wins server" ], - [ "winsuse", \&gst_replace_ini_bool, SMB_CONF, "global", "wins support" ], - [ "smbuse", \&gst_service_rcng_set_status, "samba" ], - [ "gateway", \&gst_replace_sh, RC_CONF, "defaultrouter" ], - [ "interface", \&gst_network_interfaces_set, OLD_HASH ] - ] - } - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_network_get_interface_replace_table -{ - my %dist_map = - ( - "redhat-5.2" => "redhat-5.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-7.2", - "redhat-8.0" => "redhat-8.0", - "redhat-9" => "redhat-8.0", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "mandrake-9.0", - "mandrake-9.1" => "mandrake-9.0", - "mandrake-9.2" => "mandrake-9.0", - "mandrake-10.0" => "mandrake-9.0", - "mandrake-10.1" => "mandrake-9.0", - "mandrake-10.2" => "mandrake-9.0", - "mandriva-2006.0" => "mandrake-9.0", - "mandriva-2006.1" => "mandrake-9.0", - "yoper-2.2" => "redhat-6.2", - "blackpanther-4.0" => "mandrake-9.0", - "conectiva-9" => "conectiva-9", - "conectiva-10" => "conectiva-9", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - "ubuntu-5.04" => "debian-3.0", - "ubuntu-5.10" => "debian-3.0", - "ubuntu-6.04" => "debian-3.0", - "suse-7.0" => "suse-7.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-6.2", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.2", - "fedora-2" => "redhat-7.2", - "fedora-3" => "redhat-7.2", - "fedora-4" => "redhat-7.2", - "rpath" => "redhat-7.2", - "vine-3.0" => "vine-3.0", - "vine-3.1" => "vine-3.0", - "ark" => "vine-3.0", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_tables = - ( - "redhat-6.2" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_rh62_interface_delete, - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], - [ "dev", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], - [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], - [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], - [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "redhat-7.2" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_rh72_interface_delete, - ifaces_get => \&gst_network_sysconfig_rh72_ifaces_get_existing, - fn => - { - IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#", - "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", - "/etc/sysconfig/networking/devices/ifcfg-#iface#"], - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], - [ "name", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], - [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_replace_sh, IFCFG, ESSID ], - [ "key", \&gst_replace_sh, IFCFG, KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, IFCFG, KEY, "%key%" ]], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], - [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], - [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "redhat-8.0" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_rh72_interface_delete, - ifaces_get => \&gst_network_sysconfig_rh72_ifaces_get_existing, - fn => - { - IFCFG => ["/etc/sysconfig/network-scripts/ifcfg-#iface#", - "/etc/sysconfig/networking/profiles/default/ifcfg-#iface#", - "/etc/sysconfig/networking/devices/ifcfg-#iface#"], - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], - [ "name", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], - [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_replace_sh, IFCFG, WIRELESS_ESSID ], - [ "key", \&gst_replace_sh, IFCFG, WIRELESS_KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, IFCFG, WIRELESS_KEY, "%key%" ]], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], - [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], - [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "vine-3.0" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_rh62_interface_delete, - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], - [ "name", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], - [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_replace_sh, IFCFG, ESSID ], - [ "key", \&gst_replace_sh, IFCFG, KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, IFCFG, KEY, "%key%" ]], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], - [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], - [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "mandrake-9.0" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_rh62_interface_delete, - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], - [ "name", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], - [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_replace_sh, IFCFG, WIRELESS_ESSID ], - [ "key", \&gst_replace_sh, IFCFG, WIRELESS_KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, IFCFG, WIRELESS_KEY, "%key%" ]], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], - [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], - [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "conectiva-9" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_rh62_interface_delete, - ifaces_get => \&gst_network_sysconfig_rh62_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network-scripts/ifcfg-#iface#", - CHAT => "/etc/sysconfig/network-scripts/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_rh62_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], - [ "name", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], - [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], - [ "essid", \&gst_replace_sh, IFCFG, WIRELESS_ESSID ], - [ "key", \&gst_replace_sh, IFCFG, WIRELESS_KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, IFCFG, WIRELESS_KEY, "%key%" ]], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], - [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], - [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], - [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - # wvdial settings - [ "phone_number", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Phone" ]], - [ "update_dns", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto DNS" ]], - [ "login", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Username" ]], - [ "password", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Password" ]], - [ "serial_port", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Modem" ]], - [ "serial_speed", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Baud" ]], - [ "set_default_gw", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Check Def Route" ]], - [ "persist", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Auto Reconnect" ]], - [ "dial_command", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Command" ]], - [ "external_line", \&gst_network_check_type, ["%dev%", "modem", \&gst_replace_ini, WVDIAL, "Dialer %section%", "Dial Prefix" ]], - ] - }, - - "debian-2.2" => - { - iface_set => \&gst_network_rh62_interface_activate, # They use the same ifup/ifdown cmds. - iface_delete => \&gst_network_deb22_interface_delete, - ifaces_get => \&gst_network_debian_ifaces_get_existing, - fn => - { - INTERFACES => "/etc/network/interfaces", - IFACE => "#iface#", - CHAT => "/etc/chatscripts/%section%", - PPP_OPTIONS => "/etc/ppp/peers/%section%", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - PUMP => "/etc/pump.conf" - }, - table => - [ -# not sup [ "user", \&gst_parse_sh_bool, IFCFG, USERCTL ], - [ "_always_", \&gst_network_deb22_replace_bootproto, [INTERFACES, IFACE]], - [ "bootproto", \&gst_network_deb22_replace_bootproto, [INTERFACES, IFACE]], - [ "auto", \&gst_replace_interfaces_option_kw_not, [INTERFACES, IFACE], "noauto" ], - [ "name", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "name" ], - [ "address", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "address" ], - [ "netmask", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], - [ "broadcast", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "broadcast" ], - [ "network", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "network" ], - [ "gateway", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], - [ "section", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "provider" ], - [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_kw, PPP_OPTIONS, "usepeerdns" ], -# not sup [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], -# not sup [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "noauth", \&gst_replace_kw, PPP_OPTIONS, "noauth" ], - [ "mtu", \&gst_replace_join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ], - [ "mru", \&gst_replace_join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ], - [ "remote_address", \&gst_network_debian_replace_remote_address, [INTERFACES, IFACE]], - [ "login", \&gst_replace_join_first_str, PPP_OPTIONS, "user", "[ \t]+" ], - [ "serial_port", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ], - [ "serial_speed", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ], - [ "section", \&gst_network_set_ppp_options_connect, PPP_OPTIONS ], - [ "ppp_options", \&gst_network_set_ppp_options_unsup, PPP_OPTIONS ], - [ "set_default_gw", \&gst_replace_kw, PPP_OPTIONS, "defaultroute" ], - [ "debug", \&gst_replace_kw, PPP_OPTIONS, "debug" ], - [ "persist", \&gst_replace_kw, PPP_OPTIONS, "persist" ], - [ "serial_escapechars", \&gst_replace_join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ], - [ "serial_hwctl", \&gst_replace_kw, PPP_OPTIONS, "crtscts" ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ], - ] - }, - - # Basicly the same as debian-2.2, but the "auto" option changes. - "debian-3.0" => - { - iface_set => \&gst_network_rh62_interface_activate, # They use the same ifup/ifdown cmds. - iface_delete => \&gst_network_deb22_interface_delete, - ifaces_get => \&gst_network_debian_ifaces_get_existing, - fn => - { - INTERFACES => "/etc/network/interfaces", - IFACE => "#iface#", - CHAT => "/etc/chatscripts/%section%", - PPP_OPTIONS => "/etc/ppp/peers/%section%", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - }, - table => - [ - [ "_always_", \&gst_network_deb22_replace_bootproto, [INTERFACES, IFACE]], - [ "bootproto", \&gst_network_deb22_replace_bootproto, [INTERFACES, IFACE]], - [ "auto", \&gst_network_debian_woody_set_auto, [INTERFACES, IFACE]], - [ "address", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "address" ], - [ "netmask", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "netmask" ], - [ "gateway", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "gateway" ], - [ "essid", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "wireless-essid" ], - [ "key", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "wireless-key" ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_interfaces_option_str, INTERFACES, IFACE, "wireless-key", "%key%" ]], - # ugly hack for deleting undesired options (due to syntax duality) - [ "essid", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "wireless_essid", "" ], - [ "key", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "wireless_key", "" ], - [ "key", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "wireless_key1", "" ], - # End of hack - [ "section", \&gst_replace_interfaces_option_str, [INTERFACES, IFACE], "provider" ], - [ "remote_address", \&gst_network_debian_replace_remote_address, [INTERFACES, IFACE]], - # Modem stuff - [ "section", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_connect, PPP_OPTIONS ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_network_create_pppscript, CHAT ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "isdn", \&gst_network_create_isdn_options, PPP_OPTIONS ]], - [ "update_dns", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_kw, PPP_OPTIONS, "usepeerdns" ]], - [ "noauth", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_kw, PPP_OPTIONS, "noauth" ]], - [ "set_default_gw", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_kw, PPP_OPTIONS, "defaultroute" ]], - [ "debug", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_kw, PPP_OPTIONS, "debug" ]], - [ "persist", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_kw, PPP_OPTIONS, "persist" ]], - [ "serial_hwctl", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "crtscts" ]], - [ "mtu", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], - [ "mru", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_replace_join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], - [ "serial_port", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], - [ "serial_speed", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], - [ "login", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^user (.*)", "user \"%login%\"" ]], - [ "password", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_network_set_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, [IFACE, "(modem|isdn)", \&gst_network_set_pap_passwd, CHAP, "%login%" ]], - [ "serial_escapechars", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], - [ "dial_command", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_chat, CHAT, "(atd[tp])[0-9w, -]+" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_chat, CHAT, "atd[tp]([0-9w]+)" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "isdn", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %phone_number%" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "isdn", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^number (.*)", "number %external_line%W%phone_number%" ]], - [ "volume", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_modem_volume, CHAT ]], - ] - }, - - "suse-7.0" => - { - iface_set => \&gst_network_suse70_interface_activate, - iface_delete => \&gst_network_suse70_interface_delete, - ifaces_get => \&gst_network_suse70_ifaces_get_existing, - fn => - { - IFCFG => "/etc/rc.config", - IFACE => "#iface#", - PPP_OPTIONS => "/etc/ppp/options" - }, - table => - [ -# bootproto has to go second for suse, as it uses the same value for bootproto and params. - [ "bootproto", \&gst_network_suse70_replace_bootproto, [IFCFG, IFACE] ], - [ "auto", \&gst_network_suse70_replace_iface_auto, [IFCFG, IFACE], NETCONFIG ], - [ "dev", \&gst_network_suse70_replace_iface_sh, [IFCFG, IFACE], NETDEV ], -# not sup [ "user", \&gst_parse_trivial, 0 ], # not supported. - [ "name", \&gst_network_suse70_replace_iface_sh, [IFCFG, IFACE], GST_IFACE_NAME ], - [ "address", \&gst_network_suse70_replace_iface_sh, [IFCFG, IFACE], IPADDR ], - [ "address", \&gst_network_suse70_set_ifconfig_ip, [IFCFG, IFACE] ], - [ "netmask", \&gst_network_suse70_set_ifconfig_arg, [IFCFG, IFACE], netmask ], - [ "broadcast", \&gst_network_suse70_set_ifconfig_arg, [IFCFG, IFACE], broadcast ], -# [ "network", \&gst_parse_trivial, 0 ], # not supported. -# [ "gateway", \&gst_parse_sh, IFCFG, GATEWAY ], # not supported - [ "remote_address", \&gst_network_suse70_set_ifconfig_arg, [IFCFG, IFACE], pointopoint ], - [ "update_dns", \&gst_replace_kw, PPP_OPTIONS, "usepeerdns" ] - ] - }, - - "suse-9.0" => - { - iface_set => \&gst_network_suse9_interface_activate, - iface_delete => \&gst_network_suse90_interface_delete, - ifaces_get => \&gst_network_suse90_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/network/ifcfg-#iface#", - ROUTE_CONF => "/etc/sysconfig/network/routes", - IFACE => "#iface#", - PPP_OPTIONS => "/etc/ppp/options" - }, - table => - [ - [ "auto", \&gst_network_suse90_set_auto, IFCFG, STARTMODE ], - [ "bootproto", \&gst_network_suse90_replace_bootproto, IFCFG, BOOTPROTO ], - [ "address", \&gst_replace_sh, IFCFG, IPADDR ], - [ "netmask", \&gst_replace_sh, IFCFG, NETMASK ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMOTE_IPADDR ], - [ "essid", \&gst_replace_sh, IFCFG, WIRELESS_ESSID ], - [ "key", \&gst_replace_sh, IFCFG, WIRELESS_KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, IFCFG, WIRELESS_KEY, "%key%" ]], - # Modem stuff goes here - [ "serial_port", \&gst_replace_sh, IFCFG, MODEM_DEVICE ], - [ "serial_speed", \&gst_replace_sh, IFCFG, SPEED ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPD_OPTIONS ], - [ "dial_command", \&gst_replace_sh, IFCFG, DIALCOMMAND ], - [ "external_line", \&gst_replace_sh, IFCFG, DIALPREFIX ], - [ "provider", \&gst_replace_sh, IFCFG, PROVIDER ], - [ "volume", \&gst_network_check_type, [ IFACE, "modem", \&gst_network_set_modem_volume_string, IFCFG, INIT8 ]], - [ "login", \&gst_network_suse90_replace_provider_file, "%provider%", USERNAME ], - [ "password", \&gst_network_suse90_replace_provider_file, "%provider%", PASSWORD ], - [ "phone_number", \&gst_network_suse90_replace_provider_file, "%provider%", PHONE ], - [ "dns1", \&gst_network_suse90_replace_provider_file, "%provider%", DNS1 ], - [ "dns2", \&gst_network_suse90_replace_provider_file, "%provider%", DNS2 ], - [ "update_dns", \&gst_network_suse90_replace_provider_file_bool, "%provider%", MODIFYDNS ], - [ "stupid", \&gst_network_suse90_replace_provider_file_bool, "%provider%", STUPIDMODE ], - [ "persist", \&gst_network_suse90_replace_provider_file_bool, "%provider%", PERSIST ], - [ "set_default_gw", \&gst_network_suse90_replace_provider_file_bool, "%provider%", DEFAULTROUTE ], - ] - }, - - "pld-1.0" => - { - iface_set => \&gst_network_rh62_interface_activate, - iface_delete => \&gst_network_pld10_interface_delete, - ifaces_get => \&gst_network_sysconfig_pld10_ifaces_get_existing, - fn => - { - IFCFG => "/etc/sysconfig/interfaces/ifcfg-#iface#", - CHAT => "/etc/sysconfig/interfaces/data/chat-#iface#", - IFACE => "#iface#", - WVDIAL => "/etc/wvdial.conf", - PUMP => "/etc/pump.conf" - }, - table => - [ - [ "bootproto", \&gst_network_pld10_replace_bootproto, IFCFG, BOOTPROTO ], - [ "auto", \&gst_replace_sh_bool, IFCFG, ONBOOT ], - [ "user", \&gst_replace_sh_bool, IFCFG, USERCTL ], -# [ "name", \&gst_replace_sh, IFCFG, NAME ], - [ "dev", \&gst_replace_sh, IFCFG, DEVICE ], - [ "address", \&gst_network_pld10_set_ipaddr, IFCFG, IPADDR, "address" ], - [ "netmask", \&gst_network_pld10_set_ipaddr, IFCFG, IPADDR, "netmask" ], -# [ "broadcast", \&gst_replace_sh, IFCFG, BROADCAST ], -# [ "network", \&gst_replace_sh, IFCFG, NETWORK ], - [ "gateway", \&gst_replace_sh, IFCFG, GATEWAY ], -# [ "update_dns", \&gst_network_pump_set_nodns, PUMP, "%dev%", "%bootproto%" ], - [ "update_dns", \&gst_replace_sh_bool, IFCFG, PEERDNS ], -# [ "dns1", \&gst_replace_sh, IFCFG, DNS1 ], -# [ "dns2", \&gst_replace_sh, IFCFG, DNS2 ], - [ "mtu", \&gst_replace_sh, IFCFG, MTU ], - [ "mru", \&gst_replace_sh, IFCFG, MRU ], - [ "remote_address", \&gst_replace_sh, IFCFG, REMIP ], - [ "login", \&gst_replace_sh, IFCFG, PAPNAME ], - [ "serial_port", \&gst_replace_sh, IFCFG, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, IFCFG, LINESPEED ], - [ "ppp_options", \&gst_replace_sh, IFCFG, PPPOPTIONS ], -# [ "section", \&gst_replace_sh, IFCFG, WVDIALSECT ], - [ "set_default_gw", \&gst_replace_sh_bool, IFCFG, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, IFCFG, DEBUG ], - [ "persist", \&gst_replace_sh_bool, IFCFG, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, IFCFG, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, IFCFG, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_chat, CHAT, "^atd[^0-9]*([0-9, -]+)" ] - ] - }, - - "slackware-9.1.0" => - { - iface_set => \&gst_network_slackware91_interface_activate, - iface_delete => \&gst_network_slackware91_interface_delete, - ifaces_get => \&gst_network_slackware91_ifaces_get_existing, - fn => - { - RC_INET_CONF => "/etc/rc.d/rc.inet1.conf", - RC_INET => "/etc/rc.d/rc.inet1", - RC_LOCAL => "/etc/rc.d/rc.local", - IFACE => "#iface#", - WIRELESS => "/etc/pcmcia/wireless.opts", - PPP_OPTIONS => "/etc/ppp/options", - PAP => "/etc/ppp/pap-secrets", - CHAP => "/etc/ppp/chap-secrets", - CHAT => "/etc/ppp/pppscript", - }, - table => - [ - [ "address", \&gst_replace_rcinet1conf, [ RC_INET_CONF, IFACE ], IPADDR ], - [ "netmask", \&gst_replace_rcinet1conf, [ RC_INET_CONF, IFACE ], NETMASK ], - [ "gateway", \&gst_replace_rcinet1conf_global, RC_INET_CONF, GATEWAY ], - [ "bootproto", \&gst_network_slackware91_replace_bootproto, [ RC_INET_CONF, IFACE ] ], - [ "auto", \&gst_network_slackware91_set_auto, [ RC_INET, RC_LOCAL, IFACE ] ], - [ "essid", \&gst_replace_wireless_opts, [ WIRELESS, IFACE ], \&gst_network_get_wireless_ifaces, ESSID ], - [ "key", \&gst_replace_wireless_opts, [ WIRELESS, IFACE ], \&gst_network_get_wireless_ifaces, KEY ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_wireless_opts, [ WIRELESS, IFACE ], \&gst_network_get_wireless_ifaces, KEY, "%key%" ]], - # Modem stuff - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_network_create_pppscript, CHAT ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_network_slackware91_create_pppgo ]], - [ "update_dns", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "usepeerdns" ]], - [ "noauth", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "noauth" ]], - [ "set_default_gw", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "defaultroute" ]], - [ "debug", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "debug" ]], - [ "persist", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "persist" ]], - [ "serial_hwctl", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_kw, PPP_OPTIONS, "crtscts" ]], - [ "mtu", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_join_first_str, PPP_OPTIONS, "mtu", "[ \t]+" ]], - [ "mru", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_join_first_str, PPP_OPTIONS, "mru", "[ \t]+" ]], - [ "serial_port", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^(/dev/[^ \t]+)" ]], - [ "serial_speed", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^([0-9]+)" ]], - [ "login", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_re, PPP_OPTIONS, "^name \"(.*)\"", "name \"%login%\"" ]], - [ "ppp_options", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_ppp_options_unsup, PPP_OPTIONS ]], - [ "serial_escapechars", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_join_first_str, PPP_OPTIONS, "escape", "[ \t]+" ]], - [ "password", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_pap_passwd, PAP, "%login%" ]], - [ "password", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_pap_passwd, CHAP, "%login%" ]], - [ "dial_command", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_chat, CHAT, "(atd[tp])[0-9w, -]+" ]], - [ "phone_number", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_chat, CHAT, "atd[tp]([0-9w]+)" ]], - [ "external_line", \&gst_network_check_type, [IFACE, "modem", \&gst_replace_chat, CHAT, "atd[tp]([0-9w, -]+)", "%external_line%W%phone_number%" ]], - [ "volume", \&gst_network_check_type, [IFACE, "modem", \&gst_network_set_modem_volume, CHAT ]], - ] - }, - - "gentoo" => - { - iface_set => \&gst_network_gentoo_interface_activate, - iface_delete => \&gst_network_gentoo_interface_delete, - ifaces_get => \&gst_network_gentoo_ifaces_get_existing, - fn => - { - NET => "/etc/conf.d/net", - PPPNET => "/etc/conf.d/net.#iface#", - INIT => "net.#iface#", - IFACE => "#iface#", - WIRELESS => "/etc/conf.d/wireless", - }, - table => - [ - [ "dev", \&gst_network_gentoo_create_files ], - [ "auto", \&gst_service_gentoo_set_status, INIT , 0 ], - [ "bootproto", \&gst_network_gentoo_replace_bootproto, [ NET, IFACE ]], - [ "address", \&gst_replace_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ], - [ "address", \&gst_replace_confd_net_re, NET, "config_%dev%", "^[ \t]*([0-9\.]+)" ], - [ "netmask", \&gst_replace_confd_net_re, NET, "config_%dev%", "[ \t]+netmask[ \t]+[0-9\.]*", " netmask %netmask%"], - [ "broadcast", \&gst_replace_confd_net_re, NET, "config_%dev%", "[ \t]+broadcast[ \t]+[0-9\.]*", " broadcast %broadcast%" ], - [ "remote_address", \&gst_replace_confd_net_re, NET, "config_%dev%", "[ \t]+dest_address[ \t]+[0-9\.]*", " dest_address %remote_address%" ], - [ "gateway", \&gst_replace_confd_net_re, NET, "routes_%dev%", "[ \t]*default[ \t]+(via|gw)[ \t]+[0-9\.\:]*", "default via %gateway%" ], - [ "essid", \&gst_replace_sh, WIRELESS, "essid_%dev%" ], - [ "key", \&gst_replace_sh, WIRELESS, "key_%essid%" ], - [ "key_type", \&gst_network_set_wep_key_type, [ \&gst_replace_sh, WIRELESS, "key_%essid%", "%key%" ]], - # modem stuff - [ "dev", \&gst_network_check_type, [ IFACE, "modem", \&gst_replace_sh, PPPNET, PEER ]], - [ "update_dns", \&gst_network_check_type, [ IFACE, "modem", \&gst_replace_sh_bool, PPPNET, PEERDNS ]], - [ "mtu", \&gst_replace_sh, PPPNET, MTU ], - [ "mru", \&gst_replace_sh, PPPNET, MRU ], - [ "serial_port", \&gst_replace_sh, PPPNET, MODEMPORT ], - [ "serial_speed", \&gst_replace_sh, PPPNET, LINESPEED ], - [ "login", \&gst_replace_sh, PPPNET, USERNAME ], - [ "password", \&gst_replace_sh, PPPNET, PASSWORD ], - [ "ppp_options", \&gst_replace_sh, PPPNET, PPPOPTIONS ], - [ "set_default_gw", \&gst_replace_sh_bool, PPPNET, DEFROUTE ], - [ "debug", \&gst_replace_sh_bool, PPPNET, DEBUG ], - [ "persist", \&gst_replace_sh_bool, PPPNET, PERSIST ], - [ "serial_escapechars", \&gst_replace_sh_bool, PPPNET, ESCAPECHARS ], - [ "serial_hwctl", \&gst_replace_sh_bool, PPPNET, HARDFLOWCTL ], - [ "phone_number", \&gst_replace_sh, PPPNET, NUMBER ], - [ "external_line", \&gst_replace_sh, PPPNET, NUMBER, "%external_line%W%phone_number%" ], - [ "volume", \&gst_network_set_modem_volume_string, PPPNET, INITSTRING ], - ] - }, - - "freebsd-5" => - { - iface_set => \&gst_network_freebsd_interface_activate, - iface_delete => \&gst_network_freebsd_interface_delete, - ifaces_get => \&gst_network_freebsd_ifaces_get_existing, - fn => - { - RC_CONF => "/etc/rc.conf", - STARTIF => "/etc/start_if.#iface#", - PPPCONF => "/etc/ppp/ppp.conf", - IFACE => "#iface#", - }, - table => - [ - [ "auto", \&gst_network_freebsd5_set_auto, [ RC_CONF, IFACE ]], - [ "bootproto", \&gst_network_freebsd5_replace_bootproto, [ RC_CONF, IFACE ]], - [ "address", \&gst_replace_sh_re, RC_CONF, "ifconfig_%dev%", "inet[ \t]+([0-9\.]+)", "inet %address%" ], - [ "netmask", \&gst_replace_sh_re, RC_CONF, "ifconfig_%dev%", "netmask[ \t]+([0-9\.]+)", " netmask %netmask%" ], - [ "remote_address", \&gst_replace_sh_re, RC_CONF, "ifconfig_%dev%", "dest_address[ \t]+([0-9\.]+)", " dest_address %remote_address%" ], - [ "essid", \&gst_network_freebsd5_replace_essid, [ RC_CONF, STARTIF, IFACE ]], - # Modem stuff - # we need this for putting an empty ifconfig_tunX command in rc.conf - [ "phone_number", \&gst_replace_sh, RC_CONF, "ifconfig_%dev%", " " ], - [ "file", \&gst_network_freebsd_create_ppp_startif, [ STARTIF, IFACE ]], - [ "persist", \&gst_network_freebsd_create_ppp_startif, [ STARTIF, IFACE ], "%file%" ], - [ "serial_port", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "device" ], - [ "serial_speed", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "speed" ], - [ "mtu", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "mtu" ], - [ "mru", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "mru" ], - [ "login", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "authname" ], - [ "password", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "authkey" ], - [ "update_dns", \&gst_network_replace_pppconf_bool, [ PPPCONF, STARTIF, IFACE ], "dns" ], - [ "set_default_gw", \&gst_network_replace_pppconf_route, [ PPPCONF, STARTIF, IFACE ], "default HISADDR" ], - [ "phone_number", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "phone" ], - [ "external_line", \&gst_network_replace_pppconf, [ PPPCONF, STARTIF, IFACE ], "phone", "%external_line%W%phone_number%" ], - [ "dial_command", \&gst_network_replace_pppconf_dial_command, [ PPPCONF, STARTIF, IFACE ]], - [ "volume", \&gst_network_replace_pppconf_volume, [ PPPCONF, STARTIF, IFACE ]], - ] - } - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -1; diff --git a/option.pl b/option.pl deleted file mode 100644 index 88f9d9a..0000000 --- a/option.pl +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# GNU libperl shared libraries for Perl (Option package). -# -# Copyright (C) 2000-2001 Free Software Foundation -# -# Authors: Kenneth Christiansen <kenneth@gnu.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -sub str_format # (string, size) -{ - my ($string, $size) = @_; - my @char = unpack ('C*', $string); - $size = $size-$#char; - - for ($i = 0; $i < $size; $i++){ - $string = "$string "; - } - return $string; -} - - -# get_options takes two hashes and the name of the -# program. One hash is build up of arrays with info of: -# [0] sub to run, [1] shortcut, [2] help info, [3] array -# with sub arguments. -# -# If there in [0] is written "VAR", then the variable in -# [3] will be set to 1 (ie. true). -# -# The second hash includes shortcuts associated with the -# subs declaired in the first hash. -# -# If $ARGV is empty the &msg_no_option message is shown. -# If an argument is not in the first hash the message -# &msg_invalid_option is shown. -# -# All other arguments that are not options (ie. starting -# with - or -- are returned by the get_options function - -sub get_options # (string of appname, hashref of options, hashref of shortcut) -{ - ($program, $options, $shortcuts) = @_; - my %options = %{$options}; - my %shortcuts = %{$shortcuts}; - my (@files, @args, $func, $opt, $tmp); - - if ($#ARGV < 0) { - &msg_option_none ($program); - exit; - } - - foreach $arg (@ARGV) { - - ## check if it is an option - if ($arg =~ /^-+(.*)$/) { - $opt = $1; - - ## check for legal single char options - if ($opt =~ /^(\w)$/) { - $tmp = "$shortcuts{$1}"; - $opt = $tmp if ($tmp ne ""); - } - - if ($options{$opt}) { - my ($method, $argv) = @{$options{$opt}}[0,3]; - - if ($method eq "VAR") { - ${$argv} = 1; ## setting variable to true - next; - } - elsif ($func eq ""){ - @args = @{$argv}; - $func = "$method"; - } - } - else { - &msg_option_invalid ($program, $opt); - } - } - else { - push @files, $arg; - } - } - &$func(@args) if ($func); ## execute sub associated with option - return @files; -} - -sub file_open_stringbuffer # (file) -{ - my ($file) = @_; - - local (*FILE); - local $/; # slurp mode - open (FILE, "<$file") || die "can't open $file: $!"; - return <FILE>; -} - -# -- Messages -- # - -sub msg_about # (program, release, copyright, author, year) -{ - my ($program, $version, $copyright, $author, $year) = @_; - - ## Print version information - if ($#_ < 4) { - print STRERR "WARNING: Not enought arguments given to function\n"; - } - else { - print "$program $version\n"; - printf "Written by %s, %s.\n\nCopyright (C) %s, %s \n", $author, $year, $year, $copyright; - print "This is free software; see the source for copying conditions. There is NO\n"; - print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; - } - exit; -} - -sub msg_option_none # (prog_name) -{ - my ($program) = @_; - - ## Handle invalid arguments - printf "%s: missing arguments\n", $program; - exit 1; -} - -sub msg_option_invalid # (prog_name, option) -{ - my ($program, $option) = @_; - - ## Handle invalid arguments - printf ("%s: invalid option -- %s\n", $program, $option); - printf ("Try '%s --help' for more information.\n", $program); - exit 1; -} - -sub msg_help -{ - my ($program, $usage, $desc, $author, $extra, $options) = @_; - my %options = %{$options}; - - ## Print usage information - print "Usage: $program $usage\n$desc\n\n"; - - foreach $line (keys %options) { - my ($tmp, $shortcut, $info) = @{$options{$line}}; - - if ($shortcut eq "") { - print " --"; - } else { - print " -$shortcut, --"; - } - - print str_format($line, 25) . "$info\n"; - } - - print "$extra\n" . "Report bugs to $author.\n"; - exit; -} - -1; diff --git a/org.freedesktop.SystemToolsBackends.service.in b/org.freedesktop.SystemToolsBackends.service.in new file mode 100644 index 0000000..d88dd53 --- /dev/null +++ b/org.freedesktop.SystemToolsBackends.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.freedesktop.SystemToolsBackends +Exec=@scriptsdir@/SystemToolsBackends.pl + diff --git a/package-conf.in b/package-conf.in deleted file mode 100644 index 521af82..0000000 --- a/package-conf.in +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Package lister. -# Designed to be architecture- and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Richard Bos <allabos@freeler.nl> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# --- Common stuff --- # - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - -# require "$SCRIPTSDIR/general.pl$DOTIN"; -# require "$SCRIPTSDIR/platform.pl$DOTIN"; -# require "$SCRIPTSDIR/util.pl$DOTIN"; -# require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "package"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", - "mandrake-7.2", "suse-7.0", "turbolinux-7.0"); - -$description =<<"end_of_description;"; -List available packages at the system only. Use the available package update -tooks like; rpm, apt-get, red-carpet, etc to update your system. -end_of_description; - -# --- System config file locations --- # - -# Where are the tools? - -$cmd_pack = &gst_file_locate_tool ("rpm"); - -# --- Internal configuration variables --- # - -# Configuration is parsed/read to, and printed/written from, these temporary variables. - -@cf_package = (); - - -# --- XML scanning --- # - -# --- XML printing --- # - -sub xml_print -{ - &gst_xml_print_line ("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>"); - &gst_xml_print_line ("<!DOCTYPE packages []>\n"); - &gst_xml_print_line ("<packages>"); - &gst_xml_enter (); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<!-- Configuration starts here -->\n"); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<meta>"); - &gst_xml_enter; - - my $number_of_packages = $#cf_package + 1; - &gst_xml_print_line ("<number>$number_of_packages</number>"); - &gst_xml_leave; - &gst_xml_print_line ("</meta>"); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("</packagedb>"); - &gst_xml_print_vspace (); - &gst_xml_enter; - - foreach $entry (@cf_package) { - &gst_xml_print_line ("<package>"); - &gst_xml_enter; - &gst_xml_print_line ("<name>$entry->{name}</name>"); - &gst_xml_print_line ("<version>$entry->{vers}</version>"); - &gst_xml_print_line ("<distribution>$entry->{dist}</distribution>"); - &gst_xml_leave; - &gst_xml_print_line ("</package>"); - &gst_xml_print_vspace (); - } - - &gst_xml_print_vspace (); - &gst_xml_leave (); - &gst_xml_print_line ("</packagedb>"); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<!-- End of configuration -->\n"); - - &gst_xml_print_vspace (); - &gst_xml_leave (); - &gst_xml_print_line ("</packages>"); -} - - -# --- Get (read) config --- # - -sub get_package -{ - my $dist; - my $distributor; - my $name; - my $pid; - my $vers; - my $fd; - - my %cmd_map = - ( - "rpm" => "rpm -qa --queryformat '%{name},%{version},%{release}\n'", - "deb" => "unknown" - ); - - my %dist_map = - ( - "redhat" => "$cmd_map{rpm}", - "openna" => "$cmd_map{rpm}", - "mandrake" => "$cmd_map{rpm}", - "suse" => "$cmd_map{rpm}", - "debian" => "$cmd_map{deb}", - "turbolinux" => "$cmd_map{rpm}", - ); - - ($distributor) = split /-/, $gst_dist; - - $fd = &gst_file_run_pipe_read ("$dist_map{$distributor}"); - die "Could not execute the package query command" if $fd eq undef; - - while (<$fd>) - { - chomp $_; - ($name, $vers, $dist) = split /,/, $_; - - push @cf_package, { - "name" => $name, - "vers" => $vers, - "dist" => $dist, - }; - } - &gst_file_close ($fd); -} - -sub get -{ - &gst_report ("get_packages"); - - &get_package; &gst_print_progress(); - - &gst_report_end (); - &xml_print (); -} - - -# --- Set (write) config --- # - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/partition.pl.in b/partition.pl.in deleted file mode 100644 index 92f4e59..0000000 --- a/partition.pl.in +++ /dev/null @@ -1,781 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Working with filesystems, both local and networked. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Arturo Espinosa <arturo@ximian.com> -# Carlos Garcia Campos <carlosgc@gnome.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -use Errno; - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/report.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; - -@DEVICE_NAMES = ( - { - "name" => "da", - "max" => 16, - }, - { - "name" => "ad", - "max" => 16, - }, - { - "name" => "ar", - "max" => 16, - }, - { - "name" => "fla", - "max" => 16, - }, - { - "name" => "afd", - "max" => 4, - }, - { - "name" => "mlx", - "max" => 4, - }, - { - "name" => "amrd", - "max" => 4, - }, - { - "name" => "idad", - "max" => 4, - }, - { - "name" => "twed", - "max" => 4, - }, - { - "name" => "aacd", - "max" => 4, - }, - { - "name" => "ipsd", - "max" => 4, - }, - { - "name" => "wd", - "max" => 16, - }, -); - -sub gst_partition_scan_freebsd_info -{ - my ($fd, $line); - my (%hash); - my (@table); - local (*DEV); - - # Some of this code has been adapted from the way - # sysinstall learns about devices. - foreach my $device (@DEVICE_NAMES) - { - for (my $i = 0; $i < $device->{"max"}; $i++) - { - my $dev = "/dev/" . $device->{"name"} . $i; - - if (open (DEV, $dev) || $! == EBUSY) - { - if ($! == 0) - { - close (DEV); - } - - $fd = &gst_file_run_pipe ("fdisk -s " . $dev); - - if ($fd eq undef) - { - &gst_report ("fdisk_failed"); - return undef; - } - - while ($line = <$fd>) - { - # Example output from fdisk -s: - # /dev/ad0: 26310 cyl 16 hd 63 sec - # Part Start Size Type Flags - # 1: 63 26520417 0xa5 0x80 - # - if ($line =~ /^[ \t]+(\d+):[ \t]+(\d+)[ \t]+(\d+)[ \t]+0x([a-f0-9A-F][a-f0-9A-F])[ \t]+0x([a-f0-9A-F][a-f0-9A-F])$/) - { - $bootable = ($5 eq 80)? 0: 1; - push @table, {"dev" => $dev . "s" . $1, -# "id" => $1, -# "start" => $2, -# "size" => $3, -# "boot" => $bootable, - "type" => $GST_FILESYS_TYPES{$4} - }; - } - } - - &gst_file_close ($fd); - } - } - } - - $hash{"partition"} = \@table; - - return \%hash; -} - -sub gst_partition_scan_linux_info -{ - my ($fd, $line); - my (%hash); - my (@table); - - $fd = &gst_file_run_pipe ("sfdisk -d"); - if ($fd eq undef) - { - &gst_report ("sfdisk_failed"); - return undef; - } - - while ($line = <$fd>) - { - # Woohoo! sfdisk -d scanner in one line! Gotta love perl! OK, I'm a pig. - if ($line =~ /^(\/dev\/[^ \t]+)[ \t]*: start=[ \t]*([0-9]+), size=[ \t]*([0-9]+), Id=[ \t]*([0-9a-fA-F][0-9a-fA-F]?)(, bootable)?/) - { - # we don't need empty partitions, so we reject those with id = 0 - if ($4 ne 0) - { - $bootable = ($5 eq undef)? 0: 1; - - push @table, {"dev" => $1, -# "start" => $2, -# "size" => $3, -# "id" => $4, -# "boot" => $bootable, - "type" => $GST_FILESYS_TYPES{$4} - }; - } - } - } - close $fd; - - $hash{"partition"} = \@table; - - return \%hash; -} - -sub gst_partition_scan_info -{ - my ($plat) = $$tool{"system"}; - - return &gst_partition_scan_linux_info if ($plat eq "Linux"); - return &gst_partition_scan_freebsd_info if ($plat eq "FreeBSD"); -} - -%GST_FILESYS_TYPES = - ("0" => "Empty", - "1" => "DOS 12-bit FAT", - "2" => "XENIX root", - "3" => "XENIX /usr", - "4" => "DOS 3.0+ 16-bit FAT", - "5" => "DOS 3.3+ Ext", - "6" => "DOS 3.31+ 16-bit FAT", - "7" => "NTFS, OS/2 or QNX", - "8" => "AIX boot", - "9" => "AIX data, QNX 1.x / 2.x", - "a" => "OS/2 Boot, Coherent swap or OPUS", - "b" => "WIN95 OSR2 32-bit FAT", - "c" => "WIN95 OSR2 32-bit FAT, LBA", - "e" => "WIN95: DOS 16-bit FAT, LBA", - "f" => "WIN95: Ext., LBA", - "10" => "OPUS", - "11" => "Hidden DOS 12-bit FAT", - "12" => "Compaq config", - "14" => "Hidden DOS 16-bit FAT", - "16" => "Hidden DOS 16-bit FAT", - "17" => "Hidden IFS", - "18" => "AST SmartSleep", - "19" => "Unused", - "1b" => "Hidden WIN95 OSR2 32-bit FAT", - "1c" => "Hidden WIN95 OSR2 32-bit FAT, LBA", - "1e" => "Hidden WIN95 16-bit FAT, LBA", - "20" => "Unused", - "21" => "Reserved", - "22" => "Unused", - "23" => "Reserved", - "24" => "NEC DOS 3.x", - "26" => "Reserved", - "31" => "Reserved", - "32" => "NOS", - "33" => "Reserved", - "34" => "Reserved", - "35" => "JFS on OS/2 or eCS", - "36" => "Reserved", - "38" => "THEOS 3.2 2gb", - "39" => "Plan 9 or THEOS ver 4 spanned", - "3a" => "THEOS ver 4 4gb", - "3b" => "THEOS ver 4 extended", - "3c" => "PartitionMagic recovery", - "3d" => "Hidden NetWare", - "40" => "Venix 80286", - "41" => "Personal RISC Boot", - "41" => "Power PC Reference Platform Boot", - "42" => "SFS or Windows 2000 marker", - "43" => "Linux native", - "44" => "GoBack", - "45" => "Boot-US boot manager", - "45" => "EUMEL/Elan", - "46" => "EUMEL/Elan", - "47" => "EUMEL/Elan", - "48" => "EUMEL/Elan", - "4a" => "AdaOS Aquila", - "4d" => "QNX4.x", - "4e" => "QNX4.x 2nd part", - "4f" => "QNX4.x 3rd part", - "50" => "Lynx RTOS", - "51" => "Novell", - "52" => "Microport SysV/AT", - "53" => "Disk Manager 6.0 Aux3", - "54" => "Disk Manager 6.0 Dynamic Drive Overlay", - "55" => "EZ-Drive", - "56" => "Golden Bow VFeatureed Volume", - "57" => "DrivePro", - "5c" => "Priam EDisk", - "61" => "SpeedStor", - "63" => "Unix System V", - "64" => "Novell Netware 286, 2.xx", - "65" => "Novell Netware 386, 3.xx or 4.xx", - "66" => "Novell Netware SMS", - "67" => "Novell", - "68" => "Novell", - "69" => "Novell Netware 5+, Novell Netware NSS", - "6e" => "??", - "70" => "DiskSecure Multi-Boot", - "71" => "Reserved", - "73" => "Reserved", - "74" => "Scramdisk", - "75" => "IBM PC/IX", - "76" => "Reserved", - "77" => "M2FS/M2CS", - "78" => "XOSL FS", - "7E" => "F.I.X.", - "80" => "MINIX until 1.4a", - "81" => "MINIX since 1.4b, early Linux", - "81" => "Mitac disk manager", - "82" => "Linux swap", - "83" => "Linux", - "84" => "Hibernation", - "85" => "Linux extended", - "86" => "NTFS volume set", - "87" => "NTFS volume set", - "8a" => "Linux Kernel (used by AiR-BOOT)", - "8b" => "Legacy Fault Tolerant FAT32 volume", - "8c" => "Legacy Fault Tolerant FAT32 volume using BIOS extd INT 13h", - "8d" => "Free FDISK hidden Primary DOS FAT12 partitition", - "8e" => "Linux LVM", - "90" => "Free FDISK hidden Primary DOS FAT16 partitition", - "91" => "Free FDISK hidden DOS extended partitition", - "92" => "Free FDISK hidden Primary DOS large FAT16 partitition", - "93" => "Hidden Linux native or Amoeba", - "94" => "Amoeba bad block table", - "95" => "MIT EXOPC natives", - "97" => "Free FDISK hidden Primary DOS FAT32 partitition", - "98" => "Free FDISK hidden Primary DOS FAT32 partitition (LBA)", - "99" => "DCE376 logical drive", - "9a" => "Free FDISK hidden Primary DOS FAT16 partitition (LBA)", - "9b" => "Free FDISK hidden DOS extended partitition (LBA)", - "9f" => "BSD/OS", - "a0" => "Laptop hibernation", - "a1" => "Laptop hibernation", - "a3" => "Reserved", - "a4" => "Reserved", - "a5" => "BSD/386, 386BSD, NetBSD, FreeBSD", - "a6" => "OpenBSD", - "a7" => "NEXTSTEP", - "a9" => "NetBSD", - "aa" => "Olivetti Fat 12 1.44Mb Service", - "ab" => "GO!", - "ae" => "ShagOS filesystem", - "af" => "ShagOS swap", - "b0" => "BootStar Dummy", - "b1" => "Reserved", - "b3" => "Reserved", - "b4" => "Reserved", - "b6" => "Reserved", - "b7" => "BSDI BSD/386 filesystem", - "b8" => "BSDI BSD/386 swap", - "bb" => "Boot Wizard hidden", - "be" => "Solaris 8 boot", - "c0" => "NTFT", - "c1" => "DRDOS/secured (FAT-12)", - "c2" => "Hidden Linux", - "c3" => "Hidden Linux swap", - "c4" => "DRDOS/secured (FAT-16, < 32M)", - "c5" => "DRDOS/secured (extended)", - "c6" => "DRDOS/secured (FAT-16, >= 32M)", - "c6" => "Windows NT corrupted FAT16 volume/stripe set", - "c7" => "Windows NT corrupted NTFS volume/stripe set", - "c8" => "Hidden Linux", - "c9" => "Hidden Linux", - "ca" => "Hidden Linux", - "cb" => "reserved for DRDOS/secured (FAT32)", - "cc" => "reserved for DRDOS/secured (FAT32, LBA)", - "cd" => "CTOS Memdump? ", - "ce" => "reserved for DRDOS/secured (FAT16, LBA)", - "d0" => "REAL/32 secure big", - "d1" => "Old Multiuser DOS secured FAT12", - "d4" => "Old Multiuser DOS secured FAT16 <32M", - "d5" => "Old Multiuser DOS secured extended", - "d6" => "Old Multiuser DOS secured FAT16 >=32M", - "d8" => "CP/M-86", - "da" => "Non-FS Data", - "db" => "Digital Research CP/M, Concurrent CP/M, Concurrent DOS", - "db" => "CTOS", - "dd" => "Hidden CTOS Memdump?", - "de" => "Dell PowerEdge Server utilities (FAT fs)", - "df" => "BootIt EMBRM", - "e1" => "DOS access or SpeedStor 12-bit FAT extended", - "e3" => "DOS R/O or SpeedStor", - "e4" => "SpeedStor 16-bit FAT extended < 1024 cyl.", - "e5" => "Tandy DOS with logical sectored FAT", - "e6" => "Reserved", - "eb" => "BeOS", - "ed" => "Reserved for Matthias Paul's Spryt*x", - "ee" => "Indication that this legacy MBR is followed by an EFI header", - "ef" => "Partition that contains an EFI file system", - "f0" => "Linux/PA-RISC boot loader", - "f1" => "SpeedStor", - "f2" => "DOS 3.3+ secondary", - "f3" => "Reserved", - "f4" => "Prologue single-volume", - "f5" => "Prologue multi-volume", - "f6" => "Reserved", - "fb" => "VMware File System", - "fc" => "VMware Swap", - "fd" => "Linux raid w/autodetect, persistent superblock", - "fe" => "Windows NT Disk Administrator hidden", - "ff" => "Xenix Bad Block Table"); - - - -# TODO: fix code style -sub sort_by_start -{ - return ($a->{'start'} <=> $b->{'start'}); -} - -sub get_fdisk -{ - my $check_dev = shift; - - my $fdisk_tool; - - for ($i = 0; $cf_disks[$i]; $i++) { - if (($cf_disks[$i])->{media} =~ /disk/) { - if ($check_dev) { - if (($cf_disks[$i])->{device} eq $check_dev) { - push (@check_devs, ($cf_disks[$i])->{device}); - } - } else { - push (@check_devs, ($cf_disks[$i])->{device}); - } - } - } - - $fdisk_tool = &gst_file_locate_tool("fdisk"); - - for $dev (@check_devs) - { - my ($disk, $device, $point, $fs, $options, $check, $size, $bootable, $fd); - - &gst_report ("disks_partition_probe", $dev); - - $fd = &gst_file_run_pipe_read ("fdisk -l $dev"); - # We want to cache fdisk work! - - my @fdisk_data = <$fd>; - my ($block_size, $dev_size); - my $unit = ""; - - # First of all we get the global disk data: size, unit - foreach (@fdisk_data) { - &update_disk_data ($dev, "present", 1); - if (/^Block size/) { - # fdisk in Debian PowerPC - # Block size=512, Number of Blocks=78140160 - ($block_size, $dev_size) = ($_ =~ /^Block size=([0-9]*)[^0-9]*([0-9]*).*$/); - $last_end = $dev_size; - # $unit must be 1024 - # my $fsize = ($fend - $fstart + 1) * ($unit / 1024); - # we need ($unit / 1024) = 1 - $unit = 1024; - &update_disk_data ($dev, "size", $dev_size); - &update_disk_data ($dev, "block_size", $block_size); - - } elsif (/^Disk/) { - # fdisk in Debian i386 - # Disk /dev/hda: 60.0 GB, 60022480896 bytes - ($dev_size) = ($_ =~ /^Disk [^0-9]* .* ([0-9]*) bytes$/); - $block_size=1024; - - # fdisk in Suse Desktop i386 - # Disk /dev/hda: 255 heads, 63 sectors, 2491 cylinders - if ($dev_size eq "") { - $dev_size = `fdisk -s $dev`; - $dev_size = $dev_size * $block_size; - ($last_end) = ($_ =~ /^Disk [^0-9]* [0-9]+ heads, [0-9]+ sectors, ([0-9]+) cylinders$/); - } - - &update_disk_data ($dev, "size", $dev_size/$block_size); - &update_disk_data ($dev, "block_size", $block_size); - } elsif (/^Units/) { - # i386 - # Units = cylinders * 512 - - # fdisk in Debian i386 - # Units = cylinders of 16065 * 512 = 8225280 bytes - ($unit) = ($_ =~ /^Units = cylinders of [0-9]+ \* [0-9]+ = ([0-9]+) bytes$/); - - if ($unit eq "") { - # fdisk in Suse Desktop i386 - # Units = cylinders of 16065 * 512 bytes - my ($a, $b) = ($_ =~ /^Units = cylinders of ([0-9]+) \* ([0-9]+) bytes$/); - $unit = $a * $b; - } - } elsif (/^[0-9]+ heads/) { - # i386 - # fdisk in Debian i386 - # 255 heads, 63 sectors/track, 1222 cylinders - ($last_end) = ($_ =~ /^[0-9]+ heads, [0-9]+ sectors\/track, ([0-9]+) cylinders$/); - } - - } - - # Now we get the data of each partition - my @fdisk_hash = (); - foreach (@fdisk_data) - { - if (/^\/dev/) - { - @line = split(/[ \n\r\t]+/, $_); - - my (%parts); - - # fdisk i386 - # Device Boot Start End Blocks Id System - # /dev/hda3 694 1046 2835472+ 83 Linux - # - # fdisk powerpc - # # type name length base ( size ) system - # /dev/hdc3 Apple_Driver43 Macintosh 56 @ 120 ( 28.0k) Driver 4.3 - - - # fdisk in Debian PowerBook gives the disks as the first line - next if scalar @line == 1; - - # device file - %parts->{'device'} = $line[0]; - $device = $line[0]; shift @line; - ($disk) = ($device =~ /([a-zA-Z\/]+)/); - if ($line[0] eq "\*") { - # NOTE: Currently unused. - %parts->{'bootable'} = 1; - $bootable = 1; shift @line; - } - else { %parts->{'bootable'} = 0; $bootable = 0; } - - # first cylinder of the partition - ($start) = ($line[0] =~ /^([0-9]+)/); - if ($start eq "") { - # there is no start cylinder, we are in powerpc - # look for length @ base - while ($line[0] ne "@") { - ($length) = ($line[0] =~ /^([0-9]+)/); - shift @line; - } - # skip @ - shift @line; - #print "start $line[0]\n"; - ($start) = ($line[0] =~ /^([0-9]+)/); - %parts->{'start'} = $start; - $end = $start + $length - 1; - %parts->{'end'} = $end; - %parts->{'size'} = $length; - %parts->{'type'} = ""; - push (@fdisk_hash, \%parts); - # go to next device - next; - } - %parts->{'start'} = $start; - shift @line; - - # last cylinder of the partition - ($end) = ($line[0] =~ /^([0-9]+)/); - %parts->{'end'} = $end; - shift @line; - - # size of partition in blocks - ($size) = ($line[0] =~ /([0-9]+)/); - %parts->{'size'} = $size; - shift @line; - - # FIXME: add new popular ones, such as reiser and xfs and add - # those documented by fdisk. - if ($line[0] eq "5" || $line[0] eq "f" || $line[0] eq "85") { next; } # extended. - elsif ($line[0] eq "82") { $type = "swap"; } - elsif ($line[0] eq "83") { $type = "ext2"; } - elsif ($line[0] eq "e") { $type = "vfat"; } - elsif ($line[0] eq "c" || $line[0] eq "b") { $type = "fat32"; } - elsif ($line[0] eq "6" || $line[0] eq "4" || $line[0] eq "1") { $type = "msdos"; } - elsif ($line[0] eq "7") { $type = "ntfs"; } - else { $type = ""; } - - # fs type - #%parts->{'type'} = $type; - %parts->{'type'} = &get_fs_type ($device); - push (@fdisk_hash, \%parts); - } - } - - my ($prev_end) = 0; # last cylinder of previous partition - my $max_cyl = 0; # bigest cylinder found - - # In order to find empty partitions we have to sort - # the array by start (first cylinder) - @ord = sort sort_by_start (@fdisk_hash); - my $empty_count = 1; - - # Now we update the data and detect empty partitions - foreach $partition (@ord) - { - if ($partition->{'end'} > $max_cyl) { - $max_cyl = $partition->{'end'}; - } - - if ($prev_end ne 0) { - if ($partition->{'start'} - 1 ne $prev_end) { - # There is no partition, free space found - my $fstart = $prev_end + 1; - my $fend; - $fend = $partition->{'start'} - 1; - # size = (number of cylinders) * (unit in bloks) - # number of cylinders = last cylinder - first cylinder + 1 - my $fsize = ($fend - $fstart + 1) * ($unit / 1024); - if ($fend > $max_cyl) { - $max_cyl = $fend; - } - if ($fstart ne $fend) { - &update_partition ($disk, "/dev/empty$empty_count", "", "", "empty", "noauto", 0, $fsize, 0, - 0, 1, "", $fstart, $fend); - $empty_count ++; - } - } - } else { - if ($partition->{'start'} ne 1) { - # There is no partition, free space found in the top of the disk - my $fstart = 1; - my $fend = $partition->{'start'} - 1; - # size = (number of cylinders) * (unit in bloks) - # number of cylinders = last cylinder - first cylinder + 1 - my $fsize = ($fend - $fstart + 1) * ($unit / 1024); - if ($fend > $max_cyl) { - $max_cyl = $fend; - } - if ($fend ne $fstart) { - &update_partition ($disk, "/dev/empty$empty_count", "", "", "empty", "noauto", 0, $fsize, 0, - 0, 1, "", $fstart, $fend); - $empty_count ++; - } - } - } - - # partition found update it - if ($partition->{'end'} ne $partition->{'start'}) { - &update_partition ($disk, $partition->{'device'}, "", "", $partition->{'type'}, "noauto", 0, - $partition->{'size'}, 0, $partition->{'bootable'}, 1, "", - $partition->{'start'}, $partition->{'end'}); - } - - if ($partition->{'end'} eq $last_end) { - $prev_end = 0; - } else { - $prev_end = $partition->{'end'}; - } - } - - # Now we are out of the loop and we have to check if the current disk is - # valid - if ($disk ne "") { - if (($max_cyl < $last_end) and ($max_cyl < ($last_end - 1))) { - # There is no partition, free space found in the bottom of the disk - my $fstart = $max_cyl + 1; - my $fend = $last_end; - # size = (number of cylinders) * (unit in bloks) - # number of cylinders = last cylinder - first cylinder + 1 - my $fsize = ($fend - $fstart + 1) * ($unit / 1024); - &update_partition ($disk, "/dev/empty$empty_count", "", "", "empty", "noauto", 0, $fsize, 0, - 0, 1, "", $fstart, $fend); - } - } - - &gst_file_close ($fd); - - &gst_report ("disks_size_query", $dev); - - &gst_print_progress (); - } -} - -## Mount functions -sub gst_partition_is_mounted -{ - my ($device) = @_; - - my $line = `mount | grep "$device"`; - - if ($line ne "") - { - return 1; - } - else - { - return 0; - } -} - -sub gst_partition_get_mount_point -{ - my ($device) = @_; - - my ($point) = `mount | grep $device` =~ /^$device on (.*) type .*$/; - if ($point) - { - return $point; - } - else - { - return undef; - } -} - -sub gst_partition_mount_temp -{ - my ($device) = @_; - my ($filesys); - - my ($dev) = ($device =~ /\/dev\/(.*)/); - my $point = "/tmp/disks-conf-$dev"; - - mkdir ($point); - - $cmd = "mount $device $point"; - $fd = &gst_file_run_pipe_read_with_stderr ($cmd); - - if (!$fd) - { - my $err = `umount $device`; - rmdir ($point); - return "error"; - } - - # Not mounted: not supported or unformatted - while (<$fd>) - { - if (/not supported/) - { - #($filesys) = ($_ =~ /^mount: fs type (.*) not supported by kernel$/); - &gst_file_close ($fd); - rmdir ($point); - return "not_supported::$_"; - } - elsif (/looks like swapspace/) - { - #$filesys = "swap"; - &gst_file_close ($fd); - rmdir ($point); - return "swap"; - } - elsif (/you must specify the filesystem type/) - { - #$filesys = "none"; - &gst_file_close ($fd); - rmdir ($point); - return "none"; - } - } - - &gst_file_close ($fd); - - return $point; -} - -sub gst_partition_umount_temp -{ - my ($device, $point) = @_; - - my $err = `umount $device`; - rmdir ($point); -} - -sub gst_format_partition -{ - my ($command, $device, $type, $options) = @_; - my ($cmd, $fd); - - if ($type eq "reiserfs") - { - $options = "$options -f -f"; #-f specified twice, do not ask for confirmation - } - elsif ($type eq "xfs") - { - $options = "$options -f"; - } - elsif ($type eq "xfs") - { - $options = "$options -q"; - } - - $cmd = "$command $device $options"; - - $fd = &gst_file_run_pipe_read_with_stderr ($cmd); - if (!$fd) - { - # TODO - return; - } - - while (<$fd>) - { -# print"DBG: $_\n"; - } - - &gst_file_close ($fd); - - - &gst_report_leave (); - -} - -1; diff --git a/perldoc.pl b/perldoc.pl deleted file mode 100755 index ee2fc83..0000000 --- a/perldoc.pl +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# The Perl Documenter. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Kenneth Christiansen <kenneth@gnu.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -require "/usr/share/ximian-setup-tools/scripts/general.pl"; -require "/usr/share/ximian-setup-tools/scripts/util.pl"; -require "/usr/share/ximian-setup-tools/scripts/file.pl"; -require "./option.pl"; - -# -- Release information -- # - -my $program = "perldoc"; -my $version = "0.1"; - -# -- Global variables -- # - -my ($arg_comment, $arg_hide); - -# -- Option handeling -- # - -my %options = (); -my %shortcuts = (); - -my @about_helper = ($program, $version, "Free Software Foundation", - "Kenneth Christiansen <kenneth\@gnu.org>", "2001"); - -my @help_helper = ($program, "[OPTIONS] ...[REGEX]", - "A JavaDoc like system for Perl.", - "<kenneth\@gnu.org>", "", \%options); - -%options = -( - help => ["msg_help", "H", "shows the help information", \@help_helper], - version => ["msg_about", "V", "shows version information", \@about_helper], - comment => ["VAR", "", "show comments associated to sub", \$arg_comment], - hide => ["VAR", "", "hide subs without arg description", \$arg_hide], -); - -%shortcuts = (H => "help", V => "version"); - -# -- Misc Methods -- # - -sub print_underscore # string -{ - my ($string) = @_; - - my @char = unpack ('C*', $string); - my ($size, $line, $i); - $size = $#char+1; - - for ($i = 0; $i < $size; $i++) - { - $line = "$line-"; - } - return "$string\n$line\n"; -} - - -sub find_desc # array of files -> hash -{ - my %hash = (); - my $comment; - my $spaceln_cnt = 0; - - foreach my $file (@_) { - open BUFF, $file; - - foreach $i (<BUFF>) - { - if ($spaceln_cnt == 2) - { - $comment = ""; - } - if ($i =~ /^# ([^--].*)$/) - { - $comment = "$comment $1\n"; - $comment =~ s/[ \t]*$//; - } - elsif ($i =~ /^sub (\w+)[ \t]*#[ \t]*(.*)$/) - { - $name = $1; - $info = $2; - $info =~ s/^\((.*)\)$/$1/; - - $hash{"$file;$name"} = ["($info)", $comment]; - } - elsif ($i =~ /^sub (\w+)/) - { - $name = $1; - if (!$arg_hide) { - $hash{"$file;$name"} = ["NO DESCRIPTION AVAILABLE", $comment]; - } - } - elsif ($i =~ /^\n/) - { - $spaceln_cnt++; - } - else - { - $comment = ""; - } - } - } - return %hash; -} - -sub manage_args -{ - if ($ARGV[0] eq "") { - print "Usage: ./perldoc.pl [REGEX]\n\n"; - } - - foreach my $i (@ARGV) { - if ($i =~ /^--comment/) { $arg_comment = 1; } - if ($i =~ /^--hide/) { $arg_hide = 1; } - } -} - -sub print_perldoc -{ - my ($regex) = @_; - - my %hash = &find_desc (<*.pl*>); - my $filename; - - foreach my $i (sort keys %hash) { - my ($file, $type); - my ($info, $comment) = @{$hash{$i}}; - - ($file, $method) = split (/;/, $i); - - $regex =~ s/^\"(.*)\"$/$1/; - - if ($method =~ /$regex/) - { - if ($filename ne $file) - { - print &print_underscore("$file"); - $filename = $file; - } - - print "$method $info\n"; - - if ($comment ne "") - { - print "$comment\n" if ($arg_comment); - } - } - } -} - -# -- Main -- # - -my @non_options = &get_options($program, \%options, \%shortcuts); - -&print_perldoc($non_options[0]); diff --git a/po/.cvsignore b/po/.cvsignore index db4fbbc..f4e88d5 100644 --- a/po/.cvsignore +++ b/po/.cvsignore @@ -13,3 +13,4 @@ po2tbl.sed.in shares.desktop.in setup-tools-backends.pot stamp-cat-id +stamp-it diff --git a/print-conf.in b/print-conf.in deleted file mode 100755 index 125383e..0000000 --- a/print-conf.in +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Print configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# Michael Vogt <mvo@debian.org> (Debian Support) -# Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/resolv.conf -# /etc/host.conf -# /etc/hosts -# /etc/sysconfig/print -# /etc/rc.config -# /etc/smb.conf - -# Running programs affected: -# -# smbd -# nmbd -# ifconfig: check current printers and activate/deactivate. - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/print.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "print"; -$version = "@VERSION@"; -@platforms = ("redhat-7.0", "redhat-7.1", "debian-woody", "turbolinux-7.0"); - -$description =<<"end_of_description;"; - Configures the lpr subsystem. -end_of_description; - -$progress_max = 10; - - -# --- XML parsing --- - -# Scan XML from standard input to an internal tree. - -sub xml_parse -{ - my ($tree, %hash); - # Scan XML to tree. - - $tree = &gst_xml_scan; - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "print" tag. - - while (@$tree) - { - if ($$tree[0] eq "print") { &xml_parse_print ($$tree[1], \%hash); } - - shift @$tree; - shift @$tree; - } - - return(\%hash); -} - -# <print>...</print> - -sub xml_parse_print -{ - my $tree = $_[0]; - my $hash = $_[1]; - my %printer; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "printer") { &xml_parse_printer ($$tree[1], \%printer); } - - shift @$tree; - shift @$tree; - } - - %$hash = %printer if scalar keys %printer; -} - -# <printer>...</printer> - -sub xml_parse_printer -{ - my $tree = $_[0]; - my $printer = $_[1]; - my %hash, %section_hash; - my $dev; - - shift @$tree; - - while (@$tree) - { - $hash{$$tree[0]} = &gst_xml_get_pcdata ($$tree[1]); - - # If get_pcdata returns an array instead of a scalar, we have - # a subsection to process. - if ( ref($hash{$$tree[0]}) eq "ARRAY" ) { - $hash{$$tree[0]} = &xml_parse_section($$tree[1]); - } - - shift @$tree; - shift @$tree; - } - - $dev = $hash{"name"}; - $$printer{$dev} = \%hash; -} - -sub xml_parse_section -{ - my $tree = $_[0]; - my %hash; - my $dev; - - while (@$tree) - { - $hash{$$tree[0]} = &gst_xml_get_pcdata ($$tree[1]); - - shift @$tree; - shift @$tree; - } - - return \%hash; -} - -# --- XML printing --- # - -sub xml_print_section -{ - -} - -sub xml_print_printer -{ - my ($h, $spool) = @_; - my ($i, $val, $section); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<printer>\n"); - &gst_xml_enter (); - - $val = &gst_xml_quote ($spool); - &gst_xml_print_line ("<name>$val</name>"); - - foreach $i (keys (%$h)) - { - $val = &gst_xml_quote ($$h{$i}); - &gst_xml_print_line ("<$i>$val</$i>\n"); - } - - &gst_xml_leave (); - &gst_xml_print_line ("</printer>\n"); -} - -sub xml_print -{ - my $h = $_[0]; - my ($i, $val); - - &gst_xml_print_begin (); - - foreach $i (keys (%$h)) - { - &xml_print_printer ($$h{$i}, $i); - } - - &gst_xml_print_end (); -} - - -# Top-level actions. - - -sub get -{ - my $hash; - - $hash = &gst_print_conf_get (); - &gst_report_end (); - &xml_print ($hash); -} - - -sub set -{ - my $hash; - - $hash = &xml_parse (); - &gst_print_conf_set ($hash); - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - my $hash; - - $hash = &xml_parse (); - &gst_report_end (); - &xml_print ($hash); -} - - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = -{ - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] -}; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/print.pl.in b/print.pl.in deleted file mode 100644 index 2f4f0c8..0000000 --- a/print.pl.in +++ /dev/null @@ -1,335 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Common printer configuration functionality. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/parse.pl$DOTIN"; -require "$SCRIPTSDIR/replace.pl$DOTIN"; - - -sub gst_print_conf_get -{ - my (%dist_attrib, %hash, %fn, @printers, $printer); - my ($dist, $value, $file, $proc); - my ($i, $j); - - %dist_attrib = &gst_print_get_printer_parse_table (); - %fn = %{$dist_attrib{"fn"}}; - $proc = $dist_attrib{"printers_get"}; - @printers = &$proc (); - - foreach $i (@printers) - { - foreach $j (keys (%fn)) - { - my $spooldir = "/var/spool/lpd/$i"; # Not flexible, FIXME. - - $value = $fn {$j}; - $value =~ s/\#printer\#/$i/; - $value =~ s/\#spooldir\#/$spooldir/; - $ {$dist_attrib{"fn"}}{$j} = $value; - } - - $printer = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - $hash {$i} = $printer; - } - - return \%hash; -} - -sub gst_print_conf_set -{ - my ($values_hash) = @_; - my ($old_hash); - my (%dist_attrib, %hash, %fn, @printers, $printer); - my ($dist, $value, $file, $proc); - my ($i, $j); - my $res = 0; - - $old_hash = &gst_print_conf_get (); - - %dist_attrib = &gst_print_get_printer_replace_table (); - %fn = %{$dist_attrib{"fn"}}; - - # Remove unspecified printers. - - foreach $i (keys (%$old_hash)) - { - if (!$$values_hash{$i}) - { - # TODO: Delete spool dir recursively. - $proc = $dist_attrib {"printer_remove"}; - &$proc ($fn {'PRINTCAP'}, $i); - } - } - - # Change/add printer values as specified. - - foreach $i (keys (%$values_hash)) - { - foreach $j (keys (%fn)) - { - my $spooldir = "/var/spool/lpd/$i"; # Not flexible, FIXME. - - $value = $fn {$j}; - $value =~ s/\#printer\#/$i/; - $value =~ s/\#spooldir\#/$spooldir/; - $ {$dist_attrib{"fn"}}{$j} = $value; - } - - my $tmpres = &gst_replace_from_table ($dist_attrib {"fn"}, - $dist_attrib {"table"}, - $$values_hash {$i}, - $$old_hash {$i}); - - if ($tmpres < 0) { $res = $tmpres; } - } - - return $res; -} - -sub gst_print_printers_get_rh70 -{ - my @printers; - - @printers = &gst_parse_cap_sections ("/etc/printcap"); - return @printers; -} - -sub gst_print_printers_get_rh71 -{ - my @printers; - - @printers = &gst_parse_xml_child_names ("/etc/alchemist/namespace/printconf/local.adl", - "/adm_context/datatree/printconf/print_queues"); - return @printers; -} - -sub gst_print_remove_printer_rh71 -{ -} - -sub gst_print_get_printer_parse_table -{ - my %dist_map = - ( - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.1", - "openna-1.0" => "redhat-7.0", - "debian-2.2" => "redhat-7.0", - "debian-woody" => "redhat-7.0" - ); - - my %dist_tables = - ( - "redhat-7.0" => - { - printers_get => \&gst_print_printers_get_rh70, - fn => - { - PRINTCAP => "/etc/printcap", - GENERAL => "#spooldir#/general.cfg", - POSTSCRIPT => "#spooldir#/postscript.cfg", - TEXTONLY => "#spooldir#/textonly.cfg", - PRINTER => "#printer#" - }, - table => - [ - [ "spooldir", \&gst_parse_printcap, [PRINTCAP, PRINTER], "sd" ], - [ "jobsize_max_k", \&gst_parse_printcap, [PRINTCAP, PRINTER], "mx" ], - [ "suppress_headers", \&gst_parse_printcap_bool, [PRINTCAP, PRINTER], "sh" ], - [ "device", \&gst_parse_printcap, [PRINTCAP, PRINTER], "lp" ], - [ "filter", \&gst_parse_printcap, [PRINTCAP, PRINTER], "if" ], - [ "papersize", \&gst_parse_sh_export, GENERAL, PAPERSIZE ], - [ "type", \&gst_parse_sh_export, GENERAL, PRINTERTYPE ], - [ "ascii_to_ps", \&gst_parse_sh_export_bool, GENERAL, ASCII_TO_PS ], - [ "gsdevice", \&gst_parse_sh, POSTSCRIPT, GSDEVICE ], - [ "resolution", \&gst_parse_sh, POSTSCRIPT, RESOLUTION ], - [ "color", \&gst_parse_sh, POSTSCRIPT, COLOR ], - [ "gs_papersize", \&gst_parse_sh, POSTSCRIPT, PAPERSIZE ], - [ "gs_options", \&gst_parse_sh, POSTSCRIPT, EXTRA_GS_OPTIONS ], - [ "ps_send_eof", \&gst_parse_sh_bool, POSTSCRIPT, PS_SEND_EOF ], - [ "pages_per_sheet", \&gst_parse_sh, POSTSCRIPT, NUP ], - [ "rt_margin", \&gst_parse_sh, POSTSCRIPT, RTLFTMAR ], - [ "tb_margin", \&gst_parse_sh, POSTSCRIPT, TOPBOTMAR ], - [ "text_options", \&gst_parse_sh, TEXTONLY, TEXTONLYOPTIONS ], - [ "trans_crlf", \&gst_parse_sh_bool, TEXTONLY, CRLFTRANS ], - [ "text_send_eof", \&gst_parse_sh_bool, TEXTONLY, TEXT_SEND_EOF ] - ] - }, - "redhat-7.1" => - { - printers_get => \&gst_print_printers_get_rh71, - fn => - { - PRINTCONF => "/etc/alchemist/namespace/printconf/local.adl", - PRINTER => "#printer#" - }, - table => - [ -# [ "spooldir", \&gst_parse_printcap, [PRINTCAP, PRINTER], "sd" ], -# [ "jobsize_max_k", \&gst_parse_printcap, [PRINTCAP, PRINTER], "mx" ], -# [ "suppress_headers", \&gst_parse_printcap_bool, [PRINTCAP, PRINTER], "sh" ], - [ "device", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/local_printer_device" ], -# [ "papersize", \&gst_parse_sh_export, GENERAL, PAPERSIZE ], -# [ "ascii_to_ps", \&gst_parse_sh_export_bool, GENERAL, ASCII_TO_PS ], - [ "filter_type", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "filter_type" ], - [ "type", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_type" ], - [ "printer_id", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "filter_data/printer_id" ], - [ "gsdevice", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "filter_data/gs_driver" ], - [ "smb_workgroup", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/smb_workgroup" ], - [ "smb_share", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/smb_share" ], - [ "smb_ip", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/smb_ip" ], - [ "smb_user", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/smb_user" ], - [ "smb_password", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/smb_password" ], - [ "smb_translate", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/smb_translate" ], - [ "lpd_server", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/lpd_server" ], - [ "lpd_queue", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/lpd_queue" ], - [ "lpd_server", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/lpd_server" ], - [ "jetdirect_ip", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/jetdirect_ip" ], - [ "jetdirect_port", \&gst_parse_alchemist_print, [PRINTCONF, PRINTER], "queue_data/jetdirect_port" ], - [ "resolution", \&gst_parse_alchemist_print_option, [PRINTCONF, PRINTER], "Resolution" ], -# [ "color", \&gst_parse_sh, POSTSCRIPT, COLOR ], -# [ "gs_papersize", \&gst_parse_sh, POSTSCRIPT, PAPERSIZE ], -# [ "gs_options", \&gst_parse_sh, POSTSCRIPT, EXTRA_GS_OPTIONS ], -# [ "ps_send_eof", \&gst_parse_sh_bool, POSTSCRIPT, PS_SEND_EOF ], -# [ "pages_per_sheet", \&gst_parse_sh, POSTSCRIPT, NUP ], -# [ "rt_margin", \&gst_parse_sh, POSTSCRIPT, RTLFTMAR ], -# [ "tb_margin", \&gst_parse_sh, POSTSCRIPT, TOPBOTMAR ], -# [ "text_options", \&gst_parse_sh, TEXTONLY, TEXTONLYOPTIONS ], -# [ "trans_crlf", \&gst_parse_sh_bool, TEXTONLY, CRLFTRANS ], -# [ "text_send_eof", \&gst_parse_sh_bool, TEXTONLY, TEXT_SEND_EOF ] - ] - } - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub gst_print_get_printer_replace_table -{ - my %dist_map = - ( - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.1", - "openna-1.0" => "redhat-7.0", - "debian-2.2" => "redhat-7.0", - "debian-woody" => "redhat-7.0" - ); - - my %dist_tables = - ( - "redhat-7.0" => - { - printers_get => \&gst_print_printers_get_rh70, - printer_remove => \&gst_replace_printcap_remove_printer, - fn => - { - PRINTCAP => "/etc/printcap", - GENERAL => "#spooldir#/general.cfg", - POSTSCRIPT => "#spooldir#/postscript.cfg", - TEXTONLY => "#spooldir#/textonly.cfg", - PRINTER => "#printer#" - }, - table => - [ - [ "spooldir", \&gst_replace_printcap, [PRINTCAP, PRINTER], "sd", "=" ], - [ "jobsize_max_k", \&gst_replace_printcap, [PRINTCAP, PRINTER], "mx", "#" ], - [ "suppress_headers", \&gst_replace_printcap, [PRINTCAP, PRINTER], "sh", "" ], - [ "device", \&gst_replace_printcap, [PRINTCAP, PRINTER], "lp", "=" ], - [ "filter", \&gst_replace_printcap, [PRINTCAP, PRINTER], "if", "=" ], - [ "papersize", \&gst_replace_sh_export, GENERAL, PAPERSIZE ], - [ "type", \&gst_replace_sh_export, GENERAL, PRINTERTYPE ], - [ "ascii_to_ps", \&gst_replace_sh_export_bool, GENERAL, ASCII_TO_PS ], - [ "gsdevice", \&gst_replace_sh, POSTSCRIPT, GSDEVICE ], - [ "resolution", \&gst_replace_sh, POSTSCRIPT, RESOLUTION ], - [ "color", \&gst_replace_sh, POSTSCRIPT, COLOR ], - [ "gs_papersize", \&gst_replace_sh, POSTSCRIPT, PAPERSIZE ], - [ "gs_options", \&gst_replace_sh, POSTSCRIPT, EXTRA_GS_OPTIONS ], - [ "ps_send_eof", \&gst_replace_sh_bool, POSTSCRIPT, PS_SEND_EOF ], - [ "pages_per_sheet", \&gst_replace_sh, POSTSCRIPT, NUP ], - [ "rt_margin", \&gst_replace_sh, POSTSCRIPT, RTLFTMAR ], - [ "tb_margin", \&gst_replace_sh, POSTSCRIPT, TOPBOTMAR ], - [ "text_options", \&gst_replace_sh, TEXTONLY, TEXTONLYOPTIONS ], - [ "trans_crlf", \&gst_replace_sh_bool, TEXTONLY, CRLFTRANS ], - [ "text_send_eof", \&gst_replace_sh_bool, TEXTONLY, TEXT_SEND_EOF ] - ] - }, - "redhat-7.1" => - { - printers_get => \&gst_print_printers_get_rh71, - printer_remove => \&gst_print_remove_printer_rh71, - fn => - { - PRINTCONF => "/etc/alchemist/namespace/printconf/local.adl", - PRINTER => "#printer#" - }, - table => - [ -# [ "spooldir", \&gst_replace_printcap, [PRINTCAP, PRINTER], "sd", "=" ], -# [ "jobsize_max_k", \&gst_replace_printcap, [PRINTCAP, PRINTER], "mx", "#" ], -# [ "suppress_headers", \&gst_replace_printcap, [PRINTCAP, PRINTER], "sh", "" ], - [ "device", \&gst_replace_alchemist_print, [PRINTCONF, PRINTER], "queue_data/local_printer_device/", "STRING" ], - [ "filter_type", \&gst_replace_alchemist_print, [PRINTCONF, PRINTER], "filter_type", "STRING" ], - [ "type", \&gst_replace_alchemist_print, [PRINTCONF, PRINTER], "queue_type", "STRING" ], - [ "printer_id", \&gst_replace_alchemist_print, [PRINTCONF, PRINTER], "filter_data/printer_id", "STRING" ], -# [ "filter", \&gst_replace_printcap, [PRINTCAP, PRINTER], "if", "=" ], -# [ "papersize", \&gst_replace_sh_export, GENERAL, PAPERSIZE ], -# [ "ascii_to_ps", \&gst_replace_sh_export_bool, GENERAL, ASCII_TO_PS ], - [ "gsdevice", \&gst_replace_alchemist_print, [PRINTCONF, PRINTER], "filter_data/gs_driver", "STRING" ], - [ "resolution", \&gst_replace_alchemist_print_option, [PRINTCONF, PRINTER], "Resolution", "enum" ] -# [ "color", \&gst_replace_sh, POSTSCRIPT, COLOR ], -# [ "gs_papersize", \&gst_replace_sh, POSTSCRIPT, PAPERSIZE ], -# [ "gs_options", \&gst_replace_sh, POSTSCRIPT, EXTRA_GS_OPTIONS ], -# [ "ps_send_eof", \&gst_replace_sh_bool, POSTSCRIPT, PS_SEND_EOF ], -# [ "pages_per_sheet", \&gst_replace_sh, POSTSCRIPT, NUP ], -# [ "rt_margin", \&gst_replace_sh, POSTSCRIPT, RTLFTMAR ], -# [ "tb_margin", \&gst_replace_sh, POSTSCRIPT, TOPBOTMAR ], -# [ "text_options", \&gst_replace_sh, TEXTONLY, TEXTONLYOPTIONS ], -# [ "trans_crlf", \&gst_replace_sh_bool, TEXTONLY, CRLFTRANS ], -# [ "text_send_eof", \&gst_replace_sh_bool, TEXTONLY, TEXT_SEND_EOF ] - ] - } - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -1; diff --git a/removable-media.pl.in b/removable-media.pl.in deleted file mode 100644 index 8a3e559..0000000 --- a/removable-media.pl.in +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Detect, print and manipulate local removable media devices. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/be.pl$DOTIN"; -require "$SCRIPTSDIR/media.pl$DOTIN"; - - -# gst_removable_media_get_list -# -# Return a list of hashes describing the removable media devices present -# on this machine. - -sub gst_removable_media_get_list -{ - my @devices; - - @devices = &gst_media_get_list(); - - # TODO: Weed out fixed media. - - return @devices; -} - - -# gst_removable_media_xml_print -# -# Given a media hash-list, prints the removables inside a <removables> tag -# pair, using current indent levels. - -sub gst_removable_media_xml_print -{ - &gst_xml_print_vspace (); - &gst_xml_print_line ("<removables>\n"); - &gst_xml_enter (); - - - - &gst_xml_leave (); - &gst_xml_print_line ("</removables>\n"); - &gst_xml_print_vspace (); -} diff --git a/rhprinterdb2gstxml.pl b/rhprinterdb2gstxml.pl deleted file mode 100755 index be456a6..0000000 --- a/rhprinterdb2gstxml.pl +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env perl - -$indent_level = 0; - -sub print_xml_line -{ - my ($text) = @_; - - print " " x $indent_level; - print $text . "\n"; -} - -sub xml_enter -{ - $indent_level += 2; -} - -sub xml_leave -{ - $indent_level -= 2; -} - -sub xml_quote -{ - my $in = $_[0]; - my $out = ""; - my @xe; - my $joined = 0; - my @xml_entities = ( "<", '<', ">", '>', "'", '\'', """, '"', "&", '&' ); - - my @clist = split (//, $in); - - while (@clist) - { - # Find character and join its entity equivalent. - # If none found, simply join the character. - - $joined = 0; # Cumbersome. - - for (@xe = @xml_entities; @xe && !$joined; ) - { - if ($xe [1] eq $clist [0]) { $out = join ('', $out, $xe [0]); $joined = 1; } - shift @xe; shift @xe; - } - - if (!$joined) { $out = join ('', $out, $clist [0]); } - shift @clist; - } - - return $out; -} - -sub convert_about -{ - &print_xml_line ("<comment>"); - - while (<STDIN>) - { - chomp; - s/^[ \t]+//; - s/[ \\]+$//; - if (/^\#/) { next; } - if (/^\}/) { last; } - s/\\n\\n/\n/g; - s/\\n/\n/g; - - print &xml_quote ($_) . "\n"; - } - - &print_xml_line ("</comment>"); -} - -sub convert -{ - while (<STDIN>) - { - chomp; - s/^[ \t]+//; - s/[ \\]+$//; - if (/^\#/ || /^$/) { next; } - - if (/^StartEntry: *(.*)/) - { - &print_xml_line ("<printerdef id='" . &xml_quote ($1) . "'>"); - &xml_enter; - } - elsif (/^EndEntry/) - { - &xml_leave; - &print_xml_line ("</printerdef>\n"); - } - elsif (/^GSDriver: *(.*)/) - { - &print_xml_line ("<gsdriver name='" . &xml_quote ($1) . "'/>"); - } - elsif (/^Description: *{ *(.*) *}/) - { - &print_xml_line ("<description>" . &xml_quote ($1) . "</description>"); - } - elsif (/^About:/) - { - &convert_about (); - } - elsif (/^Resolu?tion: *\{ *([a-zA-Z0-9]+) *\} *\{ *([a-zA-Z0-9]+) *\}/) - { - &print_xml_line ("<resolution x='" . &xml_quote ($1) . "' y='" . &xml_quote ($2) . "'/>"); - } - elsif (/^BitsPerPixel: *\{ *([^\} ]+) *\} *\{ *([^\}]+)\}/) - { - &print_xml_line ("<mode id='" . &xml_quote ($1) . "'>" . &xml_quote ($2) . "</mode>"); - } - else - { - print "\t*** " . $_ . "\n"; - } - } -} - -&convert (); diff --git a/service.pl.in b/service.pl.in deleted file mode 100644 index 2a35a1f..0000000 --- a/service.pl.in +++ /dev/null @@ -1,2082 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Functions for manipulating system services, like daemons and network. -# -# Copyright (C) 2002 Ximian, Inc. -# -# Authors: Carlos Garnacho Parro <garparr@teleline.es>, -# Hans Petter Jansson <hpj@ximian.com>, -# Arturo Espinosa <arturo@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -$rcd_path; -$initd_path; -$relative_path; - -$SCRIPTSDIR = "@scriptsdir@"; -$FILESDIR = "@filesdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $FILESDIR = "files"; - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -use File::Copy; - -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/report.pl$DOTIN"; -require "$SCRIPTSDIR/service-list.pl$DOTIN"; - -# Where is the SysV subsystem installed? -sub gst_service_sysv_get_paths -{ - my %dist_map = - ( - # gst_dist => [rc.X dirs location, init.d scripts location, relative path location] - "redhat-5.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-6.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-6.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-6.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-7.3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-8.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "redhat-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "openna-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "mandrake-7.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-7.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-9.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-9.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-9.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-10.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-10.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandrake-10.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandriva-2006.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "mandriva-2006.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "yoper-2.2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "blackpanther-4.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "conectiva-9" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "conectiva-10" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "debian-2.2" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "debian-3.0" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "debian-sarge" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "ubuntu-5.04" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "ubuntu-5.10" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - "ubuntu-6.04" => ["$gst_prefix/etc", "$gst_prefix/etc/init.d", "../init.d"], - - "suse-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d", "../"], - "suse-9.0" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], - "suse-9.1" => ["$gst_prefix/etc/init.d", "$gst_prefix/etc/init.d", "../"], - - "turbolinux-7.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "pld-1.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "pld-1.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "pld-1.99" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "fedora-1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "fedora-2" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "fedora-3" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "fedora-4" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "rpath" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - - "vine-3.0" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "vine-3.1" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - "ark" => ["$gst_prefix/etc/rc.d", "$gst_prefix/etc/rc.d/init.d", "../init.d"], - ); - my $res; - - $res = $dist_map{$gst_dist}; - &gst_report ("service_sysv_unsupported", $gst_dist) if ($res eq undef); - return @$res; -} - -# Those runlevels that are usually used. Maybe we should add -# the current running runlevel, using the "runlevel" command. -sub gst_service_sysv_get_runlevels -{ - my %dist_map = - ( - "redhat-5.2" => [3, 5], - "redhat-6.0" => [3, 5], - "redhat-6.1" => [3, 5], - "redhat-6.2" => [3, 5], - "redhat-7.0" => [3, 5], - "redhat-7.1" => [3, 5], - "redhat-7.2" => [3, 5], - "redhat-7.3" => [3, 5], - "redhat-8.0" => [3, 5], - "redhat-9" => [3, 5], - "openna-1.0" => [3, 5], - - "mandrake-7.1" => [3, 5], - "mandrake-7.2" => [3, 5], - "mandrake-9.0" => [3, 5], - "mandrake-9.1" => [3, 5], - "mandrake-9.2" => [3, 5], - "mandrake-10.0" => [3, 5], - "mandrake-10.1" => [3, 5], - "mandrake-10.2" => [3, 5], - "mandriva-2006.0" => [3, 5], - "mandriva-2006.1" => [3, 5], - - "yoper-2.2" => [3, 5], - - "blackpanther-4.0" => [3, 5], - - "conectiva-9" => [3, 5], - "conectiva-10" => [3, 5], - - "debian-2.2" => [2, 3], - "debian-3.0" => [2, 3], - "debian-sarge" => [2, 3], - "ubuntu-5.04" => [2, 3], - "ubuntu-5.10" => [2, 3], - "ubuntu-6.04" => [2, 3], - - "suse-7.0" => [3, 5], - "suse-9.0" => [3, 5], - "suse-9.1" => [3, 5], - - "turbolinux-7.0" => [3, 5], - - "pld-1.0" => [3, 5], - "pld-1.1" => [3, 5], - "pld-1.99" => [3, 5], - - "fedora-1" => [3, 5], - "fedora-2" => [3, 5], - "fedora-3" => [3, 5], - "fedora-4" => [3, 5], - "rpath" => [3, 5], - - "vine-3.0" => [3, 5], - "vine-3.1" => [3, 5], - "ark" => [3, 5], - ); - my $res; - - $res = $dist_map{$gst_dist}; - &gst_report ("service_sysv_unsupported", $gst_dist) if ($res eq undef); - return @$res; -} - -sub gst_service_get_runlevel_roles -{ - my (%dist_map, %runlevels, $desc, $distro); - %dist_map = - ( - "redhat-5.2" => "redhat-5.2", - "redhat-6.0" => "redhat-5.2", - "redhat-6.1" => "redhat-5.2", - "redhat-6.2" => "redhat-5.2", - "redhat-7.0" => "redhat-5.2", - "redhat-7.1" => "redhat-5.2", - "redhat-7.2" => "redhat-5.2", - "redhat-7.3" => "redhat-5.2", - "redhat-8.0" => "redhat-5.2", - "redhat-9" => "redhat-5.2", - "openna-1.0" => "redhat-5.2", - - "mandrake-7.1" => "redhat-5.2", - "mandrake-7.2" => "redhat-5.2", - "mandrake-9.0" => "redhat-5.2", - "mandrake-9.1" => "redhat-5.2", - "mandrake-9.2" => "redhat-5.2", - "mandrake-10.0" => "redhat-5.2", - "mandrake-10.1" => "redhat-5.2", - "mandrake-10.2" => "redhat-5.2", - "mandriva-2006.0" => "redhat-5.2", - "mandriva-2006.1" => "redhat-5.2", - - "yoper-2.2" => "redhat-5.2", - - "blackpanther-4.0" => "redhat-5.2", - - "conectiva-9" => "redhat-5.2", - "conectiva-10" => "redhat-5.2", - - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "ubuntu-5.04" => "debian-2.2", - "ubuntu-5.10" => "debian-2.2", - "ubuntu-6.04" => "debian-2.2", - - "suse-7.0" => "redhat-5.2", - "suse-9.0" => "redhat-5.2", - "suse-9.1" => "redhat-5.2", - - "turbolinux-7.0" => "redhat-5.2", - "pld-1.0" => "redhat-5.2", - "pld-1.1" => "redhat-5.2", - "pld-1.99" => "redhat-5.2", - "fedora-1" => "redhat-5.2", - "fedora-2" => "redhat-5.2", - "fedora-3" => "redhat-5.2", - "fedora-4" => "redhat-5.2", - "rpath" => "redhat-5.2", - - "vine-3.0" => "redhat-5.2", - "vine-3.1" => "redhat-5.2", - "ark" => "redhat-5.2", - - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - - "archlinux" => "freebsd-5", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - %runlevels= - ( - "redhat-5.2" => {"0" => "HALT", - "1" => "RECOVER", - "2" => "NONE", - "3" => "TEXT", - "4" => "NONE", - "5" => "GRAPHICAL", - "6" => "REBOOT" - }, - "debian-2.2" => {"0" => "HALT", - "1" => "RECOVER", - "2" => "NONE", - "3" => "NONE", - "4" => "NONE", - "5" => "NONE", - "6" => "REBOOT" - }, - "gentoo" => {"boot" => "BOOT", - "default" => "GRAPHICAL", - "nonetwork" => "RECOVER" - }, - "freebsd-5" => {"rc" => "GRAPHICAL" }, - "slackware-9.1.0" => {"4" => "GRAPHICAL" } - ); - - $distro = $dist_map{$gst_dist}; - $desc = $runlevels{$distro}; - - return $runlevels{$distro}; -} - -# --- Plain process utilities --- # - -# Get owners list (login) of named process. -sub gst_service_proc_get_owners -{ - my ($service) = @_; - my ($user, $pid, $command); - my ($fd); - my (@arr); - - &gst_report_enter (); - - $fd = gst_file_run_pipe_read ("ps acx -o user,pid,command"); - - while (<$fd>) - { - /(.*)[ \t]+(.*)[ \t]+(.*)/; - $user = $1; - $pid = $2; - $command = $3; - - push @arr, $user if ($command eq $service); - } - - &gst_report_leave (); - return \@arr; -} - -# Stops all instances of a process -sub gst_service_proc_stop_all -{ - my ($service) = @_; - - return &gst_file_run ("killall $service"); -} - -# Starts instances of a process for a given list of users -sub gst_service_proc_start_all -{ - my ($cmd, $users) = @_; - my ($fqcmd, $fqsu); - - $fqcmd = &gst_file_get_cmd_path ($cmd); - $fqsu = &gst_file_locate_tool ("su"); - - foreach $user (@$users) - { - # Can't use gst_file_run_bg here, since it clobbers the quotes. - system ("$fqsu $user -c \"$fqcmd &\" >/dev/null 2>/dev/null"); - } -} - -sub gst_service_sysv_list_dir -{ - my ($path) = @_; - my ($service, @services); - - foreach $service (<$path/*>) - { - if (-x $service) - { - $service =~ s/.*\///; - push @services, $service; - } - } - - return \@services; -} - -sub gst_service_sysv_list_available -{ - my ($rcd_path, $initd_path); - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - return &gst_service_sysv_list_dir ($initd_path); -} - -# Return 1 or 0: is the service running? -# Depends on the rc script to support the "status" arg. -# Maybe we should do something more portable. -sub gst_service_sysv_get_status -{ - my ($service) = @_; - my ($rc_path, $initd_path, $res); - my ($pid); - - &gst_report_enter (); - - # Stolen from RedHat's /etc/rc.d/init.d/functions:status - # FIXME: portable to other UNIXES? - $pid = &gst_file_run_backtick ("pidof -o %PPID -x $service"); - chomp $pid; - - if ($pid) - { - $res = 1; - &gst_report ("service_status_running", $service); - } - else - { - $res = 0; - &gst_report ("service_status_stopped", $service); - } - -# ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); -# $res = 0; -# -# if (-f "$initd_path/$service") -# { -# $res = &gst_file_run ("$initd_path/$service status")? 0 : 1; -# &gst_report ("service_status_running", $service) if $res; -# &gst_report ("service_status_stopped", $service) if !$res; -# } - - &gst_report_leave (); - return $res; -} - -# If any of the passed services is running, return true. -sub gst_service_sysv_get_status_any -{ - my (@services) = @_; - my $i; - - foreach $i (@services) - { - return 1 if &gst_service_sysv_get_status ($i); - } - - return 0; -} - -# Set start links and remove stop links at the usual runlevels. -# Old start link is removed, in case the priority is different from $pri. -sub gst_service_sysv_set_links_active -{ - my ($pri, $service) = @_; - - foreach $runlevel (&gst_service_sysv_get_runlevels ()) - { - &gst_service_sysv_remove_link ($runlevel, $service); - &gst_service_sysv_add_link ($runlevel, "S", $pri, $service); - } -} - -# Set stop links and remove start links at the usual runlevels. -sub gst_service_sysv_set_links_inactive -{ - my ($pri, $service) = @_; - - foreach $runlevel (&gst_service_sysv_get_runlevels ()) - { - &gst_service_sysv_remove_link ($runlevel, "$service"); - &gst_service_sysv_add_link ($runlevel, "K", $pri, $service); - } -} - -# Set links for active/inactive service at the given priority. -sub gst_service_sysv_set_links -{ - my ($pri, $service, $active) = @_; - - if ($active) - { - &gst_service_sysv_set_links_active ($pri, $service); - } - else - { - &gst_service_sysv_set_links_inactive (100 - $pri, $service); - } -} - - - -# Start or stop the service, depending on $active. Set -# links accordingly. $force makes this function use -# start/stop only, without considerations for restart. -# Not to be called from parse/replace tables, due to last $force -# param: use the following two functions instead. -sub gst_service_sysv_set_status_do -{ - my ($priority, $service, $active, $force) = @_; - my ($arg, $status); - - &gst_service_sysv_set_links ($priority, $service, $active); - - $status = &gst_service_sysv_get_status ($service); - if ($status && !$force) - { - # if it's already active and you want it active, restart. - $arg = $active? "restart" : "stop"; - } - else - { - # normal operation. - $arg = $active? "start" : "stop"; - } - - return &gst_service_sysv_run_initd_script ($service, $arg); -} - -sub gst_service_sysv_set_status -{ - my ($priority, $service, $active) = @_; - - return &gst_service_sysv_set_status_do ($priority, $service, $active, 0); -} - -sub gst_service_sysv_force_status -{ - my ($priority, $service, $active) = @_; - - return &gst_service_sysv_set_status_do ($priority, $service, $active, 1); -} - -sub gst_service_sysv_install_script -{ - my ($service, $file) = @_; - my ($res, $rcd_path, $initd_path); - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - if (!copy ("$FILESDIR/$file", "$initd_path/$service")) - { - &gst_report ("file_copy_failed", "$FILESDIR/$file", "$initd_path/$service"); - return -1; - } - - chmod (0755, "$initd_path/$service"); - - return 0; -} - -# THESE ARE THE FUNCTIONS WHICH EXTRACT THE CONFIGURATION FROM THE COMPUTER - -# we are going to extract the name of the script -sub gst_service_sysv_get_service_name -{ - my ($service) = @_; - - $service =~ s/$initd_path\///; - - return $service; -} - -# This function gets the state of the service along the runlevels, -# it also returns the average priority -sub gst_service_sysv_get_runlevels_status -{ - my ($service) = @_; - my ($link); - my ($runlevel, $action, $priority); - my (@arr, @ret); - - foreach $link (<$rcd_path/rc[0-6].d/[SK][0-9][0-9]$service>) - { - $link =~ s/$rcd_path\///; - $link =~ /rc([0-6])\.d\/([SK])([0-9][0-9]).*/; - ($runlevel,$action,$priority)=($1,$2,$3); - if ($action eq "S") - { - push @arr, { "name" => $runlevel, - "priority" => $priority, - "action" => "start" }; - } - elsif ($action eq "K") - { - push @arr, { "name" => $runlevel, - "priority" => (100 - $priority), - "action" => "stop" }; - } - } - - return undef if (scalar(@arr) eq 0); - - push @ret, { "runlevel" => \@arr }; - return \@ret; -} - -# We are going to extract the information of the service -sub gst_service_sysv_get_service_info -{ - my ($service) = @_; - my ($script, @actions, @runlevels); - my %hash, $role; - - # Return if it's a directory - return undef if (-d $service); - - # We have to check if the service is executable - return undef unless (-x $service); - - $script = &gst_service_sysv_get_service_name ($service); - - # We have to check out if the service is in the "forbidden" list - return undef if (&gst_service_list_service_is_forbidden ($script)); - - $runlevels = &gst_service_sysv_get_runlevels_status($script); - - $hash{"script"} = $script; - $hash{"runlevels"} = $runlevels unless ($runlevels eq undef); - $hash{"role"} = &gst_service_get_role ($script); - - return \%hash; -} - -# This function gets an ordered array of the available services from a SysV system -sub gst_service_sysv_get_services -{ - my ($service); - my (@arr,%ret); - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - foreach $service (<$initd_path/*>) - { - my (%hash); - $hash = &gst_service_sysv_get_service_info ($service); - if ($hash ne undef) - { - $ret{$service} = $hash; - } - } - - return \%ret; -} - -# This functions get an ordered array of the available services from a file-rc system -sub gst_service_filerc_get_runlevels_status -{ - my ($start_service, $stop_service, $priority) = @_; - my (@arr, @ret); - - # we start with the runlevels in which the service starts - if ($start_service !~ /-/) { - my (@runlevels); - - @runlevels = split /,/, $start_service; - - foreach $runlevel (@runlevels) - { - push @arr, { "name" => $runlevel, - "action" => "start", - "priority" => $priority}; - } - } - - # now let's go with the runlevels in which the service stops - if ($stop_service !~ /-/) { - my (@runlevels); - - @runlevels = split /,/, $stop_service; - - foreach $runlevel (@runlevels) - { - push @arr, { "name" => $runlevel, - "action" => "stop", - "priority" => $priority}; - } - } - - push @ret, {"runlevel" => \@arr}; - return \@ret; -} - -sub gst_service_filerc_get_service_info -{ - my ($line, %ret) = @_; - my %hash; - my @runlevels; - - if ($line =~ /^([0-9][0-9])[\t ]+([0-9\-S,]+)[\t ]+([0-9\-S,]+)[\t ]+\/etc\/init\.d\/(.*)/) - { - $priority = $1; - $stop_service = $2; - $start_service = $3; - $script = $4; - - return undef if (&gst_service_list_service_is_forbidden ($script)); - - $hash{"script"} = $script; - - $hash{"runlevels"} = &gst_service_filerc_get_runlevels_status ($start_service, $stop_service, $priority); - $hash{"role"} = &gst_service_get_role ($script); - - return (\%hash); - } - - return undef; -} - -sub gst_service_filerc_get_services -{ - my ($script); - my (%ret); - - open FILE, "$gst_prefix/etc/runlevel.conf" or return undef; - while ($line = <FILE>) - { - if ($line !~ /^#.*/) - { - my (%hash); - my ($start_service, $stop_service); - $hash = &gst_service_filerc_get_service_info ($line); - - if ($hash ne undef) - { - $script = $$hash{"script"}; - - if ($ret{$script} eq undef) - { - $ret{$script} = $hash; - } - else - { - my (@runlevels); - - # We need to mix the runlevels - @runlevels = $$hash{"runlevels"}[0]{"runlevel"}; - foreach $runlevel (@runlevels) - { - push @{$ret{$script}{"runlevels"}[0]{"runlevel"}}, $runlevel; - } - } - } - } - } - - return \%ret; -} - -# this functions get a list of the services that run on a bsd init -sub gst_service_bsd_get_service_info -{ - my ($service) = @_; - my ($script); - my (%hash); - my (@arr, @rl); - - $script = $service; - $script =~ s/^.*\///; - $script =~ s/^rc\.//; - - return undef if (! gst_file_exists ($service)); - - return undef if (&gst_service_list_service_is_forbidden ($script)); - - $hash {"script"} = $service; - - # we hardcode the fourth runlevel, it's the graphical one - if ( -x $service) - { - push @arr, { "name" => 4, - "action" => "start" }; - } - else - { - push @arr, { "name" => 4, - "action" => "stop" }; - } - - push @rl, { "runlevel" => \@arr }; - - $hash{"runlevels"} = \@rl; - $hash{"role"} = &gst_service_get_role ($script); - - return \%hash; -} - -sub gst_service_bsd_get_services -{ - my (%ret); - my ($files) = [ "rc.M", "rc.inet2", "rc.4" ]; - my ($file); - - foreach $i (@$files) - { - $file = "/etc/rc.d/" . $i; - $fd = &gst_file_open_read_from_names ($file); - - if (!$fd) { - &gst_report ("rc_file_read_failed", $file); - return undef; - } - - while (<$fd>) - { - $line = $_; - - if ($line =~ /^if[ \t]+\[[ \t]+\-x[ \t]([0-9a-zA-Z\/\.\-_]+) .*\]/) - { - my (%hash); - $service = $1; - - $hash = &gst_service_bsd_get_service_info ($service); - - if ($hash ne undef) - { - $ret{$service} = $hash; - } - } - } - - gst_file_close ($fd); - } - - return \%ret; -} - -# these functions get a list of the services that run on a gentoo init -sub gst_service_gentoo_get_service_status -{ - my ($script, $runlevel) = @_; - my ($services) = &gst_service_gentoo_get_services_by_runlevel ($runlevel); - - foreach $i (@$services) - { - return 1 if ($i eq $script); - } - - return 0; -} - -sub gst_service_gentoo_get_runlevels -{ - my($raw_output) = gst_file_run_backtick("rc-status -l"); - my(@runlevels) = split(/\n/,$raw_output); - - return @runlevels; -} - -sub gst_service_gentoo_get_services_by_runlevel -{ - my($runlevel) = @_; - my($raw_output) = gst_file_run_backtick("rc-status $runlevel"); - my(@raw_lines) = split(/\n/,$raw_output); - my(@services); - my($line); - - foreach $line (@raw_lines) - { - if ($line !~ /^Runlevel/) - { - $line=(split(" ",$line))[0]; - push(@services,$line); - } - } - - return \@services -} - -sub gst_service_gentoo_get_services_list -{ - return &gst_service_sysv_list_dir ("/etc/init.d/"); -} - -sub gst_service_gentoo_service_exist -{ - my($service) = @_; - my($services) = &gst_service_gentoo_get_services_list(); - - foreach $i (@$services) - { - return 1 if ($i =~ /$service/); - } - - return 0; -} - -sub gst_service_gentoo_get_runlevels_by_service -{ - my ($service) = @_; - my(@runlevels,@services_in_runlevel,@contain_runlevels, $runlevel); - my ($elem); - - # let's do some caching to improve performance - if ($gentoo_services_hash eq undef) - { - @runlevels = &gst_service_gentoo_get_runlevels (); - - foreach $runlevel (@runlevels) - { - $$gentoo_services_hash{$runlevel} = &gst_service_gentoo_get_services_by_runlevel ($runlevel); - } - } - - if (&gst_service_gentoo_service_exist($service)) - { - foreach $runlevel (keys %$gentoo_services_hash) - { - $services_in_runlevel = $$gentoo_services_hash {$runlevel}; - - foreach $elem (@$services_in_runlevel) - { - push (@contain_runlevels, $runlevel) if ($elem eq $service); - } - } - } - - return @contain_runlevels; -} - -sub gst_service_gentoo_runlevel_status_by_service -{ - my ($service) = @_; - my (@arr, @ret); - my (@runlevels) = &gst_service_gentoo_get_runlevels(); - my (@started) = &gst_service_gentoo_get_runlevels_by_service($service); - my (%start_runlevels) = map { $started[$_], 1 } 0 .. $#started; - - foreach $runlevel (@runlevels) - { - if (defined $start_runlevels{$runlevel}) - { - push @arr, { "name" => $runlevel, - "action" => "start" }; - } - else - { - push @arr, { "name" => $runlevel, - "action" => "stop" }; - } - } - - push @ret, { "runlevel" => \@arr }; - return @ret; -} - -sub gst_service_gentoo_get_service_info -{ - my ($service) = @_; - my ($script, @actions, @runlevels); - my %hash; - - # We have to check out if the service is in the "forbidden" list - return undef if (&gst_service_list_service_is_forbidden ($service)); - - my($runlevels) = &gst_service_gentoo_runlevel_status_by_service ($service); - - $hash{"script"} = $service; - $hash{"runlevels"} = $runlevels unless ($runlevels eq undef); - $hash{"role"} = &gst_service_get_role ($service); - - return \%hash; -} - -sub gst_service_gentoo_get_services -{ - my ($service); - my (%ret); - my ($service_list) = &gst_service_gentoo_get_services_list (); - - foreach $service (@$service_list) - { - my (%hash); - $hash = &gst_service_gentoo_get_service_info ($service); - - $ret{$service} = $hash if ($hash ne undef); - } - - return \%ret; -} - -# rcNG functions, mostly for FreeBSD - - -sub gst_service_archlinux_status_by_service -{ - my ($service) = @_; - return 1 if( -f "/var/run/daemons/$service"); - return 0; -} - -sub gst_service_rcng_status_by_service -{ - my ($service) = @_; - my ($fd, $line, $active); - - $fd = &gst_file_run_pipe_read ("/etc/rc.d/$service rcvar"); - - while (<$fd>) - { - $line = $_; - - if ($line =~ /^\$.*=YES$/) - { - $active = 1; - last; - } - } - - gst_file_close ($fd); - return $active; -} - -sub gst_service_rcng_get_service_info -{ - my ($service) = @_; - my ($script, @actions, @runlevels); - my (%hash, @arr, @rl); - - # We have to check if the service is in the "forbidden" list - return undef if (&gst_service_list_service_is_forbidden ($service)); - - $hash{"script"} = $service; - - if (gst_service_rcng_status_by_service ($service)) - { - push @arr, { "name" => "rc", - "action" => "start" }; - } - else - { - push @arr, { "name" => "rc", - "action" => "stop" }; - } - - push @rl, { "runlevel", \@arr }; - - $hash {"runlevels"} = \@rl; - $hash{"role"} = &gst_service_get_role ($service); - - return \%hash; -} - -sub gst_service_archlinux_get_service_info -{ - my ($service) = @_; - my ($script, @actions, @runlevels); - my (%hash, @arr, @rl); - - # We have to check if the service is in the "forbidden" list - return undef if (&gst_service_list_service_is_forbidden ($service)); - - $hash{"script"} = $service; - - if (&gst_service_archlinux_status_by_service ($service)) - { - push @arr, { "name" => "rc", - "action" => "start" }; - } - else - { - push @arr, { "name" => "rc", - "action" => "stop" }; - } - - push @rl, { "runlevel", \@arr }; - - $hash {"runlevels"} = \@rl; - $hash{"role"} = &gst_service_get_role ($service); - - return \%hash; -} - -sub gst_service_archlinux_get_services -{ - my ($service); - my (%ret); - - foreach $service (<$gst_prefix/etc/rc.d/*>) - { - my (%hash); - - $service =~ s/.*\///; - $hash = &gst_service_archlinux_get_service_info ($service); - - $ret{$service} = $hash if ($hash ne undef); - } - - return \%ret; -} - -sub gst_service_rcng_get_services -{ - my ($service); - my (%ret); - - foreach $service (<$gst_prefix/etc/rc.d/*>) - { - my (%hash); - - $service =~ s/.*\///; - $hash = &gst_service_rcng_get_service_info ($service); - - $ret{$service} = $hash if ($hash ne undef); - } - - return \%ret; -} -# SuSE functions, quite similar to SysV, but not equal... -sub gst_service_suse_get_service_info ($service) -{ - my ($service) = @_; - my (%hash, @arr, @ret); - - # We have to check if the service is in the "forbidden" list - return undef if (&gst_service_list_service_is_forbidden ($service)); - - $hash{"script"} = $service; - - foreach $link (<$rcd_path/rc[0-9S].d/S[0-9][0-9]$service>) - { - $link =~ s/$rcd_path\///; - $link =~ /rc([0-6])\.d\/S[0-9][0-9].*/; - $runlevel = $1; - - push @arr, { "name" => $runlevel, - "action" => "start" }; - } - - foreach $link (<$rcd_path/boot.d/S[0-9][0-9]$service>) - { - push @arr, {"name" => "B", - "action" => "start" }; - } - - if (scalar @arr > 0) - { - push @ret, { "runlevel" => \@arr }; - $hash{"runlevels"} = \@ret; - $hash{"role"} = &gst_service_get_role ($service); - } - - return \%hash; -} - -sub gst_service_suse_get_services -{ - my ($service, %ret); - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - foreach $service (<$gst_prefix/etc/init.d/*>) - { - my (%hash); - - next if (-d $service || ! -x $service); - - $service =~ s/.*\///; - $hash = &gst_service_suse_get_service_info ($service); - - $ret{$service} = $hash if ($hash ne undef); - } - - return \%ret; -} - -# generic functions to get the available services -sub gst_get_init_type -{ - if (($gst_dist =~ /debian/) && (stat ("$gst_prefix/etc/runlevel.conf"))) - { - return "file-rc"; - } - elsif ($gst_dist =~ /slackware/) - { - return "bsd"; - } - elsif ($gst_dist =~ /freebsd/) - { - return "rcng"; - } - elsif ($gst_dist =~ /archlinux/) - { - return "archlinux"; - } - elsif (($gst_dist =~ /gentoo/) || ($gst_dist =~ /^vlos/)) - { - return "gentoo"; - } - elsif ($gst_dist =~ /suse/) - { - return "suse"; - } - else - { - return "sysv"; - } -} - -sub gst_service_get_services -{ - $type = &gst_get_init_type (); - - return &gst_service_sysv_get_services () if ($type eq "sysv"); - return &gst_service_filerc_get_services () if ($type eq "file-rc"); - return &gst_service_bsd_get_services () if ($type eq "bsd"); - return &gst_service_gentoo_get_services () if ($type eq "gentoo"); - return &gst_service_rcng_get_services () if ($type eq "rcng"); - return &gst_service_suse_get_services () if ($type eq "suse"); - return &gst_service_archlinux_get_services() if ($type eq "archlinux"); - return undef; -} - - -# This function gets the runlevel that is in use -sub gst_service_sysv_get_default_runlevel -{ - my (@arr); - - @arr = split / /, `/sbin/runlevel` ; - $arr[1] =~ s/\n//; - - return $arr[1]; -} - -sub gst_service_get_default_runlevel -{ - my ($type) = &gst_get_init_type (); - - return "default" if ($type eq "gentoo"); - return "rc" if ($type eq "rcng"); - return "rc" if ($type eq "archlinux"); - return &gst_service_sysv_get_default_runlevel (); -} - - -# THESE ARE THE FUNCTIONS WHICH APPLY THE CHANGES MADE TO THE CONFIGURATION OF THE COMPUTER - -sub gst_service_sysv_add_link -{ - my ($runlevel, $action, $priority, $service) = @_; - my ($prio) = sprintf ("%0.2d",$priority); - - symlink ("$relative_path/$service", "$rcd_path/rc$runlevel.d/$action$prio$service"); - - &gst_report_enter (); - &gst_report ("service_sysv_add_link", "$rcd_path/rc$runlevel.d/$action$prio$service"); - &gst_report_leave (); -} - -sub gst_service_sysv_remove_link -{ - my ($runlevel, $script) = @_; - - foreach $link (<$rcd_path/rc$runlevel.d/[SK][0-9][0-9]$script>) - { - &gst_report ("service_sysv_remove_link", "$link"); - unlink ("$link"); - &gst_report_leave (); - } -} - - -# These are the functions for storing the service settings from XML in SysV -sub gst_service_sysv_set_service -{ - my ($service) = @_; - my ($script, $priority, $runlevels); - my ($action); - - ($rcd_path, $initd_path, $relative_path) = &gst_service_sysv_get_paths (); - - $script = $$service{"script"}; - $runlevels = $$service{"runlevels"}[0]{"runlevel"}; - - # pass though all the runlevels checking if the service must be started, stopped or removed - for ($i = 0; $i <= 6; $i++) - { - &gst_service_sysv_remove_link ($i, $script); - - $action = undef; - foreach $j (@$runlevels) - { - if ($i == $$j{"name"}) - { - $found = 1; - $action = $$j{"action"}; - $priority = $$j{"priority"}; - $priority = 50 if (!$priority); #very rough guess - } - } - - if ($action ne undef) - { - if ($action eq "start") - { - &gst_service_sysv_add_link ($i, "S", $priority, $script); - } - else - { - &gst_service_sysv_add_link ($i, "K", 100 - $priority, $script); - } - } - } -} - -sub gst_service_sysv_set_services -{ - my ($services, $runlevel) = @_; - - foreach $i (@$services) - { - &gst_service_sysv_set_service($i); - } -} - -sub gst_service_filerc_concat_runlevels -{ - my (@runlevels) = @_; - - $str = join (",", sort (@runlevels)); - return ($str) ? $str : "-"; -} - -sub gst_service_filerc_set_service -{ - my ($buff, $service) = @_; - my (%hash, $priority, $line, $str); - - $arr = $$service{"runlevels"}[0]{"runlevel"}; - - foreach $i (@$arr) - { - $priority = 0 + $$i{"priority"}; - $priority = 50 if ($priority == 0); #very rough guess - - if ($$i{"action"} eq "start") - { - $hash{$priority}{"start"} = [] if (!$hash{$priority}{"start"}); - push @{$hash{$priority}{"start"}}, $$i{"name"}; - } - else - { - $hash{$priority}{"stop"} = [] if (!$hash{$priority}{"stop"}); - push @{$hash{$priority}{"stop"}}, $$i{"name"}; - } - } - - foreach $priority (keys %hash) - { - $line = sprintf ("%0.2d", $priority) . "\t"; - $line .= &gst_service_filerc_concat_runlevels (@{$hash{$priority}{"stop"}}) . "\t"; - $line .= &gst_service_filerc_concat_runlevels (@{$hash{$priority}{"start"}}) . "\t"; - $line .= "/etc/init.d/" . $$service{"script"} . "\n"; - - push @$buff, $line; - } -} - -# This is the function for storing the service settings from XML in file-rc -sub gst_service_filerc_set_services -{ - my ($services, $runlevel) = @_; - my ($buff, $lineno, $line, $file); - my ($rcd_path, $initd_path, $relative_path) = &gst_service_sysv_get_paths (); - - $file = "$gst_prefix/etc/runlevel.conf"; - - $buff = &gst_file_buffer_load ($file); - &gst_file_buffer_join_lines ($buff); - - $lineno = 0; - - # We prepare the file for storing the configuration, save the initial comments - # and delete the rest - while ($$buff[$lineno] =~ /^#.*/) - { - $lineno++; - } - - for ($i = $lineno; $i < scalar (@$buff); $i++) - { - $$buff[$i] =~ /.*\/etc\/init\.d\/(.*)/; - - # we need to keep the forbidden services and the services that only start in rcS.d - if (!gst_service_list_service_is_forbidden ($1)) - { - delete $$buff[$i]; - } - } - - # Now we append the services - foreach $service (@$services) - { - &gst_service_filerc_set_service ($buff, $service); - } - - @$buff = sort @$buff; - - push @$buff, "\n"; - &gst_file_buffer_clean ($buff); - &gst_file_buffer_save ($buff, $file); -} - -sub gst_service_bsd_set_services -{ - my ($services, $runlevel) = @_; - my ($script, $runlevels); - - foreach $service (@$services) - { - $script = $$service{"script"}; - $runlevels = $$service{"runlevels"}[0]{"runlevel"}[0]; - - $action = $$runlevels {"action"}; - - if ($action eq "start") - { - &gst_file_run ("chmod ugo+x $script"); - } - else - { - &gst_file_run ("chmod ugo-x $script"); - } - } -} - -sub gst_service_gentoo_set_services -{ - my ($services, $runlevel) = @_; - my ($action); - - foreach $service (@$services) - { - $script = $$service{"script"}; - $arr = $$service{"runlevels"}[0]{"runlevel"}; - - foreach $i (@$arr) - { - $action = $$i{"action"}; - $rl = $$i{"name"}; - - if ( $action eq "start") - { - &gst_file_run ("rc-update add $script $rl"); - } - elsif ($action eq "stop") - { - &gst_file_run ("rc-update del $script $rl"); - } - } - } -} - -sub gst_service_rcng_set_status -{ - my ($service, $action) = @_; - my ($fd, $key, $res); - my ($default_rcconf) = "/etc/defaults/rc.conf"; - my ($rcconf) = "/etc/rc.conf"; - - if (&gst_file_exists ("/etc/rc.d/$service")) - { - $fd = &gst_file_run_pipe_read ("/etc/rc.d/$service rcvar"); - - while (<$fd>) - { - if (/^\$(.*)=.*$/) - { - # to avoid cluttering rc.conf with duplicated data, - # we first look in the defaults/rc.conf for the key - $key = $1; - $res = &gst_parse_sh_bool ($default_rcconf, $key); - - if ($res == $action) - { - &gst_replace_sh ($rcconf, $key); - } - else - { - &gst_replace_sh_bool ($rcconf, $key, "YES", "NO", $action); - } - } - } - - &gst_file_close ($fd); - } - elsif (&gst_file_exists ("/usr/local/etc/rc.d/$service.sh")) - { - if ($action) - { - gst_file_copy ("/usr/local/etc/rc.d/$service.sh.sample", - "/usr/local/etc/rc.d/$service.sh"); - } - else - { - gst_file_remove ("/usr/local/etc/rc.d/$service.sh"); - } - } -} - -sub gst_service_rcng_set_services -{ - my ($services, $runlevel) = @_; - my ($action, $runlevels, $script); - - foreach $service (@$services) - { - $script = $$service {"script"}; - $runlevels = $$service{"runlevels"}[0]{"runlevel"}[0]; - $action = ($$runlevels {"action"} eq "start")? 1 : 0; - - &gst_service_rcng_set_status ($script, $action); - } -} - -sub gst_service_suse_set_services -{ - my ($services, $runlevel) = @_; - my ($action, $runlevels, $script, $rllist); - - foreach $service (@$services) - { - $script = $$service{"script"}; - $runlevels = $$service{"runlevels"}[0]{"runlevel"}; - $rllist = ""; - - &gst_file_run ("insserv -r $script"); - - foreach $rl (@$runlevels) - { - if ($$rl{"action"} eq "start") - { - $rllist .= $$rl{"name"} . ","; - } - } - - if ($rllist ne "") - { - $rllist =~ s/,$//; - - &gst_file_run ("insserv $script,start=$rllist"); - } - } -} - - -sub gst_service_archlinux_set_status -{ - my ($script, $active) = @_; - my $rcconf = '/etc/rc.conf'; - open DATA, "$rcconf"; - my @rcconflines = <DATA>; - close (DATA); - open DATAOUT, ">", "$rcconf"; - if(($active) && (! -f "/var/run/daemons/$script")) - { - &gst_service_archlinux_run_script($script,"start"); - } - if((!$active) && ( -f "/var/run/daemons/$script")) - { - &gst_service_archlinux_run_script($script,"start"); - } - - - foreach my $line (@rcconflines) - { - if($line =~ /\DAEMONS=/) - { - if($line =~ m/$script/) - { - if(!$active) - { - $line =~ s/$script //; - } - } - else - { - if($active) - { - $line =~ s/network/network $script/g; - } - } - } - print DATAOUT "$line"; - } - - close (DATAOUT); -} - -sub gst_service_archlinux_set_services -{ - my ($services, $runlevel) = @_; - my ($action, $runlevels, $script); - foreach $service (@$services) - { - $script = $$service {"script"}; - $runlevels = $$service{"runlevels"}[0]{"runlevel"}[0]; - $action = ($$runlevels {"action"} eq "start")? 1 : 0; - &gst_service_archlinux_set_status ($script, $action); - } -} - -sub gst_service_set_services -{ - my ($services, $runlevel) = @_; - - $type = &gst_get_init_type (); - &gst_service_sysv_set_services ($services, $runlevel) if ($type eq "sysv"); - &gst_service_filerc_set_services ($services, $runlevel) if ($type eq "file-rc"); - &gst_service_bsd_set_services ($services, $runlevel) if ($type eq "bsd"); - &gst_service_gentoo_set_services ($services, $runlevel) if ($type eq "gentoo"); - &gst_service_rcng_set_services ($services, $runlevel) if ($type eq "rcng"); - &gst_service_suse_set_services ($services, $runlevel) if ($type eq "suse"); - &gst_service_archlinux_set_services ($services, $runlevel) if ($type eq "archlinux"); -} - -sub gst_service_set_conf -{ - my ($hash) = @_; - my ($services, $runlevel); - - return unless $hash; - $services = $$hash{"services"}[0]{"service"}; - return unless $services; - $runlevel = $$hash{"runlevel"}; - return unless $runlevel; - - &gst_service_set_services($services, $runlevel); -} - -# stuff for checking whether service is running -sub gst_service_debian_get_status -{ - my ($service) = @_; - my ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - my ($output, $pidfile); - - $output = `grep "\/var\/run\/.*\.pid" $initd_path\/$service`; - - if ($output =~ /.*(\/var\/run\/.*\.pid).*/ ) - { - $pidfile = $1; - $pidval = `cat $pidfile`; - - return 0 if $pidval eq ""; - - $pid = `ps h $pidval`; - - if ($pid eq "") - { - return 0; - } - else - { - return 1; - } - } - - return undef; -} - -sub gst_service_redhat_get_status -{ - my ($service) = @_; - my ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - if (-f "/var/lock/subsys/$service") - { - return 1; - } - - return 0; -} - -sub gst_service_gentoo_get_status -{ - my ($service) = @_; - - $line = `/etc/init.d/$service status`; - - return 1 if ($line =~ /started/); - return 0; -} - -sub gst_service_rcng_get_status -{ - my ($service) = @_; - - $line = gst_file_run_backtick ("/etc/rc.d/$service forcestatus"); - return 1 if ($line =~ /pid [0-9]*/); - - # hacky as hell, we need to check services in /usr/local/etc/rc.d - # and there's no standard way to check they're running - return 1 if (-f "/var/run/$service.pid"); - - # we give up, the service isn't running - return 0; -} -sub gst_service_archlinux_get_status -{ - my ($service) = @_; - return 1 if( -f "/var/run/daemons/$service"); - return 0; -} - -sub gst_service_suse_get_status -{ - my ($service) = @_; - - $line = gst_file_run_backtick ("/etc/init.d/$service status"); - return 1 if ($line =~ /running/); - return 0; -} - -# returns true if the service is already running -sub gst_service_get_status -{ - my ($service) = @_; - my %dist_map = - ( - "debian-2.2" => \&gst_service_debian_get_status, - "debian-3.0" => \&gst_service_debian_get_status, - "debian-sarge" => \&gst_service_debian_get_status, - "ubuntu-5.04" => \&gst_service_debian_get_status, - "ubuntu-5.10" => \&gst_service_debian_get_status, - "ubuntu-6.04" => \&gst_service_debian_get_status, - - "redhat-5.2" => \&gst_service_redhat_get_status, - "redhat-6.0" => \&gst_service_redhat_get_status, - "redhat-6.1" => \&gst_service_redhat_get_status, - "redhat-6.2" => \&gst_service_redhat_get_status, - "redhat-7.0" => \&gst_service_redhat_get_status, - "redhat-7.1" => \&gst_service_redhat_get_status, - "redhat-7.2" => \&gst_service_redhat_get_status, - "redhat-7.3" => \&gst_service_redhat_get_status, - "redhat-8.0" => \&gst_service_redhat_get_status, - "redhat-9" => \&gst_service_redhat_get_status, - "mandrake-7.2" => \&gst_service_redhat_get_status, - "fedora-1" => \&gst_service_redhat_get_status, - "fedora-2" => \&gst_service_redhat_get_status, - "fedora-3" => \&gst_service_redhat_get_status, - "fedora-4" => \&gst_service_redhat_get_status, - - "rpath" => \&gst_service_redhat_get_status, - - "suse-9.0" => \&gst_service_suse_get_status, - "suse-9.1" => \&gst_service_suse_get_status, - "archlinux" => \&gst_service_archlinux_get_status, - "gentoo" => \&gst_service_gentoo_get_status, - "vlos-1.2" => \&gst_service_gentoo_get_status, - - "freebsd-5" => \&gst_service_rcng_get_status, - "freebsd-6" => \&gst_service_rcng_get_status, - ); - my $proc; - - $proc = $dist_map {$gst_dist}; - - return undef if ($proc eq undef); - - return &$proc ($service); -} - -# Functions to run a service -sub gst_service_sysv_run_initd_script -{ - my ($service, $arg) = @_; - my ($rc_path, $initd_path); - my $str; - my %map = - ("restart" => "restarted", - "stop" => "stopped", - "start" => "started"); - - &gst_report_enter (); - - if (!exists $map{$arg}) - { - &gst_report ("service_sysv_op_unk", $arg); - &gst_report_leave (); - return -1; - } - - $str = $map{$arg}; - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - if (-f "$initd_path/$service") - { - if (!&gst_file_run ("$initd_path/$service $arg")) - { - &gst_report ("service_sysv_op_success", $service, $str); - &gst_report_leave (); - return 0; - } - } - - &gst_report ("service_sysv_op_failed", $service, $str); - &gst_report_leave (); - return -1; -} - -sub gst_service_bsd_run_script -{ - my ($service, $arg) = @_; - my ($chmod) = 0; - - return if (!&gst_file_exists ($service)); - - # if it's not executable then chmod it - if (!((stat ($service))[2] & (S_IXUSR || S_IXGRP || S_IXOTH))) - { - $chmod = 1; - &gst_file_run ("chmod ugo+x $service"); - } - - &gst_file_run ("$service $arg"); - - # return it to it's normal state - if ($chmod) - { - &gst_file_run ("chmod ugo-x $service"); - } -} - -sub gst_service_gentoo_run_script -{ - my ($service, $arg) = @_; - my ($option); - - my %map = - ("stop" => "stopped", - "start" => "started" - ); - - &gst_report_enter (); - - if (!exists $map{$arg}) - { - &gst_report ("service_sysv_op_unk", $arg); - &gst_report_leave (); - return -1; - } - - if (&gst_service_gentoo_service_exist ($service)) - { - if (!&gst_file_run ("/etc/init.d/$service $arg")) - { - &gst_report ("service_sysv_op_success", $service, $str); - &gst_report_leave (); - return 0; - } - } - - &gst_report ("service_sysv_op_failed", $service, $str); - &gst_report_leave (); - return -1; -} - - -sub gst_service_rcng_run_script -{ - my ($service, $arg) = @_; - my ($farg); - - my %map = - ("stop" => "forcestop", - "start" => "forcestart" - ); - - &gst_report_enter (); - - if (!exists $map{$arg}) - { - &gst_report ("service_sysv_op_unk", $arg); - &gst_report_leave (); - return -1; - } - - $farg = $map {$arg}; - - if (!&gst_file_run ("/etc/rc.d/$service $farg")) - { - &gst_report ("service_sysv_op_success", $service, $str); - &gst_report_leave (); - return 0; - } - - &gst_report ("service_sysv_op_failed", $service, $str); - &gst_report_leave (); - return -1; -} - -sub gst_service_archlinux_run_script -{ - my ($service, $arg) = @_; - my ($farg); - - my %map = - ("stop" => "stop", - "start" => "start" - ); - - &gst_report_enter (); - - if (!exists $map{$arg}) - { - &gst_report ("service_sysv_op_unk", $arg); - &gst_report_leave (); - return -1; - } - - $farg = $map {$arg}; - - if (!&gst_file_run ("/etc/rc.d/$service $farg")) - { - &gst_report ("service_sysv_op_success", $service, $str); - &gst_report_leave (); - return 0; - } - - &gst_report ("service_sysv_op_failed", $service, $str); - &gst_report_leave (); - return -1; -} -sub gst_service_run_script -{ - my ($service, $arg) = @_; - my ($proc, $type); - my %map = - ( - "file-rc" => \&gst_service_sysv_run_initd_script, - "sysv" => \&gst_service_sysv_run_initd_script, - "bsd" => \&gst_service_bsd_run_script, - "gentoo" => \&gst_service_gentoo_run_script, - "rcng" => \&gst_service_rcng_run_script, - "suse" => \&gst_service_sysv_run_initd_script, - "archlinux" => \&gst_service_archlinux_run_script, - ); - - $type = &gst_get_init_type (); - - $proc = $map {$type}; - - &$proc ($service, $arg); -} - -# functions to know if a service will be installed -sub gst_service_sysv_installed -{ - my ($service) = @_; - my ($res, $rcd_path, $initd_path); - - &gst_report_enter (); - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - - $res = 1; - if (! -f "$initd_path/$service") - { - $res = 0; - &gst_report ("service_sysv_not_found", $service); - } - - &gst_report_leave (); - return $res; -} - -sub gst_service_bsd_installed -{ - my ($service) = @_; - - return 1 if ( -f "$service"); - return 0; -} - -sub gst_service_gentoo_installed -{ - my ($service) = @_; - - return 1 if ( -f "/etc/init.d/$service"); - return 0; -} - -sub gst_service_rcng_installed -{ - my ($service) = @_; - - return 1 if ( -f "/etc/rc.d/$service"); - return 1 if ( -f "/usr/local/etc/rc.d/$service.sh.sample"); - return 0; -} - -sub gst_service_installed -{ - my ($service) = @_; - my ($type); - $type = &gst_get_init_type (); - - return &gst_service_sysv_installed ($service) if (($type eq "sysv") || ($type eq "file-rc") || ($type eq "suse")); - return &gst_service_bsd_installed ($service) if ($type eq "bsd"); - return &gst_service_gentoo_installed ($service) if ($type eq "gentoo"); - return &gst_service_rcng_installed ($service) if ($type eq "rcng"); - return &gst_service_rcng_installed ($service) if ($type eq "archlinux"); - return 0; -} - -sub gst_service_list_any_installed -{ - my @service = @_; - my $res; - - $res = 0; - - foreach $serv (@service) - { - if (gst_service_installed ($serv)) - { - $res = 1; - } - } - - return $res; -} - -sub gst_service_bsd_set_status -{ - my ($script, $active) = @_; - my (@arr); - - if ($active) - { - &gst_file_run ("chmod ugo+x $script"); - &gst_service_run_script ($script, "start"); - } - else - { - &gst_service_run_script ($script, "stop"); - &gst_file_run ("chmod ugo-x $script"); - } -} - -sub gst_service_gentoo_set_status -{ - my ($script, $force_now, $active) = @_; - my (@arr); - - if ($active) - { - &gst_file_run ("rc-update add $script default"); - &gst_file_run ("/etc/init.d/$script start") if ($force_now == 1); - } - else - { - &gst_file_run ("rc-update del $script default"); - &gst_file_run ("/etc/init.d/$script stop") if ($force_now == 1); - } -} - -sub gst_service_suse_set_status -{ - my ($script, $active) = @_; - my (@runlevels, $rllist); - my ($rcd_path, $initd_path); - my ($rl); - - ($rcd_path, $initd_path) = &gst_service_sysv_get_paths (); - @runlevels = &gst_service_sysv_get_runlevels (); - - if ($active) - { - $rllist = join ",", @runlevels; - &gst_file_run ("insserv $script,start=$rllist"); - &gst_service_run_script ($script, "start"); - } - else - { - # to remove a service from a few runlevels we need to run - # insserv -r and then insserv blah,start=x,y,z - foreach $link (<$rcd_path/rc[0-9S].d/S[0-9][0-9]$script>) - { - $link =~ s/$rcd_path\///; - $link =~ /rc([0-9S])\.d\/S[0-9][0-9].*/; - $rllist .= "$1,"; - } - - foreach $link (<$rcd_path/boot.d/S[0-9][0-9]$service>) - { - $rllist .= "B,"; - } - - # remove the default runlevels from the list - foreach $runlevel (@runlevels) - { - $rllist =~ s/$runlevel,//; - } - - $rllist =~ s/,$//; - - &gst_file_run ("insserv -r $script"); - - if ($rllist ne "") - { - &gst_file_run ("insserv $script,start=$rllist"); - } - - &gst_service_run_script ($script, "stop"); - } -} diff --git a/services-conf.in b/services-conf.in deleted file mode 100755 index f75f130..0000000 --- a/services-conf.in +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# SysV services configurator. Aims to be designed to be architecture- and distribution independent. -# -# Copyright (C) 2002 Ximian, Inc. -# -# Authors: Carlos Garnacho Parro <garparr@teleline.es> -# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/service.pl$DOTIN"; - require "$SCRIPTSDIR/print.pl$DOTIN"; -} - -# --- Tool information --- # - -$name = "services"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", "redhat-7.1", - "redhat-7.2", "redhat-7.3", "redhat-8.0", "redhat-9", - "openna-1.0", - - "mandrake-7.1", "mandrake-7.2", "mandrake-9.0", "mandrake-9.1", "mandrake-9.2", - "mandrake-10.0", "mandrake-10.1", - - "debian-2.2", "debian-3.0", "debian-sarge", - - "suse-7.0", "turbolinux-7.0", "fedora-1", "fedora-2", "fedora-3", "rpath", - "pld-1.0", "pld-1.1", "pld-1.99", - "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0", - "vine-3.0", "vine-3.1", - "gentoo", "archlinux", "vlos-1.2", "freebsd-5", "freebsd-6", "suse-9.0", "suse-9.1"); - -$description =<<"end_of_description;"; - Configures which services are to be started or stopped at which runlevels - and with what priority. System V, file-rc and bsd init, in short. -end_of_description; - -# --- XML parsing --- # - -sub xml_parse -{ - my ($tree, %hash, $elem); - $tree = &gst_xml_scan (); - - # Walk the tree recursively and extract configuration parameters. - while ($elem = shift @$tree) - { - if ($elem eq "services") { &xml_parse_services (shift @$tree, \%hash); } - else {&gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return (\%hash); -} - -sub xml_parse_services -{ - my ($tree, $hash) = @_; - my ($services, $elem); - my ($runlevel); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "runlevels") { $runlevel = &xml_parse_runlevel_list (shift @$tree)} - elsif ($elem eq "services") { push @$services, &xml_parse_service_list (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"services"} = $services; - $$hash{"runlevel"} = $runlevel; -} - -sub xml_parse_runlevel_list -{ - my ($tree) = @_; - my ($runlevels, $elem, $runlevel); - my ($rl); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "runlevel") - { - $rl = &xml_parse_runlevel (shift @$tree); - if ($rl ne undef) - { - $runlevel = $rl; - } - } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return $runlevel; -} - -sub xml_parse_runlevel -{ - my ($tree) = @_; - my ($elem, $default, $runlevel); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "default") { $default = 1; shift @$tree } - elsif ($elem eq "name") { $runlevel = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "role") { shift @$tree; } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - if ($default eq 1) - { - return $runlevel; - } -} - -sub xml_parse_service_list -{ - my ($tree) = @_; - my ($hash, $service, $elem); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "service") { push @$service, &xml_parse_service (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"service"} = $service unless scalar @$service == 0; - return ($hash); -} - -sub xml_parse_service -{ - my ($tree) = @_; - my ($hash, $actions, $runlevels, $elem); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "actions") { push @$actions, &xml_parse_actions (shift @$tree); } - elsif ($elem eq "role") { shift @$tree } - elsif ($elem eq "runlevels") { push @$runlevels, &xml_parse_runlevels (shift @$tree); } - elsif ($elem eq "script") { $$hash{"script"} = &gst_xml_get_pcdata (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - $$hash{"actions"} = $actions unless $actions eq undef; - $$hash{"runlevels"} = $runlevels unless $runlevels eq undef; - - return ($hash); -} - -sub xml_parse_actions -{ - my ($tree) = @_; - my ($hash, $action, $elem); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "action") { push @$action, &gst_xml_get_pcdata (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - if (scalar @$action != 0) - { - $$hash{"action"} = $action; - return ($hash); - } -} - -sub xml_parse_runlevels -{ - my ($tree) = @_; - my ($hash, $runlevel, $elem); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "runlevel") { push @$runlevel, &xml_parse_single_runlevel (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - if (scalar @$runlevel != 0) - { - $$hash{"runlevel"} = $runlevel; - return ($hash); - } -} - -sub xml_parse_single_runlevel -{ - my ($tree) = @_; - my ($number, $action, $priority); - my ($elem); - - shift @$tree; #skip attributes - - while ($elem = shift @$tree) - { - if ($elem eq "name") { $number = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "action") { $action = &gst_xml_get_pcdata (shift @$tree); } - elsif ($elem eq "priority") { $priority = &gst_xml_get_pcdata (shift @$tree); } - else { &gst_report ("xml_unexp_tag", $elem); shift @$tree; } - } - - return { "name" => $number, - "action" => $action, - "priority" => $priority }; -} - -# --- XML printing --- # -sub xml_print_services -{ - my ($h) = @_; - - &gst_xml_print_line ("<services>"); - &gst_xml_enter (); - - &gst_xml_print_hash_hash ($h, "service"); - - &gst_xml_leave (); - &gst_xml_print_line ("</services>"); -} - -sub xml_print_runlevels -{ - my ($h, $default) = @_; - &gst_xml_print_line ("<runlevels>"); - &gst_xml_enter (); - - foreach $i (sort keys %$h) - { - &gst_xml_print_line ("<runlevel>"); - &gst_xml_enter (); - - &gst_xml_print_pcdata ("name", $i); - &gst_xml_print_pcdata ("role", $$h{$i}); - - if ($i eq $default) - { - # It's the default runlevel - &gst_xml_print_pcdata ("default", "1"); - } - - &gst_xml_leave (); - &gst_xml_print_line ("</runlevel>"); - } - - &gst_xml_leave (); - &gst_xml_print_line ("</runlevels>"); - &gst_xml_print_vspace (); -} - -sub xml_print -{ - my ($h) = @_; - - &gst_xml_print_begin (); - &gst_xml_print_comment ("These are the runlevels available in the system"); - &xml_print_runlevels ($$h{"runlevels"}, $$h{"runlevel"}); - - &gst_xml_print_comment ("These are the services"); - &xml_print_services ($$h{"services"}); - &gst_xml_print_end (); -} - - -# Main operations - -sub get -{ - my %hash; - - $hash{"runlevels"} = &gst_service_get_runlevel_roles (); - - $hash{"services"} = &gst_service_get_services (); - $hash{"runlevel"} = &gst_service_get_default_runlevel (); - - &gst_report_end (); - &xml_print (\%hash); -} - -sub set -{ - my %hash; - - $hash = &xml_parse (); - - if ($hash) - { - &gst_service_set_conf ($hash); - } - - &gst_report_end (); -} - -# --- Filter config: XML in, XML out --- # -sub filter -{ - my $hash = &xml_parse (); - - &gst_report_end (); - &xml_print ($hash); -} - -# --- throw_service: throws a service with a parameter --- # -sub throw_service -{ - my ($tool, $service, $parameter) = @_; - - &gst_service_run_script ($service, $parameter); - &gst_report_end (); - - &gst_xml_print_begin ("throw_service"); - &gst_xml_print_end ("throw_service"); -} - -# --- get_status: gets the status of a service --- # -sub get_status -{ - my ($tool, $service) = @_; - my ($active); - - $active = &gst_service_get_status ($service); - - &gst_report_end (); - - &gst_xml_print_begin ("get_status"); - &gst_xml_print_state_tag ("active", $active) if ($active ne undef); - &gst_xml_print_end ("get_status"); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "throw_service" => [ \&throw_service, ["service", "parameter"], "Throws a service with a parameter (start, stop...)" ], - "get_status" => [ \&get_status, ["service"], "Gets the status of a service"] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/shares-conf.in b/shares-conf.in deleted file mode 100755 index 0c7df43..0000000 --- a/shares-conf.in +++ /dev/null @@ -1,807 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Shares configurator. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/resolv.conf -# /etc/host.conf -# /etc/hosts -# /etc/sysconfig/network -# /etc/rc.config -# /etc/smb.conf - -# Running programs affected: -# -# smbd -# nmbd -# ifconfig: check current interfaces and activate/deactivate. - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/filesys.pl$DOTIN"; - require "$SCRIPTSDIR/network.pl$DOTIN"; - require "$SCRIPTSDIR/share.pl$DOTIN"; -} - -# --- Tool information --- # - -$name = "shares"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", "redhat-7.1", - "redhat-7.2", "redhat-8.0", "redhat-9", - "openna-1.0", - "mandrake-7.1", "mandrake-7.2", "mandrake-9.0", "mandrake-9.1", "mandrake-9.2", - "mandrake-10.0", "mandrake-10.1", - "blackpanther-4.0", - "debian-2.2", "debian-3.0", "debian-sarge", - "suse-7.0", "suse-9.0", - "turbolinux-7.0", "fedora-1", "fedora-2", "fedora-3", - "pld-1.0", "pld-1.1", "pld-1.99", - "conectiva-9", "conectiva-10", - "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0", - "gentoo", "vlos-1.2", "freebsd-5", "rpath"); - -$description =<<"end_of_description;"; - Configures network shares for import or export. -end_of_description; - -# --- XML parsing --- - -# Scan XML from standard input to an internal tree. - -sub xml_parse -{ - my $tree; - my $config = {}; - # Scan XML to tree. - - $tree = &gst_xml_scan; - - # Walk the tree recursively and extract configuration parameters. - while (@$tree) - { - if ($$tree[0] eq "shares") { &xml_parse_shares ($$tree[1], $config); } - - shift @$tree; - shift @$tree; - } - - return($config); -} - -# <shares>...</shares> - -sub xml_parse_shares -{ - my ($tree, $config) = @_; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "imports") { &xml_parse_imports ($$tree[1], $config); } - elsif ($$tree[0] eq "exports") { &xml_parse_exports ($$tree[1], $config); } - elsif ($$tree[0] eq "workgroup") { $$config{"smb_config"}{"workgroup"} = $$tree[1][2]; } - elsif ($$tree[0] eq "winsuse") { $$config{"smb_config"}{"winsuse"} = $$tree[1][2]; } - elsif ($$tree[0] eq "winsserver") { $$config{"smb_config"}{"winsserver"} = $$tree[1][2]; } - elsif ($$tree[0] eq "smbdesc") { $$config{"smb_config"}{"smbdesc"} = $$tree[1][2]; } - shift @$tree; - shift @$tree; - } -} - -# <imports>...</imports> - -sub xml_parse_imports -{ - my ($tree, $config) = @_; - my $table; - - $table = &gst_filesys_table_new (); - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "import") { &xml_parse_import ($$tree[1], $table); } - - shift @$tree; - shift @$tree; - } - - $$config{'imports'} = $table; -} - -# <exports>...</exports> - -sub xml_parse_exports -{ - my ($tree, $config) = @_; - my ($smb_table, $nfs_table); - - $smb_table = &gst_share_smb_table_new (); - $nfs_table = &gst_share_nfs_table_new (); - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "export") { &xml_parse_export ($$tree[1], $smb_table, $nfs_table); } - - shift @$tree; - shift @$tree; - } - - $$config{'smb_exports'} = $smb_table; - $$config{'nfs_exports'} = $nfs_table; -} - -# <import>...</import> - -sub xml_parse_import -{ - my ($tree, $table) = @_; - my $type = "", $host = "", $path = "", $comment = "", $user = "", - $password = "", $mounted = 0, $detected = 0, $point = "", $listed = 0; - - my $info = &gst_filesys_info_new (); - - $type = $$tree[0]->{type}; - shift @$tree; - - while (@$tree) - { - if ($$tree[0] eq "host") { $host = &gst_xml_get_word ($$tree[1]); } - elsif ($$tree[0] eq "path") { $path = &gst_xml_get_word ($$tree[1]); } - elsif ($$tree[0] eq "user") { $user = &gst_xml_get_text ($$tree[1]); } - elsif ($$tree[0] eq "password") { $password = &gst_xml_get_text ($$tree[1]); } - elsif ($$tree[0] eq "comment") { $comment = &gst_xml_get_text ($$tree[1]); } - elsif ($$tree[0] eq "point") { $point = &gst_xml_get_word ($$tree[1]); } - elsif ($$tree[0] eq "mounted") { $mounted = &gst_xml_get_state ($$tree[1]); } - elsif ($$tree[0] eq "detected") { $detected = &gst_xml_get_state ($$tree[1]); } - elsif ($$tree[0] eq "listed") { $listed = &gst_xml_get_state ($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - &gst_filesys_info_set_network_host ($info, $host); - &gst_filesys_info_set_network_path ($info, $path); -# &gst_filesys_info_set_comment ($info, $comment); - &gst_filesys_info_set_permanent ($info, $listed); - &gst_filesys_info_set_mounted ($info, $mounted); - &gst_filesys_info_set_detected ($info, $detected); - &gst_filesys_info_set_point ($info, $point); - - if ($type eq "nfs") - { - &gst_filesys_info_set_fs ($info, "nfs"); - &gst_filesys_info_set_option ($info, "soft", ""); - &gst_filesys_info_remove_option ($info, "hard"); - } - else - { - &gst_filesys_info_set_fs ($info, "smbfs"); - &gst_filesys_info_set_option ($info, "username", ($user eq "") ? " " : $user); - &gst_filesys_info_set_option ($info, "password", ($password eq "") ? " " : $password); - } - - &gst_filesys_table_add ($table, $info); -} - -# <export>...</export> - -sub xml_parse_export -{ - my ($tree, $smb_table, $nfs_table) = @_; - my $type = ""; - my $info; - - $type = $$tree[0]->{type}; - shift @$tree; - - if ($type eq "nfs") - { - my $path = ""; - my $client_table = &gst_share_nfs_client_table_new (); - - $info = gst_share_nfs_info_new (); - - while (@$tree) - { - if ($$tree[0] eq "path") { $path = &gst_xml_get_pcdata ($$tree[1]); } - elsif ($$tree[0] eq "allow") { &xml_parse_allow ($$tree[1], $client_table); } - - shift @$tree; - shift @$tree; - } - - if ($path ne "") - { - &gst_share_nfs_info_set_point ($info, $path); - &gst_share_nfs_info_set_client_table ($info, $client_table); - &gst_share_nfs_table_add ($nfs_table, $info); - } - } - elsif ($type eq "smb") - { - my $name = "", $path = "", $comment = "", $enabled = 0, $browseable = 0, - $public = 0, $writeable = 0; - - $info = gst_share_smb_info_new (); - - while (@$tree) - { - if ($$tree[0] eq "name") { $name = &gst_xml_get_word ($$tree[1]); } - elsif ($$tree[0] eq "path") { $path = &gst_xml_get_pcdata ($$tree[1]); } - elsif ($$tree[0] eq "comment") { $comment = &gst_xml_get_text ($$tree[1]); } - elsif ($$tree[0] eq "enabled") { $enabled = &gst_xml_get_state ($$tree[1]); } - elsif ($$tree[0] eq "browse") { $browseable = &gst_xml_get_state ($$tree[1]); } - elsif ($$tree[0] eq "public") { $public = &gst_xml_get_state ($$tree[1]); } - elsif ($$tree[0] eq "write") { $writeable = &gst_xml_get_state ($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - if ($path ne "") - { - &gst_share_smb_info_set_name ($info, $name); - &gst_share_smb_info_set_point ($info, $path); - &gst_share_smb_info_set_comment ($info, $comment); - &gst_share_smb_info_set_enabled ($info, $enabled); - &gst_share_smb_info_set_browse ($info, $browseable); - &gst_share_smb_info_set_public ($info, $public); - &gst_share_smb_info_set_write ($info, $writeable); - &gst_share_smb_table_add ($smb_table, $info); - } - } - else - { - # Unsupported share type. - - return; - } -} - -sub xml_parse_allow -{ - my ($tree, $client_table) = @_; - my $pattern = ""; - my $write = 0; - - shift @$tree; # No attributes. - - while (@$tree) - { - if ($$tree[0] eq "pattern") { $pattern = &gst_xml_get_word ($$tree[1]); } - elsif ($$tree[0] eq "write") { $write = &gst_xml_get_state ($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - my $info = &gst_share_nfs_client_info_new (); - &gst_share_nfs_client_info_set_pattern ($info, $pattern); - &gst_share_nfs_client_info_set_write ($info, $write); - &gst_share_nfs_client_table_add ($client_table, $info); -} - -# --- XML printing --- # - -sub xml_print_import_common # filesys_info -{ - my ($fsinfo) = @_; - my ($host, $path, $point); - - $point = &gst_filesys_info_get_point ($fsinfo); - $host = &gst_filesys_info_get_network_host ($fsinfo); - $path = &gst_filesys_info_get_network_path ($fsinfo); - - &gst_xml_print_pcdata ("host", $host); - &gst_xml_print_pcdata ("path", $path); - &gst_xml_print_pcdata ("point", $point); - &gst_xml_print_state_tag ("listed", &gst_filesys_info_get_permanent ($fsinfo)); - &gst_xml_print_state_tag ("mounted", &gst_filesys_info_get_mounted ($fsinfo)); - &gst_xml_print_state_tag ("detected", &gst_filesys_info_get_detected ($fsinfo)); -} - -sub xml_print_import_nfs -{ - my ($fsinfo) = @_; - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<import type='nfs'>"); - &gst_xml_enter (); - - &xml_print_import_common ($fsinfo); - - &gst_xml_leave (); - &gst_xml_print_line ("</import>"); - &gst_xml_print_vspace (); -} - -sub xml_print_import_smb -{ - my ($fsinfo) = @_; - my ($user, $password); - - $user = &gst_filesys_info_get_option ($fsinfo, "username"); - $user = "" if ($user =~ /^ +$/); - $password = &gst_filesys_info_get_option ($fsinfo, "password"); - $password = "" if ($password =~ /^ +$/); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<import type='smb'>"); - &gst_xml_enter (); - - &xml_print_import_common ($fsinfo); - if ($user ne "") { &gst_xml_print_pcdata ("user", $user); } - if ($password ne "") { &gst_xml_print_pcdata ("password", $password); } - - &gst_xml_leave (); - &gst_xml_print_line ("</import>"); - &gst_xml_print_vspace (); -} - -sub xml_print_export_nfs -{ - my ($info) = @_; - my $client_table; - - $client_table = &gst_share_nfs_info_get_client_table ($info); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<export type='nfs'>"); - &gst_xml_enter (); - - &gst_xml_print_pcdata ("name", "unknown"); - &gst_xml_print_pcdata ("path", &gst_share_nfs_info_get_point ($info)); - - for $client (@$client_table) - { - &gst_xml_container_enter ("allow"); - &gst_xml_print_pcdata ("pattern", &gst_share_nfs_client_info_get_pattern ($client)); - &gst_xml_print_state_tag ("write", &gst_share_nfs_client_info_get_write ($client)); - &gst_xml_container_leave (); - } - - &gst_xml_leave (); - &gst_xml_print_line ("</export>"); - &gst_xml_print_vspace (); -} - -sub xml_print_export_smb -{ - my ($info) = @_; - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<export type='smb'>"); - &gst_xml_enter (); - - &gst_xml_print_pcdata ("name", &gst_share_smb_info_get_name ($info)); - &gst_xml_print_pcdata ("path", &gst_share_smb_info_get_point ($info)); - &gst_xml_print_pcdata ("comment", &gst_share_smb_info_get_comment ($info)); - &gst_xml_print_state_tag ("enabled", &gst_share_smb_info_get_enabled ($info)); - &gst_xml_print_state_tag ("browse", &gst_share_smb_info_get_browse ($info)); - &gst_xml_print_state_tag ("public", &gst_share_smb_info_get_public ($info)); - &gst_xml_print_state_tag ("write", &gst_share_smb_info_get_write ($info)); - - &gst_xml_leave (); - &gst_xml_print_line ("</export>"); - &gst_xml_print_vspace (); -} - -sub xml_print -{ - my ($config) = @_; - my ($tools, $smb_config, $import_table, $smb_export_table, $nfs_export_table, $i); - - $tools = $$config{"tools"}; - $smb_config = $$config{"smb_config"}; - $import_table = $$config{"imports"}; - $smb_export_table = $$config{"smb_exports"}; - $nfs_export_table = $$config{"nfs_exports"}; - - &gst_xml_print_begin (); - - foreach $i (keys (%$tools)) - { - &gst_xml_print_pcdata ($i, $$tools{$i}); - } - &gst_xml_print_vspace (); - - foreach $i (keys (%$smb_config)) - { - &gst_xml_print_pcdata ($i, $$smb_config{$i}); - } - &gst_xml_print_vspace (); - - if (scalar @$import_table) - { - &gst_xml_container_enter ("imports"); - - foreach $i (@$import_table) - { - my ($fs); - - $fs = &gst_filesys_info_get_fs ($i); - - if ($fs eq "nfs") { &xml_print_import_nfs ($i); } - elsif ($fs eq "smbfs") { &xml_print_import_smb ($i); } - else { next; } - } - - &gst_xml_container_leave (); - &gst_xml_print_vspace (); - } - - if (scalar @$smb_export_table || scalar @$nfs_export_table) - { - &gst_xml_container_enter ("exports"); - - foreach $i (@$smb_export_table) - { - &xml_print_export_smb ($i); - } - - foreach $i (@$nfs_export_table) - { - &xml_print_export_nfs ($i); - } - - &gst_xml_container_leave (); - } - - &gst_xml_print_end (); -} - -# Misc - -sub remove_shares_from_filesys_table -{ - my ($table) = @_; - my @ltable = @$table; # We need a shallow copy. - - for $info (@ltable) - { - my $fs = &gst_filesys_info_get_fs ($info); - - if ($fs eq "smbfs" || $fs eq "nfs") - { - &gst_filesys_table_remove ($table, $info); - } - } -} - -# Configuration handling. - -sub gst_installed_daemons_parse_table -{ - my %dist_map = - ( - "redhat-5.2" => "redhat-6.2", - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - "redhat-7.0" => "redhat-6.2", - "redhat-7.1" => "redhat-6.2", - "redhat-7.2" => "redhat-6.2", - "redhat-8.0" => "redhat-6.2", - "redhat-9" => "redhat-6.2", - "openna-1.0" => "redhat-6.2", - "mandrake-7.1" => "redhat-6.2", - "mandrake-7.2" => "redhat-6.2", - "mandrake-9.0" => "redhat-6.2", - "mandrake-9.1" => "redhat-6.2", - "mandrake-9.2" => "redhat-6.2", - "mandrake-10.0" => "redhat-6.2", - "mandrake-10.1" => "redhat-6.2", - "blackpanther-4.0" => "redhat-6.2", - "conectiva-9" => "redhat-6.2", - "conectiva-10" => "redhat-6.2", - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-2.2", - "debian-sarge" => "debian-2.2", - "suse-7.0" => "redhat-6.2", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - "turbolinux-7.0" => "redhat-6.2", - "pld-1.0" => "redhat-6.2", - "pld-1.1" => "redhat-6.2", - "pld-1.99" => "redhat-6.2", - "fedora-1" => "redhat-6.2", - "fedora-2" => "redhat-6.2", - "fedora-3" => "redhat-6.2", - "rpath" => "redhat-6.2", - "vine-3.0" => "redhat-6.2", - "vine-3.1" => "redhat-6.2", - "slackware-9.1.0" => "slackware-9.1.0", - "slackware-10.0.0" => "slackware-9.1.0", - "slackware-10.1.0" => "slackware-9.1.0", - "slackware-10.2.0" => "slackware-9.1.0", - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_table = - ( - "redhat-6.2" => { - table => [ - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "smb" ], - [ "nfsuse", \&gst_service_sysv_get_status, "rpc.nfsd" ], - [ "nfsinstalled", \&gst_service_installed, "nfsserver" ], - ]}, - - "debian-2.2" => { - table => [ - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_sysv_installed, "samba" ], - [ "nfsuse", \&gst_service_sysv_get_status, "rpc.nfsd" ], - [ "nfsinstalled", \&gst_service_list_any_installed, "nfs-user-server", "nfs-kernel-server" ], - ]}, - - "suse-9.0" => { - table => [ - [ "smbuse", \&gst_service_get_status, "smb" ], - [ "smbinstalled", \&gst_service_installed, "smb" ], - [ "nfsuse", \&gst_service_sysv_get_status, "rpc.nfsd" ], - [ "nfsinstalled", \&gst_service_installed, "nfsserver" ], - ]}, - - "slackware-9.1.0" => { - table => [ - [ "smbuse", \&gst_service_sysv_get_status_any, "smbd", "nmbd" ], - [ "smbinstalled", \&gst_service_installed, "/etc/rc.d/rc.samba" ], - [ "nfsuse", \&gst_service_sysv_get_status, "rpc.nfsd" ], - [ "nfsinstalled", \&gst_service_installed, "/etc/rc.d/rc.nfsd" ], - ]}, - - "gentoo" => { - table => [ - [ "smbuse", \&gst_service_gentoo_get_status, "samba" ], - [ "smbinstalled", \&gst_service_installed, "samba" ], - [ "nfsuse", \&gst_service_sysv_get_status, "rpc.nfsd" ], - [ "nfsinstalled", \&gst_service_installed, "nfs" ], - ]}, - - "freebsd-5" => { - table => [ - [ "smbuse", \&gst_service_rcng_get_status, "smbd" ], - [ "smbinstalled", \&gst_service_installed, "samba" ], - # FIXME: How's the nfs stuff in FreeBSD? - ]}, - ); - - my $dist = $dist_map{$gst_dist}; - return %{$dist_table{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub get_installed_daemons -{ - my ($hash, %dist_attrib); - - %dist_attrib = &gst_installed_daemons_parse_table (); - $hash = &gst_parse_from_table (undef, $dist_attrib{"table"}); - return $hash; -} - -#sub get_configured_imports -#{ -# my ($imports, $listed_imports, $mounted_imports); - -# $listed_imports = &gst_filesys_fstab_parse (&distro_file ("fstab")); -# $mounted_imports = &gst_filesys_mtab_parse (&distro_file ("mtab")); - -# &gst_filesys_table_set_permanent_true ($listed_imports); -# &gst_filesys_table_set_mounted_true ($mounted_imports); - -# $imports = &gst_filesys_table_merge_superset ($mounted_imports, $listed_imports); -# return $imports; -#} - -sub get_distro_files -{ - my ($smb_comb, $exports); - - %dist_attrib = &gst_network_get_parse_table (); - $smb_conf = $dist_attrib{"fn"}{"SMB_CONF"}; - - # This is pretty standard - $exports = "/etc/exports"; - - return ($smb_conf, $exports); -} - -sub get_configured_exports -{ - my ($smb_exports, $nfs_exports); - my (%dist_attrib, $smb_conf, $exports); - - ($smb_conf, $exports) = &get_distro_files (); - - $smb_exports = &gst_share_parse_smb_conf ($smb_conf); - $nfs_exports = &gst_share_parse_nfs_exports ($exports); - - return ($smb_exports, $nfs_exports); -} - -sub get_smb_config -{ - my ($smb_conf, $exports); - my %config; - - ($smb_conf, $exports) = &get_distro_files (); - - $$config{"workgroup"} = &gst_parse_ini ($smb_conf, "global", "workgroup"); - $$config{"smbdesc"} = &gst_parse_ini ($smb_conf, "global", "server string"); - $$config{"winsserver"} = &gst_parse_ini ($smb_conf, "global", "wins server"); - $$config{"winsuse"} = &gst_parse_ini_bool ($smb_conf, "global", "wins support"); - - return $config; -} - -# Top-level actions. - -sub get -{ - my ($tools, $smb_config, $imports, $smb_exports, $nfs_exports); - my $config = {}; - - $tools = &get_installed_daemons (); - $smb_settings = &get_smb_config (); -# $imports = &get_configured_imports (); - ($smb_exports, $nfs_exports) = &get_configured_exports (); - - $$config{"tools"} = $tools; - $$config{"smb_config"} = $smb_settings; - $$config{"imports"} = $imports; - $$config{"smb_exports"} = $smb_exports; - $$config{"nfs_exports"} = $nfs_exports; - - &gst_report_end (); - &xml_print ($config); -} - -sub set -{ - my $config; -# my ($fs, $fs_no_shares, $fs_new_shares); - my ($smb_conf, $exports); -# my $imports; - - ($smb_conf, $exports) = &get_distro_files (); - - $config = &xml_parse (); - -# $imports = $$config{"imports"}; -# for $import (@$imports) -# { -# &gst_filesys_info_settings_to_options ($import); -# } - -# $fs = &gst_filesys_fstab_parse (&distro_file ("fstab")); -# &gst_filesys_table_set_permanent_true ($fs); - -# $fs_no_shares = &gst_filesys_table_dup ($fs); -# &remove_shares_from_filesys_table ($fs_no_shares); - -# $fs_new_shares = &gst_filesys_table_merge_superset ($$config{"imports"}, $fs_no_shares); -# $fs_new_shares = &gst_filesys_table_merge_subset ($fs_new_shares, $fs); - -# &gst_filesys_fstab_replace (&distro_file ("fstab"), $fs_new_shares); - - &gst_replace_ini ($smb_conf, "global", "workgroup", $$config{"smb_config"}{"workgroup"}); - &gst_replace_ini ($smb_conf, "global", "server string", $$config{"smb_config"}{"smbdesc"}); - &gst_replace_ini ($smb_conf, "global", "wins server", $$config{"smb_config"}{"winsserver"}); - &gst_replace_ini_bool ($smb_conf, "global", "wins support", $$config{"smb_config"}{"winsuse"}); - - &gst_share_replace_smb_conf ($smb_conf, $$config{"smb_exports"}); - &gst_share_replace_nfs_exports ($exports, $$config{"nfs_exports"}); - -# &gst_filesys_mount_sync_all (&distro_file ("fstab"), &distro_file ("mtab"), $$config{"imports"}); - - &gst_report_end (); -} - -sub filter -{ - my $config; - - $config = &xml_parse (); - &gst_report_end (); - &xml_print ($config); -} - -sub scan -{ - my %config; - - $config{"imports"} = &gst_share_scan_network_imports (); - &gst_report_end (); - &xml_print (\%config); -} - -sub get_network_conf -{ - my ($hash, $ifaces, $i, @arr); - - $ifaces = &gst_network_interfaces_get_info (); - - foreach $i (keys %$ifaces) - { - if (($$ifaces{$i}{"enabled"} == 1) - && ($$ifaces{$i}{"dev"} ne "lo")) - { - $$ifaces{$i}{"network"} = &gst_network_ipv4_calc_subnet ($$ifaces{$i}{"addr"}, - $$ifaces{$i}{"mask"}); - push @arr, $$ifaces{$i}; - } - } - - # network interface stuff - $hash = &gst_network_conf_get (); - &gst_report_end (); - - &gst_xml_print_begin ("network-conf"); - &network_xml_print_statichost ($hash); - &gst_xml_print_structure (\@arr, "interface"); - &gst_xml_print_end ("network-conf"); -} - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ], - "get_network_conf" => [ \&get_network_conf, [], "Gets the hosts info plus the interfaces networks." ], - "scan_network" => [ \&scan, [], "Looks for smb or nfs shares in the network." ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); diff --git a/system-tools-backends.pc.in b/system-tools-backends-2.0.pc.in index 185778f..185778f 100644 --- a/system-tools-backends.pc.in +++ b/system-tools-backends-2.0.pc.in diff --git a/test-backends b/test-backends new file mode 100755 index 0000000..4025b78 --- /dev/null +++ b/test-backends @@ -0,0 +1,87 @@ +#!/usr/bin/env perl + +use Net::DBus; +use Net::DBus::Reactor; + +sub print_tabified +{ + my ($tab, $str, $do_cr) = @_; + + print " " x $tab; + print $str; + print "\n" if ($do_cr); +} + +sub print_recursive +{ + my ($obj, $tab) = @_; + + if (ref $obj eq "ARRAY") + { + print_tabified ($tab, "ARRAY = [", 1); + + foreach $elem (@{$obj}) + { + print_recursive ($elem, $tab + 2); + } + + print_tabified ($tab, "]", 1); + } + elsif (ref $obj eq "HASH") + { + print_tabified ($tab, "HASH = {", 1); + + foreach $elem (keys %$obj) + { + $sibling_ref = ref $$obj{$elem}; + + #print child arrays and hashes in a new line + print_tabified ($tab + 2, "'$elem'\t=>" , ($sibling_ref eq "ARRAY" || $sibling_ref eq "HASH")); + print_recursive ($$obj{$elem}, $tab + 4); + } + + print_tabified ($tab, "}", 1); + } + else + { + print_tabified ($tab, $obj, 1); + } +} + +sub print_object +{ + my ($service, $object) = @_; + my ($item); + + my $obj = $service->get_object ("/org/freedesktop/SystemToolsBackends/$object"); + my @arr = $obj->get (); + + foreach $i (@arr) { + &print_recursive ($i, 0); + } +} + +# Main program +my $bus = Net::DBus->system; +my $service = $bus->get_service("org.freedesktop.SystemToolsBackends"); + +if (!$ARGV[0]) +{ + print "Which backend object do you want to query? (i.e.: UsersConfig):\n"; + $object = <STDIN>; + chomp $object; + + print_object ($service, $object); +} +else +{ + foreach $i (@ARGV) + { + chomp $i; + print "$i\n================================\n"; + print_object ($service, $i); + print "\n\n"; + } +} + +print "Have a good day!\n"; diff --git a/test.pl b/test.pl deleted file mode 100755 index 0b9e580..0000000 --- a/test.pl +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env perl - -require "media.pl"; -require "network.pl"; -require "parse.pl"; -require "debug.pl"; -require "filesys.pl"; -require "share.pl"; -require "print.pl"; - - -@platforms = ( "redhat-6.2", "redhat-7.0", "redhat-7.1", "debian-2.2" ); - -sub set -{ -} - -sub get -{ -} - -sub filter -{ -} - -$directives = -{ - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] -}; - - -$tool = &gst_init ("test", "0.0.0", "Test script.", $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); - - -# $tree = &gst_xml_scan ("/etc/alchemist/namespace/printconf/local.adl"); -# &gst_debug_print_struct ($tree); - -print "He.\n"; - -#($model, $compressed) = &gst_xml_model_scan ("/etc/alchemist/namespace/printconf/local.adl"); -#print &gst_xml_model_print ($model); - -&gst_replace_xml_attribute_with_type ("/etc/alchemist/namespace/printconf/local.adl", - "/adm_context/datatree/printconf/print_queues/new/fitte/", - "VALUE", "STRING", "p0ke"); - -# $branch = &gst_xml_model_find ($model, "/adm_context/datatree/"); -# &gst_xml_model_set_pcdata ($branch, "FAAN"); -# &gst_xml_model_set_attribute ($branch, "Jern", "Jepp"); - -# print &gst_parse_xml ("/etc/alchemist/namespace/printconf/local.adl", -# "/adm_context/datatree/printconf/print_queues/lpekk/filter_type", "VALUE") . "\n"; - diff --git a/time-conf.in b/time-conf.in deleted file mode 100755 index 665646e..0000000 --- a/time-conf.in +++ /dev/null @@ -1,1028 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Time configurator. Designed to be architecture- and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com> -# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) -# James Ogley <james@usr-local-bin.org> (SuSE 9.0 support) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected/used: -# -# /usr/share/zoneinfo/zone.tab -# /etc/ntp.conf -# /etc/ntp/step-tickers -# /etc/localtime - -# Running programs affected/used: -# -# date - -use File::Copy; - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/service.pl$DOTIN"; - require "$SCRIPTSDIR/parse.pl$DOTIN"; - require "$SCRIPTSDIR/replace.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "time"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", "redhat-7.1", - "redhat-7.2", "redhat-7.3", "redhat-8.0", "redhat-9", - "openna-1.0", - "mandrake-7.1", "mandrake-7.2", "mandrake-9.0", "mandrake-9.1", "mandrake-9.2", - "mandrake-10.0", "mandrake-10.1", - "debian-2.2", "debian-3.0", "debian-sarge", - "suse-7.0", "suse-9.0", "suse-9.1", "turbolinux-7.0", - "slackware-8.0.0", "slackware-8.1", "slackware-9.0.0", "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0", - "gentoo", "vlos-1.2", "pld-1.0", "pld-1.1", "pld-1.99", "fedora-1", "fedora-2", "fedora-3", "rpath", - "vine-3.0", "vine-3.1", - "archlinux", - "freebsd-5", "freebsd-6"); - -$description =<<"end_of_description;"; - Configures your system clock, timezone and time server list. -end_of_description; - -$progress_max = 365; - - -# --- XML parsing --- # - - -# Scan XML from standard input to an internal tree. - -sub xml_parse -{ - my ($tree, %hash); - - # Scan XML to tree. - - $tree = &gst_xml_scan; - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "time" tag. - - while (@$tree) - { - if ($$tree[0] eq "time") { &xml_parse_time($$tree[1], \%hash); } - - shift @$tree; - shift @$tree; - } - - return(\%hash); -} - - -# <time>...</time> - -sub xml_parse_time -{ - my $tree = $_[0]; - my $hash = $_[1]; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "local_time"){ $$hash{"local_time"} = &xml_parse_local_time ($$tree[1]); } - elsif ($$tree[0] eq "timezone") { $$hash{"timezone"} = &gst_xml_get_word ($$tree[1]); } - elsif ($$tree[0] eq "sync") { $$hash{"sync"} = &xml_parse_sync ($$tree[1], $hash); } - - shift @$tree; - shift @$tree; - } -} - - -sub xml_parse_sync -{ - my $tree = $_[0]; - my $hash = $_[1]; - my @sync; - - $$hash{"sync_active"} = &gst_util_read_boolean($$tree[0]->{active}); - shift @$tree; - - while (@$tree) - { - if ($$tree[0] eq "server") { push (@sync, &gst_xml_get_word($$tree[1])); } - - shift @$tree; - shift @$tree; - } - - return \@sync; -} - - -sub xml_parse_local_time -{ - my $tree = $_[0]; - my $hash; - - shift @$tree; - - while (@$tree) - { - if ($$tree[0] eq "year") { $$hash{"year"} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "month") { $$hash{"month"} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "monthday") { $$hash{"monthday"} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "hour") { $$hash{"hour"} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "minute") { $$hash{"minute"} = &gst_xml_get_word($$tree[1]); } - elsif ($$tree[0] eq "second") { $$hash{"second"} = &gst_xml_get_word($$tree[1]); } - - shift @$tree; - shift @$tree; - } - - return $hash; -} - -# --- XML printing --- # - - -sub xml_print -{ - my $h = $_[0]; - my @sync; - my @scalar_keys = qw (timezone ntpinstalled); - - $sync = $$h{"sync"}; - - &gst_xml_print_begin (); - - &gst_xml_print_vspace (); - &gst_xml_print_hash ($$h{"local_time"}, "local_time"); - &gst_xml_print_vspace (); - - &gst_xml_print_vspace (); - &gst_xml_print_line ("<sync active='" . &gst_print_boolean_yesno ($$h{'sync_active'}) . "'>\n"); - - &gst_xml_enter (); - foreach $server (@$sync) - { - &gst_xml_print_line ("<server>$server</server>\n"); - } - &gst_xml_leave (); - - &gst_xml_print_line ("</sync>\n"); - &gst_xml_print_vspace (); - - &gst_xml_print_scalars ($h, @scalar_keys); - &gst_xml_print_vspace (); - - &gst_xml_print_end (); -} - -# Main operations - -sub get -{ - my $hash; - - $hash = &conf_get (); - - &gst_report_end (); - &xml_print ($hash); -} - - -sub set -{ - my $hash; - - $hash = &xml_parse (); - - &conf_set ($hash); - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - my $hash; - - $hash = &xml_parse (); - &gst_report_end (); - &xml_print ($hash); -} - - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); -&gst_run ($tool); - -# Portable code. - -sub time_get_local_time -{ - my (%h, $trash); - - ($h{"second"}, $h{"minute"}, $h{"hour"}, $h{"monthday"}, $h{"month"}, $h{"year"}, - $trash, $trash, $trash) = localtime (time); - - $h{"month"}++; - $h{"year"} += 1900; - - return \%h; -} - -sub time_get_rh62_zone -{ - my ($local_time_file, $zoneinfo_dir) = @_; - local *TZLIST; - my $zone; - my $size_search; - my $size_test; - - *TZLIST = &gst_file_open_read_from_names($zoneinfo_dir . "/zone.tab"); - if (not *TZLIST) { return; } - - &gst_report ("time_timezone_scan"); - - # Get the filesize for /etc/localtime so that we don't have to execute - # a diff for every file, only for file with the correct size. This speeds - # up loading - $size_search = (stat ($local_time_file))[7]; - - while (<TZLIST>) - { - if (/^\#/) { next; } # Skip comments. - ($d, $d, $zone) = split /[\t ]+/, $_; # Get 3rd column. - chomp $zone; # Remove linefeeds. - - - # See if this zone file matches the installed one. - &gst_report ("time_timezone_cmp", $zone); - &gst_print_progress(); - $size_test = (stat("$zoneinfo_dir/$zone"))[7]; - if ($size_test eq $size_search) - { - if (!&gst_file_run ("diff $zoneinfo_dir/$zone $local_time_file")) - { - # Found a match. - last; - } - } - - $zone = ""; - } - - return $zone; - close (TZLIST); -} - -sub conf_get -{ - my %dist_attrib; - my $hash; - - %dist_attrib = &conf_get_parse_table (); - - $hash = &gst_parse_from_table ($dist_attrib{"fn"}, - $dist_attrib{"table"}); - - return $hash; -} - -# This function will force date format when setting time -sub time_change_date -{ - my ($time) = @_; - my ($plat) = $$tool {"system"}; - my ($command); - - my $plat_table = { - "Linux" => "date %02d%02d%02d%02d%04d.%02d", - "FreeBSD" => "date -f %%m%%d%%H%%M%%Y.%%S %02d%02d%02d%02d%04d.%02d" - }; - - $command = sprintf ($$plat_table {$plat}, - $$time{"month"}, $$time{"monthday"}, - $$time{"hour"}, $$time{"minute"}, - $$time{"year"}, $$time{"second"}); - - &gst_report ("time_localtime_set", $command); - - return &gst_file_run ($command); -} - -sub time_set_local_time -{ - my ($time) = @_; - my ($res, $xscreensaver_owners); - - &gst_report_enter (); - - # Kill screensaver, so it doesn't confuse the users. - $xscreensaver_owners = &gst_service_proc_get_owners ("xscreensaver"); - &gst_service_proc_stop_all ("xscreensaver"); - - $res = &time_change_date ($time); - - # Restart screensaver. - &gst_service_proc_start_all ("xscreensaver -no-splash", $xscreensaver_owners); - - &gst_report_leave (); - return -1 if $res; - return 0; -} - -sub time_set_archlinux_zone -{ - my ($localtime, $zonebase, $timezone) =@_; - &gst_report_enter (); - &gst_report ("time_timezone_set", $timezone); - - $tz = "$zonebase/$timezone"; - if (stat($tz) ne "") - { - my $rcconf = '/etc/rc.conf'; - open DATA, "$rcconf"; - my @rcconflines = <DATA>; - close (DATA); - open DATAOUT, ">", "$rcconf"; - - foreach my $line (@rcconflines) - { - if ( $line =~ /\TIMEZONE=/i) - { - $line = "TIMEZONE=$timezone\n"; - } - - print DATAOUT "$line"; - } - - close (DATAOUT); - unlink $localtime; - &gst_report_enter (); - $res = copy ($tz, $localtime); - &gst_report_leave (); - return -1 unless $res; - return 0; - } - - &gst_report_leave (); - return -1; -} - -sub time_set_rh62_zone -{ - my ($localtime, $zonebase, $timezone) = @_; - - &gst_report_enter (); - &gst_report ("time_timezone_set", $timezone); - - $tz = "$zonebase/$timezone"; - - if (stat($tz) ne "") - { - unlink $localtime; # Important, since it might be a symlink. - - &gst_report_enter (); - $res = copy ($tz, $localtime); - &gst_report_leave (); - return -1 unless $res; - return 0; - } - - &gst_report_leave (); - return -1; -} - -sub time_sync_hw_from_sys -{ - &gst_file_run ("hwclock --systohc"); - return 0; -} - -sub time_replace_ntp_servers -{ - my ($file, $key, $re, $value) = @_; - my ($fd, @line, @res); - my ($buff, $i); - my ($pre_space, $post_comment); - my ($line_key, $val, $rest); - my ($n, $ret); - - &gst_report_enter (); - &gst_report ("replace_split", $key, $file); - - $buff = &gst_file_buffer_load ($file); - - foreach $i (@$buff) - { - $pre_space = $post_comment = ""; - - chomp $i; - - $pre_space = $1 if $i =~ s/^([ \t]+)//; - $post_comment = $1 if $i =~ s/([ \t]*\#.*)//; - - if ($i ne "") - { - @line = split ($re, $i, 3); - $line_key = shift (@line); - $val = shift (@line); - $rest = shift (@line); - - # found the key? - if ($line_key eq $key) - { - $n = 0; - - while (@$value[$n] && (@$value[$n] ne $val)) - { - $n++; - } - - if (@$value[$n] ne $val) - { - $i = ""; - next; - } - - delete @$value[$n]; - chomp $val; - $i = &set_value ($key, $val, $re) . " " . $rest; - } - } - - $i = $pre_space . $i . $post_comment . "\n"; - } - - foreach $i (@$value) - { -# print "$key $i\n"; - push (@$buff, &set_value ($key, $i, $re) . "\n") if ($i ne ""); - } - - &gst_file_buffer_clean ($buff); - $ret = &gst_file_buffer_save ($buff, $file); - &gst_report_leave (); - return $ret; -} - -sub conf_set -{ - my $values_hash = $_[0]; - my %dist_attrib; - - # we need to init those values to start/stop ntp properly, - # if the system is not sysV it will warn and return safely - ($rcd_path, $initd_path, $relative_path) = &gst_service_sysv_get_paths (); - - %dist_attrib = &conf_get_replace_table (); - - $res = &gst_replace_from_table ($dist_attrib{"fn"}, $dist_attrib{"table"}, - $values_hash); - - &time_sync_hw_from_sys (); - - return $res; -} - -sub conf_get_parse_table -{ - my %dist_map = - ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.0", - "redhat-7.2" => "redhat-7.0", - "redhat-7.3" => "redhat-7.0", - "redhat-8.0" => "redhat-7.0", - "redhat-9" => "redhat-7.0", - "openna-1.0" => "redhat-7.0", - - "mandrake-7.1" => "redhat-7.0", - "mandrake-7.2" => "redhat-7.0", - "mandrake-9.0" => "redhat-7.0", - "mandrake-9.1" => "redhat-7.0", - "mandrake-9.2" => "redhat-7.0", - "mandrake-10.0" => "redhat-7.0", - "mandrake-10.1" => "redhat-7.0", - - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - - "suse-7.0" => "suse-7.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - - "turbolinux-7.0" => "redhat-7.0", - - "slackware-8.0.0" => "debian-2.2", - "slackware-8.1" => "debian-2.2", - "slackware-9.0.0" => "debian-2.2", - "slackware-9.1.0" => "debian-2.2", - "slackware-10.0.0" => "debian-2.2", - "slackware-10.1.0" => "debian-2.2", - "slackware-10.2.0" => "debian-2.2", - - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "archlinux" => "archlinux", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.0", - "fedora-2" => "redhat-7.0", - "fedora-3" => "redhat-7.0", - - "rpath" => "redhat-7.0", - - "vine-3.0" => "redhat-7.0", - "vine-3.1" => "redhat-7.0", - - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_tables = - ( - "redhat-6.2" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - STEP_TICKERS => "/etc/ntp/step-tickers", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_get_status, "xntpd" ], - [ "ntpinstalled", \&gst_service_sysv_installed, "xntpd" ], - ] - }, - - "redhat-7.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_sysv_installed, "ntpd" ], - ] - }, - - "debian-2.2" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_first_array_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_sysv_installed, "ntp" ], - ] - }, - - "debian-3.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_sysv_installed, "ntp-server" ], - ] - }, - - "suse-7.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_get_status, "xntpd" ], - [ "ntpinstalled", \&gst_service_sysv_installed, "xntpd" ], - ] - }, - - "suse-9.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_get_status, "xntpd" ], - [ "ntpinstalled", \&gst_service_installed, "xntpd" ], - ] - }, - - "pld-1.0" => - { - fn => - { - NTP_CONF => "/etc/ntp/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_sysv_installed, "ntpd" ], - ] - }, - - - "gentoo" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_gentoo_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_list_any_installed, [ "ntpd", "openntpd" ]], - ] - }, - - "archlinux" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_archlinux_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_rcng_installed, [ "ntpd", "openntpd" ]], - ] - }, - - "freebsd-5" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "local_time", \&time_get_local_time ], - [ "timezone", \&time_get_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "sync", \&gst_parse_split_all_array_with_pos, NTP_CONF, "server", 0, "[ \t]+", "[ \t]+" ], - [ "sync_active", \&gst_service_rcng_get_status, "ntpd" ], - [ "ntpinstalled", \&gst_service_installed, "ntpd" ], - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - -sub conf_get_replace_table -{ - my %dist_map = - ( - "redhat-6.0" => "redhat-6.2", - "redhat-6.1" => "redhat-6.2", - "redhat-6.2" => "redhat-6.2", - - "redhat-7.0" => "redhat-7.0", - "redhat-7.1" => "redhat-7.0", - "redhat-7.2" => "redhat-7.0", - "redhat-7.3" => "redhat-7.0", - "redhat-8.0" => "redhat-7.0", - "redhat-9" => "redhat-7.0", - "openna-1.0" => "redhat-7.0", - - "mandrake-7.1" => "redhat-7.0", - "mandrake-7.2" => "redhat-7.0", - "mandrake-9.0" => "redhat-7.0", - "mandrake-9.1" => "redhat-7.0", - "mandrake-9.2" => "redhat-7.0", - "mandrake-10.0" => "redhat-7.0", - "mandrake-10.1" => "redhat-7.0", - - "debian-2.2" => "debian-2.2", - "debian-3.0" => "debian-3.0", - "debian-sarge" => "debian-3.0", - - "suse-7.0" => "suse-7.0", - "suse-9.0" => "suse-9.0", - "suse-9.1" => "suse-9.0", - - "turbolinux-7.0" => "redhat-7.0", - - "slackware-8.0.0" => "debian-2.2", - "slackware-9.0.0" => "debian-2.2", - "slackware-9.1.0" => "debian-2.2", - "slackware-10.0.0" => "debian-2.2", - "slackware-10.1.0" => "debian-2.2", - "slackware-10.2.0" => "debian-2.2", - - "gentoo" => "gentoo", - "vlos-1.2" => "gentoo", - "archlinux" => "archlinux", - "pld-1.0" => "pld-1.0", - "pld-1.1" => "pld-1.0", - "pld-1.99" => "pld-1.0", - "fedora-1" => "redhat-7.0", - "fedora-2" => "redhat-7.0", - "fedora-3" => "redhat-7.0", - "rpath" => "redhat-7.0", - - "vine-3.0" => "redhat-7.0", - "vine-3.1" => "redhat-7.0", - - "freebsd-5" => "freebsd-5", - "freebsd-6" => "freebsd-5", - ); - - my %dist_tables = - ( - "redhat-6.2" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - STEP_TICKERS => "/etc/ntp/step-tickers", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_set_status, 90, "xntpd", "%sync_active%" ], - ] - }, - - "redhat-7.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_set_status, 90, "ntpd", "%sync_active%" ], - ] - }, - - "debian-2.2" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_set_status, 23, "ntp", "%sync_active%" ], - ] - }, - - "debian-3.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime", - TIMEZONE => "/etc/timezone" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "timezone", \&gst_replace_line_first, TIMEZONE ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_set_status, 23, "ntp-server", "%sync_active%" ], - ] - }, - - "suse-7.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_set_status, 90, "xntpd", "%sync_active%" ], - ] - }, - - "suse-9.0" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_suse_set_status, "xntpd" ], - ] - }, - - "pld-1.0" => - { - fn => - { - NTP_CONF => "/etc/ntp/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&gst_replace_join_all, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_sysv_set_status, 90, "ntpd", "%sync_active%" ], - ] - }, - - "gentoo" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_gentoo_set_status, "ntpd", 1, "%sync_active%" ], - ] - }, - - "archlinux" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_archlinux_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_archlinux_set_status, "ntpd", "%sync_active%" ], - ] - }, - - "freebsd-5" => - { - fn => - { - NTP_CONF => "/etc/ntp.conf", - ZONEINFO => "/usr/share/zoneinfo", - LOCAL_TIME => "/etc/localtime" - }, - table => - [ - [ "timezone", \&time_set_rh62_zone, [LOCAL_TIME, ZONEINFO] ], - [ "local_time", \&time_set_local_time ], - [ "sync", \&time_replace_ntp_servers, NTP_CONF, "server", "[ \t]+" ], - [ "sync_active", \&gst_service_rcng_set_status, "ntpd", "%sync_active%" ], - ] - }, - ); - - my $dist = $dist_map {$gst_dist}; - return %{$dist_tables{$dist}} if $dist; - - &gst_report ("platform_no_table", $gst_dist); - return undef; -} - diff --git a/tokenizer.pl.in b/tokenizer.pl.in deleted file mode 100755 index 2c2d1ed..0000000 --- a/tokenizer.pl.in +++ /dev/null @@ -1,368 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - - -############################################### - -# Please : do not use this functions yet as they need renaming and the order of the -# parameters are going to chamge. Chema. - -############################################### - - -# Functions for tokenizing files -# -# Copyright (C) 2001 Ximian, Inc. -# -# Authors: Chema Celorio <chema@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/file.pl$DOTIN"; - -# -------------------------------- Test --------------------------- -sub gst_tokenizer_test -{ - my ($file) = @_; - my $in, $out; - my $token; - - $out = \@dummy_arrayt; # Otherwise push @$out doesn't work - $in = &gst_tokenize ($file); - - while (defined ($token = &gst_tokenize_get_token ($in, $out))) { - # Replace a token - if ("subnet" eq $token) { - my $subnet = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_replace_token (out, "123\.123\.123\.123"); - } - # Append tokens - if ("option" eq $token) { - &gst_tokenize_append_token ($out, " now"); - } - # Remove and skip till - if ("range" eq $token) { - &gst_tokenize_remove_till ($out,";"); - &gst_tokenize_skip_till ($in, ";"); - } - } - - &gst_file_buffer_save ($out, $file . ".new"); - - printf STDERR "Tested tokenizer with $file. Output in $file.new\n"; - printf STDERR "You can :\n"; - printf STDERR "diff $file $file.new\n"; -} -#&gst_tokenizer_test ("/etc/dhcpd.conf"); - -# -------------------------------- token functions ------------------- -sub gst_tokenize_warning -{ - my ($mess) = @_; - - printf STDERR "Warning ***: $mess\n"; -} - -sub gst_tokenize_error -{ - my ($mess) = @_; - - printf STDERR "Error ***: $mess\n"; - - exit; -} - -sub gst_tokenize_verify_token -{ - my ($in, $verifyme, $out) = @_; - my $token = &gst_tokenize_get_token ($in, $out); - - if ($token ne $verifyme) { - &gst_tokenize_warning ("Expected \"" . $verifyme . "\" found \"" . $token . "\" at line ?"); - } -} - -sub gst_tokenize_get_token -{ - my ($in, $out) = @_; - my $token = ""; - - while ($token eq "") { - if (not ($token = shift @$in)) { - return undef; - } - if (defined $out) { - push (@$out, $token); - } - $token =~ s/\s//g; - $token =~ s/\#.*//; - } - - return $token; -} - -sub gst_tokenize_get_token_unclean -{ - my ($in, $out) = @_; - my $token = ""; - - if (not ($token = shift @$in)) { - return undef; - } - - if (defined $out) { - push (@$out, $token); - } - - return $token; -} - -sub gst_tokenize_get_token_till -{ - my ($in, $out, $till_me) = @_; - my $resp; - - while (defined ($token = &gst_tokenize_get_token ($in, $out)) and - ($token ne $till_me)){ - if (defined $resp) { - $resp .= " "; - } - $resp .= $token; - } - - return $resp; -} - -sub gst_tokenize_replace_token -{ - my ($out, $new_token) = @_; - my $token = pop (@$out); - my $clean = $token; - - $clean =~ s/\s//g; - $clean =~ s/\#.*//; - - $token =~ s/$clean/$new_token/; - - push (@$out, $token); -} - -sub gst_tokenize_append_token -{ - my ($out, $token) = @_; - - # Fixme, split tokens while adding them so that - # we maintain consistency - push (@$out, $token); -} - -sub gst_tokenize_remove_token -{ - my ($out, $number) = @_; - - if (not defined ($number)) { - $number = 1; - } - - while ($number gt 0) { - pop (@$out); - $number --; - } -} - -sub gst_tokenize_skip_token -{ - my ($in, $number) = @_; - - if (not defined ($number)) { - $number = 1; - } - - while ($number gt 0) { - shift (@$in); - $number --; - } -} - -sub gst_tokenize_undo -{ - my ($in, $out, $number) = @_; - - if (not defined ($number)) { - $number = 1; - } - - while ($number gt 0) { - @$in = (my $token = pop @$out, @$in); - $token =~ s/\s//g; - $token =~ s/\#.*//; - if ($token ne "") { - $number --; - } - } -} - -sub gst_tokenize_advance_till -{ - my ($in, $till_me, $out) = @_; - - while (defined (my $token = &gst_tokenize_get_token ($in, $out))) { - if ($token eq $till_me) { - return; - } - } -} - -sub gst_tokenize_skip_till -{ - my ($in, $till_me) = @_; - my $token; - - while (1) { - $token = &gst_tokenize_get_token ($in, $out); - &gst_tokenize_remove_token ($out); - if ($token eq $till_me) { - return; - } - } - -} - -sub gst_tokenize_remove_till -{ - my ($out, $till_me) = @_; - my @dont_remove; - - while (1) { - my $removed = pop (@$out); - - $clean = $removed; - $clean =~ s/\s//g; - $clean =~ s/\#.*//; - - if ($clean eq "") { - # Don't remove lines we ignore - @dont_remove = ($removed, @dont_remove); - } - if ($clean eq $till_me) { - push (@$out, $removed); - @$out = (@$out, @dont_remove); - return; - } - } -} - -# -------------------------------- tokenizer ------------------- -sub gst_tokenize -{ - my ($file) = @_; - my $buf = &gst_file_buffer_load ($file); - - my @out; - my $out_index; - - while (@$buf) { - my $line = $$buf[0]; - my $i = 0; - - if (&gst_ignore_line ($line)) { - $out[$out_index++] = $line; - shift @$buf; - next; - } - - # first skip all the white space/tabs - my $line_copy = $line; - $line_copy =~ s/^(\s+)//; - # save what we removed for later - my $leading = $1; - - # Now, handle token delimiters - $line_copy =~ s/\;/ \; /g; # ";" is a token by itself - $line_copy =~ s/,/ , /g; # "," is a token by itself - - # Remove leading white space again, this time don't save it - # since we added it ourselves - $line_copy =~ s/^(\s+)//; - - # Get the first token in the string by splitting it - my @list = split (' ', $line_copy); - my $token = $list[0]; - - # Add the leading white space that we removed - $token = $leading . $token; - - # Now remove our token from the buffer, to "eat" it from it - $$buf[0] =~ s/$token//; - - # Tambet had this code, which looks right but when i run it - # it behaves the same as the one above. It escapes the - # pattern before running the s// - if (0) { - my $pattern = $token; - $pattern =~ s/(\W)/\\$1/g; - $$buf[0] =~ s/$pattern//; - } - - # This is a special case, if what follows our token is a newline - # we want it to be part of the token so that if we delete it we will - # also delete the newline. If we don't do this, our files can build up - # a lot of newlines. We can't do this above because split will consume - # newlines. - # - # Use the remainder of the last operation where we remove $token from $buf - $_ = $'; - # We have 2 matches posible - # a) whitespace + newline and - # b) ws + comment (with an implicit newline) - if ((/^\s*\n/) || (/^\s*\#/)) { - # If it matches, add it to our token and remove it from $buf - $token = $token . $_ ; - $$buf[0] =~ s/$_//; - } - - $out[$out_index++] = $token; - - # If we removed all of the current line, shift buffer - # so that in the next iteration $line is not empy - if ($$buf[0] eq "") { - shift @$buf; - next; - } - - } - - #construc the input file to compare it. - if (0) { - my $res = ""; - @copy = @out; - while (@copy) { - $res .= $copy[0]; - shift @copy; - } - } - - return \@out; -} - -1; - diff --git a/type1inst b/type1inst deleted file mode 100755 index 86d6425..0000000 --- a/type1inst +++ /dev/null @@ -1,1387 +0,0 @@ -#!/usr/bin/perl -# -# You may need to change the above path. -# -#----------------------------------------------------------------------------- -# -# Copyright (C) 1996-1998 James Macnicol -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2, or (at your option) any later -# version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -#----------------------------------------------------------------------------- -# -# type1inst : Generate a "fonts.scale" file for Type 1 fonts in PFB format -# for use with your favourite X server. Also generate a "Fontmap" for use -# with ghostscript. -# -# cd to the directory you want to install fonts in and invoke this script. -# Options: -# -# -samples Create sample PS files for each font -# -nox Do not create fonts.scale and fonts.dir for X11 -# -nogs Do not create Fontmap for GhostScript -# -quiet Don't print anything on the stdout, just to the log -# (see also next section). -# -silent Same as -quiet (for backwards compatiblity) -# -q Same as -quiet -# -nolog Don't create a log file -# -version Print version info and quit -# -v Same as -version -# -# -# -# THIS IS BETA SOFTWARE! PLEASE READ THE "README" FILE!!! -# -# Direct all correspondence regarding this software to -# -# J.Macnicol@student.anu.edu.au -# -# -# Good luck! -# -# -# James Macnicol -# -#----------------------------------------------------------------------------- - -# Version number and date information - -# NOTE THAT MY E-MAIL ADDRESS HAS CHANGED (AS OF VERSION 0.6.1) !!!! - -$version = "0.6.1"; -$versiondate = "11th February 1998"; -$emailaddress = "james.macnicol\@mailexcite.com"; -$copyright = "Copyright (C) 1996-1998 James Macnicol ($emailaddress)"; - -# -# Map identifying strings in /Notice into foundry names. Separate identifier -# from name with a :. Someone let me know if this is a problem (i.e. foundry -# has a : in its name which really ought to be there (although I may not -# believe it) ; we'll change it to ! or something. -# -# You probably want to put foundries which license type from others near the -# top of this list (e.g. Adobe). If the name of the original source of the -# face is listed lower down then it will be used that instead. It's just that -# Adobe does have its own faces too, but more often than not they are -# licensed. Doing it this way will make it work out correctly in either case. -# - - -@foundries = ( - "Adobe:adobe", - "Allied Corporation:allied", - "Publishers' Paradise:paradise", - "PUBLISHERS' PARADISE:paradise", - "Bigelow & Holmes:b&h", - "Bitstream:bitstream", - "Corel Corporation:corel", - "International Typeface Corporation:itc", - "IBM:ibm", - "LETRASET:letraset", - "Monotype Corporation:monotype", - "SoftMaker:softmaker", - "URW:urw", - "Jonathan Brecher:brecher", - "Brendel Informatik:brendel", - "A. Carr:carr", - "FontBank:fontbank", - "Hershey:hershey", - "A.S.Meit:meit", - "Andrew s. Meit:meit", - "S.G. Moye:moye", - "S. G. Moye:moye", - "D. Rakowski:rakowski", - "David Rakowski:rakowski", - "Reasonable Solutions:reasonable", - "Southern Software:southern", - "Title Wave:titlewave", - "ZSoft:zsoft", - "Digiteyes Multimedia:digiteyes", - "MWSoft:mwsoft", - "MacroMind:macromind", - "Three Islands Press:3ip", - "Hank Gillette:gillette", - "Doug Miles:miles", - "Richard Mitchell:mitchell"); - -# Note: Hershey is the public Hershey fonts which come with Ghostscript. -# These cause no end of problems since they look inside like funny PS -# programs rather than standard fonts. The current version of type1inst will -# refuse to process such fonts. Older versions (< 0.6) tended to fall over -# when these were present. - -# Note 2 : Some of these are obviously names of people only, not companies. -# They are generally public domain fonts. - -# Note 3 : Publisher's Paradise did not produce a majority of the fonts that -# contain their name in the /Notice field, rather they distributed them on -# their BBS. Unfortunately there is no other identifying info in these fonts. - -# -# These are font weights. Some are synonyms, e.g. regular for medium. It -# has been suggested we map "thin" to "light", however there are some font -# families which have both "thin" and "light" variants. An example is -# Linotype's Helvetica Neue. Please let me know if you find a font where -# assuming "semi", and "demi" to be the same fails. -# - -@weights = ( - "book:book", - "demibold:demibold", - "semibold:demibold", - "demi:demibold", - "semi:demibold", - "extrabold:extrabold", - "boldface:bold", - "bold:bold", - "heavyface:heavyface", - "heavy:heavy", - "ultrablack:ultrablack", - "extrablack:extrablack", - "ultra:ultra", # it's gonna break some widths... - "black:black", - "extralight:extralight", - "light:light", - "thin:thin", - "super:super", - "thin:thin", - "light:light", - "semi:demi", - "bold:bold", - "heavy:heavy", - "black:black", - "normal:medium", - "regular:regular", - "roman:regular" # this too might break something... - ); - -# -# Likewise for slants -# - -@slants = ( - "italic:i", - "roman:r", - "regular:r", - # "it:i", - "cursive:i", - "kursiv:i", - "oblique:o", - "obl:o", - "slanted:o", - # Cyrillic fonts - "upright:r", - "inclined:i"); - -# -# Style. Wondering if we should put "serif" in here somehow....? -# -# I haven't put "ultracondensed" here since I think they're two different -# things, i.e. Garamond Ultra Condensed is very bold but condensed. - -@styles = ( - "extracondensed:extracondensed", - "condensed:condensed", - "cond:condensed", - "sans:sans", - "wide:wide", - "cn:condensed", - "narrow:narrow", - "extracompressed:extracompressed", - "compressed:compressed", - "extraextended:extraextended", - "extended:extended", - "expanded:expanded", - "normal:normal"); - -# -# Additional styles. Refer to the line that puts together $xline. -# - -@addstyles = ("alt:alternate", - "beginning:beginning", - "display:display", - "dfr:dfr", - "ending:ending", - # "exp" and "ep" seems to be sometimes part of a fonts name, - # sometimes part of additional classification. I'm crying... :-( - "ep:expert", - "exp:expert", - "ornaments:ornaments", - "osf:oldstylefigures", - "outline:outline", - "sc:smallcaps", - "shaded:shaded", - "shadowed:shadowed", - "stencil:stencil", - "swash:swash", - "sw:swash", - "one:one", - "two:two", - "three:three", - "four:four", - # Some fonts use just "a" to mean a font with alternate - # character set. - "a:alternate"); - -# -# Write a message to the stdout and/or the log file depending on what the -# user chose. -# - -sub log_msg { - ($msg) = @_; - - if (! $silent) { - print STDOUT "$msg"; - } - if ($dologfile) { - print LOG "$msg"; - } -} - -sub log_only_msg { - ($msg) = @_; - - if ($dologfile) { - print LOG "$msg"; - } -} - -# -# Die with a bug message -# - -sub die_bug { - ($msg) = @_; - - die("BUG: $msg\nIf you have not modified the script in a way which might have\ncaused this error you are encouraged to report it as a bug to\n\n$emailaddress\n\n"); -} - -# -# Print out a string with a given minimum width. This is used to make the -# Fontmap entries look nice. -# - -sub print_min_width { - ($stream, $minwidth, $string) = @_; - $_ = $string; - $strlength = length($string); - # Print the string - print $stream $string; - # Now pad out the rest of the space if the string is short. - if ($strlength < $minwidth) { - for ($i = 0; $i < ($minwidth - $strlength); $i = $i + 1) { - print $stream " "; - } - } -} - -# -# Indicate progress through the directory on the command line -# - -sub print_progress { - $totalfonts = $numpffonts + $numgsfonts + $badfonts; - if (! $silent) { - if (($totalfonts % 10) == 0) { - print "[$totalfonts]\n"; - } - } -} - -# -# Put the processing stuff into a procedure since we want to do the same for -# .pfb, .pfa and .gsf files (once .pfb's are decompressed). -# -# Argument : filename. -# Returns : X font description, name of font for Fontmap -# - -sub process_font { - ($fname) = @_; - local($xline); - - # Check to see if this is a ghostscript font - if ($fname =~ /\.gsf\s*$/) { - $gsfont = 1; - } else { - $gsfont = 0; - } - - # Default is not MultipleMaster - $mm = 0; - - open(IN, $fname) || die "cannot open $file for reading"; - # An unlikely name to check to see we get a fontname out of the file. - $fontname = "abcXYZ:!@#"; - $foundry = "unknown"; - $notice = "No notice given."; - while(<IN>) { - if (/\/isFixedPitch\s+(.+)\s+def\s*/) { - if ($1 =~ /true/) { - $fixedpitch = "m"; - } else { - $fixedpitch = "p"; - } - } - - # I think that we should accept the manufacturers classification. - # Try to extract this from FontName only if it's missing. - # (It shouldn't. There are other reasons why this won't work, though.) - if (/\/FamilyName\s*\((.+)\)\s+readonly\s+def\s*/) { - $familyname = $1; - - # Convert to lower case (because case is insignificant). - # Spaces are acceptable according to XLFD. - $familyname =~ tr/A-Z/a-z/; - } - # Previous applies to this also... This might make xfontsels list a - # a little cluttered, though. Perhaps it would be better to map it - # to standard strings like you do. It's named $weight_add because - # you already used $weight... - if (/\/Weight\s*\((.+)\)\s+readonly\s+def\s*/) { - $weight_add = $1; - - # Convert to lower case. Spaces are acceptable according to XLFD? - # Remove for consistency (as there would be any left after my - # slaughtering). - $weight_add =~ tr/A-Z/a-z/; - $weight_add =~ s/\s*//g; - - # Remember if it's a MultipleMaster font - $mm = 1 if ($weight_add =~ /^all$/); - # Strange. This field seems to contain also width sometimes... remove it. - $numstyles = @styles; - for ($x = 0; $x < $numstyles; $x = $x + 1) { - $ident = $styles[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The style identification \"$ident\" is bad\n"); - } - # Remove matched word from the font's name - $weight_add =~ s/$fields[0]//; - } - } - # FullName might contain useful information in determining - # the properties of a font. - if (/\/FullName\s*\((.+)\)\s+readonly\s+def\s*/) { - $fullname = $1; - - # Convert to lower case - $fullname =~ tr/A-Z/a-z/; - - # Some names got extra numerical information at the start. - $fullname =~ s/^\d*\s*(.+)/$1/; - } - # Note : some fonts have a suspect /FontName declaration where there - # is no space between /FontName and the name of the font itself.... - if (/\/FontName\s*[\/\(]([^\)]+)\)?\s+def\s*/) { - $fontname = $1; - - # Remove any embedded spaces - # (Probably unnecessary. If I remember it right, it can't contain any spaces, - # because it's a PostScript identifier/keyword or what's the right term...) - $fontname =~ s/\s//g; - - # Save a copy of original full name for later - $fontnamecopy = $fontname; - - # Convert to lower case - $fontname =~ tr/A-Z/a-z/; - - # There are fonts like Mendoza Roman, Baskerville Book etc, where what - # looks like weight is part of the font's name, not it's weight. - # Split the name into fontname and fontstyle instead and handle them separate. - ($fontname, $fontstyle) = split(/-/, $fontname); - - # Remove -s - $fontname =~ s/-//g; - $fontstyle =~ s/-//g; - - - # Check for weight modifiers (medium, bold, demi, light etc.) - $weight = "medium"; - $numweights = @weights; - for ($x = 0; $x < $numweights; $x = $x + 1) { - $ident = $weights[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The weight identification \"$ident\" is bad\n"); - } - if ($fontstyle =~ /$fields[0]/) { - $weight = $fields[1]; - } elsif ($weight_add) { - # Try any possible way - $weight = $weight_add; - } - # Remove matched word from the font's name - $fontstyle =~ s/$fields[0]//; - } - - # Check for slant (italic, roman, oblique) - $slant = "r"; - - $numslants = @slants; - for ($x = 0; $x < $numslants; $x = $x + 1) { - $ident = $slants[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The slant identification \"$ident\" is bad\n"); - } - if ($fontstyle =~ /$fields[0]/) { - $slant = $fields[1]; - } - # Remove matched word from the font's name - $fontstyle =~ s/$fields[0]//; - } - - # Check for style (condensed, normal, sans, or wide) - $style = "normal"; - - $numstyles = @styles; - for ($x = 0; $x < $numstyles; $x = $x + 1) { - $ident = $styles[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The style identification \"$ident\" is bad\n"); - } - if ($fontstyle =~ /$fields[0]/) { - $style = $fields[1]; - } - # Remove matched word from the font's name - $fontstyle =~ s/$fields[0]//; - } - - # Check for additional styles (alternate, smallcaps, oldstylefigures etc.) - $addstyle = ""; - - $numaddstyles = @addstyles; - for ($x = 0; $x < $numaddstyles; $x = $x + 1) { - $ident = $addstyles[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The additional style identification \"$ident\" is bad.\n"); - } - if ($fontstyle =~ /$fields[0]/) { - $addstyle = $fields[1]; - } - # Remove matched word from the font's name - $fontstyle =~ s/$fields[0]//; - } - } - if (/^\/Encoding\s+(\S+)\s*/) { - if ($1 =~ /StandardEncoding/) { - $encoding = "iso8859-1"; - } else { - # This needs work - $encoding = "adobe-fontspecific"; - } - } - - if (/^\s*\/Notice\s*(.*)$/) { - $notice = $1; - - $notice =~ s/readonly def//g; - - $numfoundries = @foundries; - for ($x = 0; $x < $numfoundries; $x = $x + 1) { - $ident = $foundries[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The foundry identification \"$ident\" is bad.\n"); - } - if ($notice =~ /$fields[0]/) { - $foundry = $fields[1]; - } - } - } - - # MultipleMaster fonts have this field. - if (/\/BlendAxisTypes\s+\[([^\]]+)\]\s*def/) { - $axis = $1; - # Remove axises we don't need - $axis =~ s/\/Weight\s+//; - $axis =~ s/\/Width\s+//; - # Are there still some axises left? - if ($axis =~ /\//) { - # Remove trailing spaces - $axis =~ s/^(.*?)\s*$/$1/; - $axis =~ s/\/\S+/0/g; - $axis= "[$axis]"; - } - } - - # Break out of loop if we've passed the interesting stuff. - # And time to try another way to find out the fontname. - if ((! $gsfont) && (/currentfile\s+eexec/)) { - &try_another_way(); - # This is for .pfa and .pfb fonts - last; - } elsif (($gsfont) && (/currentdict\s+end/)) { - &try_another_way(); - # This is for ghostscript .gsf fonts. Why don't all these have a - # currentfile eexec ? - last; - } - } - close(IN); - - # I use quite different mechanism to get fontname etc. However it's done, - # the results are hard to get right. Should it be a command-line option? - # Now I try both ways. - - # familyname, use fontname - $familyname = ($anotherway ? $familyname : $fontname); - - # Oh, we are dealing with a MultipleMaster font... - if ($mm) { - $weight = "0"; - $style = "0"; - $addstyle .= $axis; - } - - if ($familyname =~ /abcXYZ\:\!\@\#/) { - log_only_msg("\n"); - log_only_msg("$filename : could not determine font name\n"); - log_only_msg("\n"); - $badfonts = $badfonts + 1; - &print_progress(); - return; - } - - if (($dox) && (! $gsfont) && ($foundry =~ /unknown/)) { - $nofoundry = $nofoundry + 1; - log_only_msg("\n"); - log_only_msg("$filename ($fontnamecopy) : foundry not matched\n"); - log_only_msg(" /Notice said : \"$notice\"\n"); - log_only_msg("\n"); - } elsif ($dox) { -# log_only_msg("$filename ($fontnamecopy) : okay\n"); - } - - if (($dox) && (! $gsfont)) { - # Addstyle is any extra information needed to uniquely identify a variation of a font - # in it's family, like "alternate" (ACaslon-AltRegular) or "one" (EuropeanPi-One). - # Changed fontname to familyname because it describes that field better, but that's - # just my opinion... - $xline = "-$foundry-$familyname-$weight-$slant-$style-$addstyle-0-0-0-0-$fixedpitch-0-$encoding"; - } - - # Update count of each type - if ($gsfont) { - $numgsfonts = $numgsfonts + 1; - } else { - $numpffonts = $numpffonts + 1; - } - - &print_progress(); - - ($xline, $fontnamecopy); -} - - -# -# An alternative way to get fontname -# - -sub try_another_way { - # Strip familyname from fullname. This seems to work most of time. - # Some fontnames have extra numerical information after familyname. - # Strip it if it's longer than two numbers. - # Otherwise, it's probably part of additional style classification. - # In a few cases it IS part of the name, and this algorithm should break. - # Sometimes there's a strange string of *'s somewhere. Get rid of it. - $fullname =~ s/\*//g; - print STDERR "1: ${fullname}:\n" if $debug; - if ($fullname =~ s/^$familyname\s*(\d\d+)?\s*(.*)/$2/) { - # Wow. It worked. Let's continue and remove excess whitespace. - $anotherway = 1; - $fullname =~ s/\s+//g; - - # familyname can now stripped of -s - $familyname =~ s/-//g; # Or space? - print STDERR "2: ${fullname}:\n" if $debug; - - # Check for weight modifiers (medium, bold, demi, light etc.) - $weight = "medium"; - $numweights = @weights; - for ($x = 0; $x < $numweights; $x = $x + 1) { - $ident = $weights[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The weight identification \"$ident\" is bad\n"); - } - if ($fullname =~ /$fields[0]/) { - $weight = $fields[1]; - $weight =~ s/-//g; - } - # Remove matched word from the font's name - $fullname =~ s/$fields[0]//; - } - - print STDERR "3: ${fullname}:\n" if $debug; - - # Check for slant (italic, oblique) - $slant = "r"; - - $numslants = @slants; - for ($x = 0; $x < $numslants; $x = $x + 1) { - $ident = $slants[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The slant identification \"$ident\" is bad\n"); - } - if ($fullname =~ /$fields[0]/) { - $slant = $fields[1]; - $slant =~ s/-//g; - } - # Remove matched word from the font's name - $fullname =~ s/$fields[0]//; - } - print STDERR "4: ${fullname}:\n" if $debug; - # Check for style (normal or sans) - $style = "normal"; - - $numstyles = @styles; - for ($x = 0; $x < $numstyles; $x = $x + 1) { - $ident = $styles[$x]; - @fields = split(/:/, $ident); - $numfields = @fields; - if ($numfields != 2) { - die_bug("The style identification \"$ident\" is bad\n"); - } - if ($fullname =~ /$fields[0]/) { - $style = $fields[1]; - $style =~ s/-//g; - } - # Remove matched word from the font's name - $fullname =~ s/$fields[0]//; - } - - # What's left of fullname is probably additional style information. - # Some fontnames have some strange numerical information here too. - # If it's just one number, it usually refers to some variant of the - # fontfamily, otherwise, just get rid of it. - $fullname = "" if ($fullname =~ /^\d\d+$/); - print STDERR "5: ${fullname}:\n" if $debug; - $addstyle = $fullname; - $addstyle =~ s/-//g; - } else { - $anotherway = 0; - } -} - -# -# Makes associative array out of current entries in fonts.scale -# - -sub read_fonts_scale { - local($finish, %rv, $line, $filename, $fontname); - - $finish = open(SCALE, "fonts.scale") ? 0 : 1; - if ($finish == 1) { - %rv; - } - - log_only_msg("Reading fonts.scale ...."); - - # First line should be an integer saying how many fonts there are. - # Discard. - $line = <SCALE>; - if (! $line =~ /\s*[0-9]+\s*/) { - log_only_msg("Warning : first line of fonts.scale is bad\n"); - } - - while (<SCALE>) { - # Very rough pattern - if (/\s*(\S+)\s+(.+)\s*/) { - chop; - $filename = $1; - $fontname = $2; - if (! -e $filename) { - $numxremoved++; - log_only_msg("Removed fonts.scale entry \"$_\" since the file did not exist\n"); - next; - } - if ($rv{$filename}) { - $numxduplicates++; - log_only_msg("Warning : fonts.scale already contains a line for file \"$filename\"\n"); - log_only_msg(" the line \"$_\" has been ignored\n"); - } else { - $rv{$filename} = $fontname; - } - } else { - log_only_msg(" Couldn't understand line : \n"); - log_only_msg(" \"$_\"\n"); - } - } - close(SCALE); - - log_only_msg("Done.\n"); - - %rv; -} - -# -# Write out an associative array into fonts.scale, making a backup copy -# first. -# - -sub write_fonts_scale { - (%fontdata) = @_; - local($numentries, $key); - - # First, make backup copy - if (-e "fonts.scale") { - system ("cp -f fonts.scale fonts.scale.bak"); - } - - log_only_msg("Writing fonts.scale....\n"); - - $numentries = keys(%fontdata); - open(SCALE, ">fonts.scale") || die("Can't open fonts.scale!\n"); - print SCALE "$numentries\n"; - foreach $key (sort(keys %fontdata)) { - print_min_width(SCALE, 12, $key); - print SCALE " "; - print SCALE "$fontdata{$key}\n"; - } - close(SCALE); - system ("chmod 0755 fonts.scale") && log_msg("Coudln't chmod \"fonts.scale\" ... continuing on anyway\n"); - - log_only_msg(" Done.\n"); -} - -# -# Read the current Fontmap and return associative array with data. -# - -sub read_fontmap { - local(%rv, $finish, $fontname, $filename); - - $finish = open(FONTMAP, "Fontmap") ? 0 : 1; - if ($finish) { - %rv; - } - - log_only_msg("Reading Fontmap ....\n"); - - while (<FONTMAP>) { - if (/\/+(\S+)\s+\((.*)\)\s+;\s+/) { - chop; - $fontname = $1; - $filename = $2; - if (! -e $filename) { - $numgsremoved++; - log_only_msg("Removed Fontmap entry \"$_\" since the file did not exist\n"); - next; - } - if ($rv{$filename}) { - # Entry already exists - $numgsduplicates++; - log_only_msg("Warning : the Fontmap already contains a line for file \"$filename\"\n"); - log_only_msg(" the line \"$_\" has been ignored\n"); - } else { - $rv{$filename} = $fontname; - } - } else { - $numgsbarf++; - log_only_msg("Couldn't understand line :\n"); - log_only_msg(" $_\n"); - } - } - - close(FONTMAP); - - log_only_msg("Done.\n"); - - %rv; -} - -# -# Write associative array containing font data to Fontmap -# - -sub write_fontmap { - (%fontdata) = @_; - local($numentries, $key); - - # First, make backup copy - if (-e "Fontmap") { - system ("cp -f Fontmap Fontmap.bak"); - } - - log_only_msg("Writing Fontmap...."); - - $numentries = keys(%fontdata); - open(FONTMAP, ">Fontmap") || die("Couldn't open Fontmap!\n"); - foreach $key (sort(keys %fontdata)) { - print_min_width(FONTMAP, 40, "/$fontdata{$key}"); - print FONTMAP " "; - print FONTMAP "($key)\t;\n"; - } - close(FONTMAP); - system ("chmod 0755 Fontmap") && log_msg("Couldn't chmod \"Fontmap\" ... continuing on anyway\n"); - - log_only_msg(" Done.\n"); -} - -# -# Add a font (either X or gs) to hash table -# - -sub add_font_to_aarray { - ($fname, $text, %aa) = @_; - - if (($text =~ /^\s*$/) || ($fname =~ /^\s*$/)) { - # This will occur if the font is a dud (e.g. a Hershey font). We - # assume that $badfonts has been incremented and we just return. - %aa; - } - - if (! $aa{$fname}) { - $aa{$fname} = $text; - } - - %aa; -} - -# -# Create sample text using each font -# - -sub font_sample { - ($filename, $fontname, $height) = @_; - local($text, $alltext, $samplefile); - - if (($filename =~ /^\s*$/) || ($fontname =~ /^s*$/)) { - print "font_sample: $filename, $fontname\n"; - die_bug("Bad argument(s) to font_sample()!\n"); - } - -# Here we create a full page sample for the current font. It contains -# a large point-size version, a normal sized version, and a small version. - - $text = <<"TEXT"; -%! -%%EndComments -/$samplefont findfont -18 scalefont -setfont -newpath -200 715 moveto -(File : $filename) show -200 695 moveto -(Font Name : $fontname) show -% t1embed : $filename $fontname -closepath - -/$fontname findfont -60 scalefont -setfont -newpath -40 640 moveto -(ABCDE) show -40 575 moveto -(FGHIJK) show -40 510 moveto -(LMNOP) show -40 445 moveto -(QRSTU) show -40 380 moveto -(VWXYZ) show -40 305 moveto -(abcdefghijklm) show -40 240 moveto -(nopqrstuvwxyz) show -40 175 moveto -(1234567890) show -closepath - -/$fontname findfont -12 scalefont -setfont -newpath -50 148 moveto -(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) show -50 132 moveto -(a b c d e f g h i j k l m n o p q r s t u v w x y z) show -50 116 moveto -(1 2 3 4 5 6 7 8 9 0 \! \$ \% \& \\\( \\\) \; \: \< \> ) show -closepath - -/$fontname findfont -4 scalefont -setfont -newpath -50 99 moveto -(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) show -50 93 moveto -(a b c d e f g h i j k l m n o p q r s t u v w x y z) show -50 87 moveto -(1 2 3 4 5 6 7 8 9 0 \! \$ \% \& \\\( \\\) \; \: \< \> ) show -closepath -showpage -TEXT - - $samplefile = $fontname . ".ps"; - open(SAMPLE, ">samples/$samplefile") || - die("Couldn't open samples/$samplefile\n"); - print SAMPLE "$text\n"; - close(SAMPLE); - system("chmod 0755 samples/$samplefile") && log_msg("Couldn't chmod individual sample file \"samples/$samplefile\" ... continuing on anyway\n"); - -# For the "allfont.ps" files we use a standard font for the font name so -# that in the case of non-alpha fonts we still can still read the name of -# the font (eg symbol or dingbats). - - if ($height == 700) { - $allsample = "samples/allfont-$allcount.ps"; - $allcount = $allcount + 1; - - log_only_msg("Creating new sample file \"$allsample\"...."); - open(ALLSAMPLE, ">$allsample") || - die("Couldn't open $allsample\n"); - log_only_msg("done\n"); - print ALLSAMPLE "%!\n"; - print ALLSAMPLE "%%EndComments\n"; - } - - $alltext = <<"ALLTEXT"; - -% t1embed : $filename $fontname -/$samplefont findfont -12 scalefont -setfont -newpath -30 $height moveto -($fontname : ) show -/$fontname findfont -20 scalefont -setfont -(AbCdEfGhIjKlMnOpQrStUvWxYz 0123456789) show -closepath -ALLTEXT - - print ALLSAMPLE "$alltext\n"; - $height = $height - 32; - if ($height < 100) { - print ALLSAMPLE "showpage\n"; - close(ALLSAMPLE); - system("chmod 0755 $allsample") && log_msg("Couldn't chmod all sample sheet \"$allsample\" ... continuing on anyway\n"); - $height = 700; - } - - ($height); -} - -# -# Some users have had problems with perl's file globbing not working. This -# gets a shell to do it for us. It matches all files with the extension -# specified in the parameter, i.e. if pat = "foo" then it matches all of -# *.foo . -# - -sub do_glob { - ($pat) = @_; - local($raw, @fnames); - open(SHELL, "echo *.$pat|") || die("Couldn't open shell in do_glob\n"); - $raw = <SHELL>; - $raw =~ s/\*\.$pat//; - @fnames = split(/\s/,$raw); - close(SHELL); - (@fnames); -} - -# ------------------------------------------------------------------------ -# Start of program proper -# ------------------------------------------------------------------------ - -# Process command line arguments -$workdir = 0; -$dox = 1; -$dogs = 1; -$silent = 0; -$samples = 0; -$dologfile = 1; -@argvcopy = (@ARGV); -$numargs = @ARGV; -for ($x = 0; $x < $numargs; $x = $x + 1) { - $arg = $ARGV[$x]; - if ($arg =~ /-nox/) { - $dox = 0; - } elsif ($arg =~ /-nogs/) { - $dogs = 0; - } elsif ($arg =~ /-silent/) { - $silent = 1; - } elsif ($arg =~ /-quiet/) { - $silent = 1; - } elsif ($arg =~ /-q/) { - $silent = 1; - } elsif ($arg =~ /-samples/) { - $samples = 1; - } elsif ($arg =~ /-nolog/) { - $dologfile = 0; - } elsif ($arg =~ /-d/) { - $x++; - $workdir = $ARGV[$x]; - } elsif ($arg =~ /-version/) { - die("type1inst version $version ($versiondate)\n$copyright\n"); - } elsif ($arg =~ /-v/) { - die("type1inst version $version ($versiondate)\n$copyright\n"); - } else { - die("Usage: $0 [-silent] [-quiet] [-q] [-nox] [-nogs] [-samples] [-version] [-v]\n"); - } -} -if ((! $dox) && (! $dogs) && (! $samples)) { - die("$0: Nothing to do!\n"); -} - -if ($workdir) { - chdir $workdir || die "Cannot change to \"$workdir\""; -} - -# Open logfile -if ($dologfile) { - open(LOG, ">type1inst.log") || die "Cannot open log file \"type1inst.log\""; -} - -log_only_msg("type1inst Version $version ($versiondate)\n"); -log_only_msg("$copyright\n\n"); -open (DATE, "date|") || die("Couldn't run \"date\"\n"); -$currenttime = <DATE>; -log_only_msg("Run started at $currenttime\n"); -close(DATE); - -# Setup directory for font samples -if ($samples) { - if (! -e "samples") { - # Create directory for sample text PS files - log_only_msg("Creating directory for samples ...\n"); - system("mkdir samples"); - system("chmod 0755 samples") && log_msg("Coudln't chmod \"samples\" directory\n"); - - } elsif (-f "samples") { - die("$0: remove file \"samples\" or do not use -samples option\n"); - } else { - log_msg("Clearing samples directory\n"); - system("rm -f samples/*.ps"); - } - $height = 700; - $samplefont = "Helvetica"; - $allcount = 0; - $allsample = "samples/allfont-$allcount.ps"; - log_only_msg("Creating new sample file \"$allsample\"...."); - open(ALLSAMPLE, ">$allsample") || die("Couldn't open all sample file \"$allsample\"\n"); - log_only_msg("done\n"); - print ALLSAMPLE "%!\n"; - print ALLSAMPLE "%%EndComments\n"; -} - - -# Counts how many fonts we come across -$numpffonts = 0; -$numgsfonts = 0; -$nofoundry = 0; -$badfonts = 0; -$numskipped = 0; -$numxremoved = 0; -$numgsremoved = 0; -$numxduplicates = 0; -$numgsduplicates = 0; -$numxbarf = 0; -$numgsbarf = 0; - -if (! $silent) { - print "type1inst Version $version ($versiondate)\n"; - print "$copyright\n\n"; -} - -$totalfonts = 0; -foreach $filename (do_glob("pfa")) { - $totalfonts++; -} -foreach $filename (do_glob("pfb")) { - $totalfonts++; -} -foreach $filename (do_glob("pfa.gz")) { - $totalfonts++; -} -foreach $filename (do_glob("pfb.gz")) { - $totalfonts++; -} -foreach $filename (do_glob("gsf")) { - $totalfonts++; -} -if (! $silent) { - if ($totalfonts == 0) { - die("There are no PostScript fonts in this directory\n"); - } elsif ($totalfonts == 1) { - print "There is 1 PostScript font in this directory\n"; - } else { - print "There are a total of $totalfonts PostScript fonts in this directory\n"; - } -} - -if ($dox) { - %fs = &read_fonts_scale(); -} -if (($dogs) || ($samples)) { - %fm = &read_fontmap(); -} - -# Process ASCII PS fonts -foreach $filename (do_glob("pfa")) { - if (($dox && (! $fs{$filename})) || - (($dogs || $samples) && (! $fm{$filename}))) { - ($x, $gs) = &process_font($filename); - if ($dox) { - %fs = &add_font_to_aarray($filename, $x, %fs); - } - if (($dogs) || ($samples)) { - %fm = &add_font_to_aarray($filename, $gs, %fm); - } - } else { - $numpffonts = $numpffonts + 1; - $numskipped = $numskipped + 1; - &print_progress(); - } - if ($samples) { - ($height) = &font_sample($filename, $fm{$filename}, $height); - } -} - -# Process binary PS fonts -foreach $filename (do_glob("pfb")) { - if (($dox && (! $fs{$filename})) || - (($dogs || $samples) && (! $fm{$filename}))) { - system("pfbtops $filename > foo"); - ($x, $gs) = &process_font("foo"); - system("rm foo"); - if ($dox) { - %fs = &add_font_to_aarray($filename, $x, %fs); - } - if ($dogs || $samples) { - %fm = &add_font_to_aarray($filename, $gs, %fm); - } - } else { - $numpffonts = $numpffonts + 1; - $numskipped = $numskipped + 1; - &print_progress(); - } - if ($samples) { - ($height) = &font_sample($filename, $fm{$filename}, $height); - } -} - -# Process binary PS fonts -foreach $filename (do_glob("pfa.gz")) { - if (($dox && (! $fs{$filename})) || - (($dogs || $samples) && (! $fm{$filename}))) { - system("gunzip -c $filename > foo"); - ($x, $gs) = &process_font("foo"); - system("rm foo"); - if ($dox) { - %fs = &add_font_to_aarray($filename, $x, %fs); - } - if ($dogs || $samples) { - %fm = &add_font_to_aarray($filename, $gs, %fm); - } - } else { - $numpffonts = $numpffonts + 1; - $numskipped = $numskipped + 1; - &print_progress(); - } - if ($samples) { - ($height) = &font_sample($filename, $fm{$filename}, $height); - } -} - -# Process binary PS fonts -foreach $filename (do_glob("pfb.gz")) { - if (($dox && (! $fs{$filename})) || - (($dogs || $samples) && (! $fm{$filename}))) { - system("gunzip -c $filename | pfbtops > foo"); - ($x, $gs) = &process_font("foo"); - system("rm foo"); - if ($dox) { - %fs = &add_font_to_aarray($filename, $x, %fs); - } - if ($dogs || $samples) { - %fm = &add_font_to_aarray($filename, $gs, %fm); - } - } else { - $numpffonts = $numpffonts + 1; - $numskipped = $numskipped + 1; - &print_progress(); - } - if ($samples) { - ($height) = &font_sample($filename, $fm{$filename}, $height); - } -} - -# Process Ghostscript fonts -if ($dogs || $samples) { - foreach $filename (do_glob("gsf")) { - if (! $fm{$filename}) { - ($x, $gs) = &process_font($filename); - %fm = &add_font_to_aarray($filename, $gs, %fm); - } else { - $numgsfonts = $numgsfonts + 1; - $numskipped = $numskipped + 1; - &print_progress(); - } - if ($samples) { - ($height) = &font_sample($filename, $fm{$filename}, $height); - } - } -} - -if ($dox) { - &write_fonts_scale(%fs); - system("mkfontdir"); # Generate fonts.dir - system("chmod 0755 fonts.dir") && log_msg("Couldn't chmod \"fonts.dir\" ... continuing on anyway\n"); -} -if ($dogs) { - &write_fontmap(%fm); -} - -# Finish up the all font sample file -if ($samples) { - log_only_msg("Finished font sample files\n"); - if ($height < 700) { - print ALLSAMPLE "showpage\n"; - close(ALLSAMPLE); - system("chmod 0755 $allsample") && log_msg("Couldn't chmod \"$allsample\" ... continuing on anyway\n"); - } -} - -# Report -if (! $silent) { - $totalfonts = $numpffonts + $numgsfonts + $badfonts; - - # List statistics - print "-------------------------------------------------------\n"; - if ($totalfonts == 0) { - print "No fonts were found in this directory\n"; - } elsif ($totalfonts == 1) { - print "1 font was found in this directory\n"; - } else { - print "$totalfonts fonts found\n"; - } - if ($numpffonts == 1) { - print "1 was a PostScript font\n"; - } elsif ($numpffonts > 1) { - print "$numpffonts were standard PostScript fonts\n"; - } - if ($numgsfonts == 1) { - print "1 was a Ghostscript font\n"; - } elsif ($numgsfonts > 1) { - print "$numgsfonts were Ghostscript fonts\n"; - } - if ($numskipped == 1) { - print "\n"; - print "I skipped one of these fonts because it already had\n"; - print "an overriding entry in both fonts.scale and/or Fontmap\n"; - print "(X Windows font or Ghostscript font respectively).\n"; - } elsif ($numskipped > 1) { - print "\n"; - print "I skipped $numskipped of these fonts because they already\n"; - print "had overriding entries in both fonts.scale and/or Fontmap\n"; - print "(X Windows fonts or Ghostscript fonts respectively).\n"; - } - - # Print error messages - $wereerrors = 0; - if ($badfonts > 0) { - $wereerrors = 1; - print "-------------------------------------------------------\n"; - if ($badfonts == 1) { - print "I couldn't extract a font name for 1 font in\n"; - } else { - print "I couldn't extract font names for $ badfonts fonts in\n"; - } - print "this directory. This means the font file had a non-standard\n"; - print "format which this program doesn't know about or cannot do\n"; - print "anything with. Check the README file to find out more.\n"; - } - if ($dox) { - if ($nofoundry > 0) { - $wereerrors = 1; - print "-------------------------------------------------------\n"; - print "For $nofoundry of these I couldn't figure out which foundry\n"; - print "the font is from. Thus, these fonts will appear under the\n"; - print "foundry unknown, i.e. X font name -unknown-*.\n"; - print "Please consult the README file to see what this means.\n"; - } - - if ($numxremoved > 0) { - $wereerrors = 1; - print "-------------------------------------------------------\n"; - if ($numxremoved == 1) { - print "While reading the existing fonts.scale file I saw 1 entry\n"; - } else { - print "While reading the existing fonts.scale file I saw $numxremoved entries\n"; - } - print "which mentioned a filename which now does not exist. Most likely\n"; - print "you removed or renamed the file. I ignored these entries.\n"; - } - if ($numxbarf > 0) { - $wereerrors = 1; - print "-------------------------------------------------------\n"; - if ($numxbarf == 1) { - print "There was a line in fonts.scale I couldn't understand.\n"; - } else { - print "There were $numxbarf lines in fonts.scale which I couldn't understand\n"; - } - print "These were ignored.\n"; - } - } - if ($dogs) { - if ($numgsremoved > 0) { - $wereerrors = 1; - print "-------------------------------------------------------\n"; - if ($numgsremoved == 1) { - print "While reading the existing Fontmap file I saw 1 entry\n"; - } else { - print "While reading the existing Fontmap file I saw $numgsremoved entries\n"; - } - print "which mentioned a filename which now does not exist. Most likely\n"; - print "you removed or renamed the file. I ignored these entries.\n"; - } - if ($numgsbarf > 0) { - $wereerrors = 1; - print "-------------------------------------------------------\n"; - if ($numgsbarf == 1) { - print "There was a line in Fontmap I couldn't understand.\n"; - } else { - print "There were $numgsbarf lines in Fontmap which I couldn't understand\n"; - } - print "These were ignored.\n"; - } - } - - if ($wereerrors) { - print "-------------------------------------------------------\n"; - print "\n"; - print "A log of errors is located in the file \"type1inst.log\"\n"; - print "\n"; - } -} diff --git a/users-conf.in b/users-conf.in deleted file mode 100644 index bc8a69a..0000000 --- a/users-conf.in +++ /dev/null @@ -1,1633 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - -# Users account mannager. Designed to be architecture and distribution independent. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Hans Petter Jansson <hpj@ximian.com>, -# Arturo Espinosa <arturo@ximian.com>, -# Tambet Ingo <tambet@ximian.com>. -# Grzegorz Golawski <grzegol@pld-linux.org> (PLD Support) -# -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -# Best viewed with 100 columns of width. - -# Configuration files affected: -# -# /etc/passwd -# /etc/group -# /etc/shadow -# /etc/login.defs -# /etc/shells -# /etc/skel/ - -# NIS support will come later. - -# Running programs affected/used: -# -# adduser: creating users. -# usermod: modifying user data. -# passwd: assigning or changing passwords. (Un)locking users. -# chfn: modifying finger information - Name, Office, Office phone, Home phone. -# pw: modifying users/groups and user/group data on FreeBSD. - - -BEGIN { - $SCRIPTSDIR = "@scriptsdir@"; - if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) - { - $SCRIPTSDIR = "."; - $DOTIN = ".in"; - } - - require "$SCRIPTSDIR/general.pl$DOTIN"; - require "$SCRIPTSDIR/platform.pl$DOTIN"; - require "$SCRIPTSDIR/util.pl$DOTIN"; - require "$SCRIPTSDIR/file.pl$DOTIN"; - require "$SCRIPTSDIR/xml.pl$DOTIN"; - require "$SCRIPTSDIR/replace.pl$DOTIN"; -} - - -# --- Tool information --- # - -$name = "users"; -$version = "@VERSION@"; -@platforms = ("redhat-5.2", "redhat-6.0", "redhat-6.1", "redhat-6.2", "redhat-7.0", "redhat-7.1", - "redhat-7.2", "redhat-7.3", "redhat-8.0", "redhat-9", - "openna-1.0", - "mandrake-7.1", "mandrake-7.2", "mandrake-9.0", "mandrake-9.1", "mandrake-9.2", - "mandrake-10.0", "mandrake-10.1", - "debian-2.2", "debian-3.0", "debian-sarge", - "suse-7.0", "suse-9.0", "suse-9.1", "turbolinux-7.0", - "slackware-8.0.0", "slackware-8.1", "slackware-9.0.0", "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0", - "freebsd-4", "freebsd-5", "freebsd-6", - "gentoo", "vlos-1.2", - "archlinux", - "pld-1.0", "pld-1.1", "pld-1.99", "fedora-1", "fedora-2", "fedora-3", "rpath", "vine-3.0", "vine-3.1"); - -$description =<<"end_of_description;"; - Manages system users. -end_of_description; - -# --- System config file locations --- # - -# We list each config file type with as many alternate locations as possible. -# They are tried in array order. First found = used. - -@passwd_names = ( "/etc/passwd" ); -@shadow_names = ( "/etc/shadow", "/etc/master.passwd" ); -@group_names = ( "/etc/group" ); -@login_defs_names = ( "/etc/login.defs", "/etc/adduser.conf" ); -@shell_names = ( "/etc/shells" ); -@skel_dir = ( "/usr/share/skel", "/etc/skel" ); - -$profile_file = "profiles.xml"; - - -# Where are the tools? - -$cmd_usermod = &gst_file_locate_tool ("usermod"); -$cmd_userdel = &gst_file_locate_tool ("userdel"); -$cmd_useradd = &gst_file_locate_tool ("useradd"); -$cmd_groupdel = &gst_file_locate_tool ("groupdel"); -$cmd_groupadd = &gst_file_locate_tool ("groupadd"); -$cmd_groupmod = &gst_file_locate_tool ("groupmod"); -$cmd_gpasswd = &gst_file_locate_tool ("gpasswd"); -$cmd_chfn = &gst_file_locate_tool ("chfn"); -$cmd_pw = &gst_file_locate_tool ("pw"); - -# --- Mapping constants --- # - -%users_prop_map = (); -@users_prop_array = (); - -if ($$tool{"platform"} eq "Linux") -{ - @users_prop_array = ( - "key", 0, - "login", 1, - "password", 2, - "uid", 3, - "gid", 4, - "comment", 5, - "home", 6, - "shell", 7, - "last_mod", 8, # Read shadow (5) for these. - "passwd_min_life", 9, - "passwd_max_life", 10, - "passwd_exp_warn", 11, - "passwd_exp_disable", 12, - "passwd_disable", 13, - "reserved", 14, - "is_shadow", 15, - "", ""); -} -else -{ - @users_prop_array = ( - "key", 0, - "login", 1, - "password", 2, - "uid", 3, - "gid", 4, - "comment", 5, - "home", 6, - "shell", 7, - "", ""); -} - -for ($i = 0; $users_prop_array[$i] ne ""; $i += 2) -{ - $users_prop_map {$users_prop_array[$i]} = $users_prop_array[$i + 1]; - $users_prop_map {$users_prop_array[$i + 1]} = $users_prop_array[$i]; -} - -%groups_prop_map = (); -@groups_prop_array = ( - "key", 0, - "name", 1, - "password", 2, - "gid", 3, - "users", 4, - "", ""); - -for ($i = 0; $groups_prop_array[$i] ne ""; $i += 2) -{ - $groups_prop_map {$groups_prop_array[$i]} = $groups_prop_array[$i + 1]; - $groups_prop_map {$groups_prop_array[$i + 1]} = $groups_prop_array[$i]; -} - -# Please, keep this list sorted -%groups_desc_map = ( - # TRANSLATORS: this is a list of infinitive actions - "adm" => _("Monitor system logs"), - "admin" => _("Administer the system"), - "audio" => _("Use audio devices"), - "cdrom" => _("Use CD-ROM drives"), - "dialout" => _("Use modems"), - "dip" => _("Connect to Internet using a modem"), - "fax" => _("Send and receive faxes"), - "floppy" => _("Use floppy drives"), - "plugdev" => _("Enable access to external storage devices automatically"), - "scanner" => _("Use scanners"), - "tape" => _("Use tape drives"), - "wheel" => _("Be able to get administrator privileges"), -); - -%login_defs_prop_map = (); -%profiles_prop_map = (); - -sub get_login_defs_prop_array -{ - my @prop_array; - my @login_defs_prop_array_default = - ( - "QMAIL_DIR", "qmail_dir", - "MAIL_DIR", "mailbox_dir", - "MAIL_FILE", "mailbox_file", - "PASS_MAX_DAYS", "pwd_maxdays", - "PASS_MIN_DAYS", "pwd_mindays", - "PASS_MIN_LEN", "pwd_min_length", - "PASS_WARN_AGE", "pwd_warndays", - "UID_MIN", "umin", - "UID_MAX", "umax", - "GID_MIN", "gmin", - "GID_MAX", "gmax", - "USERDEL_CMD", "del_user_additional_command", - "CREATE_HOME", "create_home", - "", ""); - - my @login_defs_prop_array_suse = - ( - "QMAIL_DIR", "qmail_dir", - "MAIL_DIR", "mailbox_dir", - "MAIL_FILE", "mailbox_file", - "PASS_MAX_DAYS", "pwd_maxdays", - "PASS_MIN_DAYS", "pwd_mindays", - "PASS_MIN_LEN", "pwd_min_length", - "PASS_WARN_AGE", "pwd_warndays", - "UID_MIN", "umin", - "UID_MAX", "umax", - "SYSTEM_GID_MIN", "gmin", - "GID_MAX", "gmax", - "USERDEL_CMD", "del_user_additional_command", - "CREATE_HOME", "create_home", - "", ""); - - if ($gst_dist =~ /^suse/) - { - @prop_array = @login_defs_prop_array_suse; - } - else - { - @prop_array = @login_defs_prop_array_default; - } - - for ($i = 0; $prop_array [$i] ne ""; $i += 2) - { - $login_defs_prop_map {$prop_array [$i]} = $prop_array [$i + 1]; - $login_defs_prop_map {$prop_array [$i + 1]} = $prop_array [$i]; - } -} - -sub get_profiles_prop_array -{ - my @prop_array; - my @profiles_prop_array_default = - ( - "NAME" , "name", - "COMMENT", "comment", - "LOGINDEFS", "login_defs", - "HOME_PREFFIX", "home_prefix", - "SHELL", "shell", - "GROUP", "group", - "SKEL_DIR", "skel_dir", - "QMAIL_DIR" , "qmail_dir", - "MAIL_DIR" , "mailbox_dir", - "MAIL_FILE" , "mailbox_file", - "PASS_RANDOM", "pwd_random", - "PASS_MAX_DAYS" , "pwd_maxdays", - "PASS_MIN_DAYS" , "pwd_mindays", - "PASS_MIN_LEN" , "pwd_min_length", - "PASS_WARN_AGE" , "pwd_warndays", - "UID_MIN" , "umin", - "UID_MAX" , "umax", - "GID_MIN" , "gmin", - "GID_MAX" , "gmax", - "USERDEL_CMD" , "del_user_additional_command", - "CREATE_HOME" , "create_home", - "", ""); - - my @profiles_prop_array_suse = - ( - "NAME" , "name", - "COMMENT", "comment", - "LOGINDEFS", "login_defs", - "HOME_PREFFIX", "home_prefix", - "SHELL", "shell", - "GROUP", "group", - "SKEL_DIR", "skel_dir", - "QMAIL_DIR" , "qmail_dir", - "MAIL_DIR" , "mailbox_dir", - "MAIL_FILE" , "mailbox_file", - "PASS_RANDOM", "pwd_random", - "PASS_MAX_DAYS" , "pwd_maxdays", - "PASS_MIN_DAYS" , "pwd_mindays", - "PASS_MIN_LEN" , "pwd_min_length", - "PASS_WARN_AGE" , "pwd_warndays", - "UID_MIN" , "umin", - "UID_MAX" , "umax", - "GID_MIN" , "gmin", - "GID_MAX" , "gmax", - "USERDEL_CMD" , "del_user_additional_command", - "CREATE_HOME" , "create_home", - "", ""); - - if ($gst_dist =~ /suse/) - { - @prop_array = @profiles_prop_array_suse; - } - else - { - @prop_array = @profiles_prop_array_default; - } - - for ($i = 0; $prop_array[$i] ne ""; $i += 2) - { - $profiles_prop_map {$prop_array [$i]} = $prop_array [$i + 1]; - $profiles_prop_map {$prop_array [$i + 1]} = $prop_array [$i]; - } -} - -my $rh_logindefs_defaults = { - 'shell' => '/bin/bash', - 'group' => '$user', - 'skel_dir' => '/etc/skel/', -}; - -my $gentoo_logindefs_defaults = { - 'shell' => '/bin/bash', - 'group' => 'users', - 'skel_dir' => '/etc/skel/', -}; - -my $freebsd_logindefs_defaults = { - 'shell' => '/bin/sh', - 'group' => '$user', - 'skel_dir' => '/etc/skel/', -}; - -my $logindefs_dist_map = { - 'redhat-5.2' => $rh_logindefs_defaults, - 'redhat-6.0' => $rh_logindefs_defaults, - 'redhat-6.1' => $rh_logindefs_defaults, - 'redhat-6.2' => $rh_logindefs_defaults, - 'redhat-7.0' => $rh_logindefs_defaults, - 'redhat-7.1' => $rh_logindefs_defaults, - 'redhat-7.2' => $rh_logindefs_defaults, - 'redhat-7.3' => $rh_logindefs_defaults, - 'redhat-8.0' => $rh_logindefs_defaults, - 'redhat-9' => $rh_logindefs_defaults, - 'openna-1.0' => $rh_logindefs_defaults, - 'mandrake-7.1' => $rh_logindefs_defaults, - 'mandrake-7.2' => $rh_logindefs_defaults, - 'mandrake-9.0' => $rh_logindefs_defaults, - 'mandrake-9.1' => $rh_logindefs_defaults, - 'mandrake-9.2' => $rh_logindefs_defaults, - 'mandrake-10.0' => $rh_logindefs_defaults, - 'mandrake-10.1' => $rh_logindefs_defaults, - 'pld-1.0' => $rh_logindefs_defaults, - 'pld-1.1' => $rh_logindefs_defaults, - 'pld-1.99' => $rh_logindefs_defaults, - 'fedora-1' => $rh_logindefs_defaults, - 'fedora-2' => $rh_logindefs_defaults, - 'fedora-3' => $rh_logindefs_defaults, - 'rpath' => $rh_logindefs_defaults, - 'debian-2.2' => $rh_logindefs_defaults, - 'debian-3.0' => $rh_logindefs_defaults, - 'debian-sarge' => $rh_logindefs_defaults, - 'vine-3.0' => $rh_logindefs_defaults, - 'vine-3.1' => $rh_logindefs_defaults, - 'gentoo' => $gentoo_logindefs_defaults, - 'vlos-1.2' => $gentoo_logindefs_defaults, - 'archlinux' => $gentoo_logindefs_defaults, - 'slackware-9.1.0' => $gentoo_logindefs_defaults, - 'slackware-10.0.0' => $gentoo_logindefs_defaults, - 'slackware-10.1.0' => $gentoo_logindefs_defaults, - 'slackware-10.2.0' => $gentoo_logindefs_defaults, - 'freebsd-4' => $freebsd_logindefs_defaults, - 'freebsd-5' => $freebsd_logindefs_defaults, - 'freebsd-6' => $freebsd_logindefs_defaults, - 'suse-7.0' => $gentoo_logindefs_defaults, - 'suse-9.0' => $gentoo_logindefs_defaults, - 'suse-9.1' => $gentoo_logindefs_defaults, - - # FIXME: I don't know about those, so using RH values for now. - 'turbolinux-7.0' => $rh_logindefs_defaults, - 'slackware-8.0.0' => $rh_logindefs_defaults, - 'slackware-8.1' => $rh_logindefs_defaults, - 'slackware-9.0.0' => $rh_logindefs_defaults, -}; - - -# Add reporting table. - -&gst_report_table ({ - 'users_read_profiledb_success' => ['info', 'Profiles read successfully.'], - 'users_read_profiledb_fail' => ['warn', 'Profiles read failed.'], - 'users_read_users_success' => ['info', 'Users read successfully.'], - 'users_read_users_fail' => ['warn', 'Users read failed.'], - 'users_read_groups_success' => ['info', 'Groups read successfully.'], - 'users_read_groups_fail' => ['warn', 'Groups read failed.'], - 'users_read_shells_success' => ['info', 'Shells read successfully.'], - 'users_read_shells_fail' => ['warn', 'Reading shells failed.'], - - 'users_write_profiledb_success' => ['info', 'Profiles written successfully.'], - 'users_write_profiledb_fail' => ['warn', 'Writing profiles failed.'], - 'users_write_users_success' => ['info', 'Users written successfully.'], - 'users_write_users_fail' => ['warn', 'Writing users failed.'], - 'users_write_groups_success' => ['info', 'Groups written successfully.'], - 'users_write_groups_fail' => ['warn', 'Writing groups failed.'], -}); - - -# --- Utility stuff --- # - -sub max -{ - return $_[0] > $_[1]? $_[0]: $_[1]; -} - -sub arr_cmp_recurse -{ - my ($a1, $a2) = @_; - my $i; - - return -1 if ($#$a1 != $#$a2); - - for ($i = 0; $i <= $#$a1; $i++) { - if (ref ($$a1[$i]) eq "ARRAY") { # see if this is a reference. - return -1 if &arr_cmp_recurse ($$a1[$i], $$a2[$i]); # we assume it is a ref to an array. - } elsif ($$a1[$i] ne $$a2[$i]) { - return -1; - } - } - - return 0; -} - -sub get_logindefs -{ - my $profiledb = shift; - return unless $profiledb; - - foreach my $profile (@$profiledb) - { - return $profile if (exists ($profile->{'login_defs'})); - } -} - -# --- Configuration manipulation --- # - -sub read -{ - my (%hash); - - &read_group (\%hash); - &read_passwd_shadow (\%hash); - &read_profiledb (\%hash); - &read_shells (\%hash); - - return \%hash; -} - -sub check_use_md5 -{ - my ($file) = @_; - my ($fh, @line, $i, $use_md5); - - my $fh = &gst_file_open_read_from_names ("/etc/pam.d/$file"); - return 0 if (!$fh); - - $use_md5 = 0; - - while (<$fh>) - { - next if &gst_ignore_line ($_); - chomp; - @line = split /[ \t]+/; - - if ($line[0] eq "\@include") - { - $use_md5 = &check_use_md5 ($line[1]); - } - elsif ($line[0] eq "password") - { - foreach $i (@line) - { - $use_md5 = 1 if ($i eq "md5"); - } - } - } - - close $fh; - return $use_md5; -} - -sub logindefs_add_defaults -{ - # Common for all distros - my $logindefs = { - 'name' => _("Default"), - 'comment' => _("Default profile"), - 'default' => 1, - 'login_defs' => 1, - 'home_prefix' => '/home/$user', - }; - - # Distro specific - my $dist_specific = $logindefs_dist_map->{$gst_dist}; - - # Just to be 100% sure SOMETHING gets filled: - unless ($dist_specific) - { - $dist_specific = $rh_logindefs_defaults; - &gst_debug_print_line ("logindefs_add_defaults: Couldn't find distro specific parameters."); - } - - foreach my $key (keys %$dist_specific) - { - # Make sure there's no crappy entries - if (exists ($profiles_prop_map{$key}) || $key eq "groups") - { - $logindefs->{$key} = $dist_specific->{$key}; - } - } - return $logindefs; -} - -sub read_logindefs -{ - my $profiledb = shift; - my $logindefs = &get_logindefs ($profiledb); - - unless ($logindefs) - { - $logindefs = &logindefs_add_defaults (); - push @$profiledb, $logindefs; - } - - # Get new data in case someone has changed login_defs manually. - my $fh = &gst_file_open_read_from_names (@login_defs_names); - - if ($fh) - { - while (<$fh>) - { - next if &gst_ignore_line ($_); - chomp; - my @line = split /[ \t]+/; - if (exists $login_defs_prop_map{$line[0]}) - { - $logindefs->{$login_defs_prop_map{$line[0]}} = $line[1]; - } - } - - close $fh; - } - else - { - # Put safe defaults for distros/OS that don't have any defaults file - $logindefs->{"umin"} = '1000'; - $logindefs->{"umax"} = '60000'; - $logindefs->{"gmin"} = '1000'; - $logindefs->{"gmax"} = '60000'; - } -} - -sub read_profiledb -{ - my ($hash) = @_; - my $path; - my $profiles = []; - - $$hash{'profiledb'} = $profiles; - - $path = &gst_file_get_data_path () . "/" . $main::tool->{'name'} . "/" . $profile_file; - my $tree = &gst_xml_scan ($path, $tool); - - if ($tree && scalar @$tree) - { - if ($$tree[0] eq 'profiledb') - { - &xml_parse_profiledb ($$tree[1], $hash); - } - else - { - &gst_report ('xml_unexp_tag', $$tree[0]); - } - } - - &read_logindefs ($profiles); - - if (scalar @$profiles) - { - &gst_report ('users_read_profiledb_success'); - } - else - { - &gst_report ('users_read_profiledb_fail'); - } -} - -sub read_passwd_shadow -{ - my ($hash) = @_; - my ($ifh, @users, %users_hash, $passwd_last_modified); - my (@line, $copy, %tmphash); - my $login_pos = $users_prop_map{"login"}; - my $i = 0; - - # Find the passwd file. - - $ifh = &gst_file_open_read_from_names(@passwd_names); - unless ($ifh) - { - &gst_report ('users_read_users_fail'); - return; - } - $passwd_last_modified = (stat ($ifh))[9]; # &get the mtime. - - # Parse the file. - - @users = (); - %users_hash = (); - - while (<$ifh>) - { - chomp; - # FreeBSD allows comments in the passwd file. - next if &gst_ignore_line ($_); - $_ = &gst_xml_quote ($_); - - @line = split ':', $_, -1; - unshift @line, sprintf ("%06d", $i); - $copy = [@line]; - $users_hash{sprintf ("%06d", $i)} = $copy; - $tmphash{$line[$login_pos]} = $copy; - push (@users, $copy); - $i ++; - } - &gst_file_close ($ifh); - - # Find the shadow file. - - $ifh = &gst_file_open_read_from_names(@shadow_names); - if ($ifh) { - my ($login, $passwd); - my $passwd_pos = $users_prop_map{"password"}; - - while (<$ifh>) - { - chomp; - # FreeBSD allows comments in the shadow passwd file. - next if &gst_ignore_line ($_); - $_ = &gst_xml_quote ($_); - - @line = split ':', $_, -1; - push @line, 1; - $login = shift @line; - $passwd = shift @line; - push @{$tmphash{$login}}, @line; - @{$tmphash{$login}}[$passwd_pos] = $passwd; - } - - &gst_file_close ($ifh); - } - - $$hash{"users"} = \@users; - $$hash{"users_hash"} = \%users_hash; - $$hash{"passwd_last_modified"} = $passwd_last_modified; - $$hash{"use_md5"} = &check_use_md5 ("passwd"); - - if (scalar @users) - { - &gst_report ('users_read_users_success'); - } - else - { - &gst_report ('users_read_users_fail'); - } -} - -sub read_group -{ - my ($hash) = @_; - my ($ifh, @groups, %groups_hash, $group_last_modified); - my (@line, $copy, @a); - my $i = 0; - - # Find the file. - - $ifh = &gst_file_open_read_from_names(@group_names); - unless ($ifh) - { - &gst_report ('users_read_groups_fail'); - return; - } - $group_last_modified = (stat ($ifh))[9]; # &get the mtime. - - # Parse the file. - - @groups = (); - %groups_hash = (); - - while (<$ifh>) - { - chomp; - - # FreeBSD allows comments in the group file. */ - next if &gst_ignore_line ($_); - $_ = &gst_xml_unquote ($_); - - @line = split ':', $_, -1; - unshift @line, sprintf ("%06d", $i); - @a = split ',', pop @line; - push @line, [@a]; - $copy = [@line]; - $groups_hash{sprintf ("%06d", $i)} = $copy; - push (@groups, $copy); - $i ++; - } - &gst_file_close ($ifh); - - $$hash{"groups"} = \@groups; - $$hash{"groups_hash"} = \%groups_hash; - $$hash{"group_last_modified"} = $group_last_modified; - - if (scalar @groups) - { - &gst_report ('users_read_groups_success'); - } - else - { - &gst_report ('users_read_groups_fail'); - } -} - -sub read_shells -{ - my ($hash) = @_; - my ($ifh, @shells); - - # Init @shells, I think every *nix has /bin/false. - push (@shells, "/bin/false") if (stat ("/bin/false")); - - $ifh = &gst_file_open_read_from_names(@shell_names); - return unless $ifh; - - while (<$ifh>) - { - next if &gst_ignore_line ($_); - chomp; - push (@shells, $_) if (stat ($_) ne ""); - } - &gst_file_close ($ifh); - - $$hash{"shelldb"} = \@shells; - &gst_report ('users_read_shells_success'); -} - - -sub write_group_passwd -{ - my ($hash) = @_; - my ($users, $users_hash, $groups, $groups_hash); - my ($passwd_last_modified, $group_last_modified); - my ($i, $j, $k); - my (%old_hash); - my (%users_all, $parse_users_hash, $parse_users, $parse_passwd_last_modified); - my (%groups_all, $parse_groups_hash, $parse_groups, $parse_group_last_modified); - - $parse_users = $$hash{"users"}; - $parse_users_hash = $$hash{"users_hash"}; - $parse_passwd_last_modified = $$hash{"passwd_last_modified"}; - $parse_groups = $$hash{"groups"}; - $parse_groups_hash = $$hash{"groups_hash"}; - $parse_group_last_modified = $$hash{"group_last_modified"}; - - &read_passwd_shadow (\%old_hash); - &read_group (\%old_hash); - - $users = $old_hash{"users"}; - $users_hash = $old_hash{"users_hash"}; - $passwd_last_modified = $old_hash{"passwd_last_modified"}; - $groups = $old_hash{"groups"}; - $groups_hash = $old_hash{"groups_hash"}; - $group_last_modified = $old_hash{"group_last_modified"}; - -# if ($passwd_last_modified > $parse_passwd_last_modified) -# { -# print STDERR "Password file may be inconsistent! No changes made.\n"; -# return; -# } - - foreach $i (keys (%$users_hash)) - { - $users_all{$i} |= 1; - } - - foreach $i (keys (%$parse_users_hash)) - { - $users_all{$i} |= 2; - } - - foreach $i (keys (%$groups_hash)) - { - $groups_all{$i} |= 1; - } - - foreach $i (keys (%$parse_groups_hash)) - { - $groups_all{$i} |= 2; - } - - foreach $i (sort (keys (%users_all))) - { - &del_user ($$users_hash{$i}) if ($users_all{$i} == 1); - } - - foreach $i (sort (keys (%groups_all))) - { - &del_group ($$groups_hash{$i}) if ($groups_all{$i} == 1); - } - - foreach $i (sort (keys (%groups_all))) - { - &add_group ($$parse_groups_hash{$i}) if ($groups_all{$i} == 2); - } - - foreach $i (sort (keys (%users_all))) - { - &add_user ($$parse_users_hash{$i}) if ($users_all{$i} == 2); - } - - foreach $i (sort (keys (%groups_all))) - { - if ($groups_all{$i} == 3 && &arr_cmp_recurse ($$groups_hash{$i}, $$parse_groups_hash{$i})) - { - &change_group ($$groups_hash{$i}, $$parse_groups_hash{$i}); - } - } - - foreach $i (sort (keys (%users_all))) - { - if ($users_all{$i} == 3 && &arr_cmp_recurse ($$users_hash{$i}, $$parse_users_hash{$i})) - { - &change_user ($$users_hash{$i}, $$parse_users_hash{$i}); - } - } - - &gst_report ('users_write_users_success'); - &gst_report ('users_write_groups_success'); -} - -sub del_user -{ - my ($data) = @_; - my ($command); - - if ($gst_dist =~ /^freebsd/) { - $command = "$cmd_pw userdel -n \'" . $$data[$users_prop_map{"login"}] . "\' "; - } else { - $command = "$cmd_userdel \'" . $$data[$users_prop_map{"login"}] . "\'"; - } - &gst_file_run ($command); -} - -sub change_user_chfn -{ - my ($old_comment, $comment, $username) = @_; - my ($fname, $office, $office_phone, $home_phone); - my ($command, @line, @old_line); - - return if !$username; - - @line = split /\,/, $comment; - @old_line = split /\,/, $old_comment; - - # Compare old and new data - return if (!&arr_cmp_recurse (\@line, \@old_line)); - - if ($gst_dist =~ /^freebsd/) - { - $command = "$cmd_pw usermod -n " . $username . " -c \'" . $comment . "\'"; - } - else - { - ($fname, $office, $office_phone, $home_phone) = @line; - - $fname = "-f \'" . $fname . "\'"; - $home_phone = "-h \'" . $home_phone . "\'"; - - if ($gst_dist =~ /^debian/ || $gst_dist =~ /^archlinux/) - { - $office = "-r \'" . $office . "\'"; - $office_phone = "-w \'" . $office_phone . "\'"; - } - else - { - $office = "-o \'" . $office . "\'"; - $office_phone = "-p \'" . $office_phone . "\'"; - } - - $command = "$cmd_chfn $fname $office $office_phone $home_phone $username"; - } - - &gst_file_run ($command); -} - -sub add_user -{ - my ($data) = @_; - my ($home_parents, $tool_mkdir); - - $log = $$data[$users_prop_map{"login"}]; - $tool_mkdir = &gst_file_locate_tool ("mkdir"); - - if ($gst_dist =~ /^freebsd/) - { - my $pwdpipe; - my $home; - - # FreeBSD doesn't create the home directory - $home = $$data[$users_prop_map{"home"}]; - &gst_file_run ("$tool_mkdir -p $home"); - - $command = "$cmd_pw useradd " . - " -n \'" . $$data[$users_prop_map{"login"}] . "\'" . - " -u \'" . $$data[$users_prop_map{"uid"}] . "\'" . - " -d \'" . $$data[$users_prop_map{"home"}] . "\'" . - " -g \'" . $$data[$users_prop_map{"gid"}] . "\'" . - " -s \'" . $$data[$users_prop_map{"shell"}] . "\'" . - " -H 0"; # pw(8) reads password from STDIN - - $pwdpipe = &gst_file_run_pipe($command, $GST_FILE_WRITE); - print $pwdpipe $$data[$users_prop_map{"password"}]; - &gst_file_close ($pwdpipe); - } - else - { - $home_parents = $$data[$users_prop_map{"home"}]; - $home_parents =~ s/\/+[^\/]+\/*$//; - &gst_file_run ("$tool_mkdir -p $home_parents"); - - $command = "$cmd_useradd" . " -d \'" . $$data[$users_prop_map{"home"}] . - "\' -g \'" . $$data[$users_prop_map{"gid"}] . - "\' -m -p \'" . $$data[$users_prop_map{"password"}] . - "\' -s \'" . $$data[$users_prop_map{"shell"}] . - "\' -u \'" . $$data[$users_prop_map{"uid"}] . - "\' \'" . $$data[$users_prop_map{"login"}] . "\'"; - &gst_file_run ($command); - } - - &change_user_chfn (undef, $$data[$users_prop_map{"comment"}], $$data[$users_prop_map{"login"}]); -} - -sub change_user -{ - my ($old_data, $new_data) = @_; - - if ($gst_dist =~ /^freebsd/) - { - my $pwdpipe; - - $command = "$cmd_pw usermod \'" . $$old_data[$users_prop_map{"login"}] . "\'" . - " -l \'" . $$new_data[$users_prop_map{"login"}] . "\'" . - " -u \'" . $$new_data[$users_prop_map{"uid"}] . "\'" . - " -d \'" . $$new_data[$users_prop_map{"home"}] . "\'" . - " -g \'" . $$new_data[$users_prop_map{"gid"}] . "\'" . - " -s \'" . $$new_data[$users_prop_map{"shell"}] . "\'" . - " -H 0"; # pw(8) reads password from STDIN - - $pwdpipe = &gst_file_run_pipe($command, $GST_FILE_WRITE); - print $pwdpipe $$data[$users_prop_map{"password"}]; - &gst_file_close ($pwdpipe); - } - else - { - $command = "$cmd_usermod" . " -d \'" . $$new_data[$users_prop_map{"home"}] . - "\' -g \'" . $$new_data[$users_prop_map{"gid"}] . - "\' -l \'" . $$new_data[$users_prop_map{"login"}] . - "\' -p \'" . $$new_data[$users_prop_map{"password"}] . - "\' -s \'" . $$new_data[$users_prop_map{"shell"}] . - "\' -u \'" . $$new_data[$users_prop_map{"uid"}] . - "\' \'" . $$old_data[$users_prop_map{"login"}] . "\'"; - &gst_file_run ($command); - } - - &change_user_chfn ($$old_data[$users_prop_map{"comment"}], - $$new_data[$users_prop_map{"comment"}], - $$new_data[$users_prop_map{"login"}]); -} - -sub del_group -{ - my ($data) = @_; - - if ($gst_dist =~ /^freebsd/) - { - $command = "$cmd_pw groupdel -n \'" . $$data[$groups_prop_map{"name"}] . "\'"; - } - else - { - $command = "$cmd_groupdel \'" . $$data[$groups_prop_map{"name"}] . "\'"; - } - &gst_file_run ($command); -} - -sub add_group -{ - my ($data) = @_; - my ($u, $user, $users); - - $u = [ @{$$data[$groups_prop_map{"users"}]} ]; sort @$u; - - if ($gst_dist =~ /^freebsd/) - { - $users = join (",", @$u); - - $command = "$cmd_pw groupadd -n \'" . $$data[$groups_prop_map{"name"}] . - "\' -g \'" . $$data[$groups_prop_map{"gid"}] . - "\' -M \'" . $users . "\'"; - &gst_file_run ($command); - } - else - { - $command = "$cmd_groupadd -g \'" . $$data[$groups_prop_map{"gid"}] . - "\' " . $$data[$groups_prop_map{"name"}]; - &gst_file_run ($command); - - foreach $user (@$u) - { - $command = "$cmd_gpasswd -a \'" . $user . - "\' " . $$data[$groups_prop_map{"name"}]; - &gst_file_run ($command); - } - } -} - -sub change_group -{ - my ($old_data, $new_data) = @_; - my ($n, $o, $users, $i, $j, $max_n, $max_o, $r, @tmp); # for iterations - - if ($gst_dist =~ /^freebsd/) - { - $n = [ @{$$new_data[$groups_prop_map{"users"}]} ]; sort @$n; - $users = join (",", @$n); - - $command = "$cmd_pw groupmod -n \'" . $$old_data[$groups_prop_map{"name"}] . - "\' -g \'" . $$new_data[$groups_prop_map{"gid"}] . - "\' -l \'" . $$new_data[$groups_prop_map{"name"}] . - "\' -M \'" . $users . "\'"; - - &gst_file_run ($command); - } - else - { - $command = "$cmd_groupmod -g \'" . $$new_data[$groups_prop_map{"gid"}] . - "\' -n \'" . $$new_data[$groups_prop_map{"name"}] . "\' " . - "\'" . $$old_data[$groups_prop_map{"name"}] . "\'"; - - &gst_file_run ($command); - - # Let's see if the users that compose the group have changed. - if (&arr_cmp_recurse ($$new_data[$groups_prop_map{"users"}], - $$old_data[$groups_prop_map{"users"}])) { - - $n = [ @{$$new_data[$groups_prop_map{"users"}]} ]; sort @$n; - $o = [ @{$$old_data[$groups_prop_map{"users"}]} ]; sort @$o; - - $max_n = $#$n; - $max_o = $#$o; - for ($i = 0, $j = 0; $i <= &max ($max_n, $max_o); ) { - $r = $$n[$i] cmp $$o[$j]; - $r *= -1 if (($$o[$j] eq "") || ($$n[$i] eq "")); - - if ($r < 0) { # add this user to the group. - $command = "$cmd_gpasswd -a \'" . $$n[$i] . "\' \'" . - $$new_data[$groups_prop_map{"name"}] . "\'"; - $i ++; - - &gst_file_run ($command); - } elsif ($r > 0) { # delete the user from the group. - $command = "$cmd_gpasswd -d \'" . $$o[$j] . "\' \'" . - $$new_data[$groups_prop_map{"name"}] . "\'"; - $j ++; - - &gst_file_run ($command); - } else { # The information is the same. Go to next tuple. - $i ++; $j ++; - } - } - } - } -} - - -sub write_logindefs -{ - my ($login_defs) = @_; - my ($key); - my $file; - - return unless $login_defs; - - foreach $key (@login_defs_names) - { - if (-e $key) - { - &gst_debug_print_line ("write_logindefs:$key"); - $file = $key; - last; - } - } - - unless ($file) - { - &gst_report ("file_open_read_failed", join (", ", @login_defs_names)); - return; - } - - foreach $key (keys (%$login_defs)) - { - # Write ONLY login.defs values. - if (exists ($login_defs_prop_map{$key})) - { - &gst_replace_split ($file, $login_defs_prop_map{$key}, "[ \t]+", $$login_defs{$key}); - } - } -} - - -sub write_profiledb -{ - my ($hash) = @_; - my $profiledb = $hash->{'profiledb'}; - - unless ($profiledb) - { - &gst_report ('users_write_profiledb_fail'); - return; - } - - # Update login.defs file. - &write_logindefs (&get_logindefs ($profiledb)); - - # Write our profiles. - my $path = &gst_file_get_data_path () . "/" . $main::tool->{'name'} . "/" . $profile_file; - my $fh = &gst_file_open_write_from_names ($path); - if ($fh) - { - local *STDOUT = $fh; - &xml_print_profiledb ($hash); - close ($fh); - &gst_report ('users_write_profiledb_success'); - } - else - { - &gst_report ('users_write_profiledb_fail'); - } -} - - -# --- XML parsing --- # - -# Scan XML from standard input to an internal tree. - -sub xml_parse -{ - my ($tool) = @_; - my ($tree, %hash); - - # Scan XML to tree. - - $tree = &gst_xml_scan (undef, $tool); - - $hash{"users"} = []; - $hash{"users_hash"} = {}; - $hash{"groups"} = []; - $hash{"groups_hash"} = {}; - $hash{"profiledb"} = []; - - # Walk the tree recursively and extract configuration parameters. - # This is the top level - find and enter the "users" tag. - - while (@$tree) - { - if ($$tree[0] eq "users") { &xml_parse_users($$tree[1], \%hash); } - - shift @$tree; - shift @$tree; - } - - return (\%hash); -} - -sub xml_parse_users -{ - my ($tree, $hash) = @_; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "logindefs") { &xml_parse_login_defs ($$tree[1], $hash); } - elsif ($$tree[0] eq "passwd_last_modified") { &xml_parse_passwd_last_modified ($$tree[1], $hash); } - elsif ($$tree[0] eq "group_last_modified") { &xml_parse_group_last_modified ($$tree[1], $hash); } - elsif ($$tree[0] eq "userdb") { &xml_parse_userdb ($$tree[1], $hash); } - elsif ($$tree[0] eq "groupdb") { &xml_parse_groupdb ($$tree[1], $hash); } - elsif ($$tree[0] eq "shelldb") { } - elsif ($$tree[0] eq "profiledb") { &xml_parse_profiledb ($$tree[1], $hash); } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } -} - -sub xml_parse_passwd_last_modified -{ - my ($tree, $hash) = @_; - - shift @$tree; # Skip attributes. - - &gst_report ("xml_unexp_arg", "", "passwd_last_modified") if ($$tree[0] ne "0"); - $$hash{"passwd_last_modified"} = $$tree[1]; -} - -sub xml_parse_group_last_modified -{ - my ($tree, $hash) = @_; - - shift @$tree; # Skip attributes. - - &gst_report ("xml_unexp_arg", "", "group_last_modified") if ($$tree[0] ne "0"); - $$hash{"group_last_modified"} = $$tree[1]; -} - -sub xml_parse_userdb -{ - my ($tree, $hash) = @_; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "user") { &xml_parse_user ($$tree[1], $hash); } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } -} - -sub xml_parse_user -{ - my ($tree, $hash) = @_; - my ($users, $users_hash); - my @line = (); - - $users = $$hash{"users"}; - $users_hash = $$hash{"users_hash"}; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($users_prop_map{$$tree[0]} ne undef) - { - $line[$users_prop_map{$$tree[0]}] = &gst_xml_unquote($$tree[1][2]); - } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } - - $$users_hash{sprintf ("%06d", $line[0])} = [@line]; - push (@$users, [@line]); -} - -sub xml_parse_groupdb -{ - my ($tree, $hash) = @_; - my $tree = $_[0]; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "group") { &xml_parse_group ($$tree[1], $hash); } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } -} - -sub xml_parse_group -{ - my ($tree, $hash) = @_; - my (@line, $copy, $a, @u); - my ($groups, $users_hash); - - $groups = $$hash{"groups"}; - $groups_hash = $$hash{"groups_hash"}; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($groups_prop_map{$$tree[0]} ne undef) - { - if ($$tree[0] eq "users") { $line[$groups_prop_map{$$tree[0]}] = $$tree[1]; } - else { $line[$groups_prop_map{$$tree[0]}] = $$tree[1][2]; } - } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } - - # @$a should be a parse tree of the array of users. - $a = pop @line; - shift @$a; - while (@$a) { - if ($$a[0] eq "user") { - push @u, $$a[1][2]; - } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - shift @$a; - shift @$a; - } - - push @line, [@u]; - $copy = [@line]; - $$groups_hash{sprintf ("%06d", $line[0])} = $copy; - push (@$groups, $copy); -} - -sub xml_parse_profile_groups -{ - my ($tree) = @_; - my ($arr); - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "group") - { - push @$arr, $$tree[1][2]; - } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } - - return $arr; -} - -sub xml_parse_profile -{ - my ($tree, $hash) = @_; - my (%profile); - - shift @$tree; # Skip attributes. - - while (@$tree) - { - # The "default" tag is not in the map, but we need to parse it - if ($profiles_prop_map{$$tree[0]} || $$tree[0] eq "default") - { - $profile{$$tree[0]} = $$tree[1][2]; - } - elsif ($$tree[0] eq "groups") - { - $profile{$$tree[0]} = &xml_parse_profile_groups ($$tree[1]); - } - elsif ($$tree[0] ne "files") # files tag is ignored for parsing. # FIXME! - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } - - push @{$hash->{'profiledb'}}, \%profile; -} - -sub xml_parse_profiledb -{ - my ($tree, $hash) = @_; - - shift @$tree; # Skip attributes. - - while (@$tree) - { - if ($$tree[0] eq "profile") { &xml_parse_profile ($$tree[1], $hash); } - else - { - &gst_report ("xml_unexp_tag", $$tree[0]); - } - - shift @$tree; - shift @$tree; - } -} - - -# --- XML printing --- # - -sub xml_print_profiledb -{ - my ($hash) = @_; - - my $profiledb = $$hash{"profiledb"}; - - return unless scalar @$profiledb; - - &gst_xml_container_enter ('profiledb'); - - foreach my $profile (@$profiledb) - { - my $key; - &gst_xml_container_enter ('profile'); - foreach $key (keys %$profile) - { - if ($key eq "groups") - { - &gst_xml_container_enter ('groups'); - &gst_xml_print_array ($profile->{$key}, "group"); - &gst_xml_container_leave ('groups'); - } - else - { - &gst_xml_print_pcdata ($key, $profile->{$key}); - } - } - &gst_xml_container_leave (); - } - - &gst_xml_container_leave (); - &gst_xml_print_vspace (); -} - -sub xml_print_shells -{ - my ($hash) = @_; - my ($i, $shells); - - $shells = $$hash{"shelldb"}; - return unless scalar @$shells; - - &gst_xml_container_enter ('shelldb'); - - foreach $i (@$shells) { - &gst_xml_print_pcdata ('shell', $i); - } - - &gst_xml_container_leave (); - &gst_xml_print_vspace (); -} - -sub xml_print -{ - my ($hash) = @_; - my ($key, $value, $i, $j, $k); - my ($passwd_last_modified, $users, $desc); - - $passwd_last_modified = $$hash{"passwd_last_modified"}; - $users = $$hash{"users"}; - $group_last_modified = $$hash{"group_last_modified"}; - $groups = $$hash{"groups"}; - - &gst_xml_print_begin (); - - &gst_xml_print_pcdata ("use_md5", $$hash{"use_md5"}); - - &gst_xml_print_vspace (); - &gst_xml_print_comment ('Profiles configuration starts here'); - &gst_xml_print_vspace (); - - &xml_print_profiledb ($hash); - &xml_print_shells ($hash); - - &gst_xml_print_comment ('Now the users'); - &gst_xml_print_vspace (); - - &gst_xml_print_comment ('When was the passwd file last modified (since the epoch)?'); - &gst_xml_print_vspace (); - &gst_xml_print_pcdata ('passwd_last_modified', $passwd_last_modified); - &gst_xml_print_vspace (); - - &gst_xml_container_enter ('userdb'); - foreach $i (@$users) - { - &gst_xml_print_vspace (); - &gst_xml_container_enter ('user'); - for ($j = 0; $j < ($#users_prop_array - 1) / 2; $j++) - { - &gst_xml_print_pcdata ($users_prop_map{$j}, $$i[$j]); - } - &gst_xml_container_leave (); - } - &gst_xml_container_leave (); - &gst_xml_print_vspace (); - - &gst_xml_print_comment ('Now the groups'); - &gst_xml_print_vspace (); - - &gst_xml_print_comment ('When was the group file last modified (since the epoch)?'); - &gst_xml_print_vspace (); - &gst_xml_print_pcdata ('group_last_modified', $group_last_modified); - &gst_xml_print_vspace (); - - &gst_xml_container_enter ('groupdb'); - foreach $i (@$groups) - { - &gst_xml_print_vspace (); - &gst_xml_container_enter ('group'); - for ($j = 0; $j < ($#groups_prop_array - 1) / 2 - 1; $j++) - { - &gst_xml_print_pcdata ($groups_prop_map{$j}, $$i[$j]); - } - - # Add the description based on the group name - $desc = $groups_desc_map{$$i[1]}; - &gst_xml_print_pcdata ("allows_to", $desc) if ($desc ne undef); - - &gst_xml_container_enter ('users'); - $k = $$i[$groups_prop_map{"users"}]; - foreach $j (@$k) - { - &gst_xml_print_pcdata ('user', $j); - } - &gst_xml_container_leave (); - - &gst_xml_container_leave (); - } - &gst_xml_container_leave (); - &gst_xml_print_vspace (); - - &gst_xml_print_end (); -} - - -# --- Get (read) config --- # - -sub get -{ - my ($tool) = @_; - my ($hash); - - $hash = &read (); - &gst_report_end (); - &xml_print ($hash); -} - -sub set -{ - my ($tool) = @_; - my ($hash); - - $hash = &xml_parse ($tool); - - if ($hash) - { - # Make backup manually, otherwise they don't get backed up. - &gst_file_backup ($_) foreach (@passwd_names); - &gst_file_backup ($_) foreach (@shadow_names); - &gst_file_backup ($_) foreach (@group_names); - - &write_profiledb ($hash); - &write_group_passwd ($hash); - } - - &gst_report_end (); -} - - -# --- Filter config: XML in, XML out --- # - - -sub filter -{ - my ($tool) = @_; - my ($hash); - - $hash = &xml_parse ($tool); - &gst_report_end (); - &xml_print ($hash); -} - - -# --- Main --- # - -# get, set and filter are special cases that don't need more parameters than a ref to their function. -# Read general.pl.in:gst_run_directive to know about the format of this hash. - -$directives = { - "get" => [ \&get, [], "" ], - "set" => [ \&set, [], "" ], - "filter" => [ \&filter, [], "" ] - }; - -$tool = &gst_init ($name, $version, $description, $directives, @ARGV); -&gst_platform_ensure_supported ($tool, @platforms); - -&get_login_defs_prop_array (); -&get_profiles_prop_array (); - -&gst_run ($tool); diff --git a/x.pl.in b/x.pl.in deleted file mode 100644 index c5124cc..0000000 --- a/x.pl.in +++ /dev/null @@ -1,2209 +0,0 @@ -#!/usr/bin/env perl -#-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- -# -# Common functions for XF86Config file. -# -# Copyright (C) 2000-2001 Ximian, Inc. -# -# Authors: Tambet Ingo <tambet@ximian.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Library General Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - -$SCRIPTSDIR = "@scriptsdir@"; -if ($SCRIPTSDIR =~ /^@scriptsdir[@]/) -{ - $SCRIPTSDIR = "."; - $DOTIN = ".in"; -} - -require "$SCRIPTSDIR/general.pl$DOTIN"; -require "$SCRIPTSDIR/file.pl$DOTIN"; -require "$SCRIPTSDIR/xml.pl$DOTIN"; - -use Text::ParseWords; -use File::Copy; -use IO::File; -use POSIX qw(tmpnam); -use strict; - -my $x_version; - -# Data type declarations. -# Keys that *must* be present: -# 'parse', 'xml_parse', 'xml_print', 'update' , 'delete' 'add' - -my $x_unique_string = { - 'parse' => \&x_parse_unique_string, - 'xml_parse' => \&x_xml_parse_unique, - 'xml_print' => \&x_xml_print_unique, - 'update' => \&x_update_unique_string, - 'delete' => \&x_del_unique_string, - 'add' => \&x_add_unique_string, -}; - -my $x_unique_int = { - 'parse' => \&x_parse_unique_int, - 'xml_parse' => \&x_xml_parse_unique, - 'xml_print' => \&x_xml_print_unique, - 'update' => \&x_update_unique_int, - 'delete' => \&x_del_unique_int, - 'add' => \&x_add_unique_int, -}; - -my $x_list_string = { - 'parse' => \&x_parse_list_string, - 'xml_parse' => \&x_xml_parse_list, - 'xml_print' => \&x_xml_print_list, - 'update' => \&x_update_list_string, - 'delete' => \&x_del_list_string, - 'add' => \&x_add_list_string, -}; - -my $x_list_int = { - 'parse' => \&x_parse_list_int, - 'xml_parse' => \&x_xml_parse_list, - 'xml_print' => \&x_xml_print_list, - 'update' => \&x_update_list_int, - 'delete' => \&x_del_list_int, - 'add' => \&x_add_list_int, -}; - -my $x_serverlayout_screen = { - 'parse' => \&x_parse_serverlayout_screen, - 'xml_parse' => \&x_xml_parse_serverlayout_screen, - 'xml_print' => \&x_xml_print_serverlayout_screen, - 'update' => \&x_update_serverlayout_screen, - 'delete' => \&x_del_serverlayout_screen, - 'add' => \&x_add_serverlayout_screen, -}; - -my $x_modeline = { - 'parse' => \&x_parse_modeline, - 'xml_parse' => \&x_xml_parse_modeline, - 'xml_print' => \&x_xml_print_modeline, - 'update' => \&x_update_modeline, - 'delete' => \&x_del_modeline, - 'add' => \&x_add_modeline, -}; - -my $x_range_hz = { - 'parse' => \&x_parse_range_hz, - 'xml_parse' => \&x_xml_parse_range_hz, - 'xml_print' => \&x_xml_print_range_hz, - 'update' => \&x_update_range_hz, - 'delete' => \&x_del_range_hz, - 'add' => \&x_add_range_hz, -}; - -# XFree86 version 4 sections: -# Files -# ServerFlags -# Module -# InputDevice -# Device -# VideoAdaptor -# Monitor -# Modes -# Screen -# ServerLayout -# DRI -# Vendor - -my $x4_sections = { - Monitor => { - KEY => 'Identifier', - keywords => { - Identifier => $x_unique_string, - VendorName => $x_unique_string, - ModelName => $x_unique_string, - HorizSync => $x_range_hz, - VertRefresh => $x_range_hz, - ModeLine => $x_modeline, - Gamma => $x_list_int, - }, - options => {}, - }, - Device => { - KEY => 'Identifier', - keywords => { - Identifier => $x_unique_string, - Driver => $x_unique_string, - }, - options => {}, - }, - Screen => { - KEY => 'Identifier', - keywords => { - Identifier => $x_unique_string, - Device => $x_unique_string, - Monitor => $x_unique_string, - DefaultDepth => $x_unique_int, - }, - options => {}, - Display => { - KEY => 'Depth', - keywords => { - Depth => $x_unique_int, - Modes => $x_list_string, - Virtual => $x_list_int, - } - } - }, - ServerLayout => { - KEY => 'Identifier', - keywords => { - Identifier => $x_unique_string, - Screen => $x_serverlayout_screen, - }, - options => {}, - } -}; - -# XFree86 version 3 sections: -# Files -# Module -# ServerFlags -# Keyboard -# Pointer -# Monitor -# Device -# Screen -# XInput - -my $x3_sections = { - Monitor => { - KEY => 'Identifier', - keywords => { - Identifier => $x_unique_string, - VendorName => $x_unique_string, - ModelName => $x_unique_string, - HorizSync => $x_range_hz, - VertRefresh => $x_range_hz, - ModeLine => $x_modeline, - }, - options => {}, - }, - Device => { - KEY => 'Identifier', - keywords => { - Identifier => $x_unique_string, - }, - options => {}, - }, - Screen => { - KEY => 'Driver', - keywords => { - Driver => $x_unique_string, - Device => $x_unique_string, - Monitor => $x_unique_string, - DefaultColorDepth => $x_unique_int, - }, - options => {}, - Display => { - KEY => 'Depth', - keywords => { - Depth => $x_unique_int, - Modes => $x_list_string, - Virtual => $x_list_int, - } - } - }, -}; - -my @x_colordepths = (8, 15, 16, 24); -my $x_probe_file = "probe.xml"; - -# Standard modelines (VESA plus couple extras) - -my $standard_modes = q ( - -# 640x350 @ 85Hz (VESA) hsync: 37.9kHz -ModeLine "640x350@85" 31.5 640 672 736 832 350 382 385 445 +hsync -vsync - -# 640x400 @ 85Hz (VESA) hsync: 37.9kHz -ModeLine "640x400@85" 31.5 640 672 736 832 400 401 404 445 -hsync +vsync - -# 720x400 @ 85Hz (VESA) hsync: 37.9kHz -ModeLine "720x400@85" 35.5 720 756 828 936 400 401 404 446 -hsync +vsync - -# 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz -ModeLine "640x480@60" 25.2 640 656 752 800 480 490 492 525 -hsync -vsync - -# 640x480 @ 72Hz (VESA) hsync: 37.9kHz -ModeLine "640x480@72" 31.5 640 664 704 832 480 489 491 520 -hsync -vsync - -# 640x480 @ 75Hz (VESA) hsync: 37.5kHz -ModeLine "640x480@75" 31.5 640 656 720 840 480 481 484 500 -hsync -vsync - -# 640x480 @ 85Hz (VESA) hsync: 43.3kHz -ModeLine "640x480@85" 36.0 640 696 752 832 480 481 484 509 -hsync -vsync - -# 800x600 @ 56Hz (VESA) hsync: 35.2kHz -ModeLine "800x600@56" 36.0 800 824 896 1024 600 601 603 625 +hsync +vsync - -# 800x600 @ 60Hz (VESA) hsync: 37.9kHz -ModeLine "800x600@60" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync - -# 800x600 @ 72Hz (VESA) hsync: 48.1kHz -ModeLine "800x600@72" 50.0 800 856 976 1040 600 637 643 666 +hsync +vsync - -# 800x600 @ 75Hz (VESA) hsync: 46.9kHz -ModeLine "800x600@75" 49.5 800 816 896 1056 600 601 604 625 +hsync +vsync - -# 800x600 @ 85Hz (VESA) hsync: 53.7kHz -ModeLine "800x600@85" 56.3 800 832 896 1048 600 601 604 631 +hsync +vsync - -# 1024x768i @ 43Hz (industry standard) hsync: 35.5kHz -ModeLine "1024x768@43" 44.9 1024 1032 1208 1264 768 768 776 817 +hsync +vsync Interlace - -# 1024x768 @ 60Hz (VESA) hsync: 48.4kHz -ModeLine "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -hsync -vsync - -# 1024x768 @ 70Hz (VESA) hsync: 56.5kHz -ModeLine "1024x768@70" 75.0 1024 1048 1184 1328 768 771 777 806 -hsync -vsync - -# 1024x768 @ 75Hz (VESA) hsync: 60.0kHz -ModeLine "1024x768@75" 78.8 1024 1040 1136 1312 768 769 772 800 +hsync +vsync - -# 1024x768 @ 85Hz (VESA) hsync: 68.7kHz -ModeLine "1024x768@85" 94.5 1024 1072 1168 1376 768 769 772 808 +hsync +vsync - -# 1152x864 @ 75Hz (VESA) hsync: 67.5kHz -ModeLine "1152x864@75" 108.0 1152 1216 1344 1600 864 865 868 900 +hsync +vsync - -# 1280x960 @ 60Hz (VESA) hsync: 60.0kHz -ModeLine "1280x960@60" 108.0 1280 1376 1488 1800 960 961 964 1000 +hsync +vsync - -# 1280x960 @ 85Hz (VESA) hsync: 85.9kHz -ModeLine "1280x960@85" 148.5 1280 1344 1504 1728 960 961 964 1011 +hsync +vsync - -# 1280x1024 @ 60Hz (VESA) hsync: 64.0kHz -ModeLine "1280x1024@60" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync - -# 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz -ModeLine "1280x1024@75" 135.0 1280 1296 1440 1688 1024 1025 1028 1066 +hsync +vsync - -# 1280x1024 @ 85Hz (VESA) hsync: 91.1kHz -ModeLine "1280x1024@85" 157.5 1280 1344 1504 1728 1024 1025 1028 1072 +hsync +vsync - -# 1400x1050 @ 60Hz (VESA GFT) hsync: 65.5kHz -ModeLine "1400x1050@60" 122.0 1400 1488 1640 1880 1050 1052 1064 1082 +hsync +vsync - -# 1400x1050 @ 75Hz (VESA GFT) hsync: 82.2kHz -ModeLine "1400x1050@75" 155.8 1400 1464 1784 1912 1050 1052 1064 1090 +hsync +vsync - -# 1600x1200 @ 60Hz (VESA) hsync: 75.0kHz -ModeLine "1600x1200@60" 162.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync - -# 1600x1200 @ 65Hz (VESA) hsync: 81.3kHz -ModeLine "1600x1200@65" 175.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync - -# 1600x1200 @ 70Hz (VESA) hsync: 87.5kHz -ModeLine "1600x1200@70" 189.0 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync - -# 1600x1200 @ 75Hz (VESA) hsync: 93.8kHz -ModeLine "1600x1200@75" 202.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync - -# 1600x1200 @ 85Hz (VESA) hsync: 106.3kHz -ModeLine "1600x1200@85" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +hsync +vsync - -# 1792x1344 @ 60Hz (VESA) hsync: 83.6kHz -ModeLine "1792x1344@60" 204.8 1792 1920 2120 2448 1344 1345 1348 1394 -hsync +vsync - -# 1792x1344 @ 75Hz (VESA) hsync: 106.3kHz -ModeLine "1792x1344@75" 261.0 1792 1888 2104 2456 1344 1345 1348 1417 -hsync +vsync - -# 1856x1392 @ 60Hz (VESA) hsync: 86.3kHz -ModeLine "1856x1392@60" 218.3 1856 1952 2176 2528 1392 1393 1396 1439 -hsync +vsync - -# 1856x1392 @ 75Hz (VESA) hsync: 112.5kHz -ModeLine "1856x1392@75" 288.0 1856 1984 2208 2560 1392 1393 1396 1500 -hsync +vsync - -# 1920x1440 @ 60Hz (VESA) hsync: 90.0kHz -ModeLine "1920x1440@60" 234.0 1920 2048 2256 2600 1440 1441 1444 1500 -hsync +vsync - -# 1920x1440 @ 75Hz (VESA) hsync: 112.5kHz -ModeLine "1920x1440@75" 297.0 1920 2064 2288 2640 1440 1441 1444 1500 -hsync +vsync - - ); -BEGIN { - &gst_report_table ({ - 'x_version' => ['info', _('Detected X version [%s].')], - 'x_parse' => ['info', _('Configuration file [%s] successfully parsed.')], - 'x_parse_error' => ['error', _('Error parsing keyword [%s].')], - 'x_probe_needed' => ['info', _('Going to probe your X server, hold on.')], - 'x_probe_error' => ['error', _('Error occured on X server probe on colordepth [%s].')], - 'x_general_warn' => ['warn', _('Internal error: [%s].')], - } - ); -} - -sub x_version -{ - return $x_version if $x_version; # Cache - - my ($command, $number, $driver); - my @paths = qw (/etc/X11/X /usr/X11R6/bin/XFree86 /usr/X11R6/bin/X); - - foreach my $tmp (@paths) { - if (-x $tmp) { - $command = $tmp; - last; - } - } - - unless ($command) { - # TODO: add report; - &gst_debug_print_line ("Couldn't find X binary."); - return; - } - - open (FD, "$command -version 2>&1 |"); - while (<FD>) { - if (/^XFree86 Version (\d+)\.(\d+)\.(\d+)/) { - $number = $1 . $2 . $3; - } - elsif ($number > 0 && $number < 400 && /^[ \t]*(\w+): (accelerated)?[ ]*server/) { - $driver = $1; - $driver = 'Accel' if $2; - last; - } - } - close (FD); - - &gst_report ('x_version', $number); - - $x_version->{'command'} = $command; - $x_version->{'sections'} = ($number >= 400) ? $x4_sections : $x3_sections; - $x_version->{'number'} = $number; - $x_version->{'driver'} = $driver if $driver; - - return $x_version; -} - -# Difference from gst_item_is_in_list is that XF86Config keywords are -# case-insensitive and "_" characters are ignored. -# Returns found value from list or 0. -sub x_keyword_in_list -{ - my $keyword = shift @_; - - $keyword =~ s/\_//g; # We don't care about underscores (_) - - foreach my $item (@_) { - my $pattern = $item; - $pattern =~ s/(\W)/\\$1/g; - return $item if ($keyword =~ /^$pattern$/i); - } - - return; -} - -sub x_option_in_list -{ - my $keyword = shift @_; - - $keyword =~ s/\"//g; # We don't care about quotes (") - $keyword =~ s/^No//i; # and it could start with optional "No" - - foreach my $item (@_) { - my $pattern = $item; - $pattern =~ s/(\W)/\\$1/g; - return 1 if ($keyword =~ /^$pattern$/i); - } - - return; -} - -# parse_option -# Parses "Option" line form XF86Config. -# Arguments: -# $line - ref to array containing the actual line split by \s. -# Returns hash with one key (Option) containing hash with option -# name as key and option value as val. -sub parse_option_old -{ - my $line = shift; - my ($name, $value); - my ($val, $bool); - - shift @$line; # Remove "Option" - - $name = shift @$line; - $value = shift @$line; - - $name =~ s/\"//g; - $value =~ s/\"//g; - - if ($value =~ /^(1|on|true|yes)$/i) { - $val = 1; - $bool = 1; - } elsif ($value =~ /^(0|off|false|no)$/i) { - $val = 0; - $bool = 1; - } else { - $val = $value; - } - - if ($bool) { - $val = !$val if ($name =~ s/^No//i); - - $val = 'true' if $val; - $val = 'false' if not $val; - } - - bless [ $name, $val ], "GstXOption"; -} - -# ------------------------------------------------------ -# Data type functions -# ------------------------------------------------------ - -# Unique string data type. -sub x_parse_unique_string -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - - # Format example: 'Identifier "name"' - - my $val = &x_get_token ($buf); - goto ERROR unless defined ($val); - goto ERROR unless $val =~ /^\".*\"$/; - - $val =~ s/\"//g; - &gst_debug_print_line ("x_parse_unique_string: warning: '$kw' is unique but" . - "already has value '$config->{$kw}'.") - if exists ($config->{$kw}); - - $config->{$kw} = $val; - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_unique_string: error parsing $kw"); -} - -sub x_xml_parse_unique -{ - my $hash = shift; - my $kw = shift; - - $hash->{$kw} = &gst_xml_get_text (shift @_); -} - -sub x_xml_print_unique -{ - my ($key, $val) = @_; - &gst_xml_print_pcdata ($key, $val); -} - -sub x_update_unique_string -{ - my ($buf, $ptr, $old_val, $new_val) = @_; - my $token = &x_update_get_token ($buf, $ptr); - return if ($old_val eq $new_val); - - $old_val = "\"" . $old_val . "\"" if $old_val; - $new_val = "\"" . $new_val . "\"" if $new_val; - - &x_update_token ($buf, $ptr, $old_val, $new_val); -} - -sub x_del_unique_string -{ - my ($buf, $ptr, $kw, $old_val) = @_; - &x_update_token ($buf, $ptr, $kw); - &x_update_unique_string ($buf, $ptr, $old_val); -} - -sub x_add_unique_string -{ - my ($buf, $ptr, $kw, $new_val) = @_; - - $new_val = "" unless defined ($new_val); - &x_update_add_token ($buf, $ptr, $kw) if $kw; - $new_val = "\"" . $new_val . "\""; - &x_update_add_token ($buf, $ptr, $new_val, 1); -} - -# Unique int data type. -sub x_parse_unique_int -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - - # Format example: 'Depth depth' - - my $val = &x_get_token ($buf); - goto ERROR unless defined ($val); - goto ERROR unless $val =~ /^[0-9]+$/; - - &gst_debug_print_line ("x_parse_unique_string: warning: '$kw' is unique but" . - "already has value '$config->{$kw}'.") - if exists ($config->{$kw}); - - $config->{$kw} = $val; - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_unique_int: error parsing $kw"); -} - -sub x_update_unique_int -{ - my ($buf, $ptr, $old_val, $new_val) = @_; - my $token = &x_update_get_token ($buf, $ptr); - - if ($old_val != $new_val) { - &x_update_token ($buf, $ptr, $old_val, $new_val); - } -} - -sub x_del_unique_int -{ - my ($buf, $ptr, $kw, $old_val) = @_; - &x_update_token ($buf, $ptr, $kw); - &x_update_unique_int ($buf, $ptr, $old_val); -} - -sub x_add_unique_int -{ - my ($buf, $ptr, $kw, $new_val) = @_; - - &x_update_add_token ($buf, $ptr, $kw) if $kw; - &x_update_add_token ($buf, $ptr, $new_val, 1); -} - -# String list data type. -sub x_parse_list_string -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - - # Format example: 'Modes "mode-name" ...' - - my @list; - while (my $token = &x_peek_token ($buf)) { - if ($token =~ /^\".*\"$/) { - $token = &x_get_token ($buf); - goto ERROR unless defined ($token); - $token =~ s/\"//g; - push @list, $token; - } else { - last; - } - } - - goto ERROR if (scalar @list < 1); - - foreach (@list) { - push @{$config->{$kw}}, $_; - } - - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_list_string: error parsing $kw"); -} - -sub x_xml_parse_list -{ - my $hash = shift; - my $kw = shift; - my $values = shift; - my $i = 1; - while (defined (my $tmp = &gst_xml_get_attribute ($values, 'arg' . $i))) { - push @{$hash->{$kw}}, $tmp; - $i++; - } -} - -sub x_xml_print_list -{ - my $key = shift; - my $array = shift; - - my $str = $key; - my $i = 1; - foreach (@$array) { - $str .= ' arg' . $i . "=\"$_\""; - $i++; - } - &gst_xml_print_line ("<$str/>"); -} - -sub x_update_list_string -{ - my ($buf, $ptr, $old_val, $new_val) = @_; - - while (@$old_val) { - &x_update_unique_string ($buf, $ptr, $$old_val[0], $$new_val[0]); - shift @$old_val; - shift @$new_val; - } - - while (@$new_val) { - $$new_val[0] = "\"" . $$new_val[0] . "\""; - &x_update_add_token ($buf, $ptr, $$new_val[0], 1); - shift @$new_val; - } -} - -sub x_del_list_string -{ - my ($buf, $ptr, $kw, $old_val) = @_; - &x_update_token ($buf, $ptr, $kw); - - if ($old_val) { - while (@$old_val) { - &x_update_unique_string ($buf, $ptr, $old_val); - shift @$old_val; - } - } -} - -sub x_add_list_string -{ - my ($buf, $ptr, $kw, $new_val) = @_; - - &x_update_add_token ($buf, $ptr, $kw); - &x_update_list_string ($buf, $ptr, [], $new_val); -} - -# Int list data type. -sub x_parse_list_int -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - - # Format example: 'Virtual xdim ydim' - - my @list; - while (my $token = &x_peek_token ($buf)) { - if ($token =~ /^[0-9\.]+$/) { - $token = &x_get_token ($buf); - goto ERROR unless defined ($token); - push @list, $token; - } else { - last; - } - } - - goto ERROR if (scalar @list < 1); - - foreach (@list) { - push @{$config->{$kw}}, $_; - } - - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_list_int: error parsing $kw"); -} - -sub x_update_list_int -{ - my ($buf, $ptr, $old_val, $new_val) = @_; - - if ($old_val) { - while (@$old_val) { - &x_update_unique_int ($buf, $ptr, $$old_val[0], $$new_val[0]); - shift @$old_val; - shift @$new_val; - } - } - - while (@$new_val) { - &x_update_add_token ($buf, $ptr, $$new_val[0], 1); - shift @$new_val; - } -} - -sub x_del_list_int -{ - my ($buf, $ptr, $kw, $old_val) = @_; - &x_update_token ($buf, $ptr, $kw); - - if ($old_val) { - while (@$old_val) { - &x_update_unique_int ($buf, $ptr, shift @$old_val); - } - } -} - -sub x_add_list_int -{ - my ($buf, $ptr, $kw, $new_val) = @_; - - &x_update_add_token ($buf, $ptr, $kw); -# push @$new_val, "\n"; - &x_update_list_int ($buf, $ptr, undef, $new_val); -} - -# Screen keyword from ServerLayout Section. -sub x_parse_serverlayout_screen -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - my ($hash, $token, $tmp); - - # Format example: 'Screen screen-num "screen-id" position-information' - - my $screens = 0; - $screens = scalar (keys %{$config->{'Screen'}}) if exists $config->{'Screen'}; - - # Screen number - $token = &x_peek_token ($buf); - goto ERROR unless defined ($token); - if ($token =~ /^\d+$/) { - $hash->{'num'} = &x_get_token ($buf); - } else { - $hash->{'num'} = $screens; - } - - # Screen id - $token = &x_peek_token ($buf); - goto ERROR unless defined ($token); - $hash->{'id'} = &x_get_token ($buf) if ($token =~ /^\".+\"$/); - $hash->{'id'} =~ s/\"//g; - - # Position - my $pos = {}; - my @known_pos_xy = qw (Absolute Relative); - my @known_pos_id = qw (RightOf LeftOf Above Below); - - $token = &x_peek_token ($buf); - goto ERROR unless defined ($token); - - if ($tmp = &x_keyword_in_list ($token, @known_pos_xy)) { - &x_get_token ($buf); - $pos->{'name'} = $tmp; - - foreach my $i (1, 2) { - $token = &x_peek_token ($buf); - goto ERROR unless (defined ($token) || $token =~ /^\d+$/); - - $pos->{"val$i"} = &x_get_token ($buf); - } - $hash->{'pos'} = $pos; - } - - elsif ($tmp = &x_keyword_in_list ($token, @known_pos_id)) { - &x_get_token ($buf); - $pos->{'name'} = $tmp; - - $token = &x_peek_token ($buf); - goto ERROR unless (defined ($token) || $token =~ /^\".+\"$/); - - $pos->{'val1'} = &x_get_token ($buf); - $pos->{'val1'} =~ s/\"//g; - $hash->{'pos'} = $pos; - } - - elsif ($token =~ /^\d+$/) { - $pos->{'name'} = 'Absolute'; - - foreach my $i (1, 2) { - $token = &x_peek_token ($buf); - goto ERROR unless (defined ($token) || $token =~ /^\d+$/); - - $pos->{"val$i"} = &x_get_token ($buf); - } - $hash->{'pos'} = $pos; - } - - $config->{'Screen'}->{$hash->{'num'}} = - { - 'Identifier' => $hash->{'id'} - }; - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_serverlayout_screen: error parsing $kw"); -} - -sub x_xml_parse_serverlayout_screen -{ - my $hash = shift; - my $kw = shift; - my $tag = shift; - - $hash->{$kw} = {} unless exists $hash->{$kw}; - - my $number = &gst_xml_get_attribute ($tag, "number"); - my $screen = { 'Identifier' => &gst_xml_get_attribute ($tag, "name") }; - $hash->{$kw}->{$number} = $screen; -} - -sub x_xml_print_serverlayout_screen -{ - my ($key, $val) = @_; - - foreach my $screen (keys %$val) { - my $name = $val->{$screen}->{'Identifier'}; - &gst_xml_print_line ("<$key number=\"$screen\" name=\"$name\"/>"); - } -} - -sub x_update_serverlayout_screen -{ - my ($buf, $ptr, $old_val, $new_val) = @_; - - # Just get enough tokens from con file. - # FIXME: Make it actually WORK. - - # Screen number - my $token = &x_update_get_token ($buf, $ptr); - unless ($token =~ /^\d+$/) { - &x_update_unget_token ($buf, $ptr); - } - - # Screen id - $token = &x_update_get_token ($buf, $ptr); - - # Position - my @known_pos_xy = qw (Absolute Relative); - my @known_pos_id = qw (RightOf LeftOf Above Below); - my $tmp; - - $token = &x_update_get_token ($buf, $ptr); - if ($tmp = &x_keyword_in_list ($token, @known_pos_xy)) { - $token = &x_update_get_token ($buf, $ptr); - $token = &x_update_get_token ($buf, $ptr); - } - elsif ($tmp = &x_keyword_in_list ($token, @known_pos_id)) { - $token = &x_update_get_token ($buf, $ptr); - } - elsif ($token =~ /^\d+$/) { - $token = &x_update_get_token ($buf, $ptr); - } - else { - $token = &x_update_unget_token ($buf, $ptr); - } -} - -sub x_del_serverlayout_screen -{ - my ($buf, $ptr, $kw, $old_val) = @_; - - #FIXME: Doesn't do anything. -# &x_update_token ($buf, $ptr, $kw); - - &x_update_serverlayout_screen ($buf, $ptr, $old_val); -} - -sub x_add_serverlayout_screen -{ - my ($buf, $ptr, $kw, $new_val) = @_; - - &x_update_add_token ($buf, $ptr, $kw); - &x_update_add_token ($buf, $ptr, 0, 1); - - &x_add_unique_string ($buf, $ptr, undef, $new_val); - - &x_update_add_token ($buf, $ptr, 0, 1); - &x_update_add_token ($buf, $ptr, 0, 1); -} - -# ModeLines. - -sub x_parse_modeline -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - my @keys = qw (dotclock hdisp hsyncstart hsyncend htotal - vdisp vsyncstart vsyncend vtotal); - my @flags = qw (Interlace DoubleScan +HSync -HSync +VSync -VSync - Composite +CSync -CSync); - - my $modeline = {}; - my $token = &x_get_token ($buf); - goto ERROR unless defined ($token); - $token =~ s/\"//g; - $modeline->{'name'} = $token; - - foreach my $tmp (@keys) { - my $token = &x_get_token ($buf); - goto ERROR unless defined ($token); - goto ERROR unless $token =~ /^[\d\.]+$/; #digit or '.' - - $modeline->{$tmp} = $token; - } - - # Get flags - while (my $token = &x_peek_token ($buf)) { - if (my $tmp = &x_keyword_in_list ($token, @flags)) { - &x_get_token ($buf); - push @{$modeline->{'flags'}}, $tmp; - } else { - last; - } - } - - push @{$config->{$kw}}, $modeline; - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_modeline: error parsing $kw"); -} - -sub x_xml_parse_modeline -{ - my $hash = shift; - my $kw = shift; - my $list = shift; - - shift @$list; - - while (@$list) { - my $mode = {}; - shift @$list; - my $modeline = shift @$list; - - shift @$modeline; - while (@$modeline) { - my $field = shift @$modeline; - if ($field ne 'flag') { - $mode->{$field} = &gst_xml_get_text (shift @$modeline); - } else { - push @{$mode->{$field}}, &gst_xml_get_text (shift @$modeline); - } - } - push @{$hash->{$kw}}, $mode; - } -} - -sub x_xml_print_modeline -{ - my ($key, $list) = @_; - - &gst_xml_container_enter ("ModeLine"); - - foreach (@$list) { - my $modeline = $_; - &gst_xml_container_enter ("Mode"); - foreach my $field (keys %$modeline) { - my $type = ref ($modeline->{$field}); - - if (!$type) { &gst_xml_print_pcdata ($field, $modeline->{$field}); } - elsif ($type eq 'ARRAY') { - foreach my $flag (@{$modeline->{$field}}) { - &gst_xml_print_pcdata ('flag', $flag); - } - } - else { - my $msg = "unknown data type $type"; - &gst_report ('x_general_warn', $msg); - &gst_debug_print_line ("x_xml_print_modeline: $msg"); - } - } - &gst_xml_container_leave (); - } - &gst_xml_container_leave (); -} - -sub x_update_modeline -{ - my ($buf, $ptr, $old_val, $new_val) = @_; - my $token = &x_update_get_token ($buf, $ptr); -} - -sub x_del_modeline -{ -} - -sub x_add_modeline -{ - my ($buf, $ptr, $kw, $new_val) = @_; - my @keys = qw (dotclock hdisp hsyncstart hsyncend htotal - vdisp vsyncstart vsyncend vtotal); - - foreach my $modeline (@$new_val) { - &x_update_add_token ($buf, $ptr, $kw); - &x_add_unique_string ($buf, $ptr, undef, $modeline->{'name'}); - - foreach my $key (@keys) { - &x_update_add_token ($buf, $ptr, $modeline->{$key}, 1); - } - - foreach my $key (@{$modeline->{'flags'}}) { - &x_update_add_token ($buf, $ptr, $key, 1); - } - - &x_update_add_token ($buf, $ptr, "\n"); - } -} - -# Hertz range datatype -sub x_parse_range_hz -{ - my $config = shift; - my $buf = shift; - my $kw = shift; - - my @list; - while (defined (my $token = &x_peek_token ($buf))) { - my ($min, $max); - for ($token) { - - /^([\d.]+)\-([\d\.]+)$/ and do { - $min = $1; - $max = $2; - &x_get_token ($buf); - last; - }; - - /^[\d\.]+$/ and do { - $min = &x_get_token ($buf); - $token = &x_peek_token ($buf); - if ($token eq '-') { - &x_get_token ($buf); - $max = &x_get_token ($buf); - } else { - $max = $min; - } - - last; - - }; - - # Default - last; - } - - if ($min && $max) { - push @list, [ $min, $max ]; - } else { last; } - } - - goto ERROR if (scalar @list < 1); - - foreach (@list) { - push @{$config->{$kw}}, $_; - } - - return; - - ERROR: - &gst_report ('x_parse_error', $kw); - &gst_debug_print_line ("x_parse_range_hz: error parsing $kw"); -} - -sub x_xml_parse_range_hz -{ - my $hash, shift; - my $kw = shift; - - push @{$hash->{$kw}}, &gst_xml_get_text (shift @_); -} - -sub x_xml_print_range_hz -{ - my $key = shift; - my $array = shift; - - foreach my $tmp (@$array) { - my $val = $$tmp[0]; - $val .= '-' . $$tmp[1] if $$tmp[0] != $$tmp[1]; - - &gst_xml_print_pcdata ($key, $val); - } -} - -sub x_update_range_hz -{ - # TODO: - my ($buf, $ptr, $old_val, $new_val) = @_; -} - -sub x_del_range_hz -{ - # TODO: - my ($buf, $ptr, $kw, $old_val) = @_; -} - -sub x_add_range_hz -{ - my ($buf, $ptr, $kw, $new_val) = @_; - - foreach my $tmp (@$new_val) { - my $val = $$tmp[0]; - $val .= '-' . $$tmp[1] if $$tmp[0] != $$tmp[1]; - &x_update_add_token ($buf, $ptr, $kw); - &x_update_add_token ($buf, $ptr, $val, 1); - } -} - - - -# ------------------------------------------------------- -# Parser -# ------------------------------------------------------- - -sub x_get_token -{ - my $buf = shift; - my $dest_buf = shift; - my $token; - - while (@$buf) { - my $line = $$buf[0]; - - if (&gst_ignore_line ($line)) { - push @$dest_buf, $line if defined ($dest_buf); - shift @$buf; - next; - } - - $line =~ s/^(\s+)//; - push @$dest_buf, $1 if defined ($1); - my @list = "ewords ('[ \t]+', 1, $line); - $token = $list[0]; - chomp $token; - my $pattern = $token; - $pattern =~ s/(\W)/\\$1/g; - $$buf[0] =~ s/$pattern//; - last; - } - - return $token; -} - -sub x_peek_token -{ - my $buf = shift; - my $token; - - foreach (@$buf) { - my $line = $_; - - if (&gst_ignore_line ($line)) { - next; - } - - $line =~ s/^\s+//; - my @list = "ewords ('[ \t]+', 1, $line); - $token = $list[0]; - chomp $token; - last; - } - - return $token; -} - -sub x_parse_section_start -{ - my $buf = shift; - my $sections = shift; - my $new_buf = shift; - - my $token = &x_get_token ($buf, $new_buf); - $token =~ s/\"//g; - - return &x_keyword_in_list ($token, keys %$sections); -} - -sub x_parse -{ - my $fname = shift; - my ($tmp); - - $x_version = &x_version () unless $x_version; - - my $buf = &gst_file_buffer_load ($fname); - return unless $buf; - - # Init section stack - my $section_ptr; - my @section_stack = (); - $section_ptr = $x_version->{'sections'}; - unshift @section_stack, $section_ptr; - - # Init config stack - my $config = {}; - my $config_ptr = $config; - my @config_stack = (); - unshift @config_stack, $config_ptr; - - while (defined (my $token = &x_get_token ($buf))) { - for ($token) { - - /^(Sub)?Section/i and do { - if ($tmp = &x_parse_section_start ($buf, $section_ptr)) { - $section_ptr = $section_ptr->{$tmp}; - unshift @section_stack, $section_ptr; - - push @{$config_ptr->{$tmp}}, {}; - $config_ptr = $config_ptr->{$tmp}[$#{$config_ptr->{$tmp}}]; - unshift @config_stack, $config_ptr; - } - last; - }; - - /^(End(Sub)?Section)/i and do { - if (scalar @section_stack > 1) { - shift @section_stack; - $section_ptr = $section_stack[0]; - - shift @config_stack; - $config_ptr = $config_stack[0]; - } - last; - }; - - (scalar @section_stack <= 1) and do { - # Inside unknown section - last; - }; - - ($tmp = &x_keyword_in_list ($token, keys %{$section_ptr->{'keywords'}})) and do { - my $func = $section_ptr->{'keywords'}{$tmp}{'parse'}; - &$func ($config_ptr, $buf, $tmp); - last; - }; - - # Default - 1; - } - } - - &gst_report ('x_parse', $fname); - return $config; -} - -# ------------------------------------------------ -# XML Printing. -# ------------------------------------------------ - -sub x_xml_print_section -{ - my $hash = shift; - my $section = shift; - my $section_list = shift; - my $section_ptr = shift; - my ($key); - - return if (!&x_keyword_in_list ($section, @$section_list)); - - $section_ptr = $x4_sections unless $section_ptr; # Always print using X4_sections. - - return unless (exists ($section_ptr->{$section})); - &gst_xml_container_enter ("$section"); - - $section_ptr = $section_ptr->{$section}; - foreach $key (keys %$hash) { - if (exists $section_ptr->{'keywords'}{$key}) { - my $func = $section_ptr->{'keywords'}{$key}{'xml_print'}; - &$func ($key, $hash->{$key}); - } - - elsif (exists $section_ptr->{$key}) { - foreach my $tmp (@{$hash->{$key}}) { - &x_xml_print_section ($tmp, $key, $section_list, $section_ptr); - } - } - - else { - my $msg = "unknown keyword $key in section $section"; - &gst_report ('x_general_warn', $msg); - &gst_debug_print_line ("x_xml_print_section: $msg"); - } - } - - &gst_xml_container_leave (); -} - -# -------------------------------------------------------------------- -# XML parser -# -------------------------------------------------------------------- - -# Internal -sub x_xml_parse_section -{ - my ($config, $tree, $section_desc, $section_name) = @_; - my ($keywords) = $section_desc->{'keywords'}; - my ($options) = $section_desc->{'options'}; - - my $hash = {}; - shift @$tree; - - while (@$tree) { - my $func; - - if (exists $keywords->{$$tree[0]}) { - $func = $keywords->{$$tree[0]}{'xml_parse'}; - if ($func eq "") { - - # TODO: - # print STDERR "$tree->[0]\n"; - 1; - } else { - &$func ($hash, $$tree[0], $$tree[1]); - } - } - - elsif (exists $options->{$$tree[0]}) { - # TODO: implement 'Option' xml parser. -# $func = $options->{$$tree[0]}[1]; - 1; - } - - elsif (exists $section_desc->{$$tree[0]}) { - &x_xml_parse_section ($hash, $$tree[1], $section_desc->{$$tree[0]}, $$tree[0]); - } - - shift @$tree; - shift @$tree; - } - - unshift @{$config->{$section_name}}, $hash; -} - -sub x_xml_parse -{ - my $tree = shift; - my $sections = $x4_sections; # XML uses always X4 format. - - shift @$tree; # Skip attributes. - - my $config = {}; - - while (@$tree) { - my ($section); - - if ($section = &x_keyword_in_list ($$tree[0], keys %$sections)) { - &x_xml_parse_section ($config, $$tree[1], $sections->{$section}, $section); - } - - else { - my $msg = "received unknown xml tag $$tree[0]"; - &gst_report ('xml_unexp_tag', $$tree[0]); - &gst_debug_print_line ("x_xml_parse: $msg"); - } - - shift @$tree; - shift @$tree; - } - - return $config; -} - -# ---------------------------------------------- -# Update -# ---------------------------------------------- - -sub x_update_get_token -{ - my $buf = shift; - my $ptr = shift; - - for ($ptr->{'line'}; $ptr->{'line'} < @$buf; $ptr->{'line'}++, $ptr->{'col'} = 0) { - my $line = substr ($$buf[$ptr->{'line'}], $ptr->{'col'}); - - next if &gst_ignore_line ($line); - - $line =~ s/^(\s+)//; - $ptr->{'col'} += length ($1) if defined ($1); - - my @list = "ewords ('[ \t]+', 1, $line); - my $token = $list[0]; - $ptr->{'col'} += length ($token); - $ptr->{'col'} -= chomp $token; - return $token; - } - - return; -} - -sub x_update_unget_token -{ - my $buf = shift; - my $ptr = shift; - - my $line = substr ($$buf[$ptr->{'line'}], 0, $ptr->{'col'}); - my @list = "ewords ('[ \t]+', 1, $line); - my $token = $list[$#list]; - - if (scalar @list == 2 && length ($list[0]) == 0 || - scalar @list <= 1) { - --$ptr->{'line'}; - $ptr->{'col'} = length $$buf[$ptr->{'line'}]; - } else { - $ptr->{'col'} -= length ($token); - } -} - -sub x_update_token -{ - my $buf = shift; - my $ptr = shift; - my $old_val = shift; - my $new_val = shift; - - my $pattern = $old_val; - $pattern =~ s/(\W)/\\$1/g; - substr ($$buf[$ptr->{'line'}], 0, $ptr->{'col'}) =~ s/$pattern$/$new_val/; - - if ($$buf[$ptr->{'line'}] =~ /^\s*$/) { - $$buf[$ptr->{'line'}] = ''; - $ptr->{'col'} = 0; - } else { - my $diff = length ($old_val) - length ($new_val); - $ptr->{'col'} -= $diff; - } -} - -sub x_update_add_token -{ - my $buf = shift; - my $ptr = shift; - my $val = shift; - my $same_line = shift; -# my $new_val = $same_line ? " " : "\n"; - my $new_val = $same_line ? ' ' : ''; - $new_val .= $val; - - my $head = substr ($$buf[$ptr->{'line'}], 0, $ptr->{'col'}); - my $tail = substr ($$buf[$ptr->{'line'}], $ptr->{'col'}); - - $$buf[$ptr->{'line'}] = $head . $new_val . $tail; - $ptr->{'col'} += length ($new_val); -} - -sub x_update_skip_section -{ - my ($buf, $ptr) = @_; - my $depth = 1; - - while (defined (my $token = &x_update_get_token ($buf, $ptr))) { - if ($token =~ /End(Sub)?Section/i) { - $depth--; - last if $depth == 0; - } - - $depth++ if $token =~ /(Sub)?Section/i; - } -} - -sub x_update_del_section -{ - my ($buf, $ptr) = @_; - - my $first = $ptr->{'line'}; - &x_update_skip_section ($buf, $ptr); - my $last = $ptr->{'line'}; - - for ($first .. $last) { $$buf[$_] = ''; } -} - -sub x_update_add_section -{ - my ($buf, $ptr, $section, $section_name, $section_list, $sub_section) = @_; - my $section_str = $sub_section ? "Subsection" : "Section"; - - &x_update_add_token ($buf, $ptr, "\n$section_str \"$section_name\"\n"); - - foreach my $key (keys %$section) { - if (exists ($section_list->{$section_name}{'keywords'}{$key})) { - my $func = $section_list->{$section_name}{'keywords'}{$key}{'add'}; - if ($func) { - &$func ($buf, $ptr, $key, $section->{$key}); - &x_update_add_token ($buf, $ptr, "\n"); - } - } - - elsif (exists ($section_list->{$section_name}{$key})) { - foreach my $tmp (@{$section->{$key}}) { - &x_update_add_section ($buf, $ptr, $tmp, $key, $section_list->{$section_name}, 1) if $tmp; - } - } - - else { - my $msg = "unknown keyword $key in section $section"; - &gst_report ('x_general_warn', $msg); - &gst_debug_print_line ("x_update_add_section: $msg"); - } - } - - &x_update_add_token ($buf, $ptr, "End$section_str\n"); -} - -sub x_update_section -{ - my $buf = shift; - my $ptr = shift; - my $config = shift; - my $xml_config = shift; - my $section_list = shift; - my $new_section; - - # Read section name - my $section_name = &x_update_get_token ($buf, $ptr); - $section_name =~ s/\"//g; - $section_name = &x_keyword_in_list ($section_name, keys %$section_list); - - unless ($section_name) { - &x_update_skip_section ($buf, $ptr); - return; - } - - $section_list = $section_list->{$section_name}; - my $section = shift @{$config->{$section_name}}; - my $ident_str = $section_list->{KEY}; - - # Find section from xml config - for (my $i = 0; $i <= scalar @{$xml_config->{$section_name}}; $i++) { - next unless exists $xml_config->{$section_name}[$i]; - if ($xml_config->{$section_name}[$i]->{$ident_str} eq $section->{$ident_str}) { - $new_section = $xml_config->{$section_name}[$i]; - delete $xml_config->{$section_name}[$i]; - last; - } - } - - unless ($new_section) { - &x_update_del_section ($buf, $ptr); - return; - } - - while (defined (my $token = &x_update_get_token ($buf, $ptr))) { - if ($token =~ /End(Sub)?Section/i) { - last; - } - - if (my $kw = &x_keyword_in_list ($token, keys %{$section_list->{'keywords'}})) { - if (exists $new_section->{$kw}) { - my $func = $section_list->{'keywords'}{$kw}{'update'}; - &$func ($buf, $ptr, $section->{$kw}, $new_section->{$kw}) if $func; - delete $new_section->{$kw}; - } else { - my $func = $section_list->{'keywords'}{$kw}{'delete'}; - &$func ($buf, $ptr, $kw, $section->{$kw}) if $func; - } - - next; - } - - if ($token =~ /(Sub)?Section/i) { - &x_update_section ($buf, $ptr, $section, $new_section, $section_list); - next; - } - } - - # Add new values - - my $first_time = 1; - foreach my $kw (keys %$new_section) { - &x_update_unget_token ($buf, $ptr) if $first_time; - - if (exists $section_list->{'keywords'}{$kw}) { - my $func = $section_list->{'keywords'}{$kw}{'add'}; - &$func ($buf, $ptr, $kw, $new_section->{$kw}); - &x_update_add_token ($buf, $ptr, "\n"); - } - - elsif (exists $section_list->{$kw}) { - foreach my $tmp (@{$new_section->{$kw}}) { - &x_update_add_section ($buf, $ptr, $tmp, $kw, $section_list, 1) if $tmp; - } - } - - else { - my $msg = "unknown keyword $kw in section $section_name"; - &gst_report ('x_general_warn', $msg); - &gst_debug_print_line ("x_update_section: $msg"); - } - - undef $first_time if $first_time; - } - - &x_update_get_token ($buf, $ptr) unless $first_time; - - # Remove empty old data structs - if (scalar @{$xml_config->{$section_name}} < 1) { - delete $xml_config->{$section_name}; - } -} - -sub x_config_set -{ - my $fname = shift; - my $config = shift; - my $xml_config = shift; - - return unless $fname; - return unless $config; - return unless $xml_config; - - my $section_list = $x_version->{'sections'}; - my $buf = &gst_file_buffer_load ($fname); - return unless $buf; - - my $ptr = {}; - while (defined (my $token = &x_update_get_token ($buf, $ptr))) { - for ($token) { - /^(Sub)?Section/i and do { &x_update_section ($buf, $ptr, $config, $xml_config, $section_list) }; - - # Default: - } - } - - # Add new sections - foreach my $key (keys %$xml_config) { - if (exists ($section_list->{$key})) { - foreach my $tmp (@{$xml_config->{$key}}) { - &x_update_add_section ($buf, $ptr, $tmp, $key, $section_list) if $tmp; - } - } - } - - &gst_file_buffer_save ($buf, $fname); -} - - - - - -# ------------------------------------------------------ -# Compat layer -# ------------------------------------------------------ - -# internal. -sub x_get_active_screen -{ - my $config = shift; - return unless $config; - - # Make sure there is at least one screen - unless (exists ($config->{'Screen'}) || scalar @{$config->{'Screen'}} > 0) { - # TODO: No 'Screen's found. give error or add one. - return; - } - - # First try to get it from ServerLayout. - if (exists ($config->{'ServerLayout'}) && - scalar @{$config->{'ServerLayout'}} > 0) { - my $active_screen = $config->{'ServerLayout'}[0]{'Screen'}; - $active_screen = $active_screen->{0}->{'Identifier'}; - foreach my $screen (@{$config->{'Screen'}}) { - if ($screen->{'Identifier'} eq $active_screen) { - return $screen; - } - } - # TODO: give error that Screen found at ServerLayout doesn;t exist. - } - - # Get active Screen: - - my $section = $config->{'Screen'}; - if ($x_version->{'number'} < 400) { - foreach my $screen (@$section) { - # Find screen with right 'Identifier'. - return $screen if ($screen->{'Identifier'} =~ /$x_version->{'driver'}/i); - } - } - else { - return $$section[0]; - } - - # Didn't find screen. - # TODO: give error or add a screen - - return; -} - -# ServerLayout is optional, compose one if none present -sub x_check_get_serverlayout -{ - my $config = shift; - return unless $config; - - # No need to 'fix' anything. - return if ($config->{'ServerLayout'}); - - my $section = "ServerLayout"; - my $hash = {}; - - # Add 'Identifier' - $hash->{'Identifier'} = 'Gst Configured'; - - # Add 'Screen' - my $ref = &x_get_active_screen ($config, $x_version); - if ($ref) { - $hash->{'Screen'} = { 0 => - { - 'Identifier' => $ref->{'Identifier'} - } - }; - } - - push @{$config->{$section}}, $hash; -} - -# X3 doesn't have ServerLayout keyword -sub x_check_set_serverlayout -{ - my $config = shift; - return unless $config; - - if ($x_version->{'number'} < 400) { - delete $config->{'GstXServerLayout'} if (exists ($config->{'GstXServerLayout'})); - } -} - -# internal. X verisions earlier than 4.0 didn't have 'Identifier' in 'Screen' section but -# 'Driver' was used as one. -sub x3_fix_screen -{ - my $config = shift; - my $get = shift; - - return unless $config; - - unless (exists ($config->{'Screen'})) { - # TODO: No 'Screen's found. give error or add one. - return; - } - - my $section = $config->{'Screen'}; - foreach my $screen (@$section) { - if ($get) { - # Driver -> Identifier - $screen->{'Identifier'} = $screen->{'Driver'}; - delete $screen->{'Driver'}; - } else { - # Identifier -> Driver - $screen->{'Driver'} = $screen->{'Identifier'}; - delete $screen->{'Identifier'}; - } - - # Color depth - if ($get) { - # GET - if (exists $screen->{'DefaultColorDepth'}) { - # DefaultColorDepth -> DefaultDepth - $screen->{'DefaultDepth'} = $screen->{'DefaultColorDepth'}; - delete $screen->{'DefaultColorDepth'}; - } else { - # Add default depth - $screen->{'DefaultDepth'} = 8; - } - } else { - # SET - # DefaultDepth -> DefaultColorDepth - $screen->{'DefaultColorDepth'} = $screen->{'DefaultDepth'}; - delete $screen->{'DefaultDepth'}; - } - } -} - -# Internal. -sub x_get_active_serverlayout -{ - my $config = shift; - return unless $config; - - if (! $config->{'ServerLayout'} || - scalar @{$config->{'ServerLayout'}} < 1) { - return; - } - - # Active == first - my $active = $config->{'ServerLayout'}[0]; - unless ($active->{'Identifier'} || $active->{'Screen'}) { - &gst_debug_print_line ("x_get_active_serverlayout: Incomplete active layout."); - return; - } - - return $active; -} - -# Internal -sub x_get_active_display -{ - my $config = shift; - return unless $config; - - my $screen = &x_get_active_screen ($config); - return unless $screen; - - if (scalar @{$screen->{'Display'}} < 1) { - &gst_debug_print_line ("x_get_active_display: No 'Display' subsections found."); - return; - } - - foreach my $disp (@{$screen->{'Display'}}) { - return $disp if $screen->{'DefaultDepth'} == $disp->{'Depth'}; - } - - &gst_debug_print_line ("x_get_active_display: No 'Display' subsection found."); - return; -} - -# Internal -sub x_check_display -{ - my $config = shift; - return unless $config; - - my $display = &x_get_active_display ($config); - return unless $display; - - my $modes = $display->{'Modes'}; - if (scalar @$modes < 1) { - &gst_debug_print_line ("x_check_display: No 'Modes' found."); - return; - } - - my ($maxx, $maxy) = (0, 0); - foreach my $mode (@$modes) { - my ($x, $y) = ($1, $2) if $mode =~ /^(\d+)x(\d+)$/i; - $maxx = $x if $x > $maxx; - $maxy = $y if $y > $maxy; - } - - my $active_mode = $$modes[0]; - my ($x, $y) = ($1, $2) if $active_mode =~ /^(\d+)x(\d+)$/i; - if ($x < $maxx || $y < $maxy) { - $display->{'Virtual'} = [ $x, $y ]; - } else { - delete $display->{'Virtual'}; - } -} - -sub x_config_fix -{ - my $config = shift; - my $get = shift; - return unless $config; - - $x_version = &x_version () unless $x_version; - - if ($x_version->{'number'} < 400) { - &x3_fix_screen ($config, $get); - } - - if ($get) { - &x_check_get_serverlayout ($config); - } else { - &x_check_set_serverlayout ($config); - } - - &x_check_display ($config); -} - - -# ----------------------------------------------------------- -# Probe functions -# ----------------------------------------------------------- - -# Internal -sub x_probe_get_modelines -{ - my $config = shift; - my $std_modelines = {}; - - return unless $config; - - my @buf = split ('\n', $standard_modes); - while (defined (my $token = &x_get_token (\@buf))) { - &x_parse_modeline ($std_modelines, \@buf, $token); - } - - return $std_modelines; -} - -# Internal -sub x_probe_get_monitor -{ - my $config = shift; - my $screen = shift; - my $monitor; - - return unless $config; - return unless $screen; - - my $active_monitor = $screen->{'Monitor'}; - foreach $monitor (@{$config->{'Monitor'}}) { - if ($monitor->{'Identifier'} eq $active_monitor) { - return $monitor; - } - } - - return; -} - -# Internal -sub x_probe_add_monitor -{ - my $config = shift; - my $monitor = shift; - my $modes = shift; - - return unless $config; - return unless $monitor; - - my $new; - $new->{'Identifier'} = 'GstTestMonitor'; - $new->{'HorizSync'} = $monitor->{'HorizSync'}; - $new->{'VertRefresh'} = $monitor->{'VertRefresh'}; - $new->{'ModeLine'} = (); - - $new->{'ModeLine'} = $modes->{'ModeLine'}; - push @{$config->{'Monitor'}}, $new; - - return $new; -} - -# Internal -sub x_probe_add_screen -{ - my $config = shift; - my $screen = shift; - my $monitor = shift; - - return unless $config; - return unless $screen; - return unless $monitor; - - my $new; - $new->{'Identifier'} = 'GstTestScreen'; - $new->{'Device'} = $screen->{'Device'}; - $new->{'Monitor'} = 'GstTestMonitor'; - - foreach my $depth (@x_colordepths) { - my $display; - - $display->{'Depth'} = $depth; - foreach my $mode (@{$monitor->{'ModeLine'}}) { - push @{$display->{'Modes'}}, $mode->{'name'}; - } - push @{$new->{'Display'}}, $display; - } - - push @{$config->{'Screen'}}, $new; -} - -# Internal -sub x_probe_save -{ - my $orig_file = shift; - my $config = shift; - - return unless $orig_file; - return unless $config; - - my $cfg_fname; - do { $cfg_fname = tmpnam () } - until my $fh = IO::File->new ($cfg_fname, O_RDWR|O_CREAT|O_EXCL); - - copy ($orig_file, $cfg_fname); - my $orig_cfg = &x_parse ($cfg_fname); - - &x_config_set ($cfg_fname, $orig_cfg, $config); - - return $cfg_fname; -} - -# Internal -sub x_probe_scan -{ - my $cfg_file = shift; - my $depth = shift; - my $depth_cmd = ($x_version->{'number'} >= 400) ? "-depth " : "-bpp "; - $depth_cmd .= $depth; - - my $command = $x_version->{'command'}; - &gst_debug_print_line ("$command :9 -xf86config $cfg_file -probeonly $depth_cmd -screen GstTestScreen 2>&1 |"); - open (FD, "$command :9 -xf86config $cfg_file -probeonly $depth_cmd -screen GstTestScreen 2>&1 |"); - if (FD) { - my @content = (<FD>); - close (FD); - my @list = grep (/^\(\*\*\) \w+\(0\): Mode \"/, @content); - return \@list if scalar @list; - } - - return; -} - -# Internal -sub x_probe_collect -{ - my $data = shift; - my $modes = shift; - my $depth = shift; - - if (scalar @$data) { - my $mode; - my $list = []; - - foreach $mode (@{$modes->{'ModeLine'}}) { - foreach (@$data) { - my $modename = $1 if /\"(.+)\"/; - if ($modename eq $mode->{'name'}) { - push @$list, $mode; - last; - } - } - } - return $list; - } - - &gst_report ('x_probe_error', $depth); - &gst_debug_print_line ("x_probe_collect: error reading XFree's output at depth $depth."); - return; -} - -# Internal -sub x_probe_run -{ - my $cfg_file = shift; - my $modes = shift; - - return unless $cfg_file; - - my $hash; - foreach my $depth (@x_colordepths) { - my $proc = &gst_process_fork (\&x_probe_scan, $cfg_file, $depth); - &gst_process_list_check_ready (15, $proc); - my $list = &gst_process_result_collect ($proc, \&x_probe_collect, $modes, $depth); - if ($list && scalar @$list) { - $hash->{$depth} = $list; - } else { - last; - } - } - - unless ($hash) { - &gst_report ('x_probe_error', "Error running XFree server"); - return; - } - - return $hash; -} - -# Internal -sub x_probe_print_xml -{ - my $list = shift; - - return unless $list; - - &gst_xml_print_begin (); - &gst_xml_print_vspace (); - - foreach my $depth (keys %$list) { - &gst_xml_print_line ("<Depth value=\"$depth\">"); - &gst_xml_enter (); - &x_xml_print_modeline (0, $list->{$depth}); - &gst_xml_leave (); - &gst_xml_print_line (q(</Depth>)); - } - - &gst_xml_print_end (); -} - -# Internal -sub x_probe_store -{ - my $config = shift; - my $list = shift; - - return unless $config; - # TODO: Write monitor and card information also. - - my $file = &gst_file_get_data_path () . "/" . $main::tool->{'name'} . "/" . $x_probe_file; - - my $fh = &gst_file_open_write_from_names ($file); - if ($fh) { - local *STDOUT = $fh; - &x_probe_print_xml ($list); - close ($fh); - } -} - -# Internal -sub x_probe_load -{ - my $config = shift; - - return unless $config; - # TODO: Check if monitor || card is changed - - my $file = &gst_file_get_data_path () . "/" . $main::tool->{'name'} . "/" . $x_probe_file; - my $fh = &gst_file_open_read_from_names ($file); - - if ($fh) { - my @content = <$fh>; - close ($fh); - - return @content if (scalar @content > 0); - } - - return; -} - -sub x_probe -{ - my $orig_file = shift; - my $config = shift; - my $direct = shift; - - return unless $orig_file; - return unless $config; - - unless ($direct) { - my @content = &x_probe_load ($config); - &gst_report ('x_probe_needed') unless @content; - &gst_report_end (); - print @content; - return; - } - - my $modes = &x_probe_get_modelines ($config); - my $screen = &x_get_active_screen ($config); - my $monitor = &x_probe_get_monitor ($config, $screen); - - $monitor = &x_probe_add_monitor ($config, $monitor, $modes); - &x_probe_add_screen ($config, $screen, $monitor); - - my $cfg_file = &x_probe_save ($orig_file, $config); - my $list = &x_probe_run ($cfg_file, $modes); - unlink ($cfg_file); - - if ($list) { - &x_probe_store ($config, $list); - &gst_report_end (); - &x_probe_print_xml ($list); - return; - } - - &gst_report_end (); -} - - -1; |