Blame SOURCES/lshw-B.02.19.2-cmake.patch

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