Compare commits

...
10 Commits
Author SHA1 Message Date
Alexander Shaduri af2f758717 Tagging 0.8.5:
GSmartControl now uses XDG config directory for per-user configuration on
        UNIX and CSIDL_PROFILE directory on Windows. Existing configuration is
        migrated automatically.
    The names are shown correctly for unsupported devices even with the latest
        smartctl snapshots now.
    Smartctl SVN revision is shown (if available).
    The progress bars update properly when parallel tests are run.
    Windows: GSmartControl should be able to operate on any valid filesystem
        path (not just locale-representable ones).
    Windows: GSmartControl is now officially compilable on x86_64 via mingw64.
    Fixed compilation under very old gtkmm/libglademm, and with gcc 4.4.
    Fixed parsing of multiple error types in SMART error log.
    Added minor features and fixed miscellaneous bugs.
2010-12-26 19:51:27 +00:00
Alexander Shaduri 2ca8174054 Importing 0.8.5. 2010-12-26 19:50:52 +00:00
Alexander Shaduri 10e4496bb7 Importing 0.8.4. 2010-12-26 19:46:54 +00:00
Alexander Shaduri 880d876ccf Importing 0.8.4-pre-2009-03-21. 2010-12-26 19:44:01 +00:00
Alexander Shaduri 2ffec89ed8 Importing 0.8.3 2010-12-26 19:40:08 +00:00
Alexander Shaduri 5c257ffdc4 Tagging 0.8.2. 2010-12-26 19:33:25 +00:00
Alexander Shaduri dc6297b0c9 Importing 0.8.1 2010-12-26 19:24:29 +00:00
Alexander Shaduri 3a181b6880 Imported 0.8.0rc4. 2010-12-26 18:54:11 +00:00
Alexander Shaduri 9677b33f54 SVN cleanup 2010-12-26 18:49:40 +00:00
Alexander Shaduri 0503d97e62 Importing 0.8.0rc3.
SVN cleanup.
2010-12-26 18:48:16 +00:00
333 changed files with 14378 additions and 251165 deletions
@@ -10,3 +10,7 @@ aclocal.m4
config.h.in
missing
install-sh
*.glade.cpp
*.ui.cpp
*.txt.cpp
gsmartcontrol.spec
View File
+1
View File
@@ -0,0 +1 @@
See the NEWS file.
View File
+25
View File
@@ -0,0 +1,25 @@
Copyright (c) 2006-2008 Alexander Chemeris
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -18,12 +18,19 @@ If not, see <http://www.gnu.org/licenses/>.
See LICENSE_gpl2.txt and LICENSE_gpl3.txt for details.
All files which don't have any copyright notices, as well as tests and
examples are covered under the Whatever License. See LICENSE_whatever.txt for
details.
Portions of this software are copyright Google Inc. See LICENSE_pcrecpp.txt
for details.
This product includes the HZ library (or portions of it). See LICENSE_hz.txt
for details.
This product includes icons from Crystal Project,
copyright 2006-2007 Everaldo Coelho.
http://www.everaldo.com/crystal, http://www.yellowicon.com .
@@ -4,21 +4,37 @@ HZ Library License
The HZ library contains software licensed under several different licenses.
This is due to HZ including portions of other software.
All original code is licensed under the Zlib License. See LICENSE_zlib.txt for
details.
Portions of this software are copyright Regents of the University of California,
see LICENSE_bsd-ucb.txt for details.
All original code (except for the tests) is licensed under the Zlib License.
See LICENSE_zlib.txt for details.
All tests and examples are covered under the Whatever License. See
LICENSE_whatever.txt for details.
Portions of this software are copyright Regents of the University of
California, see LICENSE_bsd-ucb.txt for details.
Portions of this software are copyright Alexander Chemeris, see
LICENSE_bsd-ac.txt for details.
Portions of this software are licensed under Boost Software License, see
LICENSE_boost_1_0.txt and individual source files for copyright information.
Each source file contains its copyright information.
If you intend to use HZ in your product, please note that you MUST include
these licenses somewhere in your distribution (simply redistributing the
license files or reproducing their texts in documentation and/or other supplied
materials is OK):
license files or reproducing their texts in documentation and/or other
supplied materials is OK):
* LICENSE_zlib.txt (source distributions only);
* LICENSE_bsd-ucb.txt (source and binary distributions);
* LICENSE_boost_1_0.txt (source distributions only).
If you use only portions of HZ, you may ignore this requirement for files you
don't use. For example, if you don't use any of the Boost-licensed files, you
are not required to distribute the Boost license.
+12
View File
@@ -0,0 +1,12 @@
Whatever License
THIS SOFTWARE IS PROVIDED 'AS-IS', WITHOUT ANY EXPRESS OR IMPLIED
WARRANTY. IN NO EVENT WILL THE AUTHORS BE HELD LIABLE FOR ANY DAMAGES
ARISING FROM THE USE OF THIS SOFTWARE.
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely.
+132
View File
@@ -0,0 +1,132 @@
# Add autoconf.m4 directory to local macro search path
ACLOCAL_AMFLAGS = -I autoconf.m4
SUBDIRS = data debian.dist src
# These files are actually needed for compilation.
noinst_DATA = AUTHORS.txt LICENSE_gsmartcontrol.txt README.txt
# For the files to be bundled with the distribution, specify them in
# one of the following.
# These will be installed into docdir.
# Some of these files are actually needed for compilation (see src/res/Makefile.am).
dist_doc_DATA = AUTHORS.txt ChangeLog NEWS README.txt \
LICENSE_boost_1_0.txt \
LICENSE_bsd-ac.txt \
LICENSE_bsd-ucb.txt \
LICENSE_gpl2.txt \
LICENSE_gpl3.txt \
LICENSE_gsmartcontrol.txt \
LICENSE_hz.txt \
LICENSE_pcrecpp.txt \
LICENSE_whatever.txt \
LICENSE_zlib.txt
# nobase_ preserves their directory names.
nobase_dist_doc_DATA = contrib/cron-based_noadmin/README \
contrib/cron-based_noadmin/cron_gather_smart.sh \
contrib/cron-based_noadmin/crontab.example \
contrib/cron-based_noadmin/smartctl_subst.sh
# Extra files bundled with distribution.
# file2csource.sh is needed for building but not installed.
EXTRA_DIST = COPYING TODO INSTALL configure autogen.sh \
baqup gsmartcontrol.kdevelop \
templates \
file2csource.sh \
gsmartcontrol.spec
# PCH support
global_macros.h.gch: $(top_srcdir)/src/global_macros.h
$(CXX) $(CXXFLAGS) $(DEFS) -x "c++-header" $(top_srcdir)/src/global_macros.h -o global_macros.h.gch
gch: global_macros.h.gch
gch-clean:
rm -f global_macros.h.gch
# rpm support
src-rpm: dist
rpmbuild -ts $(distdir).tar.bz2
# Don't use this - it does something weird, and gcc errors out with "long long long" errors, etc...
#rpm: dist
# rpmbuild -ta $(distdir).tar.bz2
# NSIS installer support.
# Requires wine, installed NSIS, smartctl-nc.exe, smartctl.exe.
# Gtkmm dlls and pcre dlls are required if linking against them.
# dos2unix on build machine.
# Execute only with win32 build present.
WIN_ZIP_NAME = $(PACKAGE)-$(VERSION)-win32
win-dist: win-dist-prepare nsis-dist-nocleanup win-zip-dist
win-dist-clean:
rm -rf gsmartcontrol-*.exe gsmartcontrol-*.zip nsis-dist $(WIN_ZIP_NAME)
win-dist-prepare: all win-dist-clean
$(MKDIR_P) nsis-dist
cp data/nsis/gsmartcontrol.nsi $(top_srcdir)/data/nsis/nsi_* nsis-dist/
cp $(top_srcdir)/data/gsmartcontrol.ico $(top_srcdir)/data/icon_*.png nsis-dist/
$(MKDIR_P) nsis-dist/doc
cp data/nsis/distribution.txt nsis-dist/doc/
cp $(top_srcdir)/AUTHORS.txt $(top_srcdir)/LICENSE_* $(top_srcdir)/README.txt nsis-dist/doc/
cp $(top_srcdir)/NEWS nsis-dist/doc/NEWS.txt
unix2dos nsis-dist/*.nsi nsis-dist/doc/*.txt
cp "@WINDOWS_BINDIR@"/smartctl-nc.exe nsis-dist/
cp "@WINDOWS_BINDIR@"/smartctl.exe nsis-dist/
cp src/gsmartcontrol.exe nsis-dist/
$(STRIP) nsis-dist/*.exe
nsis-dist: nsis-dist-nocleanup nsis-cleanup
nsis-dist-nocleanup: win-dist-prepare
cd nsis-dist && @NSIS_EXEC@ gsmartcontrol.nsi
mv nsis-dist/$(PACKAGE)-$(VERSION).exe .
nsis-cleanup:
rm -rf nsis-dist
win-zip-dist: win-zip-dist-nocleanup win-zip-dist-cleanup
win-zip-dist-nocleanup: win-dist-prepare
mv nsis-dist $(WIN_ZIP_NAME)
rm -rf $(WIN_ZIP_NAME)/gsmartcontrol.ico $(WIN_ZIP_NAME)/nsi_* $(WIN_ZIP_NAME)/*.nsi
zip -9r $(WIN_ZIP_NAME).zip $(WIN_ZIP_NAME)
win-zip-dist-cleanup:
rm -rf $(WIN_ZIP_NAME)
distclean-local: gch-clean win-dist-clean
+104
View File
@@ -0,0 +1,104 @@
Version 0.8.5, released on 2009-09-05
GSmartControl now uses XDG config directory for per-user configuration on
UNIX and CSIDL_PROFILE directory on Windows. Existing configuration is
migrated automatically.
The names are shown correctly for unsupported devices even with the latest
smartctl snapshots now.
Smartctl SVN revision is shown (if available).
The progress bars update properly when parallel tests are run.
Windows: GSmartControl should be able to operate on any valid filesystem
path (not just locale-representable ones).
Windows: GSmartControl is now officially compilable on x86_64 via mingw64.
Fixed compilation under very old gtkmm/libglademm, and with gcc 4.4.
Fixed parsing of multiple error types in SMART error log.
Added minor features and fixed miscellaneous bugs.
Version 0.8.4, released on 2009-03-23
Linux Software RAID devices are blacklisted now. (backported from Debian).
Attributes tab is before the capabilities tab now.
A man page has been generously contributed by Giuseppe Iuculano
<giuseppe@iuculano.it>.
Smartctl version now includes the CVS snapshot date (if available).
Windows: Look for "smartctl-nc.exe" instead of "smartctl.exe" by default.
Windows: Use smartmontools-supplied smartctl-nc.exe by default (if found).
Other minor changes (mainly Debian backports).
Version 0.8.3, released on 2008-12-27
A random "Smartctl returned an empty output" error on Windows was fixed.
Thanks to Zurab Khetsuriani for testing.
Fixed a parser issue which prevented running self-tests in Windows.
The supplied icon (hopefully) shows correctly in Windows 2000 now.
This release adds an official support for Windows 2000 SP4.
Added scripts to allow GSmartControl to read smartctl data from
cron-generated files. This allows users to read somewhat recent
smartctl information without having to run GSmartControl as root.
Generously contributed by Alex Butcher <alex dot butcher 'at'
assursys.co.uk>.
Configure script correctly aborts instead of printing a warning if gtkmm
or libglademm (if needed) is not found.
Configure script now accepts --enable-windows-console,
--disable-abort-if-no-gtkmm, --disable-abort-if-no-glade-reader,
as well as Windows-supporting "auto" for --enable-nsis-wine and
--with-nsis.
Configure's --with-win32-env has been renamed to --with-windows-dlls.
The "About" dialog shows version information now.
Minor bugs were fixed.
Version 0.8.2, released on 2008-12-10
Fixed gsmartcontrol_root.sh script to support distributions with no
/usr/sbin in their users' paths (thanks to Erwan Velu).
Added desktop auto-detection to gsmartcontrol_root.sh script. This allows
us to use only one desktop file (thanks to Erwan Velu).
Added Debian package directory (named "debian.dist" for now to avoid
control file conflicts with Build Service).
Renamed gsmartcontrol_root.sh to gsmartcontrol-root, to make Debian happy.
Added make targets for Windows packages (zip and NSIS).
Fixed Windows-related issues (Vista is fully supported now).
Fixed minor bugs:
Smartctl parser is win32-locale-aware now.
No more unnecessary parsing.
No segfault on exit under Windows and Solaris.
A friendlier message is displayed if smartctl was not found.
No highlighted labels when switching tabs in Information window.
Version 0.8.1, released on 2008-11-11
Disabled Linux "by-id" drive detection - it's unreliable on some broken
systems.
Added some more attribute descriptions.
Our names for attributes override smartctls' now.
Added a proper "Add Device" dialog for Windows.
Added an icon and resource file for Windows.
Fixed minor bugs.
Version 0.8.0rc4, released on 2008-10-20
FreeBSD support (tested with DesktopBSD 1.6 (FreeBSD 6.3) / x86).
NetBSD support (tested with NetBSD 4.0.1 / x86).
OpenBSD support (tested with OpenBSD 4.3 / x86-64 / gcc-3.3.5).
Solaris/gcc support (tested with Solaris 10 / x86 / gcc-3.4.3 / blastwave).
Solaris/sunstudio support (tested with Solaris 10 / x86 / sunstudio12 /
sunfreeware).
Code to support Windows, Mac OS X, QNX.
Support of older pcre versions (at least 4.5, maybe older too).
Added gsmartcontrol_root.sh script to easily run gsmartcontrol as root.
Improved .desktop files.
License for tests and examples is legally more correct now.
Minor bugfixes.
Version 0.8.0rc3, released on 2008-10-08
Added support for udevless Linux distributions by providing a fallback
/proc/partitions-based drive detection method. The new method adds
support for Linux 2.4 and older systems. Thanks to Paul Marwick for
reporting and testing.
Fixed invalid error messages with directory-related operations.
Fixed invalid verbosity levels of console output of debug messages in
non-debug builds.
Improved rpm spec file - now supports building on OpenSUSE build
service with various distributions as targets.
Version 0.8.0rc2, released on 2008-10-05
Fixed compilation under gcc 4.3. Thanks to Peter Linnell for reporting.
Removed test data (there's a lot of it and it's unnecessary).
Version 0.8.0rc1, released on 2008-10-01
Initial public release.
+168 -64
View File
@@ -10,34 +10,40 @@ Technology) data on modern hard disk drives. It allows you to inspect the
drive's SMART data to determine its health, as well as run various tests on
it.
Note: Only ATA drives (both PATA and SATA) are supported for now.
Note: Only ATA drives (both PATA and SATA) and various USB to ATA bridges are
supported for now.
http://gsmartcontrol.berlios.de
Features
Automatically report and hilight any abnormal SMART information.
* automatically reports and highlights any anomalies;
Ability to enable / disable SMART.
* allows enabling/disabling SMART;
Ability to enable / disable Automatic Offline Data Collection - A short
* allows enabling/disabling Automatic Offline Data Collection - a short
self-check that the drive will perform automatically every four hours with no
impact on performance.
impact on performance;
Ability to set global and per-drive options for smartctl.
* supports configuration of global and per-drive options for smartctl;
Display drive identity, capabilities, attributes, error and self-test logs.
* performs SMART self-tests;
Perform SMART self-tests.
* displays drive identity information, capabilities, attributes, and
self-test/error logs;
Ability to load smartctl output as a "virtual" device, which acts just like a
real (read-only) device.
* can read in smartctl output from a saved file, interpreting it as a
read-only virtual device;
Extensive help information.
* works on most smartctl-supported operating systems;
* has extensive help information.
What is SMART?
What Is SMART?
Short answer: SMART is a technology which provides hard disk drives with
methods to predict certain kinds of failures with certain chance of success.
@@ -56,7 +62,7 @@ the drive is idle, and repair the defects, reallocating the data to more safe
areas.
While having SMART sounds really good, there are some nuances to consider. One
of the commond pitfalls is that it may create a false sense of security. That
of the common pitfalls is that it may create a false sense of security. That
is, a perfectly good SMART data is NOT an indication that the drive won't fail
the next minute. The reverse is also true - some drives may function perfectly
even with not-so-good-looking SMART data. However, as studies indicate, given
@@ -84,8 +90,6 @@ these bugs and works around them.
Software Requirements
So far, only Linux 2.6 systems are supported.
You need to have the following software installed:
* pcre - http://www.pcre.org .
@@ -97,43 +101,132 @@ You need to have the following software installed:
* Gtkmm, version 2.6 or higher - see http://www.gtkmm.org .
* libglademm, version 2.4 or higher - see http://www.gtkmm.org .
libglademm is not needed when using GTK 2.12 and Gtkmm 2.12.
Note: libglademm is not needed when using GTK 2.12 and Gtkmm 2.12.
Note that GTK+ 2.12 and Gtkmm 2.12 are HIGHLY recommended. While earlier
versions may work, they may produce ugly results and buggy behaviour.
Note that having GTK+ 2.12 and Gtkmm 2.12 is HIGHLY recommended. While earlier
versions may work, they may produce suboptimal results and buggy behavior.
Libglademm is not needed when using GTK / Gtkmm 2.12.
Most of these packages are probably already provided by your distribution. For
example, to build this program on OpenSUSE, you just need to install
smartmontools, gtkmm2-devel and pcre-devel - the rest is installed
automatically by the package manager's dependency resolver.
Most of these packages are probably already provided by your distribution.
Here are the packages you need to have to build GSmartControl on some Linux
distributions:
openSUSE, SLES, SLED:
gcc-c++, pcre-devel, gtkmm2-devel, (possibly) libglademm-devel.
Fedora, CentOS, RHEL:
gcc-c++, pcre-devel, gtkmm24-devel, (possibly) libglademm24-devel.
Mandriva:
gcc-c++, gcc-cpp, libpcre-devel, gtkmm2.4-devel, (possibly)
libglademm2.4-devel.
Ubuntu, Debian GNU/Linux:
g++, libpcre3-dev, libgtkmm-2.4-dev, (possibly) libglademm-2.4-dev.
Note that usually you need to specify only these packages - the rest is
installed automatically by the package manager's dependency resolver. Keep in
mind that you also need smartmontools to run the program.
Note: If using the official Windows package, the requirements are listed on
GSmartControl's website.
The following operating systems are supported:
* Linux - All the popular configurations should work.
* FreeBSD - Tested with DesktopBSD 1.6 (FreeBSD 6.3) / x86.
* NetBSD - Tested with NetBSD 4.0.1 / x86.
* OpenBSD - Tested with OpenBSD 4.3 / x86-64 / gcc-3.3.5.
* Windows (2000 SP4 or newer) - Tested with Windows 2000 SP4, XP SP2 and Vista
SP1. The Windows port uses pd0, pd1, etc... for physical drives 0, 1, etc... .
* Solaris - Tested with Solaris 10 / x86 / gcc-3.4.3 / blastwave,
Solaris 10 / x86 / sunstudio12 / sunfreeware. OpenSolaris should work but has
not been tested yet. Note: smartctl doesn't seem to support ATA under Solaris,
while GSmartControl doesn't support SCSI yet. This only leaves various USB to
ATA bridges. See smartctl (5), -d option for details.
* Mac OS X - 3rd-party testing by Fink project.
* DragonFlyBSD - Code written but no testing has been performed yet. Expected
to work without any issues.
* QNX - Code written but no testing has been performed yet.
Installation
Short answer: ./configure; make; make install
Short answer: build and install via: ./configure; make; make install
Run gsmartcontrol-root to invoke gsmartcontrol with your desktop's su
mechanism, or use the desktop menu entry.
Long answer: read below.
First, check if you can find a pre-built package for your distribution or
operating system - they usually provide the best integration and the easiest
installation procedure.
installation procedure. For Linux, one option is to try the openSUSE Build
Service - it provides ready-to-install packages for various popular Linux
distributions (openSUSE, Fedora, etc...). See
http://download.opensuse.org/repositories/home:/alex_sh/ .
If you want to compile from source, check that you have all the required
dependencies (see Software Requirements section). Then the usual
./configure; make; make install
will build and install it. Installation usually requires root privileges, but
you don't need to install the program in order to run it directly from the
compilation directory.
will build and install it. Installation usually requires administrative
privileges, but you don't need to install the program in order to run it
directly from the build directory.
Command Line Options
GSmartControl inherits options from GTK+ and other libraries, so be sure to
run it with --help option to get a full list of accepted parameters.
Note: The Windows version may not have a text output at all, so --help and
similar arguments won't have any effect. However, --verbose will still
increase the verbosity of a log saved via "Options -> View Execution Log ->
Save All".
The most important parameters are:
-?, --help - Show help options.
-V, --version - Display version information.
-l, --no-locale - Disable locale.
--no-scan - Don't scan devices on startup.
--no-hide-tabs - Don't hide non-identity tabs when SMART is disabled.
--add-virtual - Load smartctl data from file, creating a virtual drive.
--add-device - Add this device to device list. Useful with --no-scan to list
certain drives only.
-v, --verbose - Enable verbose logging; same as --verbosity-level 5.
-q, --quiet - Disable logging; same as --verbosity-level 0.
-b, --verbosity-level - Set verbosity level [0-5].
Permission Problems
Short answer: you need to be root. In X11, use kdesu, gnomesu, sux or similar.
Short answer: you need to be root (that's Administrator in Windows).
In X11, use kdesu, gnomesu, sux, xdg-su or similar.
Long answer: read below.
@@ -141,29 +234,25 @@ Most operating systems prohibit direct access to hardware to users with
non-administrative privileges. Unfortunately, to access SMART data, smartctl
needs to directly access the hard drive.
The provided desktop and menu icons should show the "Please enter the root
The provided X11 desktop and menu icons should show the "Please enter the root
password" dialog boxes, and, after correct information is entered, should run
this program with root privileges. The dialogs should be available in most
commonly used X11 desktop environments.
However, in case the described method is somehow inaccessible, you need to
manually invoke the program with kdesu, gnomesu, sux or similar programs. For
example,
Another way is to use the included gsmartcontrol-root script, which finds the
available su program and runs gsmartcontrol with it.
Yet another way is to manually invoke the program with kdesu, gnomesu, sux or
similar programs. For example,
kdesu -u root -c gsmartcontrol
will ask for root password and run gsmartcontrol with root privileges. Replace
"kdesu" with "gnomesu" if using Gnome. The "sux" command may also help, if
neither KDE or GNOME are available.
"kdesu" with "gnomesu" if using Gnome. The "sux" or "xdg-su" commands may also
help, if neither KDE or GNOME are available.
Another method would be to set the "setuid" flag on smartctl binary, for
example (run as root):
chmod 4755 `which smartctl`
This method is not recommended, however, and is considered a security risk.
Also, some systems may reset the change automatically, unless explicitly
instructed otherwise.
Please don't set the "setuid" flag on smartctl binary. It is considered a
security risk.
@@ -181,9 +270,10 @@ previously, it will be re-enabled on reboot.
The easiest way to work around this is to set the desired settings on system
startup. You may use smartctl or smartd to do that. For example, to enable
both SMART and Automatic Offline Data Collection on /dev/sda, one would write
the following to his/her boot.local, rc.local or similar:
the following to the system startup script (e.g. boot.local, rc.local or
similar on Linux):
smartctl --smart=on --offlineauto=on /dev/sda
smartctl -s on -o on /dev/sda
For more information, see smartctl and smartd documentation.
@@ -191,12 +281,12 @@ For more information, see smartctl and smartd documentation.
Known Issues
Only ATA (both PATA and SATA) disks are supported for now. The main reasons
are:
Only ATA drives (both PATA and SATA) and various USB to ATA bridges are
supported for now. The main reasons are:
* We can't support drives which don't work with smartmontools. This affects
drives which don't support SMART or don't export SMART data correctly (e.g.
USB enclosures, RAIDs, etc...).
some USB enclosures, RAIDs, etc...).
* Smartctl's output for SCSI drives is completely different compared to ATA.
Also, SCSI drives are rarely found in desktop systems and the servers rarely
@@ -205,19 +295,14 @@ have X11 / Gtkmm running, so this is a low priority task.
* I only have ATA drives, so testing would be almost impossible.
Immediate Offline Tests are not supported. I haven't found a way to reliably
monitor them.
You may run several tests on different drives in parallel, but you will only
see the progress information of the last executing test. So, if you run tests
on drives A, B and C (in that order), you won't be able to monitor the tests
on A and B until C completes. And you won't be able to see any progress on A
until both B and C complete their tests.
monitor them yet. Besides, they run automatically anyway if Automatic Offline
Data Collection is enabled.
Testing is only supported on drives which correctly report their progress
information in capabilities.
Not all drives support disabling Automatic Offline Data Collection, even if
they report otherwise.
they report otherwise. Unfortunately, there's no way to detect such drives.
Running on GTK+ / Gtkmm versions earlier than 2.12 may cause visual artifacts,
usability issues (especially with tooltips and icons), instability, etc...
@@ -229,19 +314,38 @@ language and all.
Reporting Bugs
First, please collect the following information about your system. Without it
it may be very hard or impossible to fix the bug.
If it is a SMART or drive-related problem, please try to test it with smartctl
first. Chances are, the problem you're experiencing is not tied to
GSmartControl, but is a drive firmware or smartctl problem. For example, to
see a complete information about your /dev/sda drive, type the following in a
terminal emulator (e.g., xterm, konsole or gnome-terminal):
* Which operating system you use (for example, OpenSUSE Linux 11.0).
smartctl -a /dev/sda
* What version of GTK and Gtkmm you have installed. Finding this out is very
distribution-specific. For example, on OpenSUSE it would be
Note: If using Windows, the device name should be /dev/pd1 for the second
physical drive, etc... .
If you still think it's a GSmartControl issue, please collect the following
information about your system. Without it, it may be very hard or impossible
to fix the bug.
* Which operating system you use (for example, openSUSE Linux 11.0).
* Which version of GTK and Gtkmm you have installed. Finding this out is very
distribution-specific. For example, on openSUSE it would be
"rpm -q gtk2 gtkmm2". Some distributions have gtkmm24 instead. You may also
search them in your distribution's graphical package manager, if there is one.
* Execution log from the program, if possible. To obtain it, perform the steps
needed to reproduce the bug, then go to "Options -> View Execution Log", and
press "Save All".
* Execution log from the program, if possible. To obtain it, run the program
with -v option, e.g. (type the following in a terminal emulator or Run
dialog):
gsmartcontrol-root auto -v
Note: On Windows, run gsmartcontrol.exe with "-v" switch as Administrator.
Perform the steps needed to reproduce the bug, then go to
"Options -> View Execution Log", and click "Save All".
* Detailed description of steps you performed when the bug occurred.
@@ -262,7 +366,7 @@ For license information, see LICENSE_gsmartcontrol.txt file.
You may notice that GSmartControl is not licensed under "GNU GPL version X or
later", but under "GNU GPL version X and Y". I firmly believe that it's unwise
to license a piece of code under non-existant licenses, whatever anyone else
to license a piece of code under non-existent licenses, whatever anyone else
might say. The reason for this is that one simply CANNOT know that, say, in 20
years FSF won't be bought by some corporation who will release GPL version Z
which will completely reverse the reasons GPL was created for.
+57 -25
View File
@@ -16,44 +16,77 @@ local scope destruction also works if using stack variables.
A treeview (also iconview, combobox) from glade comes
with existing model, which should be unset
with existing model, which should be unset.
--------------------------------------------------------
GTKMM problems:
no pango_parse_markup:
gchar* no_markup = 0;
if (pango_parse_markup(markup_string, -1, 0, NULL, &no_markup, NULL, NULL)) {
// use no_markup
g_free(no_markup);
}
Lots of gtk_, GTK_, g_ in documentation.
no unset_model() on combobox and iconview.
--------------------------------------------------------
TODO:
if -q is passed, Execution log doesn't contain libdebug log. fix.
Drive detection - any cross-platform way to do it?
Support Areca controller.
When adding device, have an option to specify "-d" type and other parameters.
This is needed to support multi-disk devices.
Patch pangomm for Pango::strip_markup().
No Gtk::AboutDialog::set_logo(NULL);
libdebug:
per-channel disabling.
per-channel formatting.
all flags should be per-channel.
bug: if -q is passed, Execution log doesn't contain libdebug log. (requires per-channel status control).
use format_time() instead of ctime() and friends, with ISO formatting.
'-l sataphy' -> SATA Phy event counters: Non-SMART feature, useful to detect SATA cabling problems.
'-l xerror' -> Extended Comprehensive Error log: An multi-sector and
LBA48 capable version of '-l error'. Output is similar, except more
entries can exists and the high bytes of the registers are also printed.
Some newer drives (Samsung) only write to this log.
'-l scttemp' -> SCT Temperature history table. See below.
'-l xselftest' -> Extended Self Test Log: An multi-sector and LBA48
capable version of '-l selftest'. Output will be similar, except more
entries can exists and the LBA values can be somewhat longer.
"smartctl -l this_wont_exist" gives the list of supported logs - this
is needed to detect xerror / xselftest support in smartctl.
Careful with GPL (xerror...) stuff until the jmicron situation clears up.
Add detection for Interix (i586-pc-interix3), maybe with debian?
Re-check long double printing - win32 libc doesn't support it, a cast
to double is needed.
The underlying problem is that in msvc, long double is the same size
as double, so printf() has mingw-incompatible presentation of long double.
Support USB flash disks in CVS smartctl versions:
Try smartctl -i /dev/sdc;
If it returns "Smartctl: please specify device type with the -d option.",
try "-d scsi", which should at least give us the name.
Maybe make it easier to specify "-d" (with a dropdown?)
Not sure, "-l aaa /tmp" doesn't list all types.
----------- Feature List ----------
+Autodetect available devices (through /proc / /sys ?).
win32 support for autodetection (what about different smartctl drivers?).
+Autodetect available devices
+Select current device (from autodetected list; manually whitelist devices).
@@ -84,7 +117,6 @@ Drive detection - any cross-platform way to do it?
+ * Selective self-test log and settings
* SCT status and other stuff
Display temperature somewhere (use SCT or Attr 194 for this).
Which one is updated more frequently, SCT or attr 194?
+ * Ability to save this information to a file.
+ * On info window show: Ask to turn SMART on if it's disabled
@@ -94,13 +126,13 @@ Drive detection - any cross-platform way to do it?
+ smartctl exited with error - look it up in error map.
SCT Temperatures (do we use these?)
SCT Temperatures
-l scttemp prints temperature and history.
-t scttempint,N[,p] (N - count, p - preserve across reset or not).
This configures temperature logging interval (1 min by default) and clears the history.
Tests:
+Tests:
Ability to detect a testing drive on boot, show its info with testing tab.
Run one-time Immediate Offline test (-t offline).
@@ -26,12 +26,23 @@
AC_DEFUN([AC_CXX_EXCEPTIONS],
[AC_CACHE_CHECK(whether the compiler supports exceptions,
ac_cv_cxx_exceptions,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[try { throw 1; } catch (int i) { return i; }]])],[ac_cv_cxx_exceptions=yes],[ac_cv_cxx_exceptions=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_exceptions" = yes; then
AC_DEFINE(HAVE_EXCEPTIONS,,[define if the compiler supports exceptions])
fi
ac_cv_cxx_exceptions,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[try { throw 1; } catch (int i) { return i; }]])],
[ac_cv_cxx_exceptions=yes], [ac_cv_cxx_exceptions=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_exceptions" = yes; then
AC_DEFINE(HAVE_EXCEPTIONS, 1,
[defined to 1 if the compiler supports exceptions, 0 otherwise])
else
AC_DEFINE(HAVE_EXCEPTIONS, 0,
[defined to 1 if the compiler supports exceptions, 0 otherwise])
fi
])
@@ -26,12 +26,22 @@
AC_DEFUN([AC_CXX_NAMESPACES],
[AC_CACHE_CHECK(whether the compiler implements namespaces,
ac_cv_cxx_namespaces,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[namespace Outer { namespace Inner { int i = 0; }}]], [[using namespace Outer::Inner; return i;]])],[ac_cv_cxx_namespaces=yes],[ac_cv_cxx_namespaces=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
fi
ac_cv_cxx_namespaces,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[namespace Outer { namespace Inner { int i = 0; }}]],
[[using namespace Outer::Inner; return i;]])],
[ac_cv_cxx_namespaces=yes], [ac_cv_cxx_namespaces=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES, 1,
[defined to 1 if the compiler implements namespaces, 0 otherwise])
else
AC_DEFINE(HAVE_NAMESPACES, 0,
[defined to 1 if the compiler implements namespaces, 0 otherwise])
fi
])
@@ -26,25 +26,35 @@
AC_DEFUN([AC_CXX_RTTI],
[AC_CACHE_CHECK(whether the compiler supports Run-Time Type Identification,
ac_cv_cxx_rtti,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
class Base { public :
Base () {}
virtual int f () { return 0; }
};
class Derived : public Base { public :
Derived () {}
virtual int f () { return 1; }
};
]], [[Derived d;
Base *ptr = &d;
return typeid (*ptr) == typeid (Derived);
]])],[ac_cv_cxx_rtti=yes],[ac_cv_cxx_rtti=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_rtti" = yes; then
AC_DEFINE(HAVE_RTTI,,
[define if the compiler supports Run-Time Type Identification])
fi
ac_cv_cxx_rtti,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
class Base {
public:
Base () {}
virtual int f () { return 0; }
};
class Derived : public Base {
public :
Derived () {}
virtual int f () { return 1; }
};
]], [[
Derived d;
Base* ptr = &d;
return typeid (*ptr) == typeid (Derived);
]])],
[ac_cv_cxx_rtti=yes], [ac_cv_cxx_rtti=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_rtti" = yes; then
AC_DEFINE(HAVE_RTTI, 1,
[defined to 1 if the compiler supports Run-Time Type Identification, 0 otherwise])
else
AC_DEFINE(HAVE_RTTI, 0,
[defined to 1 if the compiler supports Run-Time Type Identification, 0 otherwise])
fi
])
@@ -25,16 +25,25 @@
AC_DEFUN([AC_CXX_VERBOSE_TERMINATE_HANDLER],
[AC_CACHE_CHECK(whether the compiler has __gnu_cxx::__verbose_terminate_handler,
ac_cv_verbose_terminate_handler,
[
AC_REQUIRE([AC_CXX_EXCEPTIONS])
AC_REQUIRE([AC_CXX_NAMESPACES])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <exception>]], [[std::set_terminate(__gnu_cxx::__verbose_terminate_handler);]])],[ac_cv_verbose_terminate_handler=yes],[ac_cv_verbose_terminate_handler=no
])
AC_LANG_POP([])
])
if test "$ac_cv_verbose_terminate_handler" = yes; then
AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, , [define if the compiler has __gnu_cxx::__verbose_terminate_handler])
fi
ac_cv_verbose_terminate_handler,
[
AC_REQUIRE([AC_CXX_EXCEPTIONS])
AC_REQUIRE([AC_CXX_NAMESPACES])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <exception>]],
[[std::set_terminate(__gnu_cxx::__verbose_terminate_handler);]])],
[ac_cv_verbose_terminate_handler=yes], [ac_cv_verbose_terminate_handler=no])
AC_LANG_POP([])
])
if test "$ac_cv_verbose_terminate_handler" = yes; then
AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, 1,
[defined to 1 if the compiler has __gnu_cxx::__verbose_terminate_handler, 0 otherwise])
else
AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, 0,
[defined to 1 if the compiler has __gnu_cxx::__verbose_terminate_handler, 0 otherwise])
fi
])
+34
View File
@@ -0,0 +1,34 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_AUTO_CLEAR_FLAGS()
# Clear user-specified CFLAGS / CXXFLAGS / LIBS / LDFLAGS if requested.
# You should call this macro before any of AC_PROG_C(XX) checks to
# avoid checking with user-specified options.
AC_DEFUN([APP_AUTO_CLEAR_FLAGS], [
AC_ARG_ENABLE(user-flags, AS_HELP_STRING([--disable-user-flags],
[ignore user-supplied compiler flags (default: user flags are enabled)]),
[app_cv_compiler_user_flags=${enableval}], [app_cv_compiler_user_flags=yes])
AC_MSG_NOTICE([Enable user-specified compiler flags: $app_cv_compiler_user_flags])
# Reset user-supplied flags if requested.
if test "x$app_cv_compiler_user_flags" = "xno"; then
CFLAGS="";
CXXFLAGS="";
LIBS="";
LDFLAGS="";
fi
])
+157
View File
@@ -0,0 +1,157 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_CHOOSE_GLD_READER([C|C++][, flags_prefix])
# This macro detects whether GtkBuilder (from gtk >= 2.12) or libglade
# are present. If the first parameter is C++, then gtkmm and libglademm
# are searched for instead.
# flags_prefixCFLAGS, flags_prefixCXXFLAGS and flags_prefixLIBS
# will be initialized (or appended to) with the correct flags in case of libglade(mm).
# app_cv_gld_reader will be set to none, libglade or gtkbuilder.
# ENABLE_LIBGLADE or ENABLE_GTKBUILDER will be exported to config.h
# You must call AX_COMPILER_VENDOR before using this macro.
AC_DEFUN([APP_CHOOSE_GLD_READER], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_ARG_ENABLE(abort-if-no-glade-reader, AS_HELP_STRING([--disable-abort-if-no-glade-reader],
[disable abort if no glade file reader is found (default: configure aborts when glade file reader is not found)]),
[app_cv_abort_if_no_glade_reader=${enableval}], [app_cv_abort_if_no_glade_reader=yes])
AC_MSG_NOTICE([Abort if no glade file reader is found: $app_cv_abort_if_no_glade_reader])
# This is just in case
# PKG_PROG_PKG_CONFIG()
# this variable will have values "none", "libglade" or "gtkbuilder".
app_cv_gld_reader="none";
# in case libglade(mm) is found, these will contain the flags.
app_cv_gld_reader_CFLAGS="";
app_cv_gld_reader_CXXFLAGS="";
app_cv_gld_reader_LIBS="";
app_cv_gld_reader_libglade_name="libglade";
app_cv_gld_reader_libglade_pkg_name="libglade-2.0";
app_cv_gld_reader_gtk_name="gtk";
app_cv_gld_reader_gtk_pkg_name="gtk+-2.0";
if test "x$1" = "xC++"; then
app_cv_gld_reader_libglade_name="libglademm";
app_cv_gld_reader_libglade_pkg_name="libglademm-2.4";
app_cv_gld_reader_gtk_name="gtkmm";
app_cv_gld_reader_gtk_pkg_name="gtkmm-2.4";
fi
# Manual control. AC_ARG_ENABLE doesn't get bash variables, so we have
# to do it this way. If put inside a shell conditional, it still shows up in configure help.
AC_ARG_ENABLE(libglade, AS_HELP_STRING([--enable-libglade],
[use libglade(mm) instead of GtkBuilder (default: auto)]),
[with_libglade=${enableval}], [with_libglade=auto])
# Try gtkbuilder first
if test "x$with_libglade" = "xno" || test "x$with_libglade" = "xauto"; then
PKG_CHECK_EXISTS([$app_cv_gld_reader_gtk_pkg_name >= 2.12.0],
[app_cv_gld_reader="gtkbuilder"])
fi
if test "$with_libglade" = "no" && test "$app_cv_gld_reader" = "none"; then
AC_MSG_ERROR([GtkBuilder support not found (you need $app_cv_gld_reader_gtk_name version 2.12 or higher). Try using $app_cv_gld_reader_libglade_name instead.])
fi
# libglade specified, or auto and no gtkbuilder. gtkmm2.4-compatible libglademm is >= 2.4.0.
# (not sure about libglade version).
if test "x$app_cv_gld_reader" = "xnone"; then
if test "x$app_cv_gld_reader_libglade_name" = "xlibglade"; then
# libglade
PKG_CHECK_MODULES([LIBGLADE], [$app_cv_gld_reader_libglade_pkg_name >= 2.4.0],
[app_cv_gld_reader="libglade"], [AC_MSG_WARN([$LIBGLADE_PKG_ERRORS])])
app_cv_gld_reader_CFLAGS="$LIBGLADE_CFLAGS";
app_cv_gld_reader_CXXFLAGS="$LIBGLADE_CFLAGS";
app_cv_gld_reader_LIBS="$LIBGLADE_LIBS";
else
# libglademm
PKG_CHECK_MODULES([LIBGLADEMM], [$app_cv_gld_reader_libglade_pkg_name >= 2.4.0],
[app_cv_gld_reader="libglade"], [AC_MSG_WARN([$LIBGLADEMM_PKG_ERRORS])])
app_cv_gld_reader_CFLAGS=""
app_cv_gld_reader_CXXFLAGS="$LIBGLADEMM_CFLAGS";
app_cv_gld_reader_LIBS="$LIBGLADEMM_LIBS";
fi
# reset them so they don't interfere later
LIBGLADE_CFLAGS="";
LIBGLADE_LIBS="";
fi
if test "x$with_libglade" = "xyes" && test "x$app_cv_gld_reader" = "xnone"; then
AC_MSG_ERROR([$app_cv_gld_reader_libglade_name not found. Try building with GtkBuilder support (you need $app_cv_gld_reader_gtk_name version 2.12 or higher).])
fi
# still not found.
if test "$app_cv_gld_reader" = "none"; then
if test "x$app_cv_abort_if_no_glade_reader" = "xno"; then
AC_MSG_WARN([$LIBGLADE_PKG_ERRORS])
AC_MSG_WARN([Neither GtkBuilder nor $app_cv_gld_reader_libglade_name found. The program will be unable to compile fully.])
else
AC_MSG_WARN([Neither GtkBuilder nor $app_cv_gld_reader_libglade_name found.])
AC_MSG_ERROR([$LIBGLADE_PKG_ERRORS])
fi
fi
# export the flags
if test "x$2" != "x"; then
if test "x$$2[]CFLAGS" = "x"; then
$2[]CFLAGS="$app_cv_gld_reader_CFLAGS";
else
$2[]CFLAGS="$$2[]CFLAGS $app_cv_gld_reader_CFLAGS";
fi
if test "x$$2[]CXXFLAGS" = "x"; then
$2[]CXXFLAGS="$app_cv_gld_reader_CXXFLAGS";
else
$2[]CXXFLAGS="$$2[]CXXFLAGS $app_cv_gld_reader_CXXFLAGS";
fi
if test "x$$2[]LIBS" = "x"; then
$2[]LIBS="$app_cv_gld_reader_LIBS";
else
$2[]LIBS="$$2[]LIBS $app_cv_gld_reader_LIBS";
fi
fi
# export to automake.am-s
AM_CONDITIONAL([ENABLE_LIBGLADE], [test "$app_cv_gld_reader" = "libglade"])
AM_CONDITIONAL([ENABLE_GTKBUILDER], [test "$app_cv_gld_reader" = "gtkbuilder"])
# export to config.h
if test "$app_cv_gld_reader" = "libglade"; then
AC_DEFINE(ENABLE_LIBGLADE, 1, [Use libglade(mm) instead of GtkBuilder])
else
AC_DEFINE(ENABLE_LIBGLADE, 0, [Use libglade(mm) instead of GtkBuilder])
fi
if test "$app_cv_gld_reader" = "gtkbuilder"; then
AC_DEFINE(ENABLE_GTKBUILDER, 1, [Use GtkBuilder instead of libglademm])
else
AC_DEFINE(ENABLE_GTKBUILDER, 1, [Use GtkBuilder instead of libglademm])
fi
# If we move this to the start, some messages get in between, so we have to have it here.
AC_MSG_CHECKING([for glade file support])
AC_MSG_RESULT([$app_cv_gld_reader])
])
+286
View File
@@ -0,0 +1,286 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_COMPILER_OPTIONS([flags_prefix])
# This macro enables various compiler flags (common warnings, optimization,
# debug, etc...), controllable through configure options.
# flags_prefixCFLAGS, flags_prefixCXXFLAGS and flags_prefixLDFLAGS
# will be initialized (or appended to) with the results.
# DEBUG and DEBUG_BUILD will be exported to config.h in case of debug builds.
# You must call AX_COMPILER_VENDOR, APP_DETECT_OS_KERNEL([target], ...)
# and APP_DETECT_OS_ENV([target], ...) before using this macro.
AC_DEFUN([APP_COMPILER_OPTIONS], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([APP_DETECT_OS_ENV])
app_cv_compiler_options_cflags="";
app_cv_compiler_options_cxxflags="";
app_cv_compiler_options_ldflags="";
# ---- Common compiler options (warnings, etc...)
AC_ARG_ENABLE(common-options, AS_HELP_STRING([--enable-common-options=<compiler>|auto|none],
[enable useful compilation options (warnings, mostly). Accepted values are auto, none, gnu, intel, sun. (Default: auto)]),
[app_cv_compiler_common_options=${enableval}], [app_cv_compiler_common_options=auto])
# the default value is "yes" (if no value given after =), treat it as auto.
if test "x$app_cv_compiler_common_options" = "xyes" || test "x$app_cv_compiler_common_options" = "xauto"; then
app_cv_compiler_common_options="$ax_cv_cxx_compiler_vendor";
fi
if test "x$app_cv_compiler_common_options" = "xno"; then
# for pretty message
app_cv_compiler_common_options="none";
fi
AC_MSG_NOTICE([Enable common compiler flags for: $app_cv_compiler_common_options])
if test "x$app_cv_compiler_common_options" != "xnone"; then
# gcc / gnu environment, mingw, cygwin.
if test "x$app_cv_compiler_common_options" = "xgnu"; then
if test "x$app_cv_target_os_env" = "xmingw32" || test "x$app_cv_target_os_env" = "xmingw64" \
|| test "x$app_cv_target_os_env" = "xcygwin"; then
# mingw gcc options:
# -mno-cygwin - generate non-cygwin executables in cygwin's mingw.
# -mms-bitfields - make structures compatible with msvc. recommended default for non-cygwin.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -mms-bitfields"
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -mms-bitfields"
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mms-bitfields"
fi
# Note: Disabled -Wconversion, it was causing lots of silly warnings under x86-64.
app_cv_compiler_tmp_var="-Wall -Wcast-align -Wcast-qual -Wconversion \
-Wctor-dtor-privacy -Wfloat-equal -Wnon-virtual-dtor -Woverloaded-virtual \
-Wpointer-arith -Wshadow -Wsign-compare -Wsign-promo -Wundef -Wwrite-strings";
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags $app_cv_compiler_tmp_var";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags $app_cv_compiler_tmp_var";
# intel / gnu environment
elif test "x$app_cv_compiler_common_options" = "xintel" && test "x$app_cv_target_os_env" = "xgnu"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -w1";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags \
-ftrapuv -fstack-security-check -early-template-check -static-libgcc -static-intel \
-Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wmissing-prototypes -Wnon-virtual-dtor \
-Wpointer-arith -Wreturn-type -Wshadow -Wtrigraphs -Wuninitialized -w1";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -static-libgcc -static-intel";
# suncc
elif test "x$app_cv_compiler_common_options" = "xsun"; then
# Enable useful language extensions (e.g. __func__ in C++). Details at
# http://docs.sun.com/app/docs/doc/820-7599/bkapy?a=view
# Additional options: "-staticlib=Crun -staticlib=Cstd" - link statically to
# C++ runtime and standard libraries.
# http://docs.sun.com/app/docs/doc/820-7599/bkaws?a=view
# STLport seems to be more standards-compliant, but incompatible
# with default Cstd. Also, it's not guaranteed to keep compatibility
# between versions. Select it with "-library=stlport4".
# http://docs.sun.com/app/docs/doc/820-7599/bkakg?a=view
# http://developers.sun.com/solaris/articles/cmp_stlport_libCstd.html
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags \
+w -errtags -erroff=notemsource,notused -features=extensions";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags \
+w -errtags -erroff=notemsource,notused -features=extensions";
fi
fi
# ---- Compiler options for debug builds
AC_ARG_ENABLE(debug-options, AS_HELP_STRING([--enable-debug-options=<compiler>|auto|none],
[enable debug build options. Accepted values are auto, none, gnu, intel, sun. (Default: none)]),
[app_cv_compiler_debug_options=${enableval}], [app_cv_compiler_debug_options=none])
# the default value is "yes" (if no value given after =), treat it as auto.
if test "x$app_cv_compiler_debug_options" = "xyes" || test "x$app_cv_compiler_debug_options" = "xauto"; then
app_cv_compiler_debug_options="$ax_cv_cxx_compiler_vendor";
fi
if test "x$app_cv_compiler_debug_options" = "xno"; then
# for pretty message
app_cv_compiler_debug_options="none";
fi
AC_MSG_NOTICE([Enable debug build flags for: $app_cv_compiler_debug_options])
if test "x$app_cv_compiler_debug_options" != "xnone"; then
# Define DEBUG and DEBUG_BUILD for debug builds (through config.h).
AC_DEFINE([DEBUG], [1], [Defined for debug builds])
AC_DEFINE([DEBUG_BUILD], [1], [Defined for debug builds])
# gcc, mingw
if test "x$app_cv_compiler_debug_options" = "xgnu"; then
# We could put libstdc++ debug options here, but it generates binary-incompatible
# C++ code, which leads to runtime errors with e.g. libsigc++.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g3 -O0";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g3 -O0";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g3 -O0";
# intel / gnu
elif test "x$app_cv_compiler_debug_options" = "xintel" && test "x$app_cv_target_os_env" = "xgnu"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g3 -O0";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g3 -O0";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g3 -O0";
# suncc
elif test "x$app_cv_compiler_debug_options" = "xsun"; then
# There's no -O0, it's the default. Debug format is stabs by default, but can be switched
# to dwarf by -xdebugformat=dwarf.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -xs -g";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -xs -g";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -xs -g";
fi
fi
# ---- Compiler options for optimized builds
AC_ARG_ENABLE(optimize-options, AS_HELP_STRING([--enable-optimize-options=<compiler>|auto|none],
[enable optimized build options. Accepted values are auto, none, gnu, intel, sun. (Default: none)]),
[app_cv_compiler_optimize_options=${enableval}], [app_cv_compiler_optimize_options=none])
# the default value is "yes" (if no value given after =), treat it as auto.
if test "x$app_cv_compiler_optimize_options" = "xyes" || test "x$app_cv_compiler_optimize_options" = "xauto"; then
app_cv_compiler_optimize_options="$ax_cv_cxx_compiler_vendor";
fi
if test "x$app_cv_compiler_optimize_options" = "xno"; then
# for pretty message
app_cv_compiler_optimize_options="none";
fi
AC_MSG_NOTICE([Enable optimized build flags for: $app_cv_compiler_optimize_options])
if test "x$app_cv_compiler_optimize_options" != "xnone"; then
# gcc, mingw
if test "x$app_cv_compiler_optimize_options" = "xgnu"; then
# -mtune=generic is since gcc 4.0 iirc
if test "x$app_cv_target_os_env" = "xmingw32"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g0 -O3 -s -march=i686";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g0 -O3 -s -march=i686";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g0 -O3 -s -march=i686";
else # mingw64, cygwin (they have new gcc), others.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g0 -O3 -s -mtune=generic";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g0 -O3 -s -mtune=generic";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g0 -O3 -s -mtune=generic";
fi
# intel / gnu
elif test "x$app_cv_compiler_optimize_options" = "xintel" && test "x$app_cv_target_os_env" = "xgnu"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g0 -O3 -s";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g0 -O3 -s";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g0 -O3 -s";
# suncc
elif test "x$app_cv_compiler_optimize_options" = "xsun"; then
# There's no -O0, it's the default. Debug format is stabs by default, but can be switched
# to dwarf by -xdebugformat=dwarf.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -xO5";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -xO5";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -s";
fi
fi
# ---- Compiler options for GCC pch support
AC_ARG_ENABLE(gcc-pch,
AS_HELP_STRING([--enable-gcc-pch],[enable precompiled header support (pch make target) (GCC only) (default: disabled)
(use "make gch" to speed up the compilation, but don't enable it if you don't intend to use it - it will slow things down)]),
[app_cv_compiler_gcc_pch=${enableval}], [app_cv_compiler_gcc_pch=no])
AC_MSG_NOTICE([Enable GCC precompiled header usage: $app_cv_compiler_gcc_pch])
# Don't check the vendor here - it's disabled by default, so it's on the user.
if test "x$app_cv_compiler_gcc_pch" = "xyes"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -Winvalid-pch -DENABLE_PCH"
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -Winvalid-pch -DENABLE_PCH"
fi
# ---- Compiler options for Mingw's mwindows/mconsole
# -mwindows - hide console window. possibly suppresses any std output / error.
# -mconsole - opposite of -mwindows, default.
AC_ARG_ENABLE(windows-console, AS_HELP_STRING([--enable-windows-console=yes|no|auto],
[enable windows console (MinGW and Cygwin only). Accepted values are yes, no, auto. ]
[Auto means disabled for optimized builds, enabled for all others. (Default: auto)]),
[app_cv_compiler_windows_console=${enableval}], [app_cv_compiler_windows_console=auto])
if test "x$app_cv_compiler_windows_console" = "xauto"; then
# disable console for optimized builds.
if test "x$app_cv_compiler_optimize_options" != "xnone"; then
app_cv_compiler_windows_console="no";
else
app_cv_compiler_windows_console="yes";
fi
fi
if test "x$app_cv_target_os_env" = "xmingw32" || test "x$app_cv_target_os_env" = "xmingw64" \
|| test "x$app_cv_target_os_env" = "xcygwin"; then
if test "x$app_cv_compiler_windows_console" = "xno"; then
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mwindows";
else
# specify -mconsole even if it's the default - it should override the user-supplied setting
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mconsole";
fi
AC_MSG_NOTICE([Enable windows console: $app_cv_compiler_windows_console])
fi
# ---- Export our variables
if test "x$$1[]CFLAGS" = "x"; then
$1[]CFLAGS="$app_cv_compiler_options_cflags";
else
$1[]CFLAGS="$$1[]CFLAGS $app_cv_compiler_options_cflags";
fi
if test "x$$1[]CXXFLAGS" = "x"; then
$1[]CXXFLAGS="$app_cv_compiler_options_cxxflags";
else
$1[]CXXFLAGS="$$1[]CXXFLAGS $app_cv_compiler_options_cxxflags";
fi
if test "x$$1[]LDFLAGS" = "x"; then
$1[]LDFLAGS="$app_cv_compiler_options_ldflags";
else
$1[]LDFLAGS="$$1[]LDFLAGS $app_cv_compiler_options_ldflags";
fi
AC_MSG_NOTICE([Compiler-specific build options:])
AC_MSG_NOTICE([CFLAGS: $app_cv_compiler_options_cflags])
AC_MSG_NOTICE([CXXFLAGS: $app_cv_compiler_options_cxxflags])
AC_MSG_NOTICE([LDFLAGS: $app_cv_compiler_options_ldflags])
])
+51
View File
@@ -0,0 +1,51 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# Check whether C++ compiler supports overloading of functions
# with function pointer argument differing only in extern "C" specification,
# that is, extern "C" function pointer and C++ function pointer. GCC and
# Intel treat them equally, so no overloads are needed (or accepted)
# there.
# SunCC accepts C++-to-C function pointer assignment in function
# parameters, but not in constructor parameters. To make such
# code work an additional C-function-pointer constructor must be
# specified. Then the constructor itself can make the conversion
# (with a compiler warning though).
# SunCC also disallows C-to-C++ function pointer specification
# for template parameters (I don't remember the exact details).
# If such overloading support is found,
# HAVE_CXX_EXTERN_C_OVERLOAD is defined.
AC_DEFUN([APP_CXX_EXTERN_C_OVERLOAD], [
AC_CACHE_CHECK(whether $CXX accepts extern C function pointer overload, ac_cv_cxx_extern_c_overload, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
extern "C" { typedef void (*c_func_t)(void); }
typedef void (*cpp_func_t)(void);
void f1(c_func_t f) { }
void f1(cpp_func_t f) { }
]], [[]])],
[ac_cv_cxx_extern_c_overload=yes], [ac_cv_cxx_extern_c_overload=no])
AC_LANG_POP([])
])
if test "x$ac_cv_cxx_extern_c_overload" = "xyes"; then
AC_DEFINE(HAVE_CXX_EXTERN_C_OVERLOAD, 1,
[Defined to 1 if the C++ complier accepts extern C function pointer overload, 0 otherwise])
else
AC_DEFINE(HAVE_CXX_EXTERN_C_OVERLOAD, 0,
[Defined to 1 if the C++ complier accepts extern C function pointer overload, 0 otherwise])
fi
])
+50
View File
@@ -0,0 +1,50 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# Check whether C++ compiler supports C99 __func__.
AC_DEFUN([APP_CXX___func__], [
AC_CACHE_CHECK(whether $CXX recognizes __func__, app_cv_cxx___func__, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[const char* s = __func__;]])],
[app_cv_cxx___func__=yes], [app_cv_cxx___func__=no])
AC_LANG_POP([])
])
if test "x$app_cv_cxx___func__" = "xyes"; then
AC_DEFINE(HAVE_CXX___func__, 1,
[Defined to 1 if the C++ complier supports __func__, 0 otherwise])
else
AC_DEFINE(HAVE_CXX___func__, 0,
[Defined to 1 if the C++ complier supports __func__, 0 otherwise])
fi
])
# Check whether C++ compiler supports __FUNCTION__.
AC_DEFUN([APP_CXX___FUNCTION__], [
AC_CACHE_CHECK(whether $CXX recognizes __FUNCTION__, app_cv_cxx___FUNCTION__, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[const char* s = __FUNCTION__;]])],
[app_cv_cxx___FUNCTION__=yes], [app_cv_cxx___FUNCTION__=no])
AC_LANG_POP([])
])
if test "x$app_cv_cxx___FUNCTION__" = "xyes"; then
AC_DEFINE(HAVE_CXX___FUNCTION__, 1,
[Defined to 1 if the C++ complier supports __FUNCTION__, 0 otherwise])
else
AC_DEFINE(HAVE_CXX___FUNCTION__, 0,
[Defined to 1 if the C++ complier supports __FUNCTION__, 0 otherwise])
fi
])
+373
View File
@@ -0,0 +1,373 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_DETECT_OS_KERNEL(triplet_name, define_macro_prefix)
# Check target OS kernel.
# triplet_name is target, host or build.
# You must call AX_COMPILER_VENDOR before using this macro.
# If you call
# APP_DETECT_OS_KERNEL([target], [CONFIG_KERNEL])
# you will get CONFIG_KERNEL_LINUX C macro exported to config.h
# (on gcc/linux).
# If no define_macro_prefix is specified, no C macro prefix will be used.
# app_cv_target_os_kernel will be set to kernel name (lowercase).
# app_cv_target_os_kernel_macro will be set to kernel name (all caps).
# TARGET_OS_KERNEL_LINUX automake conditional will be set to true.
# Note: Some operating systems / compilers have built-in defines.
# For gcc, check with
# $ gcc -dM -E - < /dev/null
AC_DEFUN([APP_DETECT_OS_KERNEL], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_MSG_CHECKING([for $1 OS kernel])
app_cv_[]$1[]_os_kernel="";
app_cv_[]$1[]_os_kernel_macro="";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
# "build" - the type of system on which the package is being configured and compiled.
# "host" - the type of system on which the package runs. Specifying it enables the
# cross-compilation mode. "target" defaults to this too.
if test "x$1" != "xbuild" && test "x$1" != "xhost" && test "x$1" != "xtarget"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[Triplet name must be build, host or target.]])
fi
case "$$1" in
*linux*)
# gcc defines __linux__ on linux. Other defines include: __linux, __unix__, __gnu_linux__,
# linux, unix, __i386__, i386.
app_cv_[]$1[]_os_kernel="linux";
app_cv_[]$1[]_os_kernel_macro="LINUX";
;;
i*86-*mingw* | i*86-*cygwin*)
# mingw defines _WIN32. msvc defines _WIN32 (built-in), and WIN32 via windows.h.
# Other mingw defines include: __WINNT, __WINNT__, __WIN32__, __i386, _X86_,
# i386, __i386__, WIN32, __MINGW32__, WINNT (all equal to 1).
app_cv_[]$1[]_os_kernel="windows32";
app_cv_[]$1[]_os_kernel_macro="WINDOWS32";
;;
x86_64-*-mingw* | x86_64-*-cygwin*)
# mingw64 defines the same stuff as 32-bit one, plus _WIN64, __MINGW64__, etc... .
app_cv_[]$1[]_os_kernel="windows64";
app_cv_[]$1[]_os_kernel_macro="WINDOWS64";
;;
*interix*)
# Interix is a kernel on top of windows, so we treat it separately.
app_cv_[]$1[]_os_kernel="interix";
app_cv_[]$1[]_os_kernel_macro="INTERIX";
;;
# This includes debian gnu/kfreebsd. Dragonfly is checked separately.
*freebsd*)
# gcc built-in defines (to check for freebsd kernel):
# defined(__FreeBSD__) || defined(__FreeBSD_kernel__).
# See http://glibc-bsd.alioth.debian.org/porting/PORTING .
app_cv_[]$1[]_os_kernel="freebsd";
app_cv_[]$1[]_os_kernel_macro="FREEBSD";
;;
*dragonfly*)
app_cv_[]$1[]_os_kernel="dragonfly";
app_cv_[]$1[]_os_kernel_macro="DRAGONFLY";
;;
*openbsd*)
app_cv_[]$1[]_os_kernel="openbsd";
app_cv_[]$1[]_os_kernel_macro="OPENBSD";
;;
# This includes debian gnu/netbsd.
*netbsd*)
app_cv_[]$1[]_os_kernel="netbsd";
app_cv_[]$1[]_os_kernel_macro="NETBSD";
;;
*solaris*)
app_cv_[]$1[]_os_kernel="solaris";
app_cv_[]$1[]_os_kernel_macro="SOLARIS";
;;
*darwin*)
app_cv_[]$1[]_os_kernel="darwin";
app_cv_[]$1[]_os_kernel_macro="DARWIN";
;;
*qnx*)
app_cv_[]$1[]_os_kernel="qnx";
app_cv_[]$1[]_os_kernel_macro="QNX";
;;
*)
app_cv_[]$1[]_os_kernel="unknown";
app_cv_[]$1[]_os_kernel_macro="UNKNOWN";
;;
esac
# Assign this - we may use this in configure itself.
if test "x$2" != "x"; then
app_cv_[]$1[]_os_kernel_macro="$2[]_${app_cv_[]$1[]_os_kernel_macro}";
fi
# config.h macros (yes, we need this many. otherwise config.h will be incorrect).
if test "x${app_cv_[]$1[]_os_kernel}" = "xlinux"; then
AC_DEFINE($2[]LINUX, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32"; then
AC_DEFINE($2[]WINDOWS32, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64"; then
AC_DEFINE($2[]WINDOWS64, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"; then
AC_DEFINE($2[]INTERIX, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xfreebsd"; then
AC_DEFINE($2[]FREEBSD, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xdragonfly"; then
AC_DEFINE($2[]DRAGONFLY, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xopenbsd"; then
AC_DEFINE($2[]OPENBSD, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xnetbsd"; then
AC_DEFINE($2[]NETBSD, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xsolaris"; then
AC_DEFINE($2[]SOLARIS, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xdarwin"; then
AC_DEFINE($2[]DARWIN, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xqnx"; then
AC_DEFINE($2[]QNX, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xunknown"; then
AC_DEFINE($2[]UNKNOWN, 1, [$1 OS kernel])
fi
# Export to Makefile.am's.
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_LINUX, [test "x${app_cv_[]$1[]_os_kernel}" = "xlinux"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_WINDOWS32, [test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_WINDOWS64, [test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_INTERIX, [test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_FREEBSD, [test "x${app_cv_[]$1[]_os_kernel}" = "xfreebsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_DRAGONFLY, [test "x${app_cv_[]$1[]_os_kernel}" = "xdragonfly"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_OPENBSD, [test "x${app_cv_[]$1[]_os_kernel}" = "xopenbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_NETBSD, [test "x${app_cv_[]$1[]_os_kernel}" = "xnetbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_SOLARIS, [test "x${app_cv_[]$1[]_os_kernel}" = "xsolaris"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_DARWIN, [test "x${app_cv_[]$1[]_os_kernel}" = "xdarwin"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_QNX, [test "x${app_cv_[]$1[]_os_kernel}" = "xqnx"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_UNKNOWN, [test "x${app_cv_[]$1[]_os_kernel}" = "xunknown"])
# composite ones, for easy checking
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_FAMILY_WINDOWS, \
[test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32" || test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64" \
|| test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"])
if test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32" || test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64" \
|| test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"; then
AC_DEFINE($2[]FAMILY_WINDOWS, 1, [$1 OS kernel family])
fi
AC_MSG_RESULT([${app_cv_[]$1[]_os_kernel}])
])
# APP_DETECT_OS_ENV(triplet_name, define_macro_prefix)
# Check target OS userland environment (mainly glibc).
# triplet_name is target, host or build.
# You must call AX_COMPILER_VENDOR before using this macro.
# If you call
# APP_DETECT_OS_ENV([target], [COMPILER], [CONFIG_OS_ENV])
# you will get CONFIG_OS_ENV_LINUX C macro exported to config.h
# (on gcc/linux).
# If no define_macro_prefix is specified, no C macro prefix will be used.
# app_cv_target_os_env will be set to env name (lowercase).
# app_cv_target_os_env_macro will be set to env name (all caps).
# TARGET_OS_ENV_LINUX automake conditional will be set to true.
AC_DEFUN([APP_DETECT_OS_ENV], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_MSG_CHECKING([for $1 OS userland environment])
app_cv_[]$1[]_os_env="";
app_cv_[]$1[]_os_env_macro="";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
# "build" - the type of system on which the package is being configured and compiled.
# "host" - the type of system on which the package runs. Specifying it enables the
# cross-compilation mode. "target" defaults to this too.
if test "x$1" != "xbuild" && test "x$1" != "xhost" && test "x$1" != "xtarget"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[Triplet name must be build, host or target.]])
fi
case "$$1" in
*cygwin*)
app_cv_[]$1[]_os_env="cygwin";
app_cv_[]$1[]_os_env_macro="CYGWIN";
;;
i*86-*mingw*)
app_cv_[]$1[]_os_env="mingw32";
app_cv_[]$1[]_os_env_macro="MINGW32";
;;
x86_64-*-mingw*)
app_cv_[]$1[]_os_env="mingw64";
app_cv_[]$1[]_os_env_macro="MINGW64";
;;
*interix*)
app_cv_[]$1[]_os_env="interix";
app_cv_[]$1[]_os_env_macro="INTERIX";
;;
# This includes gnu/linux, debian gnu/kfreebsd, debian gnu/netbsd...
*-gnu | gnu*)
app_cv_[]$1[]_os_env="gnu";
app_cv_[]$1[]_os_env_macro="GNU";
;;
# Freebsd libc
*freebsd*)
app_cv_[]$1[]_os_env="freebsd";
app_cv_[]$1[]_os_env_macro="FREEBSD";
;;
*dragonfly*)
app_cv_[]$1[]_os_env="dragonfly";
app_cv_[]$1[]_os_env_macro="DRAGONFLY";
;;
*openbsd*)
app_cv_[]$1[]_os_env="openbsd";
app_cv_[]$1[]_os_env_macro="OPENBSD";
;;
*netbsd*)
app_cv_[]$1[]_os_env="netbsd";
app_cv_[]$1[]_os_env_macro="NETBSD";
;;
*solaris*)
app_cv_[]$1[]_os_env="solaris";
app_cv_[]$1[]_os_env_macro="SOLARIS";
;;
*darwin*)
app_cv_[]$1[]_os_env="darwin";
app_cv_[]$1[]_os_env_macro="DARWIN";
;;
*qnx*)
app_cv_[]$1[]_os_env="qnx";
app_cv_[]$1[]_os_env_macro="QNX";
;;
*)
app_cv_[]$1[]_os_env="unknown";
app_cv_[]$1[]_os_env_macro="UNKNOWN";
;;
esac
# Assign this even if not using flags - we may use this in configure itself.
if test "x$2" != "x"; then
app_cv_[]$1[]_os_env_macro="$2[]_${app_cv_[]$1[]_os_env_macro}";
fi
# config.h macros (yes, we need this many. otherwise config.h will be incorrect).
if test "x${app_cv_[]$1[]_os_env}" = "xcygwin"; then
AC_DEFINE($2[]CYGWIN, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xmingw32"; then
AC_DEFINE($2[]MINGW32, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xmingw64"; then
AC_DEFINE($2[]MINGW64, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xinterix"; then
AC_DEFINE($2[]INTERIX, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xgnu"; then
AC_DEFINE($2[]GNU, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xfreebsd"; then
AC_DEFINE($2[]FREEBSD, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xdragonfly"; then
AC_DEFINE($2[]DRAGONFLY, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xopenbsd"; then
AC_DEFINE($2[]OPENBSD, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xnetbsd"; then
AC_DEFINE($2[]NETBSD, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xsolaris"; then
AC_DEFINE($2[]SOLARIS, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xdarwin"; then
AC_DEFINE($2[]DARWIN, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xqnx"; then
AC_DEFINE($2[]QNX, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xunknown"; then
AC_DEFINE($2[]UNKNOWN, 1, [$1 OS userspace environment])
fi
# Export to Makefile.am's.
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_CYGWIN, [test "x${app_cv_[]$1[]_os_env}" = "xcygwin"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_MINGW32, [test "x${app_cv_[]$1[]_os_env}" = "xmingw32"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_MINGW64, [test "x${app_cv_[]$1[]_os_env}" = "xmingw64"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_INTERIX, [test "x${app_cv_[]$1[]_os_env}" = "xinterix"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_GNU, [test "x${app_cv_[]$1[]_os_env}" = "xgnu"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_FREEBSD, [test "x${app_cv_[]$1[]_os_env}" = "xfreebsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_DRAGONFLY, [test "x${app_cv_[]$1[]_os_env}" = "xdragonfly"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_OPENBSD, [test "x${app_cv_[]$1[]_os_env}" = "xopenbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_NETBSD, [test "x${app_cv_[]$1[]_os_env}" = "xnetbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_SOLARIS, [test "x${app_cv_[]$1[]_os_env}" = "xsolaris"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_DARWIN, [test "x${app_cv_[]$1[]_os_env}" = "xdarwin"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_QNX, [test "x${app_cv_[]$1[]_os_env}" = "xqnx"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_UNKNOWN, [test "x${app_cv_[]$1[]_os_env}" = "xunknown"])
AC_MSG_RESULT([${app_cv_[]$1[]_os_env}])
])
+208
View File
@@ -0,0 +1,208 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_GET_MT_FLAGS(flags_prefix[, action-if-not-found])
# This macro detects compiler flags which are needed to compile a multi-threaded
# (preferably pthreads-based) applications on target OS. flags_prefixCFLAGS,
# flags_prefixCXXFLAGS and flags_prefixLIBS will be initialized (or appended to)
# with the correct flags.
# You must call AX_COMPILER_VENDOR, APP_DETECT_OS_KERNEL([target], ...)
# and APP_DETECT_OS_ENV([target], ...) before using this macro.
AC_DEFUN([APP_GET_MT_FLAGS], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([APP_DETECT_OS_KERNEL])
AC_REQUIRE([APP_DETECT_OS_ENV])
AC_MSG_CHECKING([for target thread support flags])
app_cv_target_thread_cflags="";
app_cv_target_thread_cxxflags="";
app_cv_target_thread_libs="";
app_cv_target_thread_found="no";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
if test "x${app_cv_target_os_kernel}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_kernel] not set.])
fi
if test "x${app_cv_target_os_env}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_env] not set.])
fi
# Compilers use at least 3 defines to enable thread-safe support:
# _THREAD_SAFE, _MT, _REENTRANT.
# We use the ones that are required for detected platform.
case "$app_cv_target_os_kernel" in
linux)
# glibc manual says that defining either _REENTRANT or _THREAD_SAFE
# enables some thread-safe implementations of glibc functions.
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "intel" \
|| test "$ax_cv_cxx_compiler_vendor" = "pathscale"; then
app_cv_target_thread_cflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_cxxflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
elif test "$ax_cv_cxx_compiler_vendor" = "sun"; then
# suncc's -mt expands to:
# "-D_REENTRANT -lpthread" on Linux, uses pthreads (pthread.h);
# "-D_REENTRANT -lthread" on Solaris, uses Solaris threads (thread.h).
# To use pthreads on Solaris, use "-mt -lpthread".
# http://docs.sun.com/app/docs/doc/820-7598/bjapp?a=view
app_cv_target_thread_cflags="-mt"
app_cv_target_thread_cxxflags="-mt"
app_cv_target_thread_libs="-mt"
app_cv_target_thread_found="yes";
fi
;;
windows*)
# NOTE: Not sure about cygwin.
# NOTE: This only enables multithreaded code generation. For linking
# with pthreads-win32 you need additional flags.
# gcc man page: -mthreads: Support thread-safe exception handling on Mingw32.
# -mthreads defines -D_MT, and links with -lmingwthrd.
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
app_cv_target_thread_cflags="-mthreads -D_THREAD_SAFE"
app_cv_target_thread_cxxflags="-mthreads -D_THREAD_SAFE"
app_cv_target_thread_libs="-mthreads"
app_cv_target_thread_found="yes"
fi
;;
interix)
# Interix kernel is implemented on top of windows kernel.
# Interix uses -D_REENTRANT for pthreads, automatically enabling -lpthread.
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
app_cv_target_thread_cflags="-D_REENTRANT"
app_cv_target_thread_cxxflags="-D_REENTRANT"
app_cv_target_thread_found="yes"
fi
;;
freebsd | dragonfly)
# NOTE: Not sure about debian gnu/kfreebsd and gnu/netbsd.
# Freebsd had -kthread, but it has been discontinued (afaik).
# For freebsd -pthread replaces libc with libc_r.
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
app_cv_target_thread_cflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_cxxflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
fi
;;
openbsd)
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
app_cv_target_thread_cflags="-pthread -D_REENTRANT"
app_cv_target_thread_cxxflags="-pthread -D_REENTRANT"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
fi
;;
netbsd)
# See sys/featuretest.h
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
app_cv_target_thread_cflags="-pthread -D_REENTRANT"
app_cv_target_thread_cxxflags="-pthread -D_REENTRANT"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
fi
;;
solaris)
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
# gnu documentation mentions -threads (and its aliases, -pthreads and -pthread).
# _REENTRANT is needed to enable some thread-safe equivalents of standard
# functions.
# http://docs.sun.com/app/docs/doc/805-8005-04/6j7hcvqs4?l=ko&a=view
app_cv_target_thread_cflags="-pthreads -D_MT -D_THREAD_SAFE -D_REENTRANT"
app_cv_target_thread_cxxflags="-pthreads -D_MT -D_THREAD_SAFE -D_REENTRANT"
app_cv_target_thread_libs="-pthreads"
app_cv_target_thread_found="yes"
elif test "$ax_cv_cxx_compiler_vendor" = "sun"; then
# suncc's -mt expands to:
# "-D_REENTRANT -lpthread" on Linux, uses pthreads (pthread.h);
# "-D_REENTRANT -lthread" on Solaris, uses Solaris threads (thread.h).
# To use pthreads on Solaris, use "-mt -lpthread".
# http://docs.sun.com/app/docs/doc/820-7598/bjapp?a=view
# http://docs.sun.com/app/docs/doc/816-5175/pthreads-5?a=view
# http://docs.sun.com/app/docs/doc/816-5137/compile-74765?a=view
# We use POSIX threads, so append -lpthread.
app_cv_target_thread_cflags="-mt -lpthread"
app_cv_target_thread_cxxflags="-mt -lpthread"
app_cv_target_thread_libs="-mt -lpthread"
app_cv_target_thread_found="yes"
fi
;;
darwin)
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
# Darwin produces mt code by default, and -pthread is an error.
app_cv_target_thread_found="yes"
fi
;;
qnx)
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
# afaik, gcc/qnx produces mt code by default (at least on newer qnx releases),
# so no flags are needed.
app_cv_target_thread_found="yes"
fi
;;
esac
if test "$app_cv_target_thread_found" = "no"; then
AC_MSG_WARN([Cannot detect compiler thread support. Set CFLAGS, CXXFLAGS and LIBS manually.])
m4_ifvaln([$2],[$2])dnl
else
AC_MSG_RESULT([CFLAGS: $app_cv_target_thread_cflags; CXXFLAGS: $app_cv_target_thread_cxxflags; LIBS: $app_cv_target_thread_libs])
if test "x$$1[]CFLAGS" = "x"; then
$1[]CFLAGS="$app_cv_target_thread_cflags";
else
$1[]CFLAGS="$$1[]CFLAGS $app_cv_target_thread_cflags";
fi
if test "x$$1[]CXXFLAGS" = "x"; then
$1[]CXXFLAGS="$app_cv_target_thread_cxxflags";
else
$1[]CXXFLAGS="$$1[]CXXFLAGS $app_cv_target_thread_cxxflags";
fi
if test "x$$1[]LIBS" = "x"; then
$1[]LIBS="$app_cv_target_thread_libs";
else
$1[]LIBS="$$1[]LIBS $app_cv_target_thread_libs";
fi
fi
])
+143
View File
@@ -0,0 +1,143 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_USE_SYSTEM_EXTENSIONS([flags_prefix])
# This macro detects compiler flags which are needed to enable
# system-specific library extensions. For example, on GNU platforms
# it's -D_GNU_SOURCE, on solaris it's -D__EXTENSIONS__, etc...
# Basically, it's the same as AC_USE_SYSTEM_EXTENSIONS,
# but uses compiler flag approach instead of config.h.
# The extensions used bring the system closer to the GNU,
# X/Open (a superset of POSIX) and POSIX systems.
# You must call AX_COMPILER_VENDOR
# and APP_DETECT_OS_ENV([target], ...) before using this macro.
# More info:
# http://www.gnu.org/software/autoconf/manual/autoconf.html#Posix-Variants
# http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
# http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined
# http://docs.sun.com/app/docs/doc/817-3946/6mjgmt4o8?l=en&a=view
AC_DEFUN([APP_USE_SYSTEM_EXTENSIONS], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([APP_DETECT_OS_ENV])
AC_MSG_CHECKING([for target system extension flags])
app_cv_target_extension_cflags="";
app_cv_target_extension_cxxflags="";
app_cv_target_extension_libs="";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
if test "x${app_cv_target_os_kernel}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_kernel] not set.])
fi
if test "x${app_cv_target_os_env}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_env] not set.])
fi
case "$app_cv_target_os_env" in
gnu)
# glibc all-extensions macro: _GNU_SOURCE.
# gcc automatically defines it in later versions.
# suncc needs the flag explicitly.
# http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
app_cv_target_extension_cflags="-D_GNU_SOURCE"
app_cv_target_extension_cxxflags="-D_GNU_SOURCE"
;;
solaris)
# The problem with solaris is that it has too many incompatible
# feature test macros, and there is no enable-all macro. Autoconf
# assumes that __EXTENSIONS__ is the one, but it should be defined
# _in addition_ to feature test macros. Note that on its own, __EXTENSIONS__
# still enables some useful stuff like _LARGEFILE64_SOURCE.
# To support some posix macros, additional link objects are also required.
# Some *_SOURCE feature test macros may be incompatible with C++.
# http://docs.sun.com/app/docs/doc/816-5175/standards-5?a=view
app_cv_target_extension_cflags="-D__EXTENSIONS__"
app_cv_target_extension_cxxflags="-D__EXTENSIONS__"
;;
netbsd)
# There is no enable-all macro.
# (_XOPEN_SOURCE >= 500 || _NETBSD_SOURCE) is recommended.
# The default is _NETBSD_SOURCE, _XOPEN_SOURCE overrides it.
# The manual says that rename() will behave posix-like if _POSIX_C_SOURCE
# is defined. However, stdio.h uses (_XOPEN_SOURCE <= 2) condition,
# which is really bogus.
# See sys/featuretest.h
;;
mingw32)
# This enables standards-compliant stdio behaviour (regarding printf and
# friends), as opposed to msvc-compatible one. This is usually enabled
# by default if one of the usual macros are encountered (_XOPEN_SOURCE,
# _GNU_SOURCE, etc...).
# Also, we make the win2k API available (includes console functions, etc...).
# Other things to consider: _NO_OLDNAMES (disable "deprecated"
# non-underscored names like chdir (use _chdir), etc...).
# See _mingw.h for details.
app_cv_target_extension_cflags="-D__USE_MINGW_ANSI_STDIO=1 -DWINVER=0x0500"
app_cv_target_extension_cxxflags="-D__USE_MINGW_ANSI_STDIO=1 -DWINVER=0x0500"
;;
mingw64)
# Same as ming32, but enable "from xp" mode, since there's no x86_64 2k.
app_cv_target_extension_cflags="-D__USE_MINGW_ANSI_STDIO=1 -DWINVER=0x0501"
app_cv_target_extension_cxxflags="-D__USE_MINGW_ANSI_STDIO=1 -DWINVER=0x0501"
;;
interix)
# As per AC_USE_SYSTEM_EXTENSIONS.
app_cv_target_extension_cflags="-D_ALL_SOURCE"
app_cv_target_extension_cxxflags="-D_ALL_SOURCE"
;;
esac
AC_MSG_RESULT([CFLAGS: $app_cv_target_extension_cflags; CXXFLAGS: $app_cv_target_extension_cxxflags; LIBS: $app_cv_target_extension_libs])
if test "x$$1[]CFLAGS" = "x"; then
$1[]CFLAGS="$app_cv_target_extension_cflags";
else
$1[]CFLAGS="$$1[]CFLAGS $app_cv_target_extension_cflags";
fi
if test "x$$1[]CXXFLAGS" = "x"; then
$1[]CXXFLAGS="$app_cv_target_extension_cxxflags";
else
$1[]CXXFLAGS="$$1[]CXXFLAGS $app_cv_target_extension_cxxflags";
fi
if test "x$$1[]LIBS" = "x"; then
$1[]LIBS="$app_cv_target_extension_libs";
else
$1[]LIBS="$$1[]LIBS $app_cv_target_extension_libs";
fi
])
@@ -28,29 +28,40 @@
AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE],
[AC_CACHE_CHECK(whether the compiler supports GCC C++ ABI name demangling,
ac_cv_cxx_gcc_abi_demangle,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
#include <cxxabi.h>
#include <string>
ac_cv_cxx_gcc_abi_demangle,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <typeinfo>
#include <cxxabi.h>
#include <string>
#include <stdlib.h> /* not cstdlib */
template<typename TYPE>
class A {};
]], [[A<int> instance;
int status = 0;
char* c_name = 0;
template<typename TYPE>
class A {};
]], [[
A<int> instance;
int status = 0;
char* c_name = 0;
c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
std::string name(c_name);
free(c_name);
std::string name(c_name);
free(c_name); /* not std::free() */
return name == "A<int>";
]])],[ac_cv_cxx_gcc_abi_demangle=yes],[ac_cv_cxx_gcc_abi_demangle=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_gcc_abi_demangle" = yes; then
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE,1,
[define if the compiler supports GCC C++ ABI name demangling])
fi
return name == "A<int>";
]])],
[ac_cv_cxx_gcc_abi_demangle=yes], [ac_cv_cxx_gcc_abi_demangle=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_gcc_abi_demangle" = yes; then
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE, 1,
[defined to 1 if the compiler supports GCC C++ ABI name demangling, 0 otherwise])
else
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE, 0,
[defined to 1 if the compiler supports GCC C++ ABI name demangling, 0 otherwise])
fi
])
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
stamp="../gsmartcontrol-`date +%F`"
echo $stamp
+262 -321
View File
@@ -1,13 +1,16 @@
AC_INIT([GSmartControl], [0.8.0rc2], [], [gsmartcontrol])
AC_INIT([GSmartControl],[0.8.5],[],[gsmartcontrol])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_TARGET
# disable portability warnings because of pattern rules in src/res.
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-bzip2 -Wall,no-portability])
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-bzip2 -Wall])
# Clear *FLAGS, LIBS, LDFLAGS if requested through configure option.
APP_AUTO_CLEAR_FLAGS()
# C compiler, C preprocessor
AC_PROG_CC
@@ -24,46 +27,61 @@ AC_PROG_CXX
#AC_LANG([C])
AC_LANG([C++])
# to be able to generate static libs
# Needed for generating static libs
AC_CHECK_TOOL(RANLIB, ranlib)
# Win32 resource file compilation
AC_CHECK_TOOL(WINDRES, windres)
# Win32 external dll stripping (already detected by autoconf)
# AC_CHECK_TOOL(STRIP, strip)
# Defines LN_S, needed for man page installation.
AC_PROG_LN_S
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Various compiler features
# ------------- Detect compiler, OS, environment. Enable system features.
# detect compiler vendor (sets $ax_cv_cxx_compiler_vendor)
AX_COMPILER_VENDOR
# detect RTTI (defines HAVE_RTTI)
AC_CXX_RTTI
# Detect target OS kernel and userspace and export to config.h
# (also define automake conditionals).
APP_DETECT_OS_KERNEL([target], [CONFIG_KERNEL_])
APP_DETECT_OS_ENV([target], [CONFIG_OS_ENV_])
APP_DETECT_OS_KERNEL([build], [CONFIG_HOST_KERNEL_])
# detect exception support (defines HAVE_EXCEPTIONS)
AC_CXX_EXCEPTIONS
# Detect common (warning, debug, optimize) compiler flags and
# export them to C(XX)FLAGS, LDFLAGS.
# We don't use prefix because this way the flags will be used for tests,
# which is important for some compatibility flags (e.g. __func__ visibility, etc...).
APP_COMPILER_OPTIONS([])
# detect abi::__cxa_demangle (defines HAVE_GCC_ABI_DEMANGLE)
AX_CXX_GCC_ABI_DEMANGLE
# Thread support for known configurations.
# Sun compiler (at least on linux) has some runtime issues with stringstream
# unless we use the thread flags. Also, Linux-based gdb fails to debug
# a gcc-compiled binary for some reason.
# Do this for all systems except mingw.
if test "$app_cv_target_os_env" != "mingw32" && test "$app_cv_target_os_env" != "mingw64"; then
APP_GET_MT_FLAGS([])
fi
# detect __gnu_cxx::__verbose_terminate_handler (defines HAVE_VERBOSE_TERMINATE_HANDLER.)
AC_CXX_VERBOSE_TERMINATE_HANDLER
# Enable _GNU_SOURCE, etc...
APP_USE_SYSTEM_EXTENSIONS([])
# detect __func__ support (defines HAVE_CXX__FUNC)
AC_CXX_VAR_FUNC
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Portability stuff
# arrange large file support (define _FILE_OFFSET_BITS 64, etc...)
# Arrange large file support (define _FILE_OFFSET_BITS 64, etc...)
AC_SYS_LARGEFILE
# ------------- Correct incomplete standard libraries
# define int8_t and friends if the standard doesn't have them
AC_TYPE_INT8_T
AC_TYPE_UINT8_T
@@ -79,6 +97,33 @@ AC_TYPE_UINTMAX_T
AC_TYPE_LONG_LONG_INT
AC_TYPE_UNSIGNED_LONG_LONG_INT
# ------------- Language / Standard Library checks
# detect RTTI (defines HAVE_RTTI)
AC_CXX_RTTI
# detect exception support (defines HAVE_EXCEPTIONS)
AC_CXX_EXCEPTIONS
# detect abi::__cxa_demangle (defines HAVE_GCC_ABI_DEMANGLE)
AX_CXX_GCC_ABI_DEMANGLE
# detect __gnu_cxx::__verbose_terminate_handler (defines HAVE_VERBOSE_TERMINATE_HANDLER.)
AC_CXX_VERBOSE_TERMINATE_HANDLER
# detect __func__ support (defines HAVE_CXX___func__)
APP_CXX___func__
# detect __FUNCTION__ support (defines HAVE_CXX___FUNCTION__)
APP_CXX___FUNCTION__
# detect if the compiler accepts extern "C" function pointer overloads
# (defines HAVE_CXX_EXTERN_C_OVERLOAD)
APP_CXX_EXTERN_C_OVERLOAD
# This may be needed for pch support
AC_CHECK_HEADERS([stdc++.h])
@@ -87,9 +132,10 @@ AC_CHECK_FUNCS([strtoll _strtoi64], [break])
# Non-C99 systems don't have strtof and strtold. some have strtodf for strtof,
# but let's ignore it. Note: They may be supported by system libc,
# but unsupported by headers (e.g. sun studio on linux). In that case,
# but not enabled by default (e.g. by glibc feature macros). In that case,
# defining them still leads to undefined symbols at link time, so we don't do it.
# header / link check:
# Header check is the best way to determine availability.
# This defines HAVE_DECL_<symbol> to 1 or 0.
AC_CHECK_DECLS([strtof, strtold], [], [], [[#include <stdlib.h>]])
# link check only:
# AC_CHECK_FUNCS([strtof strtold])
@@ -100,273 +146,10 @@ AC_CHECK_DECLS([strtof, strtold], [], [], [[#include <stdlib.h>]])
# -------------------------------------------------------------------------------------
# "build" - the type of system on which the package is being configured and compiled.
ac_windows_build="no"
ac_linux_build="no"
case "${host}" in
*mingw*)
ac_windows_build="yes"
;;
*linux*)
ac_linux_build="yes"
;;
esac
# Non-standard feature checks
# export to Makefile.am-s
AM_CONDITIONAL([WINDOWS_BUILD], [test "$ac_windows_build" = "yes"])
AM_CONDITIONAL([LINUX_BUILD], [test "$ac_linux_build" = "yes"])
# "host" - the type of system on which the package runs. Specifying it enables the
# cross-compilation mode. "target" defaults to this too.
ac_windows_target="no"
ac_linux_target="no"
case "${target}" in
*mingw*)
ac_windows_target="yes"
;;
*linux*)
ac_linux_target="yes"
;;
esac
# export to Makefile.am-s
AM_CONDITIONAL([WINDOWS_TARGET], [test "$ac_windows_target" = "yes"])
AM_CONDITIONAL([LINUX_TARGET], [test "$ac_linux_target" = "yes"])
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
COMPILER_CXXFLAGS=""
COMPILER_LDFLAGS=""
# reset original user-supplied *FLAGS
RESET_ORIGINAL="no"
AC_ARG_ENABLE(default-gcc-options,
AS_HELP_STRING([--enable-default-gcc-options],[enable default compilation options (warnings, mostly) (GCC only) (default: disabled)]),
[default_gcc_options=${enableval}], [default_gcc_options=no])
if test "$default_gcc_options" = "yes"; then
if test "$ac_windows_target" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -mms-bitfields -mwindows"
COMPILER_LDFLAGS="$COMPILER_CXXFLAGS -mms-bitfields"
fi
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS \
-Wall -Wcast-align -Wcast-qual -Wconversion \
-Wctor-dtor-privacy -Wfloat-equal -Wnon-virtual-dtor -Woverloaded-virtual \
-Wpointer-arith -Wshadow -Wsign-compare -Wsign-promo -Wundef -Wwrite-strings"
RESET_ORIGINAL="yes";
fi
AC_ARG_ENABLE(gcc-debug,
AS_HELP_STRING([--enable-gcc-debug],[enable debug build (GCC only) (default: disabled)]),
[gcc_debug=${enableval}], [gcc_debug=no])
if test "$gcc_debug" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -g3 -O0 -DDEBUG -DDEBUG_BUILD"
COMPILER_LDFLAGS="$COMPILER_LDFLAGS -g3 -O0"
RESET_ORIGINAL="yes";
fi
AC_ARG_ENABLE(gcc-optimize,
AS_HELP_STRING([--enable-gcc-optimize],[enable optimized build (GCC only) (default: disabled)]),
[gcc_optimize=${enableval}], [gcc_optimize=no])
if test "$gcc_optimize" = "yes"; then
# Note: Do NOT put CPU flags here - they make the program non-portable.
if test "$ac_windows_target" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -g0 -O3 -s"
COMPILER_LDFLAGS="$COMPILER_LDFLAGS -s"
else
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -g0 -O3 -s -mtune=generic"
COMPILER_LDFLAGS="$COMPILER_LDFLAGS -s -mtune=generic"
fi
RESET_ORIGINAL="yes";
fi
AC_ARG_ENABLE(gcc_pch,
AS_HELP_STRING([--enable-gcc-pch],[enable precompiled header support (pch make target) (GCC only) (default: disabled)
(use "make gch" to speed up the compilation)]),
[gcc_pch=${enableval}], [gcc_pch=no])
if test "$gcc_pch" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -Winvalid-pch -DENABLE_PCH"
fi
# define LINUX for linux target
if test "$ac_linux_target" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -DLINUX"
fi
# Reset user-supplied flags if one of the above options is present.
# We append COMPILER_* counterparts in the end, to override any
# previous options.
if test "$RESET_ORIGINAL" = "yes"; then
CFLAGS=""
CXXFLAGS=""
LIBS=""
LDFLAGS=""
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Enable compiler thread switches for known platforms.
AC_MSG_NOTICE([checking thread support flags...])
THREAD_CFLAGS=""
THREAD_LIBS=""
THREAD_FOUND="no"
if test "$ac_windows_target" = "yes"; then
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
THREAD_CFLAGS="-mthreads -D_THREAD_SAFE"
THREAD_LIBS="-mthreads"
THREAD_FOUND="yes"
fi
elif test "$ac_linux_target" = "yes"; then
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "intel"; then
THREAD_CFLAGS="-pthread -D_MT -D_THREAD_SAFE"
THREAD_LIBS="-pthread"
THREAD_FOUND="yes"
elif test "$ax_cv_cxx_compiler_vendor" = "sun"; then
THREAD_CFLAGS="-mt"
THREAD_LIBS="-mt"
THREAD_FOUND="yes"
fi
fi
if test "$THREAD_FOUND" = "no"; then
AC_MSG_NOTICE([Cannot detect compiler thread support. Set CXXFLAGS and LDFLAGS manually.])
else
AC_MSG_NOTICE([CFLAGS: $THREAD_CFLAGS; LIBS: $THREAD_LIBS])
CXXFLAGS="$CXXFLAGS $THREAD_CFLAGS"
LIBS="$LIBS $THREAD_LIBS"
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# iconview is available since 2.6.0. gthread is not enabled by default.
pkg_modules="gtkmm-2.4 >= 2.6.0 gthread-2.0 >= 2.0"
# define ENABLE_GLIB and friends if it's found.
gtkmm_found="no"
PKG_CHECK_MODULES([GTKMM], [$pkg_modules], [
AC_DEFINE([ENABLE_GLIB], [], [Whether GLib is installed])
AC_DEFINE([ENABLE_GLIBMM], [], [Whether GLibmm is installed])
gtkmm_found="yes"
], [
AC_MSG_WARN([$GTKMM_PKG_ERRORS])
AC_MSG_WARN([The program will be unable to compile fully.])
])
# use this instead of the above one to enable abort-on-not-found behaviour.
# PKG_CHECK_MODULES([GTKMM], [$pkg_modules])
# GTK flags must be prepended, or glib_config.h conflict between
# gtk 2.x and 1.2 may occur.
#CFLAGS="$GTKMM_CFLAGS $CFLAGS"
CXXFLAGS="$GTKMM_CFLAGS $CXXFLAGS"
LIBS="$GTKMM_LIBS $LIBS"
# needed for in-code checks (AC_DEFINE() takes care of these above, no need of them here)
# CXXFLAGS="$CXXFLAGS -DENABLE_GLIB -DENABLE_GLIBMM"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
gld_found=no; # equals to "gtkbuilder" or "libglademm" after tests
#if test "gtkmm_found" = "yes"; then
# Check whether we should use Gtk::Builder (gtkmm >= 2.12) or libglademm.
AC_ARG_ENABLE(libglademm, AS_HELP_STRING([--enable-libglademm],
[use libglademm instead of GtkBuilder (default: auto)]), [with_libglademm=${enableval}], [with_libglademm=auto])
# try gtkbuilder first
if test "$with_libglademm" = "no" || test "$with_libglademm" = "auto"; then
PKG_CHECK_EXISTS([gtkmm-2.4 >= 2.12.0], [gld_found=gtkbuilder])
fi
if test "$with_libglademm" = "no" && test "$gld_found" = "no"; then
AC_MSG_ERROR([GtkBuilder support not found (you need gtkmm version 2.12 or higher). Try using libglademm instead.])
fi
# libglade specified, or auto and no gtkbuilder. gtkmm2.4-compatible libglade is >= 2.4.0.
if test "$gld_found" = "no"; then
PKG_CHECK_MODULES([LIBGLADEMM], [libglademm-2.4 >= 2.4.0], [gld_found="libglademm"],
[AC_MSG_WARN([$LIBGLADEMM_PKG_ERRORS])])
fi
if test "$with_libglademm" = "yes" && test "$gld_found" = "no"; then
AC_MSG_ERROR([Libglademm not found. Try building with GtkBuilder support (you need gtkmm version 2.12 or higher).])
fi
# still not found.
if test "$gld_found" = "no"; then
AC_MSG_WARN([Neither GtkBuilder nor libglademm found. The program will be unable to compile fully.])
fi
AC_MSG_NOTICE([Glade file support through: $gld_found])
# merge libglademm flags
if test "$gld_found" = "libglademm"; then
CXXFLAGS="$LIBGLADEMM_CFLAGS $CXXFLAGS"
LIBS="$LIBGLADEMM_LIBS $LIBS"
fi
#fi
# export to automake.am-s
AM_CONDITIONAL([ENABLE_LIBGLADEMM], [test "$gld_found" = "libglademm"])
AM_CONDITIONAL([ENABLE_GTKBUILDER], [test "$gld_found" = "gtkbuilder"])
# export to config.h
if test "$gld_found" = "libglademm"; then
AC_DEFINE(ENABLE_LIBGLADEMM, 1, [Use libglademm instead of GtkBuilder])
fi
if test "$gld_found" = "gtkbuilder"; then
AC_DEFINE(ENABLE_GTKBUILDER, 1, [Use GtkBuilder instead of libglademm])
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
pkg_modules="libpcre"
PKG_CHECK_MODULES(PCRE, [$pkg_modules])
#CFLAGS="$PCRE_CFLAGS $CFLAGS"
CXXFLAGS="$PCRE_CFLAGS $CXXFLAGS"
LIBS="$PCRE_LIBS $LIBS"
# getrawpartition() for netbsd and openbsd in -lutil.
AC_CHECK_LIB(util, getrawpartition, [ LIBS="$LIBS -lutil" ])
# -------------------------------------------------------------------------------------
@@ -386,6 +169,157 @@ AM_CONDITIONAL([ENABLE_TESTS], [test "$with_tests" = "yes"])
# -------------------------------------------------------------------------------------
AC_ARG_ENABLE(abort-if-no-gtkmm, AS_HELP_STRING([--disable-abort-if-no-gtkmm],
[disable abort if no gtkmm is found (default: configure aborts when gtkmm is not found)]),
[app_cv_abort_if_no_gtkmm=${enableval}], [app_cv_abort_if_no_gtkmm=yes])
AC_MSG_NOTICE([Abort if no gtkmm is found: $app_cv_abort_if_no_gtkmm])
# iconview is available since 2.6.0. gthread is not enabled by default.
pkg_modules="gtkmm-2.4 >= 2.6.0" # gthread-2.0 >= 2.0
# define ENABLE_GLIB and friends if it's found.
gtkmm_found="no"
PKG_CHECK_MODULES([GTKMM], [$pkg_modules],
[gtkmm_found="yes"], [gtkmm_found="no"])
if test "x$gtkmm_found" = "xyes"; then
AC_DEFINE([ENABLE_GLIB], [1], [Defined to 1 if GLib is installed, 0 otherwise])
AC_DEFINE([ENABLE_GLIBMM], [1], [Defined to 1 if glibmm is installed, 0 otherwise])
else
AC_DEFINE([ENABLE_GLIB], [0], [Defined to 1 if GLib is installed, 0 otherwise])
AC_DEFINE([ENABLE_GLIBMM], [0], [Defined to 1 if glibmm is installed, 0 otherwise])
fi
if test "x$gtkmm_found" = "xno"; then
if test "x$app_cv_abort_if_no_gtkmm" = "xno"; then
AC_MSG_WARN([$GTKMM_PKG_ERRORS])
AC_MSG_WARN([The program will be unable to compile fully.])
else
AC_MSG_ERROR([$GTKMM_PKG_ERRORS])
fi
fi
# GTK flags must be prepended, or glib_config.h conflict between
# gtk 2.x and 1.2 may occur.
#CFLAGS="$GTKMM_CFLAGS $CFLAGS"
CXXFLAGS="$GTKMM_CFLAGS $CXXFLAGS"
LIBS="$GTKMM_LIBS $LIBS"
# Detect libglade / gtkbuilder support
APP_CHOOSE_GLD_READER([C++], [LIBGLADE_])
if test "$app_cv_gld_reader" = "libglade"; then
CFLAGS="$CFLAGS $LIBGLADE_CFLAGS"
CXXFLAGS="$CXXFLAGS $LIBGLADE_CXXFLAGS"
LIBS="$LIBS $LIBGLADE_LIBS"
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
PCRE_CFLAGS="";
PCRE_LIBS="";
# try pkg-config first
PKG_CHECK_MODULES(PCRE, [libpcre], [pcre_found=yes], [pcre_found=no])
# if not found, try pcre-config (solaris had it but not pkg-config).
if test "x$pcre_found" = "xno"; then
AC_PATH_PROG(pcre_config_binary, [pcre-config])
if test "x$pcre_config_binary" != "x"; then
PCRE_CFLAGS="`pcre-config --cflags`"
PCRE_LIBS="`pcre-config --libs`"
else
# AC_MSG_ERROR([Could not find pcre through pkg-config and pcre-config. Make sure the pcre libraries are installed])
AC_MSG_ERROR([$PCRE_PKG_ERRORS])
fi
fi
CFLAGS="$CFLAGS $PCRE_CFLAGS"
CXXFLAGS="$CXXFLAGS $PCRE_CFLAGS"
LIBS="$LIBS $PCRE_LIBS"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Test stuff here...
# <nothing>
#SDL_VERSION=1.2.0
#AM_PATH_SDL($SDL_VERSION, :,
# AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) )
#CFLAGS="$CFLAGS $SDL_CFLAGS"
#CXXFLAGS="$CXXFLAGS $SDL_CFLAGS "
#LIBS="$LIBS $SDL_LIBS"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Win32 distribution support (NSIS, zip)
AC_ARG_WITH([nsis], [AS_HELP_STRING([--with-nsis=<location>|auto],
[specify makensis.exe location to support making NSIS packages]
[ (default: "C:\Program Files\NSIS\makensis.exe" for windows, ]
["~/.wine/drive_c/Program Files/NSIS/makensis.exe" for others)])],
[with_nsis=${withval}], [with_nsis=auto])
AC_ARG_ENABLE([nsis-wine], [AS_HELP_STRING([--enable-nsis-wine=yes|no|auto],
[use wine to run makensis.exe when making NSIS packages (default: auto, which is no for windows, yes for others)])],
[with_nsis_wine=${enableval}], [with_nsis_wine=yes])
AC_ARG_WITH([windows-bindir], [AS_HELP_STRING([--with-windows-bindir],
[specify location of Windows dlls and executables when making Windows packages (default: /cross/w32/target/bin)])],
[with_windows_bindir=${withval}], [with_windows_bindir=auto])
if test "x$with_nsis" = "xauto" || test "x$with_nsis" = "x"; then
if test "x$app_cv_build_os_kernel" = "xwindows"; then
with_nsis="~/\".wine/drive_c/Program Files/NSIS/makensis.exe\"";
else
with_nsis="\"C:\\Program Files\\NSIS\\makensis.exe\"";
fi
fi
if test "x$with_nsis_wine" = "xauto"; then
if test "x$app_cv_build_os_kernel" = "xwindows"; then
with_nsis_wine="no";
else
with_nsis_wine="yes";
fi
fi
NSIS_EXEC="$with_nsis";
if test "x$with_nsis_wine" != "xno"; then
NSIS_EXEC="wine $with_nsis";
fi
if test "x$with_windows_bindir" = "xauto" || test "x$with_windows_bindir" = "x"; then
with_windows_bindir="/cross/w32/target/bin"
fi
WINDOWS_BINDIR="$with_windows_bindir";
AC_SUBST(NSIS_EXEC)
AC_SUBST(WINDOWS_BINDIR)
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
RES_FILES="src/res/gsc_about_dialog.glade \
src/res/gsc_executor_log_window.glade \
src/res/gsc_help_window.glade \
@@ -401,7 +335,7 @@ RES_DIST="" # only files in "res" directory, EXTRA_DIST
RES_TARGETS="" # entry for each file in makefile
RES_GLD_EXT="glade"
if test "$gld_found" = "gtkbuilder"; then
if test "$app_cv_gld_reader" = "gtkbuilder"; then
RES_GLD_EXT="ui"
fi
@@ -468,7 +402,8 @@ _AM_SUBST_NOTMAKE([RES_TARGETS])
# -------------------------------------------------------------------------------------
# Export some configure variables as defines for the source code
# Export some configure variables as defines for the source code.
# Note: Autoconf manual says that AC_DEFINE won't work here.
ADDITIONAL_FLAGS="-DPACKAGE_PKGDATA_DIR=\"\\\"\$(pkgdatadir)\\\"\" \
-DPACKAGE_SYSCONF_DIR=\"\\\"\$(sysconfdir)\\\"\" \
@@ -478,10 +413,6 @@ ADDITIONAL_FLAGS="-DPACKAGE_PKGDATA_DIR=\"\\\"\$(pkgdatadir)\\\"\" \
CXXFLAGS="$CXXFLAGS $ADDITIONAL_FLAGS"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Top src dir should always be in include path, before other includes.
# Add global configuration file. Note: It must be searched in top_builddir
# first (that's why -I is the first flag), for precompiled headers to work.
@@ -489,15 +420,21 @@ CXXFLAGS="$CXXFLAGS $ADDITIONAL_FLAGS"
# Add pcrecpp too, because its files use #<file> on each other.
ADDITIONAL_INCLUDES="-I\$(top_builddir) -I\$(top_srcdir)/src -I\$(top_srcdir)/src/pcrecpp"
# -include doesn't work with sun and pgi, but works with intel and gcc.
# we don't whitelist intel/gcc, because there are some gcc-frontend-based
# compilers we don't want to break (pathscale, gccfss (gcc frontend / sun backend), etc...).
if test "$ax_cv_cxx_compiler_vendor" != "sun" && test "$ax_cv_cxx_compiler_vendor" != "portland"; then
# -include works with gcc, intel, pathscale and sunstudio since 12u1, but doesn't work
# with pgi and older sunstudio (the one in solaris10, for example).
# Note: some gcc-frontend-based compilers may have to be added here
# (e.g. gccfss (gcc frontend / sun backend), etc...).
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "intel" \
|| test "$ax_cv_cxx_compiler_vendor" = "pathscale"; then
# This auto-includes this file when compiling any file. Benefits include pch support.
ADDITIONAL_INCLUDES="$ADDITIONAL_INCLUDES -include global_macros.h"
else # sun, pgi, others...
# This forces the file to be included manually.
ADDITIONAL_INCLUDES="$ADDITIONAL_INCLUDES -DHZ_NO_COMPILER_AUTOINCLUDE"
fi
#CFLAGS="$ADDITIONAL_INCLUDES $CFLAGS"
# our flags must be before all the others
#CFLAGS="$ADDITIONAL_INCLUDES $CFLAGS"
CXXFLAGS="$ADDITIONAL_INCLUDES $CXXFLAGS"
@@ -506,23 +443,12 @@ CXXFLAGS="$ADDITIONAL_INCLUDES $CXXFLAGS"
# -------------------------------------------------------------------------------------
# Append compiler flags to CXXFLAGS, so that they override
# whatever the user has set.
CXXFLAGS="$CXXFLAGS $COMPILER_CXXFLAGS"
LIBS="$LIBS $COMPILER_LDFLAGS"
# final setup
# This macro should be defined by ./configure automatically.
# However, sometimes it's not (e.g. win32, why?), so we define it manually.
CXXFLAGS="$CXXFLAGS -DHAVE_CONFIG_H"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# final setup
#CFLAGS="$CFLAGS $USER_INCLUDES"
#CXXFLAGS="$CXXFLAGS $USER_INCLUDES"
#LIBS="$LIBS $USER_LDFLAGS"
@@ -535,6 +461,8 @@ AC_SUBST(LIBS)
AC_SUBST(LDFLAGS)
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
@@ -551,11 +479,13 @@ AC_SUBST(LDFLAGS)
# print'em out for debug purposes
# print them out for debug purposes
AC_MSG_NOTICE([
CXXFLAGS:
$CXXFLAGS
LDFLAGS:
$LDFLAGS
LIBS:
$LIBS
])
@@ -566,19 +496,30 @@ $LIBS
AC_SUBST(AUTODIRS)
# ----------------------------------------------------
# -------------------------------------------------------------------------------------
AC_CONFIG_FILES([ data/gsmartcontrol_gnome.desktop data/gsmartcontrol_kde.desktop \
data/gsmartcontrol_other.desktop \
# -------------------------------------------------------------------------------------
AC_CONFIG_FILES([ data/gsmartcontrol.desktop \
data/nsis/distribution.txt data/nsis/gsmartcontrol.nsi \
debian.dist/changelog \
src/gsc_winres.rc \
gsmartcontrol.spec version compilation_flags ])
AC_CONFIG_FILES([data/gsmartcontrol-root], [chmod +x data/gsmartcontrol-root])
# these are all the makefiles to generate
AC_CONFIG_FILES([Makefile src/Makefile src/applib/Makefile src/res/Makefile src/hz/Makefile \
src/libdebug/Makefile src/pcrecpp/Makefile src/rconfig/Makefile src/rmn/Makefile \
data/Makefile data/16/Makefile data/22/Makefile data/24/Makefile data/32/Makefile \
data/48/Makefile data/64/Makefile data/128/Makefile])
data/48/Makefile data/64/Makefile data/128/Makefile data/256/Makefile data/nsis/Makefile \
debian.dist/Makefile])
AC_OUTPUT
+17
View File
@@ -0,0 +1,17 @@
This directory contains scripts and an example crontab to allow GSmartControl
to read smartctl data from cron-generated files. This allows users to read
somewhat recent smartctl information without having to run GSmartControl as
root.
Put the scripts into /usr/local/bin, run GSmartControl and set smartctl path
to "/usr/local/bin/smartctl_subst.sh" (without quotes). An example crontab
runs cron_gather_smart.sh script every 10 minutes, storing its output to
"/var/run/smart-$devname". The smartctl_subst.sh script prints the contents of
this file instead of running smartctl, thus eliminating the need to run
GSmartControl as root when reading SMART values.
Note: These scripts provide read-only capabilities only, they don't allow
changing SMART settings or running self-tests.
Contributed by Alex Butcher <alex dot butcher 'at' assursys.co.uk>.
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
############################################################################
# Copyright:
# (C) 2008 - 2009 Alex Butcher <alex dot butcher 'at' assursys.co.uk>
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_whatever.txt file
############################################################################
device="$1";
if [ "$device" = "" ]; then
echo "Usage: $0 <device>"
exit 1;
fi
dev_base="`basename \"$device\"`"
out_file=/var/run/smart-"$dev_base"
# Change the path to smartctl if necessary.
smartctl -a "$device" 2>&1 > "$out_file"
chmod 644 "$out_file"
@@ -0,0 +1,2 @@
*/10 * * * * root /usr/local/bin/cron-smart.sh /dev/sda
*/10 * * * * root /usr/local/bin/cron-smart.sh /dev/sdb
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
############################################################################
# Copyright:
# (C) 2008 - 2009 Alex Butcher <alex dot butcher 'at' assursys.co.uk>
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_whatever.txt file
############################################################################
if [ "$1" = "-V" ]; then
smartctl -V 2>&1
exit
fi
while [ $# -ge 1 ]; do
device="$1"
shift
done
if [ "$device" = "" ]; then
echo "Usage: $0 <device>"
exit 1;
fi
dev_base="`basename \"$device\"`"
out_file=/var/run/smart-"$dev_base"
cat "$out_file"

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

+4
View File
@@ -0,0 +1,4 @@
appicondir = $(datadir)/icons/hicolor/256x256/apps
appicon_DATA = gsmartcontrol.png
EXTRA_DIST = $(appicon_DATA)
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

+57
View File
@@ -0,0 +1,57 @@
SUBDIRS = 16 22 24 32 48 64 128 256 nsis
dist_man_MANS = gsmartcontrol.1
install-extra-mans:
cd $(DESTDIR)$(mandir)/man1 && $(LN_S) -f gsmartcontrol.1 gsmartcontrol-root.1
uninstall-extra-mans:
cd $(DESTDIR)$(mandir)/man1 && rm -f gsmartcontrol-root.1
# This command is needed if installing with make install (the cache
# file is ignored for rpms).
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
install-data-hook: install-extra-mans update-icon-cache
uninstall-hook: uninstall-extra-mans update-icon-cache
update-icon-cache:
@-if test -z "$(DESTDIR)"; then \
echo "Updating GTK icon cache."; \
$(gtk_update_icon_cache); \
else \
echo "*** Icon cache not updated. After (un)install, run this:"; \
echo "*** $(gtk_update_icon_cache)"; \
fi
# Application data, installs to /usr/share/appname
appdatadir = $(pkgdatadir)
appdata_DATA = icon_cddvd.png icon_hdd.png
# pkgdatadir = $(datadir)/gsmartcontrol
# pkgdata_DATA =
# Desktop files
desktopdir = $(datadir)/applications
desktop_DATA = gsmartcontrol.desktop
# Application pixmap (fallback icon for desktop files).
# Same as 48/gsmartcontrol.png.
# Also, xpm for debian menu, 32x32.
pixmapsdir = $(datadir)/pixmaps
pixmaps_DATA = 48/gsmartcontrol.png gsmartcontrol.xpm
# Put everything inside the distribution
EXTRA_DIST = $(appdata_DATA) gsmartcontrol.ico gsmartcontrol.xpm
bin_SCRIPTS = gsmartcontrol-root
CLEANFILES = $(bin_SCRIPTS)
+111
View File
@@ -0,0 +1,111 @@
#!/bin/bash
############################################################################
# Copyright:
# (C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# Run gsmartcontrol with root, asking for root password first.
EXEC_BIN="@prefix@/bin/gsmartcontrol";
prog_name="gsmartcontrol"
DESKTOP="$1";
# This works for --help too
if [ "$DESKTOP" = "" ]; then
DESKTOP="auto"; # default
elif [ "$DESKTOP" != "auto" ] && [ "$DESKTOP" != "kde" ] && \
[ "$DESKTOP" != "gnome" ] && [ "$DESKTOP" != "other" ]; then
echo "Usage: $0 [<auto|kde|gnome|other> [<${prog_name}_options>] ]";
exit 1;
fi
shift; # remove $1
# Auto-detect current desktop if auto was specified.
if [ "$DESKTOP" = "auto" ]; then
# KDE_SESSION_UID is present on kde3 and kde4.
# Note that it may be empty (but still set)
if [ "${KDE_SESSION_UID+set}" = "set" ]; then
DESKTOP="kde";
# same with gnome
elif [ "${GNOME_DESKTOP_SESSION_ID+set}" = "set" ]; then
DESKTOP="gnome";
else
DESKTOP="other";
fi
fi
# echo $DESKTOP;
# They're basically the same, only the order is different.
# sux requires xterm to ask for the password.
# xdg-su is basically like this script, except worse :)
gnome_sus="gnomesu gksu kdesu xdg-su sux";
kde_sus="kdesu gnomesu gksu xdg-su sux";
other_sus="$gnome_sus";
candidates="";
found_su=""
if [ "$DESKTOP" = "gnome" ]; then
candidates="$gnome_sus";
elif [ "$DESKTOP" = "kde" ]; then
candidates="$kde_sus";
elif [ "$DESKTOP" = "other" ]; then
candidates="$other_sus";
fi
for subin in $candidates; do
which $subin &>/dev/null
if [ $? -eq 0 ]; then
found_su="$subin";
break;
fi
done
if [ "$found_su" = "" ]; then
xmessage "Error launching ${prog_name}: No suitable su mechanism found.
Try installing kdesu, gnomesu, gksu or sux first.";
exit 1;
fi
# gnomesu and gksu (but not kdesu, not sure about others) fail to adopt
# root's PATH. Since the user's PATH may not contain /usr/sbin (with smartctl)
# on some distributions (e.g. mandriva), add it manually. We also add
# /usr/local/sbin, since that's the default location of custom-compiled smartctl.
# Add these directories _before_ existing PATH, so that the user is not
# tricked into running it from some other path (we're running as root with
# the user's env after all).
export PATH="/usr/sbin:/usr/local/sbin:$PATH"
# echo $found_su;
# Examples:
# gnomesu -c 'gsmartcontrol --no-scan'
# kdesu -c 'gsmartcontrol --no-scan'
# xterm -e sux -c 'gsmartcontrol --no-scan' # sux asks for password in a terminal
full_cmd=""
if [ "$found_su" = "sux" ]; then
full_cmd="xterm -e sux -c '$EXEC_BIN $@'"
elif [ "$found_su" = "gksu" ]; then
full_cmd="$found_su '$EXEC_BIN $@'"
else # gnomesu, kdesu, xdg-su
full_cmd="$found_su -c '$EXEC_BIN $@'"
fi
eval $full_cmd
+74
View File
@@ -0,0 +1,74 @@
.TH GSmartControl "1" "" "gsmartcontrol " "User Commands"
.SH NAME
GSmartControl \- Hard disk drive health inspection tool
.SH SYNOPSIS
\fBgsmartcontrol\fP [OPTIONS]
\fBgsmartcontrol\-root\fP [\fI<desktop>\fP [OPTIONS]]
.SH DESCRIPTION
\fBGSmartControl\fP is a graphical user interface for smartctl (from
smartmontools), which is a tool for querying and controlling SMART
(Self-Monitoring, Analysis, and Reporting Technology) data on modern hard disk
drives. It allows you to inspect the drive's SMART data to determine its
health, as well as run various tests on it.
.PP
This manual page documents briefly the \fBgsmartcontrol\fP and
\fBgsmartcontrol\-root\fP commands.
.PP
\fBgsmartcontrol\-root\fP command launches \fBgsmartcontrol\fP with
administrative privileges. The \fIdesktop\fP argument specifies which desktop
is currently running, for automatic selection of native su mechanism. Valid
values for \fIdesktop\fP are \fBauto\fP, \fBkde\fP, \fBgnome\fP, \fBother\fP.
.SH OPTIONS
.SS "Help Options:"
.TP
\fB\-?\fP, \fB\-\-help\fP
Show help options
.TP
\fB\-\-help\-all\fP
Show all help options
.TP
\fB\-\-help\-gtk\fP
Show GTK+ options
.TP
\fB\-\-help\-debug\fR
Show logging options
.SS "Application Options:"
.TP
\fB\-l\fP, \fB\-\-no\-locale\fP
Disable locale
.TP
\fB\-V\fP, \fB\-\-version\fP
Display version information
.TP
\fB\-\-no\-scan\fP
Don't scan devices on startup
.TP
\fB\-\-no\-hide\-tabs\fP
Don't hide non\-identity tabs when SMART is disabled. Useful for debugging.
.TP
\fB\-\-add\-virtual\fP
Load smartctl data from file, creating a virtual drive
.TP
\fB\-\-add\-device\fP
Add this device to device list. Useful with \fB\-\-no\-scan\fP to list certain drives only.
.TP
\fB\-\-display\fP=\fIDISPLAY\fP
X display to use
.TP
\fB\-v\fP, \fB\-\-verbose\fP
Enable verbose logging; same as \fB\-\-verbosity\-level\fP 5
.TP
\fB\-q\fP, \fB\-\-quiet\fP
Disable logging; same as \fB\-\-verbosity\-level\fP 0
.TP
\fB\-b\fP, \fB\-\-verbosity\-level\fP
Set verbosity level [0\-5]
.PP
.SH COPYRIGHT
Copyright \(co 2008 \- 2009 Alexander Shaduri <ashaduri \'at\' gmail.com>
.PP
.SH AUTHOR
This manual page was originally written by Giuseppe Iuculano
<giuseppe@iuculano.it>, for the Debian project.
@@ -1,14 +1,10 @@
[Desktop Entry]
# Desktop file for kde only.
OnlyShowIn=KDE;
# desktop file version
Version=1.0
Type=Application
Categories=System;GTK;
# Categories=Settings;HardwareSettings;
Categories=System;Monitor;
Name=GSmartControl
# short description, usually shown in parentheses after Name
@@ -26,4 +22,8 @@ Icon=gsmartcontrol
#X-KDE-SubstituteUID=true
#X-KDE-RootOnly=true
Exec=kdesu "@prefix@/bin/gsmartcontrol"
# Run with root permissions.
Exec="@prefix@/bin/gsmartcontrol-root"
# Build service rpmlint gives errors without this
X-SuSE-translate=false
Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

+394
View File
@@ -0,0 +1,394 @@
/* XPM */
static char * gsmartcontrol_xpm[] = {
"32 32 359 2",
" c None",
". c #ABAAAA",
"+ c #CCCCCC",
"@ c #C5C4C4",
"# c #C2C1C1",
"$ c #D2D1D1",
"% c #C8C7C7",
"& c #C8C7C8",
"* c #C9C8C8",
"= c #CAC8C9",
"- c #CAC9C9",
"; c #C8C6C7",
"> c #C7C6C6",
", c #CFCDCE",
"' c #D1D0D0",
") c #C6C5C6",
"! c #CFCECE",
"~ c #B9B7B7",
"{ c #D4D4D4",
"] c #DCDBDC",
"^ c #D8D7D7",
"/ c #D6D5D5",
"( c #D6D5D6",
"_ c #D7D6D6",
": c #D9D8D8",
"< c #DBDADB",
"[ c #DAD9DA",
"} c #D7D7D7",
"| c #D6D6D6",
"1 c #DAD9D9",
"2 c #E2E1E1",
"3 c #B0AFAF",
"4 c #D3D2D2",
"5 c #CDCCCC",
"6 c #CDCDCD",
"7 c #CECDCD",
"8 c #CECECE",
"9 c #CFCFCF",
"0 c #D0CFCF",
"a c #C0BFBF",
"b c #9C9A9B",
"c c #6E6B6B",
"d c #807E7F",
"e c #C8C8C8",
"f c #CAC9CA",
"g c #CACACA",
"h c #CBCACA",
"i c #CCCBCB",
"j c #CCCBCC",
"k c #D0CECF",
"l c #C3C2C2",
"m c #A09E9F",
"n c #B5B4B4",
"o c #AFADAE",
"p c #787576",
"q c #8D8B8B",
"r c #D4D3D3",
"s c #C7C6C7",
"t c #C7C7C7",
"u c #C9C8C9",
"v c #C9C9C9",
"w c #CACAC9",
"x c #BFBEBE",
"y c #A3A1A2",
"z c #A09D9E",
"A c #B4B2B2",
"B c #B6B4B4",
"C c #827F80",
"D c #969595",
"E c #C4C3C3",
"F c #C4C4C4",
"G c #C5C5C5",
"H c #C6C5C5",
"I c #C6C6C6",
"J c #C9C7C8",
"K c #B9B7B8",
"L c #A5A4A4",
"M c #A4A3A3",
"N c #A7A5A5",
"O c #B3B1B2",
"P c #BFBDBD",
"Q c #8D8A8B",
"R c #A09F9F",
"S c #DDDCDC",
"T c #C0C0C0",
"U c #C3C1C2",
"V c #C3C2C3",
"W c #C3C3C3",
"X c #C4C3C4",
"Y c #B2B1B1",
"Z c #A8A7A7",
"` c #ABA9A9",
" . c #CFCECF",
".. c #C2C0C1",
"+. c #989697",
"@. c #A8A6A7",
"#. c #DEDDDD",
"$. c #DEDDDE",
"%. c #C1C0C0",
"&. c #C2C1C2",
"*. c #B1B0B0",
"=. c #ADACAC",
"-. c #AFAEAE",
";. c #BDBCBC",
">. c #B3B2B2",
",. c #B4B3B4",
"'. c #B8B8B8",
"). c #D5D4D4",
"!. c #C0BFBE",
"~. c #C1C0C1",
"{. c #C3C1C1",
"]. c #C4C4C3",
"^. c #B2B0B1",
"/. c #B3B2B3",
"(. c #B4B3B3",
"_. c #A1A0A0",
":. c #B9B8B8",
"<. c #C4C2C3",
"[. c #BDBBBC",
"}. c #B5B4B3",
"|. c #B6B4B5",
"1. c #B7B5B6",
"2. c #B7B6B7",
"3. c #B8B7B7",
"4. c #B8B7B8",
"5. c #BCBABB",
"6. c #BBBABA",
"7. c #BFBEBF",
"8. c #C1C1C1",
"9. c #C1BFC0",
"0. c #BCBBBB",
"a. c #BEBCBD",
"b. c #BEBDBD",
"c. c #9B999A",
"d. c #9D9B9B",
"e. c #C2C2C2",
"f. c #D4D3D4",
"g. c #CECDCE",
"h. c #C7C5C5",
"i. c #A4A2A3",
"j. c #A19F9F",
"k. c #C6C4C5",
"l. c #DCDCDC",
"m. c #D0CFD0",
"n. c #CECCCD",
"o. c #A2A1A1",
"p. c #939292",
"q. c #E1E0E0",
"r. c #E3E3E3",
"s. c #B3B3B3",
"t. c #CCCACB",
"u. c #D2D2D2",
"v. c #D5D3D4",
"w. c #A7A6A6",
"x. c #959494",
"y. c #E3E2E2",
"z. c #DCDBDB",
"A. c #CBC9CA",
"B. c #E1E0E1",
"C. c #DFDEDE",
"D. c #CECCCC",
"E. c #CDCCCD",
"F. c #D2D0D0",
"G. c #D2D0D1",
"H. c #B5B4B5",
"I. c #B1AFB0",
"J. c #EDECEC",
"K. c #D1CFCF",
"L. c #CDCBCC",
"M. c #D5D5D5",
"N. c #DCDADA",
"O. c #C5C4C5",
"P. c #D2D1D2",
"Q. c #D5D4D5",
"R. c #DADADA",
"S. c #DBDADA",
"T. c #DDDCDD",
"U. c #D7D6D7",
"V. c #E8E7E7",
"W. c #D8D8D8",
"X. c #D8D6D6",
"Y. c #D9D8D9",
"Z. c #DBDBDB",
"`. c #DDDDDD",
" + c #474747",
".+ c #ECEBEB",
"++ c #F3F3F3",
"@+ c #E4E3E3",
"#+ c #E0DFDF",
"$+ c #E5E5E5",
"%+ c #EFEFEF",
"&+ c #EBEAEB",
"*+ c #E6E5E5",
"=+ c #E0E0E0",
"-+ c #E4E4E4",
";+ c #E5E4E4",
">+ c #ECECEC",
",+ c #666666",
"'+ c #585757",
")+ c #D9D9DA",
"!+ c #E2E2E2",
"~+ c #E6E5E6",
"{+ c #E1E1E1",
"]+ c #E6E6E6",
"^+ c #E7E7E7",
"/+ c #898989",
"(+ c #767575",
"_+ c #E0DFE0",
":+ c #E9E9E9",
"<+ c #BDBDBD",
"[+ c #B6B6B6",
"}+ c #B0B0B0",
"|+ c #ACACAC",
"1+ c #ACABAC",
"2+ c #A7A7A7",
"3+ c #DFDFDF",
"4+ c #E5E5E4",
"5+ c #E9E8E8",
"6+ c #E8E8E8",
"7+ c #E3E2E3",
"8+ c #D7D5D5",
"9+ c #8E8D8D",
"0+ c #807F7F",
"a+ c #494848",
"b+ c #5A5758",
"c+ c #605E5F",
"d+ c #646262",
"e+ c #555354",
"f+ c #1F1F1F",
"g+ c #282626",
"h+ c #323031",
"i+ c #3D3C3C",
"j+ c #494748",
"k+ c #555353",
"l+ c #5A5959",
"m+ c #3E3D3D",
"n+ c #434242",
"o+ c #444343",
"p+ c #414041",
"q+ c #3E3E3E",
"r+ c #4A4949",
"s+ c #706D6E",
"t+ c #6B6969",
"u+ c #6A6869",
"v+ c #696469",
"w+ c #656065",
"x+ c #595757",
"y+ c #A5A5A5",
"z+ c #767676",
"A+ c #8A8888",
"B+ c #4B4849",
"C+ c #5C5A5A",
"D+ c #686565",
"E+ c #524F50",
"F+ c #000000",
"G+ c #090607",
"H+ c #171415",
"I+ c #262324",
"J+ c #363334",
"K+ c #454343",
"L+ c #4A4748",
"M+ c #212020",
"N+ c #2A292A",
"O+ c #2C2B2B",
"P+ c #272626",
"Q+ c #242424",
"R+ c #242323",
"S+ c #3C3B3B",
"T+ c #726F70",
"U+ c #6C696A",
"V+ c #6B676A",
"W+ c #7A916C",
"X+ c #7B926B",
"Y+ c #605F60",
"Z+ c #9C9B9C",
"`+ c #606060",
" @ c #8F8D8D",
".@ c #494747",
"+@ c #595657",
"@@ c #615E5F",
"#@ c #656162",
"$@ c #525050",
"%@ c #020101",
"&@ c #0C0A0A",
"*@ c #1A1818",
"=@ c #282525",
"-@ c #454243",
";@ c #494647",
">@ c #2A2929",
",@ c #393838",
"'@ c #363536",
")@ c #323131",
"!@ c #2B292A",
"~@ c #282727",
"{@ c #444243",
"]@ c #696666",
"^@ c #666268",
"/@ c #709D48",
"(@ c #7BAD4A",
"_@ c #68686A",
":@ c #8F8E8F",
"<@ c #4E4D4E",
"[@ c #8E8C8D",
"}@ c #484546",
"|@ c #555253",
"1@ c #5D595A",
"2@ c #5F5B5C",
"3@ c #514F50",
"4@ c #0F0D0D",
"5@ c #211E1F",
"6@ c #312E2F",
"7@ c #413D3E",
"8@ c #222121",
"9@ c #2E2D2D",
"0@ c #312F30",
"a@ c #262425",
"b@ c #464344",
"c@ c #696667",
"d@ c #666263",
"e@ c #5F5E5F",
"f@ c #5A5B5B",
"g@ c #797577",
"h@ c #7A7A7A",
"i@ c #4C4A4A",
"j@ c #2A2728",
"k@ c #2C292A",
"l@ c #302D2E",
"m@ c #312F2F",
"n@ c #2E2C2C",
"o@ c #100F0F",
"p@ c #110F10",
"q@ c #141212",
"r@ c #1B1919",
"s@ c #242222",
"t@ c #2D2B2B",
"u@ c #322F30",
"v@ c #2F2D2D",
"w@ c #2B2829",
"x@ c #292728",
"y@ c #363233",
"z@ c #332F30",
"A@ c #312D2F",
"B@ c #2A2627",
"C@ c #424040",
"D@ c #454444",
"E@ c #737373",
"F@ c #828282",
"G@ c #939293",
"H@ c #9C9C9C",
"I@ c #A3A3A3",
"J@ c #A9A9A9",
"K@ c #ADADAD",
"L@ c #B2B2B2",
"M@ c #B5B5B5",
"N@ c #A4A4A4",
"O@ c #959595",
"P@ c #8C8C8C",
"Q@ c #707070",
"R@ c #FFFFFF",
" ",
" . + @ # $ % & * = - ; > * - - - * , ' ) ! ~ ",
" = { ' ] ^ { / / ( _ : < [ ^ ^ } ^ | 1 2 } 3 ",
" - 4 ' ' 5 6 6 6 7 7 8 9 ! ! 9 9 0 0 $ 5 a b c ",
" d 4 [ * e - - f g h h h i i j + 5 5 k l m n o p ",
" q _ r @ > > s s t % % * * u v - w 5 x y z A B C ",
" D 1 7 l E F @ @ G H H I > > > J * K L M N O P Q ",
" R S % T U U l V W E X F @ @ > E Y Z ` > .* ..+. ",
" @.#.$.W %.# # # &.l l V E G T *.=.-.*.5 ;.>.,.Z ",
" n '.).[ !.T ~.# ..{.U l ].x Y ^.>.A /.(.x ;.O _. ",
" :.^.<.h a %.%.# # # &.U [.}.|.1.2.3.4.K K a 5.N ",
" 6.i H 7.%.8.# &.# l * % E 9.[.5.0.[.;.a.b.;., %.c. ",
" d.> 0 a # &.e.V V % ^ f.j g - % %.....&.l V l g.h.i. ",
" j./ i # E E @ k.H l.g.%.# l E H <.b.; > % % % m.n.o. ",
" p.q.7 @ ) > % % - r.) > % * * g f s.5 t.i i i u.v.w. ",
" x.y.z.> u - g A.- B.C.D.E.! 0 7 (.6.$ ' ' F.G.).^ H. ",
" I.7 J.K.L.7 7 ! ! m.S 1 m.- %.3.8./ ).M./ | _ : N.; ",
" O., F.f.P.4 4 4 f.f.r / Q.4 4 ^ R.: : 1 [ S.< S T.U. ",
" 4 V.| ).| _ W._ X.^ : Y.1 S.Z.z.] S S `.#.C.C.2 V.q. + ",
" S..+++@+`.#+$+%+&+*+2 #+=+q.y.-+-+-+;+$+$+*+>+++Z.*+,+ ",
" '+S.# $ >+r.m.e.# 6 )+!+~+*+@+B.=+{+-+]+]+^+]+^+j 5 y./+ ",
" (+b.3 _+! m.#+:+q.r > <+[+}+|+3 '.b.8.> e 5 7 ! ^+j 1+2+ ",
" x.] ! r / ^ W.R.S 3+2 y.@+4+5+6+^+~+*+;+7+#+C.#.S.8+: V ",
" 9+0+a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+n+p+q+r+s+t+u+v+w+x+y+ ",
" z+A+B+C+d+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z+ ",
" `+ @.@+@@@#@$@%@&@*@=@J+-@;@>@,@'@)@!@~@{@c ]@^@/@(@_@:@ ",
" <@[@}@|@1@2@3@F+%@4@5@6@7@-@8@9@9@0@~@a@b@c@#@d@e@f@g@h@ ",
" i@j@k@l@m@n@o@p@q@r@s@t@u@!@l@v@v@w@x@l@y@z@6@A@B@C@D@ ",
" E@F@G@H@I@J@K@}+L@M@M@M@s.}+|+N@H@O@P@F@Q@ ",
" R@R@R@R@R@R@R@R@R@ ",
" ",
" "};

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

+2
View File
@@ -0,0 +1,2 @@
EXTRA_DIST = distribution.txt.in gsmartcontrol.nsi.in nsi_install.ico nsi_uninstall.ico
+29
View File
@@ -0,0 +1,29 @@
GSmartControl - Hard disk drive health inspection tool
Version @VERSION@
The latest version of this distribution, as well as the source code of
GSmartControl, can be found at
http://gsmartcontrol.berlios.de
and
http://developer.berlios.de/project/showfiles.php?group_id=10075
You need GTK+ for Windows Runtime package to use this program. You can get one
at http://gtk-win.sf.net (you must download at least version 2.14.4-2008-11-11
of gtk2-runtime).
This distribution includes:
* GSmartControl binary (gsmartcontrol.exe) and associated resources. The
binary was compiled for 32-bit Windows, and should work on both 32-bit and
64-bit Windows. The binary was statically compiled against Gtkmm
(http://www.gtkmm.org/) and related libraries, and PCRE (http://www.pcre.org/).
* Smartctl binaries (from smartmontools 5.39-0-20090826-r2878,
http://smartmontools.sf.net/) - smartctl-nc.exe (compiled without console
output), smartctl.exe (compiled with console output).
The combined distribution is multi-licensed under GNU GPL versions 2 and 3.
See LICENSE_gpl2.txt and LICENSE_gpl3.txt for details.
+293
View File
@@ -0,0 +1,293 @@
; NSIS2 Script
; Compatible with NSIS 2.40
!define PRODUCT_VERSION "@VERSION@"
!define PRODUCT_NAME "GSmartControl"
!define PRODUCT_NAME_SMALL "gsmartcontrol"
!define PRODUCT_PUBLISHER "Alexander Shaduri"
!define PRODUCT_WEB_SITE "http://gsmartcontrol.berlios.de"
;!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AppMainExe.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define REGISTRY_APP_PATHS "Software\Microsoft\Windows\CurrentVersion\App Paths"
; --------------- General Settings
; This compressor gives us the best results
SetCompressor /SOLID lzma
; Do a CRC check before installing
CRCCheck On
; This is used in titles
Name "${PRODUCT_NAME}" ; ${PRODUCT_VERSION}
; Output File Name
OutFile "${PRODUCT_NAME_SMALL}-${PRODUCT_VERSION}.exe"
;The Default Installation Directory
; try to install to the same directory as runtime.
InstallDir "$PROGRAMFILES\${PRODUCT_NAME_SMALL}"
; If already installed, try here
InstallDirRegKey HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory"
ShowInstDetails show
ShowUnInstDetails show
; --------------------- MUI INTERFACE
; MUI 2.0 compatible install
!include "MUI2.nsh"
;Backgound Colors. uncomment to enable fullscreen.
; BGGradient 0000FF 000000 FFFFFF
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "nsi_install.ico"
!define MUI_UNICON "nsi_uninstall.ico"
;Things that need to be extracted on first (keep these lines before any File command!)
;Only useful for BZIP2 compression
!insertmacro MUI_RESERVEFILE_LANGDLL
;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
; Pages to show during installation
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "doc\distribution.txt"
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;!define MUI_FINISHPAGE_RUN "$INSTDIR\gsmartcontrol.exe"
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Example.file"
;!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_PAGE_FINISH
; Uninstaller page
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; --------------- END MUI
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "GSmartControl"
; --------------- START INSTALLATION
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
Push 2 ;F ;22 = number of languages, F = change font
;Language selection
LangDLL::LangDialog "Installer Language" "Please select a language."
Pop $LANGUAGE
StrCmp $LANGUAGE "cancel" 0 +2
Abort
; detect previous installation
ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
StrCmp $R0 "" no_prev
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${PRODUCT_NAME} is already installed. $\n$\nClick 'OK' to remove the \
previous version or 'Cancel' to continue anyway." \
IDOK uninst_product
; Abort
goto no_prev ; if cancel was pressed, continue as if no old installation.
;Run the uninstaller
uninst_product:
ClearErrors
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
IfErrors cannot_uninst_product
;You can either use Delete /REBOOTOK in the uninstaller or add some code
;here to remove the uninstaller. Use a registry key to check
;whether the user has chosen to uninstall. If you are using an uninstaller
;components page, make sure all sections are uninstalled.
cannot_uninst_product:
no_prev: ; no old installation found, all ok
; detect GTK installation (any of available versions)
ReadRegStr $R0 HKLM "SOFTWARE\GTK\2.0" "DllPath"
StrCmp $R0 "" no_gtk
goto have_gtk
no_gtk:
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"GTK2-Runtime is not installed. This product needs it to function properly.$\n\
Please install GTK2-Runtime from http://gtk-win.sf.net/ first.$\n$\n\
Click 'Cancel' to abort the installation \
or 'OK' to continue anyway." \
IDOK have_gtk
Abort
have_gtk:
; do nothing
FunctionEnd
; ----------------- INSTALLATION TYPES
; InstType "Recommended"
InstType "Full"
;InstType "Minimal"
Section "Main" SecMain
SectionIn 1
SetOutPath "$INSTDIR"
SetOverwrite Off ; don't overwrite the config file
; File "gsmartcontrol.conf"
SetOverwrite On
File gsmartcontrol.exe
File gsmartcontrol.ico
File icon_*.png
; File *.dll
File smartctl-nc.exe
File smartctl.exe
File /r doc
; set a special path for this exe, as GTK may not be in a global path.
ReadRegStr $R3 HKLM "SOFTWARE\GTK\2.0" "DllPath"
WriteRegStr HKLM "${REGISTRY_APP_PATHS}\gsmartcontrol.exe" "Path" "$R3"
;Add Shortcuts
CreateShortCut "$SMPROGRAMS\GSmartControl.lnk" "$INSTDIR\gsmartcontrol.exe" "" "$INSTDIR\gsmartcontrol.ico" 0
SectionEnd
; ------------------ POST INSTALL
!define TEMP $R0
Section -post
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "Vendor" "Alexander Shaduri"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\gsmartcontrol_uninst.exe"
; We don't need this, MUI takes care for us
WriteRegStr HKCU "Software\${PRODUCT_NAME}" "Installer Language" $LANGUAGE
; uninstall shortcut
; CreateDirectory "$SMPROGRAMS\GSmartControl"
; CreateShortCut "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk" "$INSTDIR\gsmartcontrol_uninst.exe" "" ""
; write out uninstaller
WriteUninstaller "$INSTDIR\gsmartcontrol_uninst.exe"
SectionEnd ; post
; ---------------- UNINSTALL
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Section Uninstall
SetAutoClose false
; add delete commands to delete whatever files/registry keys/etc you installed here.
Delete "$INSTDIR\gsmartcontrol_uninst.exe"
DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}"
DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
Delete "$INSTDIR\gsmartcontrol.exe"
Delete "$INSTDIR\gsmartcontrol.ico"
Delete "$INSTDIR\icon_*.png"
; Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\smartctl-nc.exe"
Delete "$INSTDIR\smartctl.exe"
RMDir /r "$INSTDIR\doc"
RMDir "$INSTDIR" ; only if empty
DeleteRegKey HKLM "${REGISTRY_APP_PATHS}\gsmartcontrol.exe"
Delete "$SMPROGRAMS\GSmartControl.lnk"
; Delete "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk"
SectionEnd ; end of uninstall section
; eof
Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

+6
View File
@@ -0,0 +1,6 @@
noinst_DATA = changelog.in compat control copyright menu postinst postrm rules
# include the generated file too
EXTRA_DIST=changelog.in changelog compat control copyright menu postinst \
postrm rules
+5
View File
@@ -0,0 +1,5 @@
gsmartcontrol (@VERSION@+nmu1) unstable; urgency=low
* Permanently Initial Release.
-- Alexander Shaduri <ashaduriREMOVETHIS@gmail.com> Sat, 15 Nov 2008 00:12:04 +0400
+1
View File
@@ -0,0 +1 @@
5
+21
View File
@@ -0,0 +1,21 @@
Source: gsmartcontrol
Section: utils
Priority: extra
Homepage: http://gsmartcontrol.berlios.de/
Maintainer: Alexander Shaduri <ashaduriREMOVETHIS@gmail.com>
# technically, we don't need libglademm if gtkmm >= 2.12, but it won't get
# into Depends if it's not needed, so let's leave it here.
Build-Depends: debhelper (>= 5), autotools-dev,
libpcre3-dev, libgtkmm-2.4-dev (>= 2.6.0), libglademm-2.4-dev
Standards-Version: 3.7.3
Package: gsmartcontrol
Architecture: any
#Depends: ${shlibs:Depends}, ${misc:Depends}, smartmontools
Depends: ${shlibs:Depends}, smartmontools
Description: Hard disk drive health inspection tool
GSmartControl is a graphical user interface for smartctl (from smartmontools
package), which is a tool for querying and controlling SMART
(Self-Monitoring, Analysis, and Reporting Technology) data on modern hard
disk drives. It allows you to inspect the drive's SMART data to determine its
health, as well as run various tests on it.
+32
View File
@@ -0,0 +1,32 @@
This package was debianized by Alexander Shaduri <ashaduri 'at' gmail.com> on
Sat, 15 Nov 2008 00:12:04 +0400.
It was downloaded from <http://gsmartcontrol.berlios.de/>
Copyright:
Copyright (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
License:
This product is multi-licensed under GNU GPL versions 2 and 3.
You are free to choose which one you use.
This program is free software: you can redistribute it and/or modify it under
the terms of either version 2 or (at your option) version 3 of the GNU General
Public License as published by the Free Software Foundation.
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 Licenses for more details.
You should have received copies of these licenses along with this program.
If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU General
Public Licenses can be found in `/usr/share/common-licenses/GPL-2' and
`/usr/share/common-licenses/GPL-3'.
The Debian packaging is (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com> and
is licensed under the GPLv2 and GPLv3, see above.
+4
View File
@@ -0,0 +1,4 @@
?package(gsmartcontrol):needs="X11" section="Applications/System/Hardware"\
title="GSmartControl" command="/usr/bin/gsmartcontrol-root"\
longtitle="Hard Disk Health Inspection"\
icon="/usr/share/pixmaps/gsmartcontrol.xpm"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -e
if test -x /usr/bin/update-menus; then update-menus; fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -e
if test -x /usr/bin/update-menus; then update-menus; fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
config.status: configure
dh_testdir
# Add here commands to configure the package.
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
./configure --host=$(DEB_HOST_GNU_TYPE) \
--build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
# Add --enable-optimize-options=auto to configure line
# for optimized build (may not work on older gcc versions).
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
#docbook-to-man debian/gsmartcontrol.sgml > gsmartcontrol.1
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
-$(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/gsmartcontrol.
$(MAKE) DESTDIR=$(CURDIR)/debian/gsmartcontrol install-strip
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
# dh_installexamples
# dh_install
dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_python
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
@@ -1,10 +1,14 @@
#!/bin/sh
#!/bin/bash
############################################################################
# Copyright:
# (C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# We use #!/bin/bash of #!/bin/sh because freebsd (tested with 6.3) in its
# infinite wisdom has csh-like /bin/sh (even though the SUS says it
# must be bourne-compatible).
if [ "$1" == "" ] | [ "$2" == "" ] | [ "$3" == "" ]; then
echo "Usage: $0 <input_file> <cpp_file> <symbol_name>";
@@ -15,14 +15,14 @@
<projectname>gsmartcontrol</projectname>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<defaultencoding/>
<description></description>
<defaultencoding></defaultencoding>
<versioncontrol/>
</general>
<kdevautoproject>
<general>
<activetarget>src/gsmartcontrol</activetarget>
<useconfiguration>debuggy</useconfiguration>
<useconfiguration>suncc</useconfiguration>
</general>
<run>
<mainprogram>/10/devel/projects/gsmartcontrol/current/gsmartcontrol/debuggy</mainprogram>
@@ -66,7 +66,7 @@
<cflags/>
<cxxflags/>
<envvars/>
<configargs>--enable-default-gcc-options --enable-gcc-optimize --enable-gcc-pch --enable-tests</configargs>
<configargs>--disable-user-flags --enable-optimize-options --enable-tests</configargs>
<topsourcedir/>
<cppflags/>
<ldflags/>
@@ -76,42 +76,42 @@
<f77flags/>
</optimized>
<debuggy>
<configargs>--enable-default-gcc-options --enable-gcc-debug --enable-tests</configargs>
<configargs>--enable-debug-options --enable-tests</configargs>
<builddir>debuggy</builddir>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<cflags/>
<cxxflags/>
<cflags></cflags>
<cxxflags></cxxflags>
<envvars/>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<f77flags/>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<ldflags></ldflags>
<ccompilerbinary>gcc-4.4</ccompilerbinary>
<cxxcompilerbinary>g++-4.4</cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<f77flags></f77flags>
</debuggy>
<icc>
<envvars/>
<configargs>--disable-default-gcc-options --enable-tests</configargs>
<configargs>--disable-user-flags --enable-tests</configargs>
<builddir>icc</builddir>
<topsourcedir/>
<cppflags/>
<ldflags>-s -static-libgcc -static-intel</ldflags>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>icc</ccompilerbinary>
<cxxcompilerbinary>icpc</cxxcompilerbinary>
<ccompilerbinary>icc64</ccompilerbinary>
<cxxcompilerbinary>icpc64</cxxcompilerbinary>
<f77compilerbinary/>
<cflags>-w1</cflags>
<cxxflags>-g0 -O3 -m32 -ftrapuv -fstack-security-check -early-template-check -static-libgcc -static-intel -Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wmissing-prototypes -Wnon-virtual-dtor -Wpointer-arith -Wreturn-type -Wshadow -Wtrigraphs -Wuninitialized -w1</cxxflags>
<cflags/>
<cxxflags/>
<f77flags/>
</icc>
<win32>
<envvars/>
<configargs>--enable-default-gcc-options --enable-gcc-optimize --enable-gcc-pch --enable-tests --target=i386-mingw32msvc --host=i386-mingw32msvc --build=i686-linux PKG_CONFIG_PATH=/target/lib/pkgconfig PKG_CONFIG_LIBDIR=/target/lib PATH=&quot;/opt/cross-tools/bin:/target/bin:$PATH&quot;</configargs>
<configargs>--disable-user-flags --enable-optimize-options --enable-tests --build=i686-linux --host=i386-pc-mingw32 PKG_CONFIG_PATH=/cross/w32/target/lib/pkgconfig PKG_CONFIG_LIBDIR=&quot;&quot; PATH=&quot;/cross/w32/gcc-bin:/cross/w32/target/bin:$PATH&quot;</configargs>
<builddir>win32</builddir>
<topsourcedir/>
<cppflags/>
@@ -119,8 +119,8 @@
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>&quot;i386-mingw32msvc-gcc -mms-bitfields&quot;</ccompilerbinary>
<cxxcompilerbinary>&quot;i386-mingw32msvc-g++ -mms-bitfields&quot;</cxxcompilerbinary>
<ccompilerbinary>i386-pc-mingw32-gcc</ccompilerbinary>
<cxxcompilerbinary>i386-pc-mingw32-g++</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
@@ -128,21 +128,21 @@
</win32>
<suncc>
<envvars>
<envvar value="/opt/sun/sunstudio12/bin:$PATH" name="PATH" />
<envvar value="/opt/sun/sunstudio/bin:$PATH" name="PATH" />
</envvars>
<configargs>--disable-default-gcc-options --enable-tests</configargs>
<configargs>--enable-tests PKG_CONFIG_PATH=&quot;/opt/sun/target64/lib64/pkgconfig:/usr/lib64/pkgconfig&quot; PKG_CONFIG_LIBDIR=&quot;&quot;</configargs>
<builddir>suncc</builddir>
<topsourcedir/>
<cppflags/>
<ldflags>-s</ldflags>
<ldflags>-R/opt/sun/target64/lib64 -L/opt/sun/target64/lib64</ldflags>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>suncc</ccompilerbinary>
<cxxcompilerbinary>sunCC</cxxcompilerbinary>
<f77compilerbinary/>
<cflags>-DDEBUG -DDEBUG_BUILD</cflags>
<cxxflags>+w -errtags -erroff=notemsource,notused -features=extensions -DHZ_FORCE_GLOBAL_MACROS -DDEBUG -DDEBUG_BUILD -DGLIBMM_HAVE_SUN_REVERSE_ITERATOR -DSIGC_HAVE_SUN_REVERSE_ITERATOR</cxxflags>
<cflags>-errwarn=%all -I/opt/sun/target64/include</cflags>
<cxxflags>-I/opt/sun/target64/include</cxxflags>
<f77flags/>
</suncc>
<portland>
@@ -151,7 +151,7 @@
<builddir>portland</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ldflags>-s</ldflags>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
@@ -159,9 +159,43 @@
<cxxcompilerbinary>pgCC</cxxcompilerbinary>
<f77compilerbinary/>
<cflags>-Minform=warn -Bstatic_pgi</cflags>
<cxxflags>-Minform=warn -Bstatic_pgi -noswitcherror -define_macro=HZ_FORCE_GLOBAL_MACROS</cxxflags>
<cxxflags>-Minform=warn -Bstatic_pgi -noswitcherror -define_macro=HZ_NO_COMPILER_AUTOINCLUDE</cxxflags>
<f77flags/>
</portland>
<win32-debug>
<envvars/>
<configargs>--disable-user-flags --enable-debug-options --enable-tests --build=i686-linux --host=i386-pc-mingw32 PKG_CONFIG_PATH=/cross/w32/target/lib/pkgconfig PKG_CONFIG_LIBDIR=&quot;&quot; PATH=&quot;/cross/w32/gcc-bin:/cross/w32/target/bin:$PATH&quot;</configargs>
<builddir>win32-debug</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>i386-pc-mingw32-gcc</ccompilerbinary>
<cxxcompilerbinary>i386-pc-mingw32-g++</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</win32-debug>
<win64-debug>
<envvars/>
<configargs>--disable-user-flags --enable-optimize-options --enable-tests --build=i686-linux --host=x86_64-pc-mingw32 PKG_CONFIG_PATH=/cross/w64/target/lib/pkgconfig PKG_CONFIG_LIBDIR=&quot;&quot; PATH=&quot;/cross/w64/gcc-bin:/cross/w64/target/bin:$PATH&quot;</configargs>
<builddir>win64-debug</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>x86_64-pc-mingw32-gcc</ccompilerbinary>
<cxxcompilerbinary>x86_64-pc-mingw32-g++</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</win64-debug>
</configurations>
<make>
<envvars>
@@ -237,11 +271,11 @@
</kdevdoctreeview>
<kdevdebugger>
<general>
<dbgshell/>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<dbgshell></dbgshell>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>false</floatingtoolbar>
+156
View File
@@ -0,0 +1,156 @@
Name: gsmartcontrol
Version: @VERSION@
Release: 1as
License: GPLv2, GPLv3
Url: http://gsmartcontrol.berlios.de
Vendor: Alexander Shaduri <ashaduri 'at' gmail.com>
Packager: Alexander Shaduri <ashaduri 'at' gmail.com>
Source: gsmartcontrol-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: GSmartControl - Hard Disk Health Inspection Tool
%if 0%{?mandriva_version}
Group: System/Kernel and hardware
%else
Group: Hardware/Other
%endif
# Support build service rpmlint. Disabled - the build service
# stopped recognizing the flag for some architectures.
# %if 0%{?opensuse_bs} && 0%{?suse_version} >= 1010
# Support: rpmlint-bs
# %endif
# Dependencies for various distributions. The actual deps are:
# smartmontools, pcre, (gtkmm2 >= 2.12 || (gtkmm2 >= 2.6.0 && libglademm >= 2.4.0))
# (with the respective -devel packages of the libraries for build requirements).
# For non-specified distributions we don't specify any dependencies to avoid errors.
# For mandriva, these contain the su programs.
# Suggests: libgnomesu, gksu, kdebase-progs
# SUSE / OpenSUSE. SLES also defines the correct suse_version.
%if 0%{?suse_version}
%if 0%{?%suse_version} >= 1030
Requires: smartmontools, pcre, gtkmm2 >= 2.12.0
BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm2-devel >= 2.12.0
%else
%if 0%{?%suse_version} == 1020
Requires: smartmontools, pcre, gtkmm2 >= 2.6.0, libglademm >= 2.4.0
BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm2-devel >= 2.6.0, libglademm-devel >= 2.4.0
%else
Requires: smartmontools, pcre, gtkmm24 >= 2.6.0, libglademm >= 2.4.0
BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm24-devel >= 2.6.0, libglademm-devel >= 2.4.0
%endif
%endif
%endif
# Fedora, CentOS, RHEL
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
# I'm not sure about centos and rhel versions
%if 0%{?fedora_version} >= 8 || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
Requires: smartmontools, pcre, gtkmm24 >= 2.12.0
BuildRequires: gcc-c++, pcre-devel, gtkmm24-devel >= 2.12.0
%else
Requires: smartmontools, pcre, gtkmm24 >= 2.6.0, libglademm24 >= 2.4.0
BuildRequires: gcc-c++, pcre-devel, gtkmm24-devel >= 2.6.0, libglademm24-devel >= 2.4.0
%endif
%endif
# Mandriva. Check the latest official spec file at
# http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/gsmartcontrol/current/
%if 0%{?mandriva_version}
%if 0%{?mandriva_version} >= 2008
Requires: smartmontools, libpcre0, gtkmm2.4 >= 2.12.0
BuildRequires: gcc-c++, gcc-cpp, pcre-devel, gtkmm2.4-devel >= 2.12.0, desktop-file-utils
%else
Requires: smartmontools, libpcre0, gtkmm2.4 >= 2.6.0, libglademm2.4 >= 2.4.0
BuildRequires: gcc-c++, gcc-cpp, pcre-devel, gtkmm2.4-devel >= 2.6.0, libglademm2.4-devel >= 2.4.0, desktop-file-utils
%endif
%endif
%description
GSmartControl is a graphical user interface for smartctl, which is a tool for
querying and controlling SMART (Self-Monitoring, Analysis, and Reporting
Technology) data in hard disk drives. It allows you to inspect the drive's
SMART data to determine its health, as well as run various tests on it.
%prep
%setup -q
%if 0%{?mandriva_version} <= 2006
%configure
%else
%configure --enable-optimize-options=auto
%endif
%build
# Set up for parallel builds
numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :`
if [ "$numprocs" = "0" ]; then
numprocs=1
fi
make -j$numprocs
# make
%install
# %makeinstall
make DESTDIR=%buildroot install-strip
# Remove the icon cache file "make install" generates, to avoid package conflicts.
rm -f $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/icon-theme.cache
%if 0%{?mandriva_version}
desktop-file-install --vendor="" \
--remove-category="Application" \
--add-category="System" \
--add-category="X-MandrivaLinux-System-Configuration-Hardware;Settings;HardwareSettings" \
--dir $RPM_BUILD_ROOT%{_datadir}/applications $RPM_BUILD_ROOT%{_datadir}/applications/%{name}.desktop
%endif
%clean
rm -rf %buildroot
%files
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/*
# %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/*
%doc %{_datadir}/doc/gsmartcontrol
%doc %{_mandir}/man1/*
%{_datadir}/gsmartcontrol
# %{_datadir}/gsmartcontrol/*
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
%changelog
* Fri Nov 14 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
- Updated .spec file to incorporate changes from the official Mandriva package.
* Mon Oct 06 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
- Updated .spec file to support OpenSUSE < 10.3, Fedora and friends,
Mandriva (for OpenSUSE Build Service).
* Mon Sep 15 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
- Initial .spec file.
-1
View File
@@ -1 +0,0 @@
See NEWS file.
-61
View File
@@ -1,61 +0,0 @@
# Add autoconf.m4 directory to local macro search path
ACLOCAL_AMFLAGS = -I autoconf.m4
SUBDIRS = src data
# These files are actually needed for compilation.
noinst_DATA = AUTHORS.txt LICENSE_gsmartcontrol.txt README.txt
# For the files to be bundled with the distribution, specify them in
# one of the following.
# These will be installed into docdir.
# Some of these files are actually needed for compilation (see src/res/Makefile.am).
dist_doc_DATA = AUTHORS.txt ChangeLog NEWS README.txt \
LICENSE_boost_1_0.txt \
LICENSE_bsd-ucb.txt \
LICENSE_gpl2.txt \
LICENSE_gpl3.txt \
LICENSE_gsmartcontrol.txt \
LICENSE_hz.txt \
LICENSE_pcrecpp.txt \
LICENSE_zlib.txt
# Extra files bundled with distribution.
# file2csource.sh is needed for building but not installed.
EXTRA_DIST = COPYING TODO INSTALL configure autogen.sh \
baqup gsmartcontrol.kdevelop \
templates \
file2csource.sh \
gsmartcontrol.spec
# PCH support
global_macros.h.gch: $(top_srcdir)/src/global_macros.h
$(CXX) $(CXXFLAGS) $(DEFS) -x "c++-header" $(top_srcdir)/src/global_macros.h -o global_macros.h.gch
gch: global_macros.h.gch
gch-clean:
rm -f global_macros.h.gch
distclean-local: gch-clean
# rpm support
src-rpm: dist
rpmbuild -ts $(distdir).tar.bz2
# Don't use this - it does something weird, and gcc errors out with "long long long" errors, etc...
#rpm: dist
# rpmbuild -ta $(distdir).tar.bz2
-6
View File
@@ -1,6 +0,0 @@
Version 0.8.0rc2
Fix for compilation under gcc 4.3.
Removed test data (there's a lot of it and it's unnecessary).
Version 0.8.0rc1
Initial release.
@@ -1,16 +0,0 @@
AC_DEFUN([AC_CXX_VAR_FUNC],
[AC_CACHE_CHECK(whether $CXX recognizes __func__,
ac_cv_cxx_var_func,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[const char* s = __func__;]])],[ac_cv_cxx_var_func=yes],[ac_cv_cxx_var_func=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_var_func" = yes; then
AC_DEFINE(HAVE_CXX__FUNC,,[Define if the C++ complier supports __func__])
fi
])
-36
View File
@@ -1,36 +0,0 @@
SUBDIRS = 16 22 24 32 48 64 128
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
install-data-hook: update-icon-cache
uninstall-hook: update-icon-cache
update-icon-cache:
@-if test -z "$(DESTDIR)"; then \
echo "Updating GTK icon cache."; \
$(gtk_update_icon_cache); \
else \
echo "*** Icon cache not updated. After (un)install, run this:"; \
echo "*** $(gtk_update_icon_cache)"; \
fi
# installs to /usr/share/appname
appdatadir = $(pkgdatadir)
appdata_DATA = icon_cddvd.png icon_hdd.png
# pkgdatadir = $(datadir)/gsmartcontrol
# pkgdata_DATA =
desktopdir = $(datadir)/applications
desktop_DATA = gsmartcontrol_gnome.desktop gsmartcontrol_kde.desktop \
gsmartcontrol_other.desktop
# Same as 48/gsmartcontrol.png
pixmapsdir = $(datadir)/pixmaps
pixmaps_DATA = 48/gsmartcontrol.png
EXTRA_DIST = $(appdata_DATA) $(pixmaps_DATA)
@@ -1,26 +0,0 @@
[Desktop Entry]
# Desktop file for gnome only.
OnlyShowIn=GNOME;
# desktop file version
Version=1.0
Type=Application
Categories=System;GTK;
# Categories=Settings;HardwareSettings;
Name=GSmartControl
# short description, usually shown in parentheses after Name
GenericName=Hard Disk Health Inspection
# tooltip
Comment=Monitor and control SMART data on hard disks
# If it's a name only, it looks for "name.[png|xpm]" file in
# $XDG_DATA_DIRS/icons and /usr/share/pixmaps.
# An absolute file path is also supported.
Icon=gsmartcontrol
# Run with root permissions. Some desktop files used gksu,
# but it doesn't seem available on my system.
Exec=gnomesu -c "@prefix@/bin/gsmartcontrol"
@@ -1,28 +0,0 @@
[Desktop Entry]
# Desktop file for non-gnome and non-kde only.
NotShowIn=GNOME;KDE;
# desktop file version
Version=1.0
Type=Application
Categories=System;GTK;
# Categories=Settings;HardwareSettings;
Name=GSmartControl
# short description, usually shown in parentheses after Name
GenericName=Hard Disk Health Inspection
# tooltip
Comment=Monitor and control SMART data on hard disks
# If it's a name only, it looks for "name.[png|xpm]" file in
# $XDG_DATA_DIRS/icons and /usr/share/pixmaps.
# An absolute file path is also supported.
Icon=gsmartcontrol
# Run with root permissions using gnomesu (from libgnomesu).
# There is also kdesu (kdebase3-runtime, kdebase4-runtime), in different paths.
# There is also xdg-su, which doesn't work at all on my machine.
Exec=gnomesu -c "@prefix@/bin/gsmartcontrol"
# Exec=kdesu -u root "@prefix@/bin/gsmartcontrol"
-74
View File
@@ -1,74 +0,0 @@
Summary: GSmartControl - Hard Disk Health Inspection Tool
Name: gsmartcontrol
Version: @VERSION@
Release: 1as
License: GPLv2, GPLv3
Vendor: Alexander Shaduri <ashaduri 'at' gmail.com>
Url: http://gsmartcontrol.berlios.de
Packager: Alexander Shaduri <ashaduri 'at' gmail.com>
Group: Hardware/Other
Source: gsmartcontrol-%{version}.tar.bz2
# We need (gtkmm2 >= 2.12 || (gtkmm2 >= 2.6.0 && libglademm >= 2.4.0))
# Anyone knows how to specify that?
#Requires: smartmontools, pcre, gtkmm2 >= 2.6.0, libglademm >= 2.4.0
Requires: smartmontools, pcre, gtkmm2 >= 2.12.0
#BuildRequires: pcre-devel, gtkmm2-devel >= 2.6.0, libglademm-devel >= 2.4.0
BuildRequires: pcre-devel, gtkmm2-devel >= 2.12.0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
GSmartControl is a graphical user interface for smartctl, which is a tool for
querying and controlling SMART (Self-Monitoring, Analysis, and Reporting
Technology) data in hard disk drives. It allows you to inspect the drive's
SMART data to determine its health, as well as run various tests on it.
%prep
%setup -q
%configure
# Don't use configure parameters - let rpm set them.
# --prefix=/usr --enable-default-gcc-options --enable-gcc-optimize
%build
# Setup for parallel builds
numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :`
if [ "$numprocs" = "0" ]; then
numprocs=1
fi
make -j$numprocs
#make
%install
#make install-strip DESTDIR=$RPM_BUILD_ROOT
%makeinstall
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/*
#%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/*
%doc %{_datadir}/doc/gsmartcontrol
%{_datadir}/gsmartcontrol
%{_datadir}/gsmartcontrol/*
%{_datadir}/applications/*
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
%changelog
* Mon Sep 15 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
- Initial .spec file.
-17
View File
@@ -1,17 +0,0 @@
AM_CPPFLAGS = $(all_includes)
METASOURCES = AUTO
bin_PROGRAMS = gsmartcontrol
SUBDIRS = libdebug hz rmn rconfig pcrecpp applib res
gsmartcontrol_LDADD = $(top_builddir)/src/applib/libapplib.a \
$(top_builddir)/src/pcrecpp/libpcrecpp.a $(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/res/libres.a
noinst_HEADERS = global_macros.h gsc_about_dialog.h gsc_executor_error_dialog.h \
gsc_executor_log_window.h gsc_help_window.h gsc_info_window.h gsc_init.h gsc_main_window.h \
gsc_main_window_iconview.h gsc_preferences_window.h gsc_settings.h gsc_text_window.h
gsmartcontrol_SOURCES = gsc_about_dialog.cpp gsc_executor_error_dialog.cpp \
gsc_executor_log_window.cpp gsc_help_window.cpp gsc_info_window.cpp gsc_init.cpp gsc_main.cpp \
gsc_main_window.cpp gsc_preferences_window.cpp
-41
View File
@@ -1,41 +0,0 @@
AM_CPPFLAGS = $(all_includes)
METASOURCES = AUTO
noinst_LIBRARIES = libapplib.a
libapplib_a_SOURCES = app_gtkmm_utils.cpp cmdex.cpp cmdex_sync.cpp \
cmdex_sync_gui.cpp gui_utils.cpp selftest.cpp smartctl_parser.cpp storage_detector.cpp \
storage_device.cpp storage_property.cpp storage_property_descr.cpp
noinst_HEADERS = app_gtkmm_features.h app_gtkmm_utils.h app_pcrecpp.h \
app_ui_res_utils.h cmdex.h cmdex_sync.h cmdex_sync_gui.h gui_utils.h selftest.h smartctl_executor.h \
smartctl_executor_gui.h smartctl_parser.h storage_detector.h storage_device.h \
storage_property.h storage_property_colors.h storage_property_descr.h storage_settings.h \
wrapping_label.h
# don't use absolute path for the current dir's .a, because the make
# dependency resolver won't get it (needed for parallel builds)
storage_detector_test_SOURCES = storage_detector_test.cpp
storage_detector_test_LDADD = libapplib.a \
$(top_builddir)/src/pcrecpp/libpcrecpp.a $(top_builddir)/src/libdebug/libdebug.a
smartctl_executor_test_SOURCES = smartctl_executor_test.cpp
smartctl_executor_test_LDADD = libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a
smartctl_parser_test_SOURCES = smartctl_parser_test.cpp
smartctl_parser_test_LDADD = libapplib.a \
$(top_builddir)/src/pcrecpp/libpcrecpp.a $(top_builddir)/src/libdebug/libdebug.a
# Build them first
SUBDIRS=../libdebug ../pcrecpp
# we don't list them in a separate variable because otherwise kdevelop won't see them.
noinst_PROGRAMS =
if ENABLE_TESTS
noinst_PROGRAMS += smartctl_executor_test smartctl_parser_test \
storage_detector_test
endif
tests: $(noinst_PROGRAMS)
-587
View File
@@ -1,587 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
#include <sys/types.h>
#include <cerrno> // errno (not std::errno, it may be a macro)
#ifdef _WIN32
#include <io.h> // close()
#else
#include <sys/wait.h> // waitpid()'s W* macros
#include <unistd.h> // close()
#endif
#include <glibmm/shell.h>
#include <glibmm/miscutils.h> // get_current_dir()
#include <glibmm/convert.h>
#include "hz/tls.h"
#include "hz/tls_policy_glib.h"
#include "hz/debug.h"
#include "cmdex.h"
using hz::Error;
using hz::ErrorLevel;
// this is needed because these callbacks are called by glib.
extern "C" {
// callbacks
// NOTE: These functions are called in a separate threads!
inline void command_executor_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data)
{
Cmdex::on_child_watch_handler(arg_pid, waitpid_status, data);
}
inline gboolean command_executor_on_channel_io_stdout_as_available(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io_as_available(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stdout);
}
inline gboolean command_executor_on_channel_io_stderr_as_available(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io_as_available(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stderr);
}
inline gboolean command_executor_on_channel_io_stdout_buffered(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io_buffered(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stdout);
}
inline gboolean command_executor_on_channel_io_stderr_buffered(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io_buffered(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stderr);
}
inline void command_executor_on_buffered_source_destroy(gpointer data);
// this is executed in another thread!
inline gboolean command_executor_on_term_timeout(gpointer data)
{
DBG_FUNCTION_ENTER_MSG;
Cmdex* self = static_cast<Cmdex*>(data);
self->try_stop(hz::SIGNAL_SIGTERM);
return false; // one-time call
}
// this is executed in another thread!
inline gboolean command_executor_on_kill_timeout(gpointer data)
{
DBG_FUNCTION_ENTER_MSG;
Cmdex* self = static_cast<Cmdex*>(data);
self->try_stop(hz::SIGNAL_SIGTERM);
return false; // one-time call
}
} // extern "C"
bool Cmdex::execute()
{
ScopedLock locker(object_mutex_);
if (this->running || this->stopped_cleanup_needed(false))
return false;
cleanup_members();
clear_errors(false); // don't lock
str_stdout.clear();
str_stderr.clear();
std::string cmd = command_exec + " " + command_args;
std::deque<std::string> child_argv;
try {
child_argv = Glib::shell_parse_argv(cmd);
}
catch (Glib::ShellError& e) {
push_error(Error<Glib::ShellError>("gshell", ErrorLevel::error, e, e.what()), false);
return false;
}
// Reset the locale - otherwise it may mangle the output.
bool old_lang_set = false;
std::string old_lang = Glib::getenv("LANG", old_lang_set);
if (old_lang_set)
Glib::setenv("LANG", "C");
try {
// execute the command
debug_out_info("app", DBG_FUNC_MSG << "Executing \"" << cmd << "\".\n");
Glib::spawn_async_with_pipes(Glib::get_current_dir(), child_argv,
Glib::SPAWN_SEARCH_PATH | Glib::SPAWN_DO_NOT_REAP_CHILD,
sigc::slot<void>(), &this->pid,
0, &fd_stdout, &fd_stderr);
}
catch (Glib::SpawnError& e) {
push_error(Error<Glib::SpawnError>("gspawn", ErrorLevel::error, e, e.what()), false);
if (old_lang_set)
Glib::setenv("LANG", old_lang);
return false;
}
if (old_lang_set)
Glib::setenv("LANG", old_lang);
this->timer.start(); // start the timer
#ifdef _WIN32
channel_stdout = Glib::IOChannel::create_from_win32_fd(fd_stdout);
channel_stderr = Glib::IOChannel::create_from_win32_fd(fd_stderr);
#else
channel_stdout = Glib::IOChannel::create_from_fd(fd_stdout);
channel_stderr = Glib::IOChannel::create_from_fd(fd_stderr);
#endif
// The internal encoding is always UTF8. To read command output correctly, use
// "" for binary data, or set io encoding to current locale.
// If using locales, call Glib::locale_to_utf8() or Glib::convert() afterwards.
// std::string charset;
// Glib::get_charset(charset);
try {
channel_stdout->set_encoding(""); // binary IO
channel_stderr->set_encoding(""); // binary IO
// blocking writes if the pipe is full helps for small-pipe systems (see man 7 pipe).
Glib::IOFlags flags = ~Glib::IO_FLAG_NONBLOCK;
channel_stdout->set_flags(flags);
channel_stderr->set_flags(flags);
channel_stdout->set_buffer_size(channel_stdout_buffer_size);
channel_stderr->set_buffer_size(channel_stderr_buffer_size);
}
catch (Glib::IOChannelError& e) {
// What do we do? The command is already running, so let's ignore these
// errors - it's better to get a slightly mangled buffer than to abort the
// command in the mid-run.
}
// Note: glib callbacks _are_ invoked in separate threads,
// so proper locking is necessary.
// This is different from gtk callbacks, which are directly invoked from main loop
// in the same thread.
// this doesn't really work
// Glib::signal_io().connect(sigc::bind(sigc::ptr_fun(&io_handler), this), channel_stdout, cond);
GIOCondition cond = GIOCondition(G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_ERR | G_IO_NVAL);
gint io_thread_priority = G_PRIORITY_HIGH; // channel reader callback thread must read enough so that the loss is minimal
if (this->stdout_make_str_as_available) {
this->event_source_id_stdout = g_io_add_watch_full(channel_stdout->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stdout_as_available, this, NULL);
} else {
this->event_source_id_stdout = g_io_add_watch_full(channel_stdout->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stdout_buffered, this, command_executor_on_buffered_source_destroy);
}
if (this->stderr_make_str_as_available) {
this->event_source_id_stderr = g_io_add_watch_full(channel_stderr->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stderr_as_available, this, NULL);
} else {
this->event_source_id_stderr = g_io_add_watch_full(channel_stderr->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stderr_buffered, this, command_executor_on_buffered_source_destroy);
}
// If using SPAWN_DO_NOT_REAP_CHILD, this is needed to avoid zombies.
// Note: Do NOT use glibmm slot, it doesn't work here.
// The watch function is protected by mutex and won't be called before execute() exits.
// This is AFTER the channels so that it doesn't get called before the channels are attached (is this needed?).
// (the child stops being a zombie as soon as wait*() exits and this handler is called).
g_child_watch_add(static_cast<GPid>(this->pid), &command_executor_child_watch_handler, this);
this->running = true; // process is running now.
// actually, it may be already stopped, but the watcher function is blocked
// until we exit, so the actions are serialized.
return true;
}
// send SIGTERM(15) (terminate)
bool Cmdex::try_stop(hz::signal_t sig)
{
ScopedLock locker(object_mutex_);
if (!this->running || this->pid <= 0)
return false;
// other variants: SIGHUP(1) (terminal closed), SIGINT(2) (Ctrl-C),
// SIGKILL(9) (kill).
// Note that SIGKILL cannot be trapped by any process.
if (process_signal_send(this->pid, sig) == 0) { // success
this->kill_signal_sent = static_cast<int>(sig); // just the number to compare later.
return true; // the rest is done by a handler
}
// Possible: EPERM (no permissions), ESRCH (no such process, or zombie)
push_error(Error<int>("errno", ErrorLevel::error, errno), false);
return false;
}
void Cmdex::set_stop_timeouts(int term_timeout_msec, int kill_timeout_msec)
{
DBG_ASSERT(term_timeout_msec == 0 || kill_timeout_msec == 0 || kill_timeout_msec > term_timeout_msec);
ScopedLock locker(object_mutex_); // member access / serialization lock
if (!this->running) // process not running
return;
unset_stop_timeouts(false);
if (term_timeout_msec != 0)
event_source_id_term = g_timeout_add(term_timeout_msec, &command_executor_on_term_timeout, this);
if (kill_timeout_msec != 0)
event_source_id_kill = g_timeout_add(kill_timeout_msec, &command_executor_on_kill_timeout, this);
}
void Cmdex::unset_stop_timeouts(bool do_lock)
{
ScopedLock locker(object_mutex_, do_lock); // member access / serialization lock
if (event_source_id_term) {
GSource* source_term = g_main_context_find_source_by_id(NULL, event_source_id_term);
if (source_term)
g_source_destroy(source_term);
event_source_id_term = 0;
}
if (event_source_id_kill) {
GSource* source_kill = g_main_context_find_source_by_id(NULL, event_source_id_kill);
if (source_kill)
g_source_destroy(source_kill);
event_source_id_kill = 0;
}
}
// executed in main thread, manually by the caller.
void Cmdex::stopped_cleanup()
{
// DBG_FUNCTION_ENTER_MSG;
ScopedLock locker(object_mutex_); // member access / serialization lock
if (this->running || !this->stopped_cleanup_needed(false)) // huh?
return;
// remove stop timeout callbacks
unset_stop_timeouts(false);
// various statuses (see waitpid (2)):
if (WIFEXITED(waitpid_status)) { // exited normally
int exit_status = WEXITSTATUS(waitpid_status);
if (exit_status != 0) {
// translate the exit_code into a message
Glib::ustring msg = signal_exit_status_translator.emit(exit_status);
push_error(Error<int>("exit", ErrorLevel::warn, exit_status, msg), false);
}
} else {
if (WIFSIGNALED(waitpid_status)) { // exited by signal
int sig_num = WTERMSIG(waitpid_status);
// If it's not our signal, treat as error.
// Note: they will never match under win32
if (sig_num != this->kill_signal_sent) {
push_error(Error<int>("signal", ErrorLevel::error, sig_num), false);
} else { // it's our signal, treat as warning
push_error(Error<int>("signal", ErrorLevel::warn, sig_num), false);
}
}
}
Glib::spawn_close_pid(this->pid); // needed to avoid zombies
cleanup_members();
this->running = false;
}
// NOTE: This function is called in a separate thread!
void Cmdex::on_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data)
{
// DBG_FUNCTION_ENTER_MSG;
Cmdex* self = static_cast<Cmdex*>(data);
self->lock();
self->timer.stop(); // stop the timer
// wait until the IO channels are closed
// while (!(self->event_source_stdout_closed && self->event_source_stderr_closed)) {
// self->unlock();
// Glib::usleep(75*1000); // 75ms
// self->lock();
// }
self->waitpid_status = waitpid_status;
self->child_watch_handler_called = true;
self->running = false; // process is not running anymore
// Remove fd IO callbacks. They may actually be removed already.
// This will force calling the iochannel callback (they may not be called
// otherwise at all if there was no output).
if (self->event_source_id_stdout) {
GSource* source_stdout = g_main_context_find_source_by_id(NULL, self->event_source_id_stdout);
if (source_stdout)
g_source_destroy(source_stdout);
}
if (self->event_source_id_stderr) {
GSource* source_stderr = g_main_context_find_source_by_id(NULL, self->event_source_id_stderr);
if (source_stderr)
g_source_destroy(source_stderr);
}
// Cose std pipes
close(self->fd_stdout);
close(self->fd_stderr);
self->signal_exited.emit(); // ALL slots are called in non-main thread!
self->unlock();
// DBG_FUNCTION_EXIT_MSG;
}
// NOTE: This function is called in a separate thread!
// This means that all data access must be guarded by mutexes, etc...
gboolean Cmdex::on_channel_io_as_available(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type)
{
// debug_out_dump("app", "Cmdex::on_channel_io_as_available("
// << (type == channel_type_stdout ? "STDOUT" : "STDERR") << ") " << int(cond) << "\n");
bool continue_events = true;
if ((cond & G_IO_ERR) || (cond & G_IO_HUP) || (cond & G_IO_NVAL)) {
continue_events = false; // there'll be no more data
}
DBG_ASSERT(type == channel_type_stdout || type == channel_type_stderr);
// const gsize count = 4 * 1024;
// read the bytes one by one. without this, a buffered iochannel hangs while waiting for data.
// we don't use unbuffered iochannels - they may lose data on program exit.
const gsize count = 1;
char buf[count] = {0};
Cmdex::ScopedLock locker(self->object_mutex_);
Glib::RefPtr<Glib::IOChannel> channel;
std::string* output_str = 0;
if (type == channel_type_stdout) {
channel = self->channel_stdout;
output_str = &self->str_stdout;
} else if (type == channel_type_stderr) {
channel = self->channel_stderr;
output_str = &self->str_stderr;
}
try { // read() may throw something
// while there's anything to read, read it
do {
gsize bytes_read = 0;
Glib::IOStatus status = channel->read(buf, count, bytes_read);
if (bytes_read)
output_str->append(buf, bytes_read);
// IO_STATUS_NORMAL and IO_STATUS_AGAIN (resource unavailable) are continuable.
if (status == Glib::IO_STATUS_ERROR || status == Glib::IO_STATUS_EOF) {
continue_events = false;
break;
}
} while (channel->get_buffer_condition() & Glib::IO_IN);
}
catch (Glib::IOChannelError& e) {
self->push_error(Error<Glib::IOChannelError>("giochannel", ErrorLevel::error, e, e.what()), false);
}
catch (Glib::ConvertError& e) { // no conversion in binary mode, shouldn't happen
self->push_error(Error<void>("custom", ErrorLevel::error,
"Cmdex::on_channel_io_as_available(): Glib::ConvertError thrown."), false);
}
// false if the source should be removed, true otherwise.
return continue_events;
}
namespace {
// this must be thread-local, because many instances of Cmdex may call this
// from various threads. stdout and stderr are in different threads, so they won't get mixed.
// there's one-channel-per-thread situation here, so thread-local works well.
static hz::thread_local_ptr<std::string, hz::TlsPolicyGlib> s_final_str;
}
// The problem with final_str is that it may acummulate data if this function
// is never called with (continue_events = false) condition. This may
// actually happen with terminated spawned programs.
// So, we clean final_str manually from source_destroy callback.
// This callback is executed from in the same thread as on_channel_io_buffered,
// so we get the same variable (tests show cleared s_final_str, but is this really
// so? this function is executed during on_child_watch_handler (if spawn-terminated)).
inline void command_executor_on_buffered_source_destroy(gpointer data)
{
// DBG_FUNCTION_ENTER_MSG;
s_final_str.reset(); // .reset(), not ->clear - we don't want memory leaks in stopped threads.
}
// NOTE: This function is called in a separate thread!
// This means that all data access must be guarded by mutexes, etc...
gboolean Cmdex::on_channel_io_buffered(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type)
{
// debug_out_dump("app", "Cmdex::on_channel_io_buffered("
// << (type == channel_type_stdout ? "STDOUT" : "STDERR") << ") " << int(cond) << "\n");
bool continue_events = true;
if ((cond & G_IO_ERR) || (cond & G_IO_HUP) || (cond & G_IO_NVAL)) {
continue_events = false; // there'll be no more data
}
if (!s_final_str.get()) {
s_final_str.reset(new std::string);
s_final_str->reserve(g_io_channel_get_buffer_size(source));
}
// const gsize count = 4 * 1024;
// read the bytes one by one. without this, a buffered iochannel hangs while waiting for data.
// we don't use unbuffered iochannels - they may lose data on program exit.
const gsize count = 1;
static char buf[count] = {0};
// Glib::RefPtr<Glib::IOChannel> channel = Glib::wrap(source); // this segfaults on large data (?)
// while there's anything to read, read it
GError* error = 0;
do {
gsize bytes_read = 0;
GIOStatus status = g_io_channel_read_chars(source, buf, count, &bytes_read, &error);
if (bytes_read)
s_final_str->append(buf, bytes_read);
// IO_STATUS_NORMAL and IO_STATUS_AGAIN (resource unavailable) are continuable.
if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF) {
continue_events = false;
break;
}
if (error)
break;
} while (g_io_channel_get_buffer_condition(source) & G_IO_IN);
if (!continue_events || error) { // these conditions need locking
Cmdex::ScopedLock locker(self->object_mutex_);
if (error) {
try {
Glib::Error::throw_exception(error); // convert GError to exception for easy storage.
}
catch (Glib::IOChannelError& e) {
self->push_error(Error<Glib::IOChannelError>("giochannel", ErrorLevel::error, e, e.what()), false);
}
catch (Glib::ConvertError& e) { // no conversion in binary mode, shouldn't happen
self->push_error(Error<void>("custom", ErrorLevel::error,
"Cmdex::on_channel_io_buffered(): Glib::ConvertError thrown."), false);
}
}
if (!continue_events) {
if (type == channel_type_stdout) {
// set the source to be closed (the actual closing is done when we return false).
// this is needed for the caller to wait until all the channels are stopped.
self->str_stdout = *s_final_str;
} else if (type == channel_type_stderr) {
self->str_stderr = *s_final_str;
}
// glib may re-use this thread, so do a TLS cleanup.
// also, manual cleanup is needed for policies which don't support automatic one.
// source_destroy callback already does this, but it won't hurt.
s_final_str.reset(); // this will delete the previous contents.
}
}
// DBG_FUNCTION_EXIT_MSG;
// false if the source should be removed, true otherwise.
return continue_events;
}
-365
View File
@@ -1,365 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
#ifndef APP_CMDEX_H
#define APP_CMDEX_H
#include <string>
#include <sigc++/sigc++.h>
#include <glibmm/iochannel.h>
#include <glibmm/thread.h>
#include <glibmm/timer.h> // Timer
#include <glibmm/spawn.h> // Pid
#include <glib.h> // G*, g_*
#include "hz/process_signal.h" // hz::SIGNAL_*, hz::process_signal_send (cpp), win32's W* (cpp)
#include "hz/error_holder.h"
#include "hz/sync.h"
#include "hz/sync_policy_glib.h"
/*
There are two ways to detect when the command exits:
1. Add a callback to signal_exited. The callback will be executed
in non-main thread, which means that all data access MUST be
very carefully evaluated (and locked in both threads).
2. Manually poll stopped_cleanup_needed() from the main thread.
In both cases, stopped_cleanup() must be called afterwards,
from the _main_ thread.
*/
// inheriting from sigc::trackable automatically disconnects this class's
// slots upon destruction.
class Cmdex : public hz::ErrorHolder<hz::SyncPolicyGlib>, public sigc::trackable {
public:
using hz::ErrorHolder<hz::SyncPolicyGlib>::ptr_error_list_t; // auto-deleting container
using hz::ErrorHolder<hz::SyncPolicyGlib>::error_list_t;
typedef hz::ErrorHolder<hz::SyncPolicyGlib>::ErrorScopedLock ScopedLock;
typedef hz::ErrorHolder<hz::SyncPolicyGlib>::ErrorLockPolicy LockPolicy;
Cmdex(
//const sigc::slot<Glib::ustring, int>& slot_exit_status_translator,
const sigc::slot<void>& slot_exited = sigc::slot<void>()
)
: object_mutex_(error_object_mutex_),
running(false), kill_signal_sent(0), child_watch_handler_called(false),
pid(0), waitpid_status(0),
event_source_id_term(0), event_source_id_kill(0),
fd_stdout(0), fd_stderr(0),
channel_stdout_buffer_size(100 * 1024), channel_stderr_buffer_size(10 * 1024), // 100K and 10K
event_source_id_stdout(0), event_source_id_stderr(0),
stdout_make_str_as_available(false), stderr_make_str_as_available(true)
{
// signal_exit_status_translator.connect(slot_exit_status_translator);
if (!slot_exited.empty())
signal_exited.connect(slot_exited);
}
// Please don't destroy this object unless the child has exited. It will leak stuff
// and possibly crash, etc... .
~Cmdex()
{
// This will help if object is destroyed after the command has exited, but before
// stopped_cleanup() has been called.
stopped_cleanup();
}
// Call before execute.
void set_command(const std::string& command_exec_, const std::string& command_args_)
{
command_exec = command_exec_;
command_args = command_args_;
}
// launch the command.
bool execute();
// send SIGTERM(15) (terminate).
// use after execute(). using it after the command has exited has no effect.
bool try_stop(hz::signal_t sig = hz::SIGNAL_SIGTERM);
// Send SIGKILL(9) (kill). This signal cannot be overridden in child process.
// use after execute(). using it after the command has exited has no effect.
bool try_kill()
{
return try_stop(hz::SIGNAL_SIGKILL);
}
// set a timeout (since call to this function) to terminate, kill or both (use 0 to ignore the parameter).
// the timeouts will be unset automatically when the command exits.
// This has an effect only if the command is running (after execute()).
void set_stop_timeouts(int term_timeout_msec = 0, int kill_timeout_msec = 0);
// Unset timeouts. This will stop the timeout counters.
// This has an effect only if the command is running (after execute()).
// do_lock is kind of private and indicates that mutex should be locked prior to
// accessing the object members.
void unset_stop_timeouts(bool do_lock = true);
// If stopped_cleanup_needed() returned true, call this. The command
// should be exited by this time. Must be called before the next execute().
void stopped_cleanup();
// Returns true if command has stopped.
// Call repeatedly in a waiting function, after execute(). When returns true, call stopped_cleanup().
// do_lock is private, set to false only if you already hold the object lock.
bool stopped_cleanup_needed(bool do_lock = true)
{
ScopedLock locker(object_mutex_, do_lock);
return (child_watch_handler_called);
}
// The process is running. Note that if this returns false, it doesn't mean that
// the io channels have been closed or that the data may be read safely. Poll
// stopped_cleanup_needed() instead.
bool is_running() const
{
ScopedLock locker(object_mutex_);
return running;
}
// Call this before execution. There is a race-like condition - when the command
// outputs something, the io channel reads it from fd to its buffer and the event
// source callback is called. If the command dies, the io channel thread reads
// the remaining data to the channel buffer.
// Since the event source callbacks (which read from the buffer and empty it)
// happen rather sporadically in another thread, the buffer may not get read and
// emptied at all (before the command exits). This is why it's necessary to have
// a buffer size which potentially can hold _all_ the command output.
// A way to fight this is to increase event source thread priority (which may not help).
// Another way is to delay the command exit so that the event source thread
// catches on and reads the buffer.
// Use 0 to ignore the parameter. Call before execute().
void set_buffer_sizes(int stdout_buffer_size = 0, int stderr_buffer_size = 0)
{
ScopedLock locker(object_mutex_);
if (stdout_buffer_size)
channel_stdout_buffer_size = stdout_buffer_size; // 100K by default
if (stderr_buffer_size)
channel_stderr_buffer_size = stderr_buffer_size; // 10K by default
}
// Set the flags for child stdout and stderr. If stdout_str_as_available is true,
// then get_stdout_str() will return the stdout string as it becomes available,
// while false will make it available only after the command exits. Note that
// if the command outputs a lot of data in a very short period of time and
// then exits, false is much better choice because it's much faster.
// If you want to monitor the data as it becomes available and clean it to
// save some memory, use true.
// Call before execute().
void set_str_available(bool stdout_str_as_available = false, bool stderr_str_as_available = true)
{
ScopedLock locker(object_mutex_);
stdout_make_str_as_available = stdout_str_as_available;
stderr_make_str_as_available = stderr_str_as_available;
}
// If stdout_make_str_as_available is false, call this after stopped_cleanup(),
// before next execute(). If it's true, you may call this before the command has
// stopped, but it will decrease performance significantly.
std::string get_stdout_str(bool clear_existing = false)
{
ScopedLock locker(object_mutex_);
// debug_out_dump("app", str_stdout);
if (clear_existing) {
std::string ret = str_stdout;
str_stdout.clear();
return ret;
}
return str_stdout;
}
// See notes on get_stdout_str().
std::string get_stderr_str(bool clear_existing = false)
{
ScopedLock locker(object_mutex_);
if (clear_existing) {
std::string ret = str_stderr;
str_stderr.clear();
return ret;
}
return str_stderr;
}
// don't return sigc::connection - it's better for thread-safety this way.
// this will disconnect earlier slots. Call before execute().
void set_exit_status_translator(const sigc::slot<Glib::ustring, int>& slot_exit_status_translator)
{
ScopedLock locker(object_mutex_);
signal_exit_status_translator.slots().erase(signal_exit_status_translator.slots().begin(), signal_exit_status_translator.slots().end());
signal_exit_status_translator.connect(slot_exit_status_translator);
}
// Returns sigc::connection; you must use lock() / unlock() before modifying it.
// NOTE: The slot will be called in non-main thread! (the call is enclosed
// in lock/unlock).
// Don't use this unless absolutely necessary, use stopped_cleanup_needed()
// polling instead.
sigc::connection connect_signal_exited(const sigc::slot<void>& slot_exited)
{
ScopedLock locker(object_mutex_);
return signal_exited.connect(slot_exited);
}
// use lock() / unlock() if using members of this class outside of it.
void lock()
{
errors_lock(); // defer to parent's mutex - we use it for the whole object.
}
void unlock()
{
errors_unlock();
}
// protect all member variable access by this mutex, as well as
// serialize event callback execution (in respect of main thread too).
// it's possible to implement mutexes for each member individually, but
// it's impractical.
// mutable allows the definition of const member functions - they only
// read the data, but do it in a lock-protected manner.
// mutable Glib::Mutex object_mutex; // aka access serializer mutex
// use ErrorHolder's mutex
// these are sorta-private
// for passing to callback
enum channel_t {
channel_type_stdout,
channel_type_stderr
};
// Callbacks (Note: These are called by the real callbacks)
static void on_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data);
static gboolean on_channel_io_buffered(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type);
static gboolean on_channel_io_as_available(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type);
private:
// The object MUST be locked by the caller.
void cleanup_members()
{
// ScopedLock locker(object_mutex_);
kill_signal_sent = 0;
child_watch_handler_called = false;
pid = 0;
waitpid_status = 0;
channel_stdout.clear();
channel_stderr.clear();
event_source_id_stdout = 0;
event_source_id_stderr = 0;
fd_stdout = 0;
fd_stderr = 0;
}
mutable ErrorLockPolicy::Mutex& object_mutex_; // reference to parent's member
// default command and its args. std::strings, not ustrings.
std::string command_exec; // binary name. NOT affected by cleanup().
std::string command_args; // args that always go with binary. NOT affected by cleanup().
bool running; // child process is running now. NOT affected by cleanup().
int kill_signal_sent; // command has been sent this signal to terminate
bool child_watch_handler_called; // true after child_watch_handler callback, before stopped_cleanup().
Glib::Pid pid; // int in Unix, pointer in win32
int waitpid_status; // after the command is stopped, before cleanup, this will be available.
Glib::Timer timer; // keep track of elapsed time since command execution. not used by this class, but may be handy.
int event_source_id_term;
int event_source_id_kill;
int fd_stdout;
int fd_stderr;
Glib::RefPtr<Glib::IOChannel> channel_stdout;
Glib::RefPtr<Glib::IOChannel> channel_stderr;
int channel_stdout_buffer_size; // NOT affected by cleanup().
int channel_stderr_buffer_size; // NOT affected by cleanup().
int event_source_id_stdout;
int event_source_id_stderr;
int stdout_make_str_as_available; // NOT affected by cleanup().
int stderr_make_str_as_available; // NOT affected by cleanup().
std::string str_stdout; // NOT affected by cleanup().
std::string str_stderr; // NOT affected by cleanup().
// signals
// convert command exit status to message string
sigc::signal<Glib::ustring, int> signal_exit_status_translator; // NOT affected by cleanup().
// command exited signal
sigc::signal<void> signal_exited; // NOT affected by cleanup().
};
#endif
-79
View File
@@ -1,79 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
#include <gtkmm/messagedialog.h>
#include "gui_utils.h"
namespace
{
inline void show_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent, Gtk::MessageType type, bool sec_msg_markup)
{
// no markup, modal
Gtk::MessageDialog dialog("\n" + message + (sec_message.empty() ? "\n" : ""),
false, type, Gtk::BUTTONS_OK, true);
if (!sec_message.empty())
dialog.set_secondary_text(sec_message, sec_msg_markup);
if (parent) {
dialog.set_transient_for(*parent);
dialog.set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
} else {
dialog.set_position(Gtk::WIN_POS_MOUSE);
}
dialog.run(); // blocks until the dialog is closed
}
}
void gui_show_error_dialog(const std::string& message, Gtk::Window* parent)
{
show_dialog(message, "", parent, Gtk::MESSAGE_ERROR, false);
}
void gui_show_error_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent, bool sec_msg_markup)
{
show_dialog(message, sec_message, parent, Gtk::MESSAGE_ERROR, sec_msg_markup);
}
void gui_show_warn_dialog(const std::string& message, Gtk::Window* parent)
{
show_dialog(message, "", parent, Gtk::MESSAGE_WARNING, false);
}
void gui_show_warn_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent, bool sec_msg_markup)
{
show_dialog(message, sec_message, parent, Gtk::MESSAGE_WARNING, sec_msg_markup);
}
void gui_show_info_dialog(const std::string& message, Gtk::Window* parent)
{
show_dialog(message, "", parent, Gtk::MESSAGE_INFO, false);
}
void gui_show_info_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent, bool sec_msg_markup)
{
show_dialog(message, sec_message, parent, Gtk::MESSAGE_INFO, sec_msg_markup);
}
@@ -1,170 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
#include <ios> // std::boolalpha
// #include <glibmm/fileutils.h> // Dir
#include <algorithm> // std::find
#include "hz/debug.h"
#include "hz/fs_dir.h"
#include "rconfig/rconfig_mini.h"
#include "app_pcrecpp.h"
#include "storage_detector.h"
std::string StorageDetector::detect(std::vector<StorageDeviceRefPtr>& drives)
{
// std::vector<std::string> all_devices;
// try {
// Glib::Dir dir("/sys/block"); // lists all block devices which may have filesystems
// all_devices.insert(all_devices.begin(), dir.begin(), dir.end());
// }
// catch (Glib::FileError& e) {
// std::string msg = std::string("Error while detecting storage devices: ") + e.what();
// debug_out_error("app", DBG_FUNC_MSG << msg << "\n");
// return msg;
// }
// hz::Dir dir("/sys/block");
// this defaults to "/dev/disk/by-id"
std::string dev_dir;
if (!rconfig::get_data("system/device_scan_path", dev_dir) || dev_dir.empty()) {
return "Device scan directory not set.";
}
hz::Dir dir(dev_dir);
std::vector<std::string> all_devices;
if (!dir.entry_list(all_devices, false)) {
return dir.get_error_utf8();
}
// filter-out the ones with "partN" in them
std::vector<std::string> devices;
for (unsigned int i = 0; i < all_devices.size(); ++i) {
std::string entry = all_devices[i];
if (entry == "." || entry == ".." || app_pcre_match("/-part[0-9]+$/", entry))
continue;
hz::FsPath path = dev_dir + hz::DIR_SEPARATOR_S + all_devices[i];
// those are usually relative links, so find out where they are pointing to.
std::string link_dest;
if (path.get_link_destination(link_dest)) {
path = (hz::path_is_absolute(link_dest) ? link_dest : (dev_dir + hz::DIR_SEPARATOR_S + link_dest));
path.compress(); // compress in case there are ../-s.
}
// skip number-ended devices, in case we couldn't filter out the scan directory correctly
// (it's user-settable after all).
if (app_pcre_match("/[0-9]+$/", path.str()))
continue;
if (std::find(devices.begin(), devices.end(), path.str()) == devices.end()) // there may be duplicates
devices.push_back(path.str());
}
for (std::vector<std::string>::const_iterator iter = devices.begin(); iter != devices.end(); ++iter) {
std::string dev = *iter;
// try to match against patterns
for (unsigned int i = 0; i < match_patterns_.size(); i++) {
// try to match against general filter
if (!app_pcre_match(match_patterns_[i], dev))
continue;
// matched, check the blacklist
bool blacked = false;
for (unsigned int j = 0; j < blacklist_patterns_.size(); j++) {
if (app_pcre_match(blacklist_patterns_[j], dev)) { // matched the blacklist too
blacked = true;
break;
}
}
StorageDeviceRefPtr drive(new StorageDevice(dev));
debug_out_info("app", "Found device: \"" << drive->get_device() << "\".\n");
if (!blacked) {
drives.push_back(drive);
break; // no need to match other patters, go to next device
} else { // blacklisted
debug_out_info("app", "Device \"" << drive->get_device() << "\" is blacklisted, ignoring.\n");
break; // go to next device
}
}
}
return std::string();
}
std::string StorageDetector::fetch_basic_data(std::vector<StorageDeviceRefPtr>& drives,
hz::intrusive_ptr<CmdexSync> smartctl_ex, bool return_first_error)
{
fetch_data_errors_.clear();
fetch_data_error_outputs_.clear();
for (unsigned int i = 0; i < drives.size(); ++i) {
StorageDeviceRefPtr drive = drives[i];
debug_out_info("app", "Retrieving basic information about the device...\n");
smartctl_ex->set_running_msg("Running %s on " + drive->get_device() + "...");
// don't show any errors here - we don't want a screen flood.
// no need for gui-based executors here, we already show the message in
// iconview background (if called from main window)
std::string error_msg = drive->fetch_basic_data_and_parse(smartctl_ex);
// normally we skip drives with errors - possibly scsi, etc...
if (return_first_error && !error_msg.empty())
return error_msg;
if (!error_msg.empty()) {
// use original executor error if present (permits matches by our users).
// if (!smartctl_ex->get_error_msg().empty())
// error_msg = smartctl_ex->get_error_msg();
fetch_data_errors_.push_back(error_msg);
fetch_data_error_outputs_.push_back(smartctl_ex->get_stdout_str());
}
debug_out_dump("app", "Device information for " << drive->get_device() << ":\n"
<< "\tModel: " << drive->get_model_name() << "\n"
<< "\tType: " << StorageDevice::get_type_name(drive->get_type()) << "\n"
<< "\tSMART status: " << StorageDevice::get_status_name(drive->get_smart_status()) << "\n"
);
}
return std::string();
}
std::string StorageDetector::detect_and_fetch_basic_data(std::vector<StorageDeviceRefPtr>& put_drives_here,
hz::intrusive_ptr<CmdexSync> smartctl_ex)
{
std::string error_msg = detect(put_drives_here);
if (error_msg.empty())
fetch_basic_data(put_drives_here, smartctl_ex); // ignore its errors, there may be plenty of them.
return error_msg;
}
-43
View File
@@ -1,43 +0,0 @@
AM_CPPFLAGS = $(all_includes)
METASOURCES = AUTO
noinst_HEADERS = any_convert.h any_type.h any_type_holder.h ascii.h \
bad_cast_exception.h bin2ascii_encoder.h buffer.h common_types.h data_file.h debug.h \
down_cast.h errno_string.h error.h error_holder.h exceptions.h format_unit.h \
fs_common.h fs_dir.h fs_error_holder.h fs_file.h fs_path.h fs_path_utils.h \
fs_tools.h hz_config.h i18n.h instance_manager.h intrusive_ptr.h \
intrusive_scoped_lock.h launch_url.h local_algo.h locale_tools.h noncopyable.h optional_value.h \
process_signal.h ptr_container.h res_data.h static_assert.h stream_cast.h string_algo.h \
string_format.h string_num.h string_sprintf.h string_wcmatch.h sync.h sync_lock_ptr.h \
sync_multilock.h sync_part_get_policy.h sync_policy_boost.h sync_policy_glib.h \
sync_policy_glibmm.h sync_policy_poco.h sync_policy_pthread.h sync_policy_win32.h \
system_specific.h tls.h tls_policy_boost.h tls_policy_glib.h tls_policy_pthread.h \
tls_policy_win32.h type_categories.h type_properties.h win32_tools.h
any_type_test_SOURCES = any_type_test.cpp
bin2ascii_encoder_test_SOURCES = bin2ascii_encoder_test.cpp
down_cast_test_SOURCES = down_cast_test.cpp
errno_string_test_SOURCES = errno_string_test.cpp
format_unit_test_SOURCES = format_unit_test.cpp
fs_dir_test_SOURCES = fs_dir_test.cpp
fs_path_test_SOURCES = fs_path_test.cpp
string_algo_test_SOURCES = string_algo_test.cpp
string_format_test_SOURCES = string_format_test.cpp
string_num_test_SOURCES = string_num_test.cpp
string_wcmatch_test_SOURCES = string_wcmatch_test.cpp
sync_test_SOURCES = sync_test.cpp
sync_multilock_test_SOURCES = sync_multilock_test.cpp
tls_test_SOURCES = tls_test.cpp
# we don't list them in a separate variable because otherwise kdevelop won't see them.
noinst_PROGRAMS =
if ENABLE_TESTS
noinst_PROGRAMS += any_type_test bin2ascii_encoder_test down_cast_test errno_string_test \
format_unit_test fs_dir_test fs_path_test string_algo_test string_num_test string_format_test \
string_wcmatch_test sync_test sync_multilock_test tls_test
endif
tests: $(noinst_PROGRAMS)
-130
View File
@@ -1,130 +0,0 @@
/**************************************************************************
Copyright:
(C) 2006 Applied Informatics Software Engineering GmbH
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_boost_1_0.txt file
***************************************************************************/
#ifndef HZ_BUFFER_H
#define HZ_BUFFER_H
#include "hz_config.h" // feature macros
#include <cstddef> // std::size_t
#include <stdexcept> // std::out_of_range
// Don't use DBG_ASSERT() here, it's too error-prone to use in this context.
#include <cassert>
#ifndef ASSERT // assert() is undefined if NDEBUG is defined.
#define ASSERT(a) assert(a)
#endif
#include "exceptions.h" // THROW_FATAL
// This library is heavily based on Poco::Buffer class from poco
// library.
namespace hz {
// Buffer - a simple scoped buffer.
// Note: Constructing Buffer is not exception-safe!
template<typename T>
class Buffer {
public:
Buffer(std::size_t size) : size_(size), ptr_(new T[size])
{ }
~Buffer()
{
delete[] ptr_;
ptr_ = 0; // exception-safety (needed here?)
}
std::size_t size() const
{
return size_;
}
T* begin()
{
return ptr_;
}
const T* begin() const
{
return ptr_;
}
// Do NOT dereference the returned value!
T* end()
{
return ptr_ + size_;
}
// Do NOT dereference the returned value!
const T* end() const
{
return ptr_ + size_;
}
T& operator[] (std::size_t index)
{
ASSERT(index >= 0 && index < size_);
return ptr_[index];
}
const T& operator[] (std::size_t index) const
{
ASSERT(index >= 0 && index < size_);
return ptr_[index];
}
T& at(std::size_t index)
{
if (!(index >= 0 && index < size_))
THROW_FATAL(std::out_of_range("Buffer::at(): Out of range."));
return ptr_[index];
}
const T& at(std::size_t index) const
{
if (!(index >= 0 && index < size_))
THROW_FATAL(std::out_of_range("Buffer::at(): Out of range."));
return ptr_[index];
}
private:
Buffer(const Buffer&); // not implemented
Buffer& operator= (const Buffer&); // not implemented
std::size_t size_;
T* ptr_;
};
} // ns
#endif
-129
View File
@@ -1,129 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_zlib.txt file
***************************************************************************/
#ifndef HZ_ERRNO_STRING_H
#define HZ_ERRNO_STRING_H
#include "hz_config.h" // feature macros
#include <string>
#if defined ENABLE_GLIB
#include <glib.h> // g_strerror(), g_strsignal()
#else
#include <cstdio> // std::snprintf
// glibc has two versions of strerror_r:
// GNU (may or may not use buf):
// char *strerror_r(int errnum, char *buf, size_t buflen);
// XSI (posix) (returns 0 on success):
// int strerror_r(int errnum, char *buf, size_t buflen);
#if ((defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 200112L) \
|| (defined _XOPEN_SOURCE && _XOPEN_SOURCE >= 600)) && !defined _GNU_SOURCE
#define HAVE_XSI_STRERROR_R
#include <string.h> // strerror_r
#include <cerrno> // errno
#elif defined _GNU_SOURCE
#define HAVE_GNU_STRERROR_R
#include <string.h> // strerror_r
#else
#include <cstring> // std::strerror
#endif
#endif
// Compilation options:
// - Define ENABLE_GLIB to enable glib-related code (portable errno messages)
namespace hz {
// Note: This function may return messages in native language,
// possibly using LC_MESSAGES to select the language.
// If Glib is enabled, it returns messages in UTF-8 format.
// portable strerror() version for std::string.
inline std::string errno_string(int errno_value);
// ------------------------------------------ Implementation
// Portable strerror() implementation
inline std::string errno_string(int errno_value)
{
std::string msg;
#if defined ENABLE_GLIB
msg = g_strerror(errno_value); // no need to free. won't return 0. message is in utf8.
#else
char buf[128] = {0};
#if defined HAVE_XSI_STRERROR_R
if (strerror_r(errno_value, buf, 128) == 0 && *buf) { // always writes terminating 0 in those 128.
msg = buf;
} else { // errno is set on error
if (errno == EINVAL) {
std::snprintf(buf, 128, "Unknown errno: %d.", errno_value);
msg = buf;
} else if (errno == ERANGE) {
std::snprintf(buf, 128, "Insufficient buffer to store description for errno: %d.", errno_value);
msg = buf;
}
}
#elif defined HAVE_GNU_STRERROR_R
const char* rmsg = strerror_r(errno_value, buf, 128);
if (rmsg) {
msg = rmsg;
} else {
std::snprintf(buf, 128, "Error while getting description for errno: %d.", errno_value);
msg = buf;
}
#else // win32 and non-gnu/posix systems.
// use strerror(). win32 has thread-safe strerror (I think).
const char* m = std::strerror(errno_value); // no need to free.
if (m) {
msg = m;
} else {
std::snprintf(buf, 128, "Error while getting description for errno: %d.", errno_value);
msg = buf;
}
#endif
#endif
return msg;
}
} // ns
#endif
-571
View File
@@ -1,571 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_zlib.txt file
***************************************************************************/
#ifndef HZ_FS_FILE_H
#define HZ_FS_FILE_H
#include "hz_config.h" // feature macros
#include <string>
#include <stdio.h> // (not cstdio!) off_t, FILE, fopen and friends
#include <sys/types.h> // stat() needs this;
#include <sys/stat.h> // stat() needs this; chmod()
#ifdef _WIN32
#include <io.h> // stat(), unlink()
#else
#include <unistd.h> // stat(), unlink()
#endif
#include "fs_path.h" // Path
// Filesystem file manipulation
namespace hz {
// Offset & size type. may be uint32_t or uint64_t, depending on system and compilation flags.
// Note: It is usually discouraged to use this type in headers, because the library may be
// compiled with one size and the application with another. However, this problem is rather
// limited if using header-only approach, as we do.
#ifndef _WIN32
typedef off_t file_size_t; // off_t is in stdio.h
#else // win32 doesn't have off_t
typedef long file_size_t; // fseek() and friends use long.
#endif
class File : public FsPath {
public:
typedef FILE* handle_type;
File() : file_(NULL)
{ }
// Create a File object with path "path". This will NOT open the file.
File(const std::string& path) : file_(NULL)
{
set_path(path);
}
// Create a File object with path "path". This will NOT open the file.
File(const FsPath& path) : file_(NULL)
{
set_path(path.get_path());
}
// Create a File object and open a file "path" points to.
// You should check the success status with bad().
File(const std::string& path, const std::string& open_mode) : file_(NULL)
{
set_path(path);
open(open_mode);
}
// Create a File object and open a file "path" points to.
// You should check the success status with bad().
File(const FsPath& path, const std::string& open_mode) : file_(NULL)
{
set_path(path.get_path());
open(open_mode);
}
// Copy constructor. Move semantics are implemented - the ownership is transferred
// exclusively.
File(File& other) : file_(NULL)
{
*this = other; // operator=
}
~File()
{
if (file_)
close();
}
// move semantics, as with copy constructor.
inline File& operator= (File& other);
// --- these may set bad() status
// Open the file with open_mode.
inline bool open(const std::string& open_mode);
// Open the previously opened file.
inline bool close();
// Get native file handle (obtained using fopen())
handle_type get_handle()
{
return file_;
}
// Returns false on error. You must call "delete[] put_data_here".
// If the file is larger than 100M (by default), the function refuses to load it.
// Note: No additional trailing 0 is written to data!
inline bool get_contents(unsigned char*& put_data_here,
file_size_t& put_size_here, file_size_t max_size = 104857600);
// Same as above, but puts data into already allocated buffer.
// If the buffer is of insufficient size, false is returned and buffer is left untouched.
// If any other error occurs, the buffer may be left in unspecified state.
inline bool get_contents_noalloc(unsigned char*& put_data_here, file_size_t buf_size,
file_size_t& put_size_here, file_size_t max_size = 104857600);
// same as above, but for std::string (no terminating 0 is needed inside the file).
inline bool get_contents(std::string& put_data_here, file_size_t max_size = 104857600);
// write data to file, creating or truncating it beforehand. (no terminating 0 is needed inside data).
inline bool put_contents(const unsigned char* data, file_size_t data_size);
// same as above, for std::string (no terminating 0 is needed inside data or anywhere else)
inline bool put_contents(const std::string& data);
// Do NOT assign the result to int - you'll break LFS support.
inline bool get_size(file_size_t& put_here);
// Move (rename) a file to "to". The destination will be overwritten (if it exists and
// it's not a directory (even in win32)). This function is subject to rename() limitations.
// On error it sets errors in both the returned and current objects. returns the new path.
inline bool move(const std::string& to);
// Copy one file to a "to" destination (with destination being a filename).
// If "to" already exists, overwrite it. Return the new path.
// On error the errors are set in both the returned and current objects.
inline bool copy(const std::string& to);
// remove() is in Path (parent).
private:
handle_type file_; // FILE*
};
// ------------------------------------------- Implementation
// move semantics, as with copy constructor.
inline File& File::operator= (File& other)
{
file_ = other.file_;
// clear other's members, so everything is clear.
other.file_ = NULL;
other.set_path("");
other.set_error(HZ__("The file handle ownership was transferred from this object."));
return *this;
}
// Open the file with open_mode.
inline bool File::open(const std::string& open_mode)
{
clear_error();
if (file_) { // already open
set_error(std::string(HZ__("Error while opening file \"/path1/\": "))
+ HZ__("Another file is open already. Close it first."), 0, path_);
return false;
}
if (path_.empty()) {
set_error(std::string(HZ__("Error while opening file: ")) + HZ__("Supplied path is empty."));
return false;
}
file_ = fopen(path_.c_str(), open_mode.c_str());
if (!file_) {
set_error(HZ__("Error while opening file \"/path1/\": /errno/."), errno, path_);
return false;
}
return true;
}
// Open the previously opened file.
inline bool File::close()
{
clear_error();
if (file_ && fclose(file_) != 0) { // error
set_error(HZ__("Error while closing file \"/path1/\": /errno/."), errno, path_);
file_ = NULL;
return false;
}
file_ = NULL;
return true; // even if already closed
}
// Returns false on error. You must call "delete[] put_data_here".
// If the file is larger than 100M (by default), the function refuses to load it.
// Note: No additional trailing 0 is written to data!
inline bool File::get_contents(unsigned char*& put_data_here,
file_size_t& put_size_here, file_size_t max_size)
{
return get_contents_noalloc(put_data_here, static_cast<file_size_t>(-1), put_size_here, max_size);
}
// Same as above, but puts data into already allocated buffer.
// If the buffer is of insufficient size, false is returned and buffer is left untouched.
// If any other error occurs, the buffer may be left in unspecified state.
// Internal usage only: If buf_size is -1, the buffer will be automatically allocated.
inline bool File::get_contents_noalloc(unsigned char*& put_data_here, file_size_t buf_size,
file_size_t& put_size_here, file_size_t max_size)
{
clear_error();
if (path_.empty()) {
set_error(std::string(HZ__("Unable to open file for reading: ")) + HZ__("Supplied path is empty."));
return false;
}
FILE* f = fopen(path_.c_str(), "rb");
if (!f) {
set_error(HZ__("Unable to open file \"/path1/\" for reading: /errno/."), errno, path_);
return false;
}
do { // goto emulation
if (fseek(f, 0, SEEK_END) != 0) { // this should work in LFS too (I think)
set_error(HZ__("Unable to read file \"/path1/\": /errno/."), errno, path_);
break; // goto cleanup
}
#ifndef _WIN32 // win32 doesn't have ftello()
const file_size_t size = ftello(f); // LFS variant of ftell()
#else
const file_size_t size = ftell(f); // aka long
#endif
if (size == static_cast<file_size_t>(-1)) { // size may be unsigned, it's the way it works
set_error(HZ__("Unable to read file \"/path1/\": /errno/."), errno, path_);
break; // goto cleanup
}
if (size > max_size) {
set_error(std::string(HZ__("Unable to read file \"/path1/\": ")) + HZ__("File size is larger than allowed."), 0, path_);
break; // goto cleanup
}
// automatically allocate the buffer if buf_size is -1.
bool auto_alloc = (buf_size == static_cast<file_size_t>(-1));
if (!auto_alloc && buf_size < size) {
set_error(std::string(HZ__("Unable to read file \"/path1/\": ")) + HZ__("Supplied buffer is too small."), 0, path_);
break; // goto cleanup
}
rewind(f); // returns void
unsigned char* buf = put_data_here;
if (auto_alloc)
buf = new unsigned char[size]; // this may throw!
size_t read_bytes = fread(buf, 1, size, f); // I really hope this is not a byte-by-byte operation
if (size != static_cast<file_size_t>(read_bytes)) {
set_error(std::string(HZ__("Unable to read file \"/path1/\": "))
+ HZ__("Unexpected number of bytes read."), 0, path_);
if (auto_alloc)
delete[] buf;
break; // goto cleanup
}
// All OK
put_size_here = size;
if (auto_alloc)
put_data_here = buf;
} while (false);
// cleanup:
if (fclose(f) != 0) {
if (!bad()) // don't overwrite the previous error
set_error(HZ__("Error while closing file \"/path1/\": /errno/."), errno, path_);
}
return ok();
}
// same as above, but for std::string (no terminating 0 is needed inside the file).
inline bool File::get_contents(std::string& put_data_here, file_size_t max_size)
{
file_size_t size = 0;
unsigned char* buf = 0;
get_contents(buf, size, max_size);
if (bad())
return false;
// Note: No need for appending 0, it's all automatic in string.
put_data_here.reserve(size); // string takes size without trailing 0.
put_data_here.append(reinterpret_cast<char*>(buf), size);
delete[] buf;
return ok();
}
// write data to file, creating or truncating it beforehand. (no terminating 0 is needed inside data).
inline bool File::put_contents(const unsigned char* data, file_size_t data_size)
{
clear_error();
if (path_.empty()) {
set_error(std::string(HZ__("Unable to open file for for writing: ")) + HZ__("Supplied path is empty."));
return false;
}
FILE* f = fopen(path_.c_str(), "wb");
if (!f) {
set_error(HZ__("Unable to open file \"/path1/\" for writing: /errno/."), errno, path_);
return false;
}
const size_t written = fwrite(data, 1, data_size, f); // I really hope this is not a byte-by-byte operation
if (data_size != static_cast<file_size_t>(written)) {
set_error(std::string(HZ__("Unable to write file \"/path1/\": "))
+ HZ__("Number of written bytes doesn't match the data size."), 0, path_);
fclose(f); // don't check anything, it's too late
return false;
}
if (fclose(f) != 0)
set_error(HZ__("Error while closing file \"/path1/\": /errno/."), errno, path_);
return ok();
}
// // same as above, for std::string (no terminating 0 is needed inside data or anywhere else)
inline bool File::put_contents(const std::string& data)
{
return put_contents(reinterpret_cast<const unsigned char*>(data.data()), data.size());
}
// Do NOT assign the result to int - you'll break LFS support.
inline bool File::get_size(file_size_t& put_here)
{
clear_error();
if (path_.empty()) {
set_error(std::string(HZ__("Unable to get file size: ")) + HZ__("Supplied path is empty."));
return false;
}
FILE* f = fopen(path_.c_str(), "rb");
if (!f) {
set_error(HZ__("Unable to open file \"/path1/\" for reading: /errno/."), errno, path_);
return false;
}
do { // goto emulation
if (fseek(f, 0, SEEK_END) != 0) { // this should work in LFS too (I think)
set_error(HZ__("Unable to read file \"/path1/\": /errno/."), errno, path_);
break; // goto cleanup
}
#ifndef _WIN32 // win32 doesn't have ftello()
const file_size_t size = ftello(f); // LFS variant of ftell()
#else
const file_size_t size = ftell(f); // aka long
#endif
if (size == static_cast<file_size_t>(-1)) { // size may be unsigned, it's the way it works
set_error(HZ__("Unable to read file \"/path1/\": /errno/."), errno, path_);
break; // goto cleanup
}
// All OK
put_here = size;
} while (false);
// cleanup:
if (fclose(f) != 0) {
if (!bad()) // don't overwrite the previous error
set_error(HZ__("Error while closing file \"/path1/\": /errno/."), errno, path_);
}
return ok();
}
// Move (rename) a file to "to". The destination will be overwritten (if it exists and
// it's not a directory (even in win32)). This function is subject to rename() limitations.
// On error it sets errors in both the returned and current objects. returns the new path.
inline bool File::move(const std::string& to)
{
clear_error();
if (path_.empty()) {
set_error(std::string(HZ__("Unable to move filesystem entry: ")) + HZ__("Source path is empty."));
return false;
}
if (to.empty()) {
set_error(std::string(HZ__("Unable to move filesystem entry \"/path1/\": "))
+ HZ__("Destination path is empty."), 0, path_);
return false;
}
if (path_ == to) {
set_error(std::string(HZ__("Unable to move filesystem entry \"/path1/\": "))
+ HZ__("Source path is the same as destination path."), 0, path_);
return false;
}
// win32 rename() doesn't replace contents if newpath exists and says "file exists".
#ifdef _WIN32
// try remove it if it's a file. no error checks here - rename() will report the needed messages.
File dest_file(to);
if (dest_file.is_file())
dest_file.remove();
#endif
if (rename(path_.c_str(), to.c_str()) != 0)
set_error(HZ__("Unable to move filesystem entry \"/path1/\" to \"/path2/\": /errno/."), errno, path_, to);
return ok();
}
// Copy one file to a "to" destination (with destination being a filename).
// If "to" already exists, overwrite it. Return the new path.
// On error the errors are set in both the returned and current objects.
inline bool File::copy(const std::string& to)
{
clear_error();
if (path_.empty()) {
set_error(std::string(HZ__("Unable to copy file: ")) + HZ__("Source path is empty."));
return false;
}
if (to.empty()) {
set_error(std::string(HZ__("Unable to copy file \"/path1/\": "))
+ HZ__("Destination path is empty."), 0, path_);
return false;
}
if (path_ == to) {
set_error(std::string(HZ__("Unable to copy file \"/path1/\": "))
+ HZ__("Source path is the same as destination path."), 0, path_);
return false;
}
// remember permissions in case the file is deleted while copying
struct stat st;
int stat_result = stat(path_.c_str(), &st);
FILE* fsrc = fopen(path_.c_str(), "rb");
if (!fsrc) {
set_error(std::string(HZ__("Unable to copy file \"/path1/\" to \"/path2/\": "))
+ HZ__("Unable to open source file: /errno/."), errno, path_, to);
return false;
}
FILE* fdest = fopen(to.c_str(), "wb"); // this truncates it
if (!fdest) {
fclose(fsrc); // don't check status - there's nothing we can do anyway
set_error(std::string(HZ__("Unable to copy file \"/path1/\" to \"/path2/\": "))
+ HZ__("Unable to create destination file: /errno/."), errno, path_, to);
return false;
}
const unsigned int buf_size = 32*1024; // 32K
unsigned char buf[buf_size] = {0};
while (true) {
size_t read_bytes = fread(buf, 1, buf_size, fsrc);
if (read_bytes != buf_size && ferror(fsrc)) { // error
set_error(std::string(HZ__("Unable to copy file \"/path1/\" to \"/path2/\": "))
+ HZ__("Error while reading source file: /errno/."), errno, path_, to);
break;
}
size_t written_bytes = fwrite(buf, 1, read_bytes, fdest);
if (read_bytes != written_bytes) { // error
set_error(std::string(HZ__("Unable to copy file \"/path1/\" to \"/path2/\": "))
+ HZ__("Error while writing to destination file: /errno/."), errno, path_, to);
break;
}
}
if (bad()) { // error was set
fclose(fsrc); // don't check these - there's nothing we can do about them
fclose(fdest);
unlink(to.c_str());
return false;
}
if (fclose(fsrc) == -1) {
fclose(fdest);
unlink(to.c_str());
set_error(std::string(HZ__("Unable to copy file \"/path1/\" to \"/path2/\": "))
+ HZ__("Error while closing source file: /errno/."), errno, path_, to);
return false;
}
if (fclose(fdest) == -1) { // the OS may delay writing until this point (or even further).
unlink(to.c_str());
set_error(std::string(HZ__("Unable to copy file \"/path1/\" to \"/path2/\": "))
+ HZ__("Error while closing source file: /errno/."), errno, path_, to);
return false;
}
// copy permissions. don't check for errors here - they are harmless.
if (stat_result == 0)
chmod(to.c_str(), st.st_mode & 0777); // don't transfer unneeded stuff.
return true;
}
} // ns hz
#endif

Some files were not shown because too many files have changed in this diff Show More