From 0bc057b6fffc28399f09d85e413dd03d5887aabe Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Wed, 8 Mar 2017 14:18:24 +0900 Subject: [PATCH] Use CMake instead of Automake CMake is preferred build tool in Tizen. (CMake is faster than automake in this package) + Use dash instead of underscore in binary name. It looks more general. Change-Id: I451a93c68a4837841e9d20f77a8c9c9775c044a4 Signed-off-by: Sunmin Lee --- CMakeLists.txt | 6 ++++ Makefile.am | 24 -------------- autogen.sh | 21 ------------- configure.ac | 31 ------------------- packaging/session-utils.manifest | 2 +- packaging/session-utils.spec | 19 +++++------- src/systemd-user-helper/CMakeLists.txt | 22 +++++++++++++ src/systemd-user-helper/systemd-user-helper.c | 1 + 8 files changed, 37 insertions(+), 89 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile.am delete mode 100755 autogen.sh delete mode 100644 configure.ac create mode 100644 src/systemd-user-helper/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2f27d51 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(session-utils C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +ADD_SUBDIRECTORY(src/systemd-user-helper) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 5c4ec1b..0000000 --- a/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -SUBDIRS = . - -AM_CPPFLAGS = \ - -include $(top_builddir)/config.h \ - -I $(top_srcdir)/src \ - -I $(top_srcdir)/src/shared \ - $(DEFAULT_CFLAGS) - -AM_CFLAGS = $(OUR_CFLAGS) -AM_LDFLAGS = $(OUR_LDFLAGS) - -bin_PROGRAMS = \ - systemd_user_helper - -systemd_user_helper_SOURCES = \ - src/systemd-user-helper/systemd-user-helper.c - -systemd_user_helper_CFLAGS = \ - $(AM_CFLAGS) \ - ${TZPLATFORMCONF_CFLAGS} - -systemd_user_helper_LDADD = \ - ${TZPLATFORMCONF_LIBS} \ - -ldl diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 968bc8e..0000000 --- a/autogen.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -if [ -f .git/hooks/pre-commit.sample ] && [ ! -f .git/hooks/pre-commit ]; then - # This part is allowed to fail - cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \ - chmod +x .git/hooks/pre-commit && \ - echo "Activated pre-commit hook." || : -fi - -# README and INSTALL are required by automake, but may be deleted by -# clean up rules. to get automake to work, simply touch these here, -# they will be regenerated from their corresponding *.in files by -# ./configure anyway. -touch README INSTALL - -# Make sure m4 directory exist -mkdir -p m4 - -autoreconf --force --install --verbose || exit $? diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 23613fc..0000000 --- a/configure.ac +++ /dev/null @@ -1,31 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.68]) -AC_INIT(session-utils, 0.1, [BUG-REPORT-ADDRESS]) -AC_CONFIG_HEADERS([config.h]) - -AC_USE_SYSTEM_EXTENSIONS -AC_SYS_LARGEFILE -AC_PREFIX_DEFAULT([/usr]) -AM_INIT_AUTOMAKE([foreign]) - -# Checks for programs. -AC_PROG_MKDIR_P -AC_PROG_LN_S -AC_PROG_SED -AC_PROG_GREP -AC_PROG_AWK -#AC_PROG_INSTALL - -AC_PROG_CC -AM_PROG_CC_C_O - -AC_SUBST([OUR_CFLAGS], "$our_cflags") -dnl AC_SUBST([OUR_CPPFLAGS], "$OUR_CFLAGS -Wp,-D_FORTIFY_SOURCE=2") -AC_SUBST([OUR_LDFLAGS], "$our_ldflags") - -PKG_CHECK_MODULES(TZPLATFORMCONF, libtzplatform-config) - -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/packaging/session-utils.manifest b/packaging/session-utils.manifest index 90334b8..d20fa76 100644 --- a/packaging/session-utils.manifest +++ b/packaging/session-utils.manifest @@ -3,6 +3,6 @@ - + diff --git a/packaging/session-utils.spec b/packaging/session-utils.spec index 342acec..b92b335 100644 --- a/packaging/session-utils.spec +++ b/packaging/session-utils.spec @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.bz2 Source1: %{name}.manifest BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: cmake %description This package provides some utils for session control in multi-user environment. @@ -18,15 +19,9 @@ This package provides some utils for session control in multi-user environment. %build cp %{SOURCE1} . -./autogen.sh -%reconfigure \ - --disable-static \ - --prefix=%{_prefix} \ - --disable-debug-mode \ - --disable-eng-mode - -%__make %{?jobs:-j%jobs} \ - CFLAGS+=-DLIBDIR=\\\"%{_libdir}\\\" +%cmake . \ + -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DLIBDIR=%{_libdir} %install rm -rf %{buildroot} @@ -35,14 +30,14 @@ rm -rf %{buildroot} %files %license LICENSE.Apache-2.0 %manifest session-utils.manifest -%caps(cap_sys_admin,cap_mac_admin,cap_mac_override,cap_dac_override,cap_setgid=ei) %{_bindir}/systemd_user_helper +%caps(cap_sys_admin,cap_mac_admin,cap_mac_override,cap_dac_override,cap_setgid=ei) %{_bindir}/systemd-user-helper #TODO: when uninstalling, it should be restored to original file %posttrans cp -a /usr/lib/systemd/system/user\@.service /usr/lib/systemd/system/__user@.service /usr/bin/sed -i -e 's/Type=\(.*\)/Type=forking/' /usr/lib/systemd/system/user\@.service -/usr/bin/sed -i -e 's/ExecStart=\(.*\)/ExecStart=\/usr\/bin\/systemd_user_helper start %i/' /usr/lib/systemd/system/user\@.service -/usr/bin/sed -i -e '/ExecStart=\(.*\)/ a ExecStop=\/usr\/bin\/systemd_user_helper stop %i' /usr/lib/systemd/system/user\@.service +/usr/bin/sed -i -e 's/ExecStart=\(.*\)/ExecStart=\/usr\/bin\/systemd-user-helper start %i/' /usr/lib/systemd/system/user\@.service +/usr/bin/sed -i -e '/ExecStart=\(.*\)/ a ExecStop=\/usr\/bin\/systemd-user-helper stop %i' /usr/lib/systemd/system/user\@.service /usr/bin/sed -i -e '/PIDFile=\(.*\)/d' /usr/lib/systemd/system/user\@.service /usr/bin/sed -i -e '/XDG_RUNTIME_DIR/ a Environment=XDG_RUNTIME_EXT_DIR=/run/user_ext/%i' /usr/lib/systemd/system/user\@.service echo 'PIDFile=/run/user/%i/.systemd.pid' >> /usr/lib/systemd/system/user\@.service diff --git a/src/systemd-user-helper/CMakeLists.txt b/src/systemd-user-helper/CMakeLists.txt new file mode 100644 index 0000000..dc7f5ea --- /dev/null +++ b/src/systemd-user-helper/CMakeLists.txt @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(systemd-user-helper C) + +ADD_DEFINITIONS(-DLIBDIR=\"${LIBDIR}\") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${PROJECT_NAME}_pkgs REQUIRED + libtzplatform-config +) + +FOREACH(flag ${${PROJECT_NAME}_pkgs}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +ADD_EXECUTABLE(${PROJECT_NAME} systemd-user-helper.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} -ldl) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/systemd-user-helper/systemd-user-helper.c b/src/systemd-user-helper/systemd-user-helper.c index b65a7d9..f2b9620 100644 --- a/src/systemd-user-helper/systemd-user-helper.c +++ b/src/systemd-user-helper/systemd-user-helper.c @@ -23,6 +23,7 @@ * compatibility and container. */ +#define _GNU_SOURCE #include #include #include -- 2.34.1