Update to latest and convert to cmake

This commit is contained in:
Terje Røsten 2018-04-02 20:58:28 +02:00
parent 1eb4ce686d
commit b32854fbf7
7 changed files with 1240 additions and 148 deletions

View File

@ -26,7 +26,7 @@ index 0103377..8fe665e 100644
+ tar --transform s!^!$(PACKAGENAME)-$(VERSION)/! -rf $(PACKAGENAME)-$(VERSION).tar $^
gzip -f $(PACKAGENAME)-$(VERSION).tar
diff --git a/README.md b/README.md
index 64e8b0f..12b4f79 100644
index 64e8b0f..7afcae6 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Installation
@ -38,7 +38,16 @@ index 64e8b0f..12b4f79 100644
- a PA-RISC-, Alpha-, IA-64- (Itanium-), PowerPC-, ARM- or x86- based machine
- an ANSI (or close enough to ANSI compliance) C++ compiler (tested with g++ 2.95.4 and 3.x)
- for the (optional) GTK+ graphical user interface, you will need a
@@ -28,8 +28,16 @@ Installation
@@ -23,13 +23,25 @@ Installation
$ make
+ To complile with zlib support (see below), use:
+
+ $ make ZLIB=1
+
3. If you want to build the optional GUI, do:
$ make
$ make gui
@ -57,7 +66,25 @@ index 64e8b0f..12b4f79 100644
Please make sure you include enough information in your bug report: XML output from lshw is preferred over text or HTML, indicate the affected version of lshw, your platform (i386, x86-64, PA-RISC, PowerPC, etc.) and your distribution.
@@ -55,5 +63,4 @@ or
@@ -38,13 +50,15 @@ NOTE TO DISTRIBUTIONS
By default, lshw includes its own lists of PCI IDs, USB IDs, etc. but will also look for this information in
- /usr/share/lshw/,
- /usr/local/share/,
+ /usr/share/lshw/,
+ /usr/local/share/,
/usr/share/,
/etc/,
/usr/share/hwdata/,
/usr/share/misc/
+If compiled with zlib support, lshw will look for `file`.gz first, then for `file`.
+
Statically-linked and/or compressed binaries can be built by using
$ make static
@@ -55,5 +69,4 @@ or
in the `src/` directory
@ -90,10 +117,22 @@ index b46a33e..b513fa2 100644
<xs:complexType name="measured">
diff --git a/src/Makefile b/src/Makefile
index b50586b..cf11dd2 100644
index b50586b..917bf6b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -20,7 +20,7 @@ export SQLITE
@@ -3,6 +3,7 @@ export PACKAGENAME
VERSION?= $(shell git describe --tags --long | cut -d - -f 1,2 | tr - .)
SQLITE?=0
+ZLIB?=0
DESTDIR?=/
PREFIX?=/usr
@@ -17,35 +18,49 @@ export SBINDIR
export MANDIR
export DATADIR
export SQLITE
+export ZLIB
CXX?=c++
INCLUDES=-I./core/
@ -102,7 +141,12 @@ index b50586b..cf11dd2 100644
CXXFLAGS=-g -Wall -g $(INCLUDES) $(DEFINES) $(RPM_OPT_FLAGS)
ifeq ($(SQLITE), 1)
CXXFLAGS+= -DSQLITE $(shell pkg-config --cflags sqlite3)
@@ -30,7 +30,7 @@ ifneq ($(shell $(LD) --help 2| grep -- --as-needed), )
endif
+ifeq ($(ZLIB), 1)
+ CXXFLAGS+= -DZLIB $(shell pkg-config --cflags zlib)
+endif
LDFLAGS=-L./core/ -g
ifneq ($(shell $(LD) --help 2| grep -- --as-needed), )
LDFLAGS+= -Wl,--as-needed
endif
LDSTATIC=-static
@ -111,16 +155,33 @@ index b50586b..cf11dd2 100644
ifeq ($(SQLITE), 1)
LIBS+= $(shell pkg-config --libs sqlite3)
endif
@@ -39,7 +39,7 @@ export CXXFLAGS
+ifeq ($(ZLIB), 1)
+ LIBS+= $(shell pkg-config --libs zlib)
+endif
export CXXFLAGS
export LIBS
export LDFLAGS
-DATAFILES = pci.ids usb.ids oui.txt manuf.txt
+ifeq ($(ZLIB), 1)
+DATAFILES = pci.ids.gz usb.ids.gz oui.txt.gz manuf.txt.gz pnp.ids.gz pnpid.txt.gz
+else
+DATAFILES = pci.ids usb.ids oui.txt manuf.txt pnp.ids pnpid.txt
+endif
all: $(PACKAGENAME) $(PACKAGENAME).1 $(DATAFILES)
@@ -93,6 +93,12 @@ oui.txt:
.cc.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
+%.gz: %
+ gzip -c $< > $@
+
.PHONY: core
core:
+make -C core all
@@ -93,6 +108,12 @@ oui.txt:
manuf.txt:
wget -O $@ http://anonsvn.wireshark.org/wireshark/trunk/manuf
@ -133,6 +194,14 @@ index b50586b..cf11dd2 100644
install: all
$(INSTALL) -d -m 0755 $(DESTDIR)/$(SBINDIR)
$(INSTALL) -m 0755 $(PACKAGENAME) $(DESTDIR)/$(SBINDIR)
@@ -112,6 +133,7 @@ install-gui: gui
clean:
rm -f $(PACKAGENAME).o $(PACKAGENAME) $(PACKAGENAME)-static $(PACKAGENAME)-compressed
+ rm -f $(addsuffix .gz,$(DATAFILES))
make -C core clean
make -C gui clean
diff --git a/src/core/Makefile b/src/core/Makefile
index 5bf5a69..884a963 100644
--- a/src/core/Makefile
@ -191,7 +260,7 @@ index 76e5082..adff7b5 100644
pushd(PROC_SYS);
diff --git a/src/core/cpuinfo.cc b/src/core/cpuinfo.cc
index 5a2b8c0..f5665fb 100644
index 5a2b8c0..8a72d98 100644
--- a/src/core/cpuinfo.cc
+++ b/src/core/cpuinfo.cc
@@ -13,6 +13,13 @@ __ID("@(#) $Id$");
@ -290,16 +359,70 @@ index 5a2b8c0..f5665fb 100644
static vector <string> aarch64_features;
static string aarch64_processor_name;
static void cpuinfo_aarch64(hwNode & node,
@@ -237,7 +260,7 @@ static void cpuinfo_aarch64(hwNode & node,
if (node.getDescription() == "")
node.setDescription(aarch64_processor_name);
cpu->claim(true);
@@ -218,50 +241,45 @@ static void cpuinfo_aarch64(hwNode & node,
if (id == "Features")
{
- while (value.length() > 0)
- {
- size_t pos = value.find(' ');
- string capability = (pos==string::npos)?value:value.substr(0, pos);
- aarch64_features.push_back(capability);
- if (pos == string::npos)
- value = "";
- else
- value = hw::strip(value.substr(pos));
- }
- for(int i=0; i<=currentcpu; i++)
+ hwNode *cpu = getcpu(node, currentcpu);
+ if (cpu)
{
- hwNode *cpu = getcpu(node, i);
- if (cpu)
+ cpu->addHint("logo", string("aarch64"));
+ if (node.getDescription() == "")
+ node.setDescription(aarch64_processor_name);
+ cpu->claim(true);
+
+ while (value.length() > 0)
+ {
+ size_t pos = value.find(' ');
+ string capability = (pos==string::npos)?value:value.substr(0, pos);
+ aarch64_features.push_back(capability);
+ if (pos == string::npos)
+ value = "";
+ else
+ value = hw::strip(value.substr(pos));
+ }
+
+ for(size_t i=0; i < aarch64_features.size(); i++)
{
- cpu->addHint("logo", string("aarch64"));
- if (node.getDescription() == "")
- node.setDescription(aarch64_processor_name);
- cpu->claim(true);
- for(int i=0; i < aarch64_features.size(); i++)
+ for(size_t i=0; i < aarch64_features.size(); i++)
{
cpu->addCapability(aarch64_features[i]);
cpu->describeCapability("fp", "Floating point instructions");
@@ -253,15 +276,11 @@ static void cpuinfo_aarch64(hwNode & node,
- {
- cpu->addCapability(aarch64_features[i]);
- cpu->describeCapability("fp", "Floating point instructions");
- cpu->describeCapability("asimd", "Advanced SIMD");
- cpu->describeCapability("evtstrm", "Event stream");
- cpu->describeCapability("aes", "AES instructions");
- cpu->describeCapability("pmull", "PMULL instruction");
- cpu->describeCapability("sha1", "SHA1 instructions");
- cpu->describeCapability("sha2", "SHA2 instructions");
- cpu->describeCapability("crc32", "CRC extension");
- }
+ cpu->addCapability(aarch64_features[i]);
+ cpu->describeCapability("fp", "Floating point instructions");
+ cpu->describeCapability("asimd", "Advanced SIMD");
+ cpu->describeCapability("evtstrm", "Event stream");
+ cpu->describeCapability("aes", "AES instructions");
+ cpu->describeCapability("pmull", "PMULL instruction");
+ cpu->describeCapability("sha1", "SHA1 instructions");
+ cpu->describeCapability("sha2", "SHA2 instructions");
+ cpu->describeCapability("crc32", "CRC extension");
}
}
}
}
@ -315,7 +438,7 @@ index 5a2b8c0..f5665fb 100644
if (id == "processor")
currentcpu++;
@@ -307,9 +326,7 @@ string value)
@@ -307,9 +325,7 @@ string value)
}
}
}
@ -325,7 +448,7 @@ index 5a2b8c0..f5665fb 100644
static void cpuinfo_hppa(hwNode & node,
string id,
string value)
@@ -343,9 +360,7 @@ string value)
@@ -343,9 +359,7 @@ string value)
}
}
}
@ -335,7 +458,7 @@ index 5a2b8c0..f5665fb 100644
static void cpuinfo_alpha(hwNode & node,
string id,
string value)
@@ -403,9 +418,7 @@ string value)
@@ -403,9 +417,7 @@ string value)
mycpu->enable();
}
}
@ -345,7 +468,7 @@ index 5a2b8c0..f5665fb 100644
static void cpuinfo_x86(hwNode & node,
string id,
string value)
@@ -549,7 +562,6 @@ string value)
@@ -549,7 +561,6 @@ string value)
if(node.getWidth()==0) node.setWidth(cpu->getWidth());
}
}
@ -353,7 +476,7 @@ index 5a2b8c0..f5665fb 100644
bool scan_cpuinfo(hwNode & n)
{
@@ -570,6 +582,8 @@ bool scan_cpuinfo(hwNode & n)
@@ -570,6 +581,8 @@ bool scan_cpuinfo(hwNode & n)
char buffer[1024];
size_t count;
string cpuinfo_str = "";
@ -362,7 +485,7 @@ index 5a2b8c0..f5665fb 100644
while ((count = read(cpuinfo, buffer, sizeof(buffer))) > 0)
{
@@ -595,32 +609,53 @@ bool scan_cpuinfo(hwNode & n)
@@ -595,32 +608,53 @@ bool scan_cpuinfo(hwNode & n)
id = hw::strip(cpuinfo_lines[i].substr(0, pos));
value = hw::strip(cpuinfo_lines[i].substr(pos + 1));
@ -2938,10 +3061,74 @@ index 15a961d..e4d667f 100644
//scan_mii(fd, interface);
scan_ip(interface);
diff --git a/src/core/osutils.cc b/src/core/osutils.cc
index 95c8483..ff41e18 100644
index 95c8483..f023a46 100644
--- a/src/core/osutils.cc
+++ b/src/core/osutils.cc
@@ -422,7 +422,7 @@ string dirname(const string & path)
@@ -21,6 +21,9 @@
#ifndef MINOR
#include <linux/kdev_t.h>
#endif
+#ifdef ZLIB
+#include <zlib.h>
+#endif
__ID("@(#) $Id$");
@@ -114,23 +117,49 @@ bool exists(const string & path)
}
+#ifdef ZLIB
+
+typedef gzFile data_file;
+static data_file file_open(const string & file)
+{
+ data_file result = gzopen((file + ".gz").c_str(), "rb");
+ if (!result)
+ {
+ result = gzopen(file.c_str(), "rb");
+ }
+ return result;
+}
+#define file_open_error(f) ((f) == NULL)
+#define file_read(f, b, l) gzread((f), (b), (l))
+#define file_close(f) gzclose(f)
+
+#else
+
+typedef int data_file;
+#define file_open(f) open((f).c_str(), O_RDONLY);
+#define file_open_error(f) ((f) < 0)
+#define file_read(f, b, l) read((f), (b), (l))
+#define file_close(f) close(f)
+
+#endif
+
bool loadfile(const string & file,
vector < string > &list)
{
char buffer[1024];
string buffer_str = "";
size_t count = 0;
- int fd = open(file.c_str(), O_RDONLY);
+ data_file fd = file_open(file);
- if (fd < 0)
+ if (file_open_error(fd))
return false;
- while ((count = read(fd, buffer, sizeof(buffer))) > 0)
+ while ((count = file_read(fd, buffer, sizeof(buffer))) > 0)
buffer_str += string(buffer, count);
splitlines(buffer_str, list);
- close(fd);
+ file_close(fd);
return true;
}
@@ -422,7 +451,7 @@ string dirname(const string & path)
path.copy(buffer, len);
buffer[len] = '\0';
string result = dirname(buffer);
@ -2950,7 +3137,7 @@ index 95c8483..ff41e18 100644
return result;
}
@@ -773,47 +773,47 @@ string operating_system()
@@ -773,47 +802,47 @@ string operating_system()
struct utsname u;
string os = "";
@ -3019,7 +3206,7 @@ index 95c8483..ff41e18 100644
os = osinfo[0];
if(uname(&u) != 0) return "";
@@ -832,15 +832,10 @@ string operating_system()
@@ -832,15 +861,10 @@ string operating_system()
string platform()
{
@ -4527,6 +4714,32 @@ index 0000000..3d70cd6
+ <url type="homepage">http://www.ezix.org/project/wiki/HardwareLiSter</url>
+ <update_contact>support@ezix.org</update_contact>
+</component>
diff --git a/src/lshw.1 b/src/lshw.1
index 551fece..43e4eac 100644
--- a/src/lshw.1
+++ b/src/lshw.1
@@ -1,5 +1,5 @@
-.\\" auto-generated by docbook2man-spec $Revision: 1.2 $
-.TH "LSHW" "1" "30 May 2010" "$Rev: 2179 $" ""
+.\" auto-generated by docbook2man-spec from docbook-utils package
+.TH "LSHW" "1" "28 January 2018" "$Rev$" ""
.SH NAME
lshw \- list hardware
.SH SYNOPSIS
@@ -98,6 +98,7 @@ partial information.
.TP
\fB/usr/share/hwdata/pci.ids\fR
A list of all known PCI ID's (vendors, devices, classes and subclasses).
+If compiled with zlib support, lshw will look for \fIpci.ids.gz\fR first, then for \fIpci.ids\fR\&.
.TP
\fB/proc/bus/pci/*\fR
Used to access the configuration of installed PCI busses and devices.
@@ -146,4 +147,4 @@ Don't use DMI to detect hardware.
.SH "OTHER INFO"
.PP
The webpage for \fBlshw\fR is at
- <URL:http://lshw.org/>
+ <URL:http://lshw.ezix.org/>
diff --git a/src/lshw.cc b/src/lshw.cc
index 77a5932..5fc8ade 100644
--- a/src/lshw.cc
@ -4539,6 +4752,18 @@ index 77a5932..5fc8ade 100644
fprintf(stderr, _("\t-short output hardware paths\n"));
fprintf(stderr, _("\t-businfo output bus information\n"));
if(getenv("DISPLAY") && exists(SBINDIR"/gtk-lshw"))
diff --git a/src/lshw.sgml b/src/lshw.sgml
index e8b0168..2f3a3ac 100644
--- a/src/lshw.sgml
+++ b/src/lshw.sgml
@@ -166,6 +166,7 @@ partial information.
<term>/usr/share/hwdata/pci.ids</term>
<listitem><para>
A list of all known PCI ID's (vendors, devices, classes and subclasses).
+If compiled with zlib support, lshw will look for <filename>pci.ids.gz</filename> first, then for <filename>pci.ids</filename>.
</para></listitem></varlistentry>
<varlistentry><term>/proc/bus/pci/*</term>
diff --git a/src/manuf.txt b/src/manuf.txt
index a10e77e..7c96681 100644
--- a/src/manuf.txt

960
lshw-B.02.18-cmake.patch Normal file
View File

@ -0,0 +1,960 @@
From a43ffe12212e1a4dd7b0038197b53798d7a3dfb1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Terje=20R=C3=B8sten?= <terje.rosten@ntnu.no>
Date: Mon, 2 Apr 2018 14:51:55 +0200
Subject: [PATCH] cmakeify
---
CMakeLists.txt | 42 ++++++
Makefile | 20 ---
README.md | 47 ++++---
lshw.spec.in | 52 ++------
src/CMakeLists.txt | 103 +++++++++++++++
src/Makefile | 144 ---------------------
src/core/Makefile | 80 ------------
src/core/{config.h => config.h.in} | 28 ++--
src/core/db.cc | 8 ++
src/core/dump.cc | 2 +-
src/core/version.h | 2 +
src/gui/CMakeLists.txt | 67 ++++++++++
src/gui/Makefile | 61 ---------
.../{gtk-lshw.desktop => gtk-lshw.desktop.in} | 7 +-
src/gui/integration/lshw-gui.in | 5 +
src/gui/integration/org.ezix.lshw.gui.policy.in | 20 +++
src/gui/stock.c | 1 +
src/po/CMakeLists.txt | 16 +++
src/po/Makefile | 23 ----
19 files changed, 317 insertions(+), 411 deletions(-)
create mode 100644 CMakeLists.txt
delete mode 100644 Makefile
create mode 100644 src/CMakeLists.txt
delete mode 100644 src/Makefile
delete mode 100644 src/core/Makefile
rename src/core/{config.h => config.h.in} (50%)
create mode 100644 src/gui/CMakeLists.txt
delete mode 100644 src/gui/Makefile
rename src/gui/integration/{gtk-lshw.desktop => gtk-lshw.desktop.in} (51%)
create mode 100644 src/gui/integration/lshw-gui.in
create mode 100644 src/gui/integration/org.ezix.lshw.gui.policy.in
create mode 100644 src/po/CMakeLists.txt
delete mode 100644 src/po/Makefile
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6c69c37
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(lshw)
+set(VERSION "B.012.18")
+
+IF(EXISTS "${PROJECT_SOURCE_DIR}/.git")
+ find_package(Git)
+ if(GIT_FOUND)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe --tags
+ OUTPUT_VARIABLE DESCRIBE_TAG
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "B.[0-9]+.[0-9]+[-][0-9]+" VERSION ${DESCRIBE_TAG})
+ string(REPLACE "-" "." VERSION ${VERSION})
+ endif()
+endif()
+
+message("-- lshw: ${VERSION}")
+
+option(GUI "Enable GUI application (${PROJECT_NAME}-gtk)" ON)
+option(HWDATA "Install hwdata files" ON)
+option(SQLITE "Enable SQLite support" OFF)
+option(ZLIB "Enable zlib support" OFF)
+option(NOLOGO "Don't install vendor logos" OFF)
+option(STATIC "Do a static (will disable other features)" OFF)
+option(POLICYKIT "Install PolicyKit file and pfexec wrapper" OFF)
+
+include(GNUInstallDirs)
+set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE STRING "Install prefix")
+set(DATADIR "${CMAKE_INSTALL_FULL_DATADIR}")
+set(PROJECT_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}")
+set(SBINDIR "${CMAKE_INSTALL_FULL_SBINDIR}")
+set(MANDIR "${CMAKE_INSTALL_FULL_MANDIR}")
+set(LOCALEDIR "${CMAKE_INSTALL_FULL_LOCALEDIR}")
+
+configure_file(
+ "${PROJECT_SOURCE_DIR}/lshw.spec.in"
+ "${PROJECT_BINARY_DIR}/lshw.spec")
+
+add_subdirectory(src)
+add_subdirectory(src/po)
+add_subdirectory(src/gui)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 8fe665e..0000000
--- a/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-PACKAGENAME = lshw
-VERSION?= $(shell git describe --tags | cut -d - -f 1,2 | tr - .)
-export PACKAGENAME
-
-all clean install snapshot gui install-gui:
- +$(MAKE) -C src $@
-
-version.cpe: .version
- echo -n cpe:/a:ezix:$(PACKAGENAME): > $@
- cat $^ >> $@
-
-.PHONY: $(PACKAGENAME).spec
-
-$(PACKAGENAME).spec: $(PACKAGENAME).spec.in
- cat $^ | sed -e s/\@VERSION\@/$(VERSION)/g > $@
-
-release: $(PACKAGENAME).spec
- git archive --prefix=$(PACKAGENAME)-$(VERSION)/ -o $(PACKAGENAME)-$(VERSION).tar HEAD
- tar --transform s!^!$(PACKAGENAME)-$(VERSION)/! -rf $(PACKAGENAME)-$(VERSION).tar $^
- gzip -f $(PACKAGENAME)-$(VERSION).tar
diff --git a/README.md b/README.md
index 7afcae6..393da0f 100644
--- a/README.md
+++ b/README.md
@@ -15,27 +15,25 @@ Installation
1. Requirements
- Linux 2.4.x, 2.6.x, 3.x or 4.x (2.2.x might work, though)
- a PA-RISC-, Alpha-, IA-64- (Itanium-), PowerPC-, ARM- or x86- based machine
+ - cmake, GNU make or Ninja
- an ANSI (or close enough to ANSI compliance) C++ compiler (tested with g++ 2.95.4 and 3.x)
- for the (optional) GTK+ graphical user interface, you will need a
complete GTK+ development environment (gtk2-devel on RedHat/Fedora derivatives)
+ - for optional SQLite feature install SQLite
+ - for optional zlib feature install zlib and gzip
- 2. To compile it, just use:
+ 2. Use cmake options to adjust non default set:
+ -DGUI=OFF, -DZLIB=ON, -DSQLITE=ON and/or -DNOLOGO=ON
- $ make
+ 3. Do configuration and build by
- To complile with zlib support (see below), use:
-
- $ make ZLIB=1
-
- 3. If you want to build the optional GUI, do:
-
- $ make
- $ make gui
+ $ mkdir build && cd build
+ $ cmake .. -GNinja <options>
+ $ ninja-build
4. If you want to install the result, do:
- $ make install
- $ make install-gui
+ $ ninja-build install
Getting help
------------
@@ -61,12 +59,27 @@ If compiled with zlib support, lshw will look for `file`.gz first, then for `fil
Statically-linked and/or compressed binaries can be built by using
- $ make static
-
+ $ mkdir build && cd build
+ $ cmake .. -DSTATIC=ON
+ $ ninja
or
+ $ mkdir build && cd build
+ $ cmake .. -GNinja
+ $ ninja compressed
- $ make compressed
+Building compressed binaries requires `upx` (cf. https://upx.github.io/).
-in the `src/` directory
+Release and maintenance
+-----------------------
-Building compressed binaries requires `upx` (cf. https://upx.github.io/).
+Create release tarball,
+
+ 1. Edit CMakeLists.txt to set version
+ 2. Run
+ $ mkdir build && cd build
+ $ cmake .. -GNinja
+ $ ninja release
+
+Update hwdata files:
+
+ $ ninja refresh_hwdata
diff --git a/lshw.spec.in b/lshw.spec.in
index c597379..a7655f5 100644
--- a/lshw.spec.in
+++ b/lshw.spec.in
@@ -52,49 +52,17 @@ http://lshw.ezix.org/
%setup -q
%build
-%{__make} %{?_smp_mflags} \
- PREFIX="%{_prefix}" \
- SBINDIR="%{_sbindir}" \
- MANDIR="%{_mandir}" \
- DATADIR="%{_datadir}" \
- all
-%if %{!?_without_gui:1}0
-%{__make} %{?_smp_mflags} \
- PREFIX="%{_prefix}" \
- SBINDIR="%{_sbindir}" \
- MANDIR="%{_mandir}" \
- DATADIR="%{_datadir}" \
- gui
-%endif
+mkdir build && cd build
+%cmake .. %{?_without_gui:-DGUI=OFF}
+make %{?_smp_mflags} VERBOSE=1
%install
-%{__rm} -rf "%{buildroot}"
-
-%{__make} \
- DESTDIR="%{buildroot}" \
- PREFIX="%{_prefix}" \
- SBINDIR="%{_sbindir}" \
- MANDIR="%{_mandir}" \
- DATADIR="%{_datadir}" \
- INSTALL="%{__install} -p" \
- install
-%if %{!?_without_gui:1}0
-%{__make} \
- DESTDIR="%{buildroot}" \
- PREFIX="%{_prefix}" \
- SBINDIR="%{_sbindir}" \
- MANDIR="%{_mandir}" \
- DATADIR="%{_datadir}" \
- INSTALL="%{__install} -p" \
- install-gui
-%endif
-
-%clean
-%{__rm} -rf %{buildroot}
+cd build
+make install DESTDIR=%{buildroot}
%files
-%defattr(-,root,root, 0555)
-%doc README.md COPYING docs/TODO docs/Changelog docs/lshw.xsd
+%license COPYING
+%doc COPYING docs/TODO docs/Changelog docs/lshw.xsd
%{_sbindir}/lshw
%doc %{_mandir}/man?/*
%{_datadir}/lshw/
@@ -102,9 +70,11 @@ http://lshw.ezix.org/
%if %{!?_without_gui:1}0
%files gui
-%defattr(-,root,root, 0555)
-%doc COPYING
+%license COPYING
%{_sbindir}/gtk-lshw
+%{_datadir}/appdata/gtk-lshw.appdata.xml
+%{_datadir}/applications/gtk-lshw.desktop
+%{_datadir}/pixmaps/gtk-lshw.svg
%endif
%changelog
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..ab559d9
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,103 @@
+if(STATIC)
+ set(ZLIB OFF)
+ set(SQLITE OFF)
+endif()
+
+# SQLite support
+if(SQLITE)
+ pkg_check_modules(SQLITE3 sqlite3)
+ if(SQLITE3_FOUND)
+ message("-- Enabling SQLite support")
+ else()
+ message(FATAL_ERROR "SQLite not found, install lib or disable feature: -DSQLITE=OFF")
+ endif()
+else()
+ message("-- SQLite support disabled")
+endif()
+
+# zlib support
+if(ZLIB)
+ find_program(GZIP gzip "Path to gzip application")
+ if(NOT GZIP)
+ message(FATAL_ERROR "gzip program not found, install gzip or disable zlib support: -DZLIB=OFF")
+ endif()
+ pkg_check_modules(Z zlib)
+ if(Z_FOUND)
+ message("-- Enabling zlib support")
+ else()
+ message(FATAL_ERROR "zlib not found, install lib or disable feature: -DZLIB=OFF")
+ endif()
+else()
+ message("-- zlib support disabled")
+endif()
+
+if(ERROR)
+ message(FATAL_ERROR "Configuration failed")
+endif()
+
+# Some special targets, compress, refresh_hwdata and release
+add_custom_target(compressed
+ COMMAND upx -9 -o lshw-compress lshw
+ COMMENT "Creating upx compressed binary")
+add_dependencies(compressed lshw)
+
+add_custom_target(refresh_hwdata
+ COMMAND wget -N http://pciids.sourceforge.net/pci.ids
+ COMMAND wget -N http://www.linux-usb.org/usb.ids
+ COMMAND wget -N http://standards-oui.ieee.org/oui/oui.txt
+ COMMAND wget -O manuf.txt http://anonsvn.wireshark.org/wireshark/trunk/manuf
+ COMMAND wget -N https://git.fedorahosted.org/cgit/hwdata.git/plain/pnp.ids
+ COMMAND wget -N http://www-pc.uni-regensburg.de/hardware/TECHNIK/PCI_PNP/pnpid.txt
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src"
+ COMMENT "Updating hwdata files from upstream location")
+
+set(TARNAME ${PROJECT_NAME}-${VERSION})
+add_custom_target(release
+ COMMAND ${GIT_EXECUTABLE} archive --prefix=${TARNAME}/
+ -o ${PROJECT_BINARY_DIR}/${TARNAME}.tar HEAD
+ COMMAND mv ${PROJECT_BINARY_DIR}/lshw.spec ${PROJECT_SOURCE_DIR}/lshw.spec
+ COMMAND tar --owner=0 --group=0
+ --transform s,lshw.spec,${TARNAME}/lshw.spec,
+ -rf ${PROJECT_BINARY_DIR}/${TARNAME}.tar lshw.spec
+ COMMAND gzip ${PROJECT_BINARY_DIR}/${TARNAME}.tar
+ COMMAND rm ${PROJECT_SOURCE_DIR}/lshw.spec
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
+ COMMENT "Creating release tarball")
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/core/config.h.in"
+ "${PROJECT_BINARY_DIR}/config.h")
+
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/core")
+
+file(GLOB DATAFILES "pci.ids" "pnp.ids" "usb.ids" "manuf.txt" "oui.txt" "pnpid.txt")
+
+file(GLOB SOURCES "core/*.cc")
+add_library(core ${SOURCES})
+add_executable(lshw lshw.cc)
+
+if(STATIC)
+ set_target_properties(lshw PROPERTIES LINK_FLAGS "-static" )
+endif()
+
+target_link_libraries(lshw ${SQLITE3_LIBRARIES} ${Z_LIBRARIES} resolv core)
+
+if(NOT ZLIB)
+ if(HWDATA)
+ install(FILES ${DATAFILES} DESTINATION ${PROJECT_DATADIR})
+ endif()
+else()
+ foreach(DATAFILE ${DATAFILES})
+ get_filename_component(FILE ${DATAFILE} NAME)
+ add_custom_command(
+ OUTPUT ${FILE}.gz
+ COMMAND ${GZIP} -c ${DATAFILE} > ${FILE}.gz)
+ add_custom_target(${FILE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.gz)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${FILE}.gz DESTINATION ${PROJECT_DATADIR})
+ endforeach()
+endif()
+
+install(FILES lshw.1 DESTINATION ${MANDIR}/man1 COMPONENT doc)
+install(TARGETS lshw DESTINATION sbin)
+
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index 917bf6b..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,144 +0,0 @@
-PACKAGENAME:=lshw
-export PACKAGENAME
-VERSION?= $(shell git describe --tags --long | cut -d - -f 1,2 | tr - .)
-
-SQLITE?=0
-ZLIB?=0
-
-DESTDIR?=/
-PREFIX?=/usr
-SBINDIR=$(PREFIX)/sbin
-MANDIR=$(PREFIX)/share/man
-DATADIR=$(PREFIX)/share
-INSTALL?=install -p
-STRIP?=strip
-export DESTDIR
-export PREFIX
-export SBINDIR
-export MANDIR
-export DATADIR
-export SQLITE
-export ZLIB
-
-CXX?=c++
-INCLUDES=-I./core/
-DEFINES=-DPREFIX=\"$(PREFIX)\" -DSBINDIR=\"$(SBINDIR)\" -DMANDIR=\"$(MANDIR)\" -DDATADIR=\"$(DATADIR)\" -DVERSION=\"$(VERSION)\"
-CXXFLAGS=-g -Wall -g $(INCLUDES) $(DEFINES) $(RPM_OPT_FLAGS)
-ifeq ($(SQLITE), 1)
- CXXFLAGS+= -DSQLITE $(shell pkg-config --cflags sqlite3)
-endif
-ifeq ($(ZLIB), 1)
- CXXFLAGS+= -DZLIB $(shell pkg-config --cflags zlib)
-endif
-LDFLAGS=-L./core/ -g
-ifneq ($(shell $(LD) --help 2| grep -- --as-needed), )
- LDFLAGS+= -Wl,--as-needed
-endif
-LDSTATIC=-static
-LIBS+=-llshw -lresolv
-ifeq ($(SQLITE), 1)
- LIBS+= $(shell pkg-config --libs sqlite3)
-endif
-ifeq ($(ZLIB), 1)
- LIBS+= $(shell pkg-config --libs zlib)
-endif
-
-export CXXFLAGS
-export LIBS
-export LDFLAGS
-
-ifeq ($(ZLIB), 1)
-DATAFILES = pci.ids.gz usb.ids.gz oui.txt.gz manuf.txt.gz pnp.ids.gz pnpid.txt.gz
-else
-DATAFILES = pci.ids usb.ids oui.txt manuf.txt pnp.ids pnpid.txt
-endif
-
-all: $(PACKAGENAME) $(PACKAGENAME).1 $(DATAFILES)
-
-.cc.o:
- $(CXX) $(CXXFLAGS) -c $< -o $@
-
-%.gz: %
- gzip -c $< > $@
-
-.PHONY: core
-core:
- +make -C core all
-
-$(PACKAGENAME): core $(PACKAGENAME).o
- $(CXX) $(LDFLAGS) -o $@ $(PACKAGENAME).o $(LIBS)
-
-.PHONY: po
-po:
- +make -C po all
-
-.PHONY: gui
-gui: core
- +make -C gui all
-
-.PHONY: nologo
-nologo:
- cp -f gui/artwork/nologo/* gui/artwork/
-
-.PHONY: static
-static: $(PACKAGENAME)-static
-
-$(PACKAGENAME)-static: core core/lib$(PACKAGENAME).a $(PACKAGENAME).o
- $(CXX) $(LDSTATIC) $(LDFLAGS) -o $@ $(PACKAGENAME).o $(LIBS)
- $(STRIP) $@
-
-.PHONY: compressed
-compressed: $(PACKAGENAME)-compressed
-
-$(PACKAGENAME)-compressed: $(PACKAGENAME)-static
- upx -9 -o $@ $<
-
-$(PACKAGENAME).1: $(PACKAGENAME).sgml
- docbook2man $<
-
-pci.ids:
- wget http://pciids.sourceforge.net/pci.ids
-
-usb.ids:
- wget http://www.linux-usb.org/usb.ids
-
-oui.txt:
- wget http://standards.ieee.org/regauth/oui/oui.txt
-
-manuf.txt:
- wget -O $@ http://anonsvn.wireshark.org/wireshark/trunk/manuf
-
-pnp.ids:
- wget https://git.fedorahosted.org/cgit/hwdata.git/plain/pnp.ids
-
-pnpid.txt:
- wget http://www-pc.uni-regensburg.de/hardware/TECHNIK/PCI_PNP/pnpid.txt
-
-install: all
- $(INSTALL) -d -m 0755 $(DESTDIR)/$(SBINDIR)
- $(INSTALL) -m 0755 $(PACKAGENAME) $(DESTDIR)/$(SBINDIR)
- $(INSTALL) -d -m 0755 $(DESTDIR)/$(MANDIR)/man1
- $(INSTALL) -m 0644 $(PACKAGENAME).1 $(DESTDIR)/$(MANDIR)/man1
- $(INSTALL) -d -m 0755 $(DESTDIR)/$(DATADIR)/$(PACKAGENAME)
- $(INSTALL) -m 0644 $(DATAFILES) $(DESTDIR)/$(DATADIR)/$(PACKAGENAME)
- make -C po install
-
-install-gui: gui
- $(INSTALL) -d -m 0755 $(DESTDIR)/$(SBINDIR)
- $(INSTALL) -m 0755 gui/gtk-$(PACKAGENAME) $(DESTDIR)/$(SBINDIR)
- $(INSTALL) -d -m 0755 $(DESTDIR)/$(DATADIR)/$(PACKAGENAME)/artwork
- $(INSTALL) -d -m 0755 $(DESTDIR)/$(DATADIR)/$(PACKAGENAME)/ui
- $(INSTALL) -m 0644 gui/*.ui $(DESTDIR)/$(DATADIR)/$(PACKAGENAME)/ui
- $(INSTALL) -m 0644 gui/artwork/*.svg $(DESTDIR)/$(DATADIR)/$(PACKAGENAME)/artwork
-
-clean:
- rm -f $(PACKAGENAME).o $(PACKAGENAME) $(PACKAGENAME)-static $(PACKAGENAME)-compressed
- rm -f $(addsuffix .gz,$(DATAFILES))
- make -C core clean
- make -C gui clean
-
-depend:
- @makedepend -Y $(SRCS) 2> /dev/null > /dev/null
-
-
-# DO NOT DELETE
diff --git a/src/core/Makefile b/src/core/Makefile
deleted file mode 100644
index 884a963..0000000
--- a/src/core/Makefile
+++ /dev/null
@@ -1,80 +0,0 @@
-PACKAGENAME?=lshw
-
-CXX=c++
-INCLUDES=
-DEFINES=-DPREFIX=\"$(PREFIX)\" -DSBINDIR=\"$(SBINDIR)\" -DMANDIR=\"$(MANDIR)\" -DDATADIR=\"$(DATADIR)\"
-CXXFLAGS?=-g -Wall $(INCLUDES) $(DEFINES) $(RPM_OPT_FLAGS)
-LDFLAGS=
-LDSTATIC=
-LIBS=
-
-OBJS = hw.o main.o print.o mem.o dmi.o device-tree.o cpuinfo.o osutils.o pci.o version.o cpuid.o ide.o cdrom.o pcmcia-legacy.o scsi.o s390.o disk.o spd.o network.o isapnp.o pnp.o fb.o options.o usb.o sysfs.o display.o heuristics.o parisc.o cpufreq.o partitions.o blockio.o lvm.o ideraid.o pcmcia.o volumes.o mounts.o smp.o abi.o jedec.o dump.o fat.o virtio.o vio.o
-ifeq ($(SQLITE), 1)
- OBJS+= db.o
-endif
-SRCS = $(OBJS:.o=.cc)
-
-all: lib$(PACKAGENAME).a
-
-.cc.o:
- $(CXX) $(CXXFLAGS) -c $< -o $@
-
-lib$(PACKAGENAME).a: $(OBJS)
- $(AR) rs $@ $^
-
-install: all
-
-clean:
- rm -f $(OBJS) lib$(PACKAGENAME).a
-
-depend:
- @makedepend -Y $(SRCS) 2> /dev/null > /dev/null
-
-
-# DO NOT DELETE
-
-hw.o: hw.h osutils.h version.h config.h options.h heuristics.h
-main.o: hw.h print.h version.h options.h mem.h dmi.h cpuinfo.h cpuid.h
-main.o: device-tree.h pci.h pcmcia.h pcmcia-legacy.h ide.h scsi.h spd.h
-main.o: network.h isapnp.h fb.h usb.h sysfs.h display.h parisc.h cpufreq.h
-main.o: ideraid.h mounts.h smp.h abi.h s390.h virtio.h pnp.h vio.h
-print.o: print.h hw.h options.h version.h osutils.h config.h
-mem.o: version.h config.h mem.h hw.h sysfs.h
-dmi.o: version.h config.h dmi.h hw.h osutils.h
-device-tree.o: version.h device-tree.h hw.h osutils.h
-cpuinfo.o: version.h cpuinfo.h hw.h osutils.h
-osutils.o: version.h osutils.h
-pci.o: version.h config.h pci.h hw.h osutils.h options.h
-version.o: version.h config.h
-cpuid.o: version.h cpuid.h hw.h
-ide.o: version.h cpuinfo.h hw.h osutils.h cdrom.h disk.h heuristics.h
-cdrom.o: version.h cdrom.h hw.h partitions.h
-pcmcia-legacy.o: version.h pcmcia-legacy.h hw.h osutils.h
-scsi.o: version.h mem.h hw.h cdrom.h disk.h osutils.h heuristics.h sysfs.h
-disk.o: version.h disk.h hw.h osutils.h heuristics.h partitions.h
-spd.o: version.h spd.h hw.h osutils.h
-network.o: version.h config.h network.h hw.h osutils.h sysfs.h options.h
-network.o: heuristics.h
-isapnp.o: version.h isapnp.h hw.h pnp.h
-pnp.o: version.h pnp.h hw.h sysfs.h osutils.h
-fb.o: version.h fb.h hw.h
-options.o: version.h options.h osutils.h
-usb.o: version.h usb.h hw.h osutils.h heuristics.h options.h
-sysfs.o: version.h sysfs.h hw.h osutils.h
-display.o: display.h hw.h
-heuristics.o: version.h sysfs.h hw.h osutils.h
-parisc.o: version.h device-tree.h hw.h osutils.h heuristics.h
-cpufreq.o: version.h hw.h osutils.h
-partitions.o: version.h partitions.h hw.h blockio.h lvm.h volumes.h osutils.h
-blockio.o: version.h blockio.h osutils.h
-lvm.o: version.h lvm.h hw.h blockio.h osutils.h
-ideraid.o: version.h cpuinfo.h hw.h osutils.h cdrom.h disk.h heuristics.h
-pcmcia.o: version.h pcmcia.h hw.h osutils.h sysfs.h
-volumes.o: version.h volumes.h hw.h blockio.h lvm.h osutils.h
-mounts.o: version.h mounts.h hw.h osutils.h
-smp.o: version.h smp.h hw.h osutils.h
-abi.o: version.h abi.h hw.h osutils.h
-jedec.o: jedec.h
-s390.o: hw.h sysfs.h disk.h s390.h
-virtio.o: version.h hw.h sysfs.h disk.h virtio.h
-vio.o: version.h hw.h sysfs.h vio.h
diff --git a/src/core/config.h b/src/core/config.h.in
similarity index 50%
rename from src/core/config.h
rename to src/core/config.h.in
index 69023fd..ca25a5f 100644
--- a/src/core/config.h
+++ b/src/core/config.h.in
@@ -13,27 +13,15 @@
#define N_(String) gettext_noop (String)
#endif
-#ifndef PACKAGE
-#define PACKAGE "lshw"
-#endif
-
-#ifndef PREFIX
-#define PREFIX "/usr"
-#endif
-
-#ifndef SBINDIR
-#define SBINDIR PREFIX"/sbin"
-#endif
+#define PACKAGE "@PROJECT_NAME@"
+#define VERSION "@VERSION@"
-#ifndef DATADIR
-#define DATADIR PREFIX"/share/lshw"
-#endif
+#define SBINDIR "@SBINDIR@"
+#define DATADIR "@DATADIR@"
+#define MANDIR "@MANDIR@"
+#define LOCALEDIR "@LOCALEDIR@"
-#ifndef MANDIR
-#define MANDIR PREFIX"/share/man"
-#endif
+#cmakedefine SQLITE 1
+#cmakedefine ZLIB 1
-#ifndef LOCALEDIR
-#define LOCALEDIR PREFIX"/share/locale"
-#endif
#endif
diff --git a/src/core/db.cc b/src/core/db.cc
index d080295..f85c85b 100644
--- a/src/core/db.cc
+++ b/src/core/db.cc
@@ -1,6 +1,12 @@
+
#include <string.h>
#include <string>
#include <stdexcept>
+
+#include "config.h"
+
+#ifdef SQLITE
+
#include <sqlite3.h>
#include "db.h"
@@ -419,3 +425,5 @@ value statement::operator[](const string & i) const
{
return column(i);
}
+
+#endif /* SQLITE */
diff --git a/src/core/dump.cc b/src/core/dump.cc
index 6bc9674..f22f0fb 100644
--- a/src/core/dump.cc
+++ b/src/core/dump.cc
@@ -1,5 +1,5 @@
-#include "dump.h"
#include "version.h"
+#include "dump.h"
#include "osutils.h"
#include <time.h>
diff --git a/src/core/version.h b/src/core/version.h
index 91e039a..5cecdda 100644
--- a/src/core/version.h
+++ b/src/core/version.h
@@ -1,6 +1,8 @@
#ifndef _VERSION_H_
#define _VERSION_H_
+#include "config.h"
+
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define __ID(string) __asm__(".ident\t\"" string "\"")
#else
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
new file mode 100644
index 0000000..48bd3f5
--- /dev/null
+++ b/src/gui/CMakeLists.txt
@@ -0,0 +1,67 @@
+if(NOT GUI OR STATIC)
+ message("-- gtk-${PROJECT_NAME} disabled")
+ return()
+endif()
+
+find_package(PkgConfig)
+pkg_check_modules(GTK2 REQUIRED gtk+-2.0 gmodule-2.0)
+
+file(GLOB GTK_SOURCES "*.c*")
+
+include_directories("${PROJECT_BINARY_DIR}")
+include_directories("${PROJECT_SOURCE_DIR}/src/core")
+
+include_directories("${GTK2_INCLUDE_DIRS}")
+
+add_executable(gtk-lshw ${GTK_SOURCES})
+target_link_libraries(gtk-lshw ${SQLITE3_LIBRARIES} ${Z_LIBRARIES} ${GTK2_LIBRARIES} resolv core)
+install(TARGETS gtk-lshw DESTINATION sbin)
+
+if(POLICYKIT)
+ set(desktop_exec ${CMAKE_INSTALL_FULL_BINDIR}/lshw-gui)
+ configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/integration/org.ezix.lshw.gui.policy.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/org.ezix.lshw.gui.policy")
+ configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/integration/lshw-gui.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/lshw-gui")
+else()
+ set(desktop_exec ${CMAKE_INSTALL_FULL_SBINDIR}/gtk-lshw)
+endif()
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/integration/gtk-lshw.desktop.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/gtk-lshw.desktop")
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/artwork/logo.svg"
+ "${CMAKE_CURRENT_BINARY_DIR}/gtk-lshw.svg")
+
+file(GLOB LOGOS "artwork/*.svg")
+file(GLOB NOLOGOS "artwork/nologo/*.svg")
+
+if(NOLOGO)
+ install(FILES ${NOLOGOS} DESTINATION ${PROJECT_DATADIR}/artwork)
+ foreach(LOGO ${LOGOS})
+ get_filename_component(BASENAME ${LOGO} NAME)
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/artwork/nologo/${BASENAME}")
+ list(REMOVE_ITEM LOGOS ${LOGO})
+ endif()
+ endforeach()
+endif()
+
+install(FILES ${LOGOS} DESTINATION ${PROJECT_DATADIR}/artwork)
+install(FILES gtk-lshw.ui DESTINATION ${PROJECT_DATADIR}/ui)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gtk-lshw.desktop
+ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/applications)
+install(FILES integration/gtk-lshw.appdata.xml DESTINATION
+ ${CMAKE_INSTALL_FULL_DATADIR}/appdata)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gtk-lshw.svg DESTINATION
+ ${CMAKE_INSTALL_FULL_DATADIR}/pixmaps)
+
+
+if(POLICYKIT)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.ezix.lshw.gui.policy
+ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/polkit-1/actions)
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lshw-gui
+ DESTINATION bin)
+endif()
diff --git a/src/gui/Makefile b/src/gui/Makefile
deleted file mode 100644
index 2526c18..0000000
--- a/src/gui/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-PACKAGENAME?=lshw
-
-CXX?=c++
-CC?=cc
-STRIP?=strip
-OBJCOPY?=objcopy
-
-DEFINES=-DPREFIX=\"$(PREFIX)\" -DSBINDIR=\"$(SBINDIR)\" -DMANDIR=\"$(MANDIR)\" -DDATADIR=\"$(DATADIR)\"
-GTKINCLUDES=$(shell pkg-config gtk+-2.0 --cflags)
-INCLUDES=-I../core $(GTKINCLUDES)
-CXXFLAGS=-g -Wall $(INCLUDES) $(DEFINES) $(RPM_OPT_FLAGS)
-ifeq ($(SQLITE), 1)
- CXXFLAGS+= -DSQLITE $(shell pkg-config --cflags sqlite3)
-endif
-CFLAGS=$(CXXFLAGS) $(DEFINES)
-GTKLIBS=$(shell pkg-config gtk+-2.0 gmodule-2.0 --libs)
-LIBS+=-L../core -llshw -lresolv $(GTKLIBS)
-ifeq ($(SQLITE), 1)
- LIBS+= $(shell pkg-config --libs sqlite3)
-endif
-LDFLAGS=
-ifneq ($(shell $(LD) --help 2| grep -- --as-needed), )
- LDFLAGS+= -Wl,--as-needed
-endif
-
-OBJS = gtk-lshw.o callbacks.o engine.o print-gui.o stock.o
-SRCS = $(OBJS:.o=.c)
-
-all: gtk-$(PACKAGENAME)
-
-.cc.o:
- $(CXX) $(CXXFLAGS) -c $< -o $@
-
-.c.o:
- $(CC) $(CFLAGS) -c $< -o $@
-
-.PHONY: icon
-icon: gtk-$(PACKAGENAME) artwork/logo.svg
- $(OBJCOPY) --add-section .icon=artwork/logo.svg gtk-$(PACKAGENAME)
-
-interface.c: gtk-lshw.glade gtk-lshw.gladep
- glade-2 -w gtk-lshw.glade
-
-gtk-$(PACKAGENAME): $(OBJS) ../core/liblshw.a
- $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-install: all
- $(STRIP) gtk-$(PACKAGENAME)
-
-clean:
- rm -f $(OBJS) gtk-$(PACKAGENAME) gtk-lshw.glade.bak gtk-lshw.gladep.bak callbacks.c.bak callbacks.h.bak Makefile.bak
-
-depend:
- @makedepend -Y $(SRCS) 2> /dev/null > /dev/null
-
-
-# DO NOT DELETE
-
-gtk-lshw.o: stock.h engine.h
-callbacks.o: callbacks.h support.h engine.h
-stock.o: stock.h
diff --git a/src/gui/integration/gtk-lshw.desktop b/src/gui/integration/gtk-lshw.desktop.in
similarity index 51%
rename from src/gui/integration/gtk-lshw.desktop
rename to src/gui/integration/gtk-lshw.desktop.in
index 4df1c7c..7124c27 100644
--- a/src/gui/integration/gtk-lshw.desktop
+++ b/src/gui/integration/gtk-lshw.desktop.in
@@ -3,10 +3,9 @@ Name=LSHW
Comment=HardWare LiSter
Comment[fr]=Listeur de matériel
Comment[es]=Listar equipamiento
-Categories=Application;System;X-Red-Hat-Base;X-Fedora;
-Icon=/usr/share/lshw/artwork/logo.svg
-Exec=/usr/bin/gtk-lshw
+Categories=GTK;System;
+Icon=gtk-lshw
+Exec=@desktop_exec@
Type=Application
Terminal=false
Encoding=UTF-8
-X-Desktop-File-Install-Version=0.10
diff --git a/src/gui/integration/lshw-gui.in b/src/gui/integration/lshw-gui.in
new file mode 100644
index 0000000..ac0823b
--- /dev/null
+++ b/src/gui/integration/lshw-gui.in
@@ -0,0 +1,5 @@
+#! /bin/bash
+
+/usr/bin/pkexec @CMAKE_INSTALL_FULL_SBINDIR@/gtk-lshw
+
+
diff --git a/src/gui/integration/org.ezix.lshw.gui.policy.in b/src/gui/integration/org.ezix.lshw.gui.policy.in
new file mode 100644
index 0000000..cba4189
--- /dev/null
+++ b/src/gui/integration/org.ezix.lshw.gui.policy.in
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
+<policyconfig>
+ <vendor>lshw</vendor>
+ <vendor_url>http://ezix.org/project/wiki/HardwareLiSter</vendor_url>
+ <action id="org.ezix.lshw.gui.pkexec.run">
+ <description>Hardware Lister (lshw) - list hardware information</description>
+ <message>Authentication is required to run lshw-gui</message>
+ <icon_name>lshw-gui</icon_name>
+ <defaults>
+ <allow_any>no</allow_any>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ <annotate key="org.freedesktop.policykit.exec.path">@CMAKE_INSTALL_FULL_SBINDIR@/gtk-lshw</annotate>
+ <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
+ </action>
+</policyconfig>
diff --git a/src/gui/stock.c b/src/gui/stock.c
index 08675db..2f92332 100644
--- a/src/gui/stock.c
+++ b/src/gui/stock.c
@@ -1,3 +1,4 @@
+#include "config.h"
#include "stock.h"
#include <stdlib.h>
#include <string.h>
diff --git a/src/po/CMakeLists.txt b/src/po/CMakeLists.txt
new file mode 100644
index 0000000..de2f5c8
--- /dev/null
+++ b/src/po/CMakeLists.txt
@@ -0,0 +1,16 @@
+include(FindGettext)
+
+if (GETTEXT_FOUND)
+ file(GLOB POTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.po")
+ string(REPLACE ".po" " " LANGS ${POTFILES})
+ message(STATUS "gettext found: ${LANGS}")
+ string(REPLACE " " ";" LANGS ${LANGS})
+ foreach(LANG ${LANGS})
+ GETTEXT_PROCESS_PO_FILES(${LANG} ALL PO_FILES ${LANG}.po)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo"
+ DESTINATION "${CMAKE_INSTALL_FULL_LOCALEDIR}/${LANG}/LC_MESSAGES"
+ RENAME "${PROJECT_NAME}.mo")
+ endforeach()
+else()
+ message("-- gettext not found")
+endif()
diff --git a/src/po/Makefile b/src/po/Makefile
deleted file mode 100644
index 36fbdb7..0000000
--- a/src/po/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-PACKAGENAME?=lshw
-
-LANGUAGES = fr
-SRCS = $(LANGUAGES:=.po)
-CATALOGS = $(LANGUAGES:=.mo)
-
-all: $(PACKAGENAME).pot $(CATALOGS)
-
-POTFILES:
- find .. -name \*.cc > $@
- find .. -name \*.c >> $@
-
-$(PACKAGENAME).pot: POTFILES
- xgettext -F --no-wrap --indent --keyword=_ --keyword=N_ -d $(PACKAGENAME) -o $@ -f POTFILES
-
-%.mo: %.po
- msgfmt -v -o $@ $^
-
-install: $(CATALOGS)
- $(foreach i, $(LANGUAGES), install -D $(i).mo $(DESTDIR)/$(DATADIR)/locale/$(i)/LC_MESSAGES/$(PACKAGENAME).mo ;)
-
-clean:
- rm -f $(CATALOGS) $(PACKAGENAME).pot
--
2.13.6

View File

@ -1,5 +0,0 @@
#! /bin/bash
/usr/bin/pkexec /usr/sbin/lshw-gui

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2017 Daniel Rusek <mail@asciiwolf.com> -->
<component type="desktop">
<id>lshw-gui.desktop</id>
<project_license>GPL-2.0</project_license>
<metadata_license>CC0-1.0</metadata_license>
<name>LSHW</name>
<summary>Provides information on hardware</summary>
<description>
<p>
A small tool to provide detailed information on the hardware
configuration of the machine. It can report exact memory
configuration, firmware version, mainboard configuration, CPU
version and speed, cache configuration, bus speed, etc. on
DMI-capable x86 systems, on some PowerPC machines (PowerMac G4
is known to work) and AMD64.
</p>
</description>
<url type="homepage">http://www.ezix.org/project/wiki/HardwareLiSter</url>
<update_contact>mail@asciiwolf.com</update_contact>
</component>

View File

@ -1,10 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Name=Hardware Lister
Comment=Browse hardware on host computer
StartupNotify=true
Exec=/usr/bin/lshw-gui
Icon=lshw-gui
Terminal=false
Type=Application
Categories=GTK;System;

View File

@ -1,22 +1,20 @@
Summary: Hardware lister
Name: lshw
Version: B.02.18
Release: 15%{?dist}
Release: 16%{?dist}
License: GPLv2
Group: Applications/System
URL: http://ezix.org/project/wiki/HardwareLiSter
Source0: http://www.ezix.org/software/files/lshw-%{version}.tar.gz
Source1: lshw-gui.desktop
Source2: org.ezix.lshw.gui.policy
Source3: lshw-gui
Source4: lshw-gui.appdata.xml
Patch1: lshw-B.02.18-scandir.patch
Patch2: lshw-B.02.18-d05baa7.patch
Patch2: lshw-B.02.18-20cda77.patch
Patch3: lshw-B.02.18-revert-json.patch
Patch4: lshw-B.02.18-cmake.patch
BuildRequires: desktop-file-utils
BuildRequires: gettext
BuildRequires: gtk2-devel >= 2.4
BuildRequires: libappstream-glib
BuildRequires: ninja-build
BuildRequires: python3-devel
Requires: hwdata
%description
@ -43,58 +41,17 @@ format.
%patch01 -p1
%patch02 -p1
%patch03 -R -p1
%patch04 -p1
%build
make %{?_smp_mflags} SBINDIR="%{_sbindir}" RPM_OPT_FLAGS="%{optflags}" gui
# Replace copyrighted icons
pushd src
make nologo
mkdir build && pushd build
%cmake .. -DNOLOGO=ON -DHWDATA=OFF -DPOLICYKIT=ON -DBUILD_SHARED_LIBS=OFF -GNinja
%ninja_build
%install
make install \
DESTDIR="%{buildroot}" \
PREFIX="%{_prefix}" \
SBINDIR="%{_sbindir}" \
MANDIR="%{_mandir}" \
STRIP="/bin/true" \
INSTALL="install -p"
make install-gui \
DESTDIR="%{buildroot}" \
PREFIX="%{_prefix}" \
SBINDIR="%{_sbindir}" \
MANDIR="%{_mandir}" \
STRIP="/bin/true" \
INSTALL="install -p"
mv %{buildroot}%{_sbindir}/gtk-lshw %{buildroot}%{_sbindir}/lshw-gui
ln -s -f lshw-gui %{buildroot}%{_sbindir}/gtk-lshw
# don't package these copies, use the ones from hwdata instead
rm -f %{buildroot}%{_datadir}/%{name}/pci.ids
rm -f %{buildroot}%{_datadir}/%{name}/usb.ids
# don't package these copies, they're not actually used by the app,
# and even if they were, should use the hwdata versions
rm -f %{buildroot}%{_datadir}/%{name}/oui.txt
rm -f %{buildroot}%{_datadir}/%{name}/manuf.txt
# desktop icon
install -D -m 0644 -p ./src/gui/artwork/logo.svg \
%{buildroot}%{_datadir}/pixmaps/%{name}-gui.svg
install -D -m 0644 -p ./src/gui/artwork/logo.svg \
%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{name}-gui.svg
desktop-file-install %{?vendortag:--vendor fedora} \
--dir %{buildroot}%{_datadir}/applications %{SOURCE1}
# PolicyKit
install -D -m 0644 %{SOURCE2} \
%{buildroot}%{_datadir}/polkit-1/actions/org.ezix.lshw.gui.policy
install -D -m 0755 %{SOURCE3} %{buildroot}%{_bindir}/lshw-gui
# AppData
install -D -m 0644 %{SOURCE4} \
%{buildroot}%{_datadir}/appdata/lshw-gui.appdata.xml
pushd build
%ninja_install
ln -s gtk-lshw %{buildroot}%{_sbindir}/lshw-gui
# translations seems borken, remove for now
#find_lang %{name}
@ -104,6 +61,7 @@ rm -rf %{buildroot}%{_datadir}/locale/fr/
appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/appdata/*.appdata.xml
# check json output is valid
pushd build
src/lshw -json \
-disable usb -disable pcmcia -disable isapnp \
-disable ide -disable scsi -disable dmi -disable memory \
@ -114,21 +72,27 @@ src/lshw -json \
%license COPYING
%doc README.md
%{_mandir}/man1/lshw.1*
%{_sbindir}/%{name}
%{_sbindir}/lshw
%files gui
%license COPYING
%{_bindir}/%{name}-gui
%{_sbindir}/gtk-%{name}
%{_sbindir}/%{name}-gui
%{_datadir}/%{name}
%{_datadir}/pixmaps/%{name}-gui.svg
%{_datadir}/icons/hicolor/scalable/apps/%{name}-gui.svg
%{_datadir}/applications/%{name}-gui.desktop
%{_datadir}/appdata/%{name}-gui.appdata.xml
%{_bindir}/lshw-gui
%{_sbindir}/gtk-lshw
%{_sbindir}/lshw-gui
%dir %{_datadir}/lshw
%{_datadir}/lshw/artwork
%dir %{_datadir}/lshw/ui
%{_datadir}/lshw/ui/gtk-lshw.ui
%{_datadir}/pixmaps/gtk-lshw.svg
%{_datadir}/applications/gtk-lshw.desktop
%{_datadir}/appdata/gtk-lshw.appdata.xml
%{_datadir}/polkit-1/actions/org.ezix.lshw.gui.policy
%changelog
* Mon Apr 02 2018 Terje Rosten <terje.rosten@ntnu.no> - B.02.18-16
- Update to commit 20cda77
- Convert to cmake build system
* Thu Feb 08 2018 Terje Rosten <terje.rosten@ntnu.no> - B.02.18-15
- Fix JSON issue (rhbz#1543320)

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>lshw</vendor>
<vendor_url>http://ezix.org/project/wiki/HardwareLiSter</vendor_url>
<action id="org.ezix.lshw.gui.pkexec.run">
<description>Hardware Lister (lshw) - list hardware information</description>
<message>Authentication is required to run lshw-gui</message>
<icon_name>lshw-gui</icon_name>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/lshw-gui</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>