From 04f61bd50b4751c7a8ca8d6390110003099b2398 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Fri, 30 Mar 2018 14:09:58 +0900 Subject: [PATCH] make: change to cmake Change-Id: I57979761fed3eeef223a236308c8d8e529fb5b37 Signed-off-by: sanghyeok.oh --- CMakeLists.txt | 5 ++ Makefile.am | 2 - autogen.sh | 45 ----------------- configure.ac | 120 -------------------------------------------- packaging/libsyscommon.spec | 25 ++------- src/libgdbus/CMakeLists.txt | 55 ++++++++++++++++++++ src/libgdbus/libgdbus.pc.in | 16 +++--- 7 files changed, 72 insertions(+), 196 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/libgdbus/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..10850df --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(libsyscommon C) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) +ADD_SUBDIRECTORY(src/libgdbus) \ No newline at end of file diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index dfa49b2..0000000 --- a/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -AUTOMAKE_OPTIONS = foreign -SUBDIRS = src diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 3825cb5..0000000 --- a/autogen.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -set -e - -opt="$1" - -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 dir exist -mkdir -p m4 - -autoreconf --force --install --verbose || exit $? - -if [ "x$opt" = "xc" ]; then - set -x - ./configure $args - make clean > /dev/null -elif [ "x$opt" = "xd" ]; then - set -x - ./configure CFLAGS='-g -O0 -ftrapv' $args - make clean > /dev/null -elif [ "x$opt" = "xg" ]; then - set -x - ./configure CFLAGS='-g -Og -ftrapv' $args - make clean > /dev/null -elif [ "x$opt" = "xl" ]; then - set -x - ./configure CC=clang CFLAGS='-g -O0 -ftrapv' $args - make clean > /dev/null -elif [ "x$opt" = "xs" ]; then - set -x - scan-build ./configure CFLAGS='-std=gnu99 -g -O0 -ftrapv' $args - scan-build make -fi diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 0d033da..0000000 --- a/configure.ac +++ /dev/null @@ -1,120 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.68]) -AC_INIT([libsystem], [4.1], [walyong.cho@samsung.com]) - -dnl AC_CONFIG_MACRO_DIRS([m4]) -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_HEADERS([config.h]) - -AC_USE_SYSTEM_EXTENSIONS -AC_SYS_LARGEFILE -AC_PREFIX_DEFAULT([/usr]) -AM_INIT_AUTOMAKE([foreign subdir-objects]) - -LT_PREREQ(2.2) -LT_INIT([disable-static]) - -# Checks for programs. -AC_PROG_CXX -AC_PROG_AWK -AC_PROG_CC -AC_PROG_CPP -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -AC_PROG_RANLIB - -# Checks for libraries. -# FIXME: Replace `main' with a function in `-lrt': -AC_CHECK_LIB([rt], [main]) - -# Checks for header files. -AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h mntent.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_CHECK_HEADER_STDBOOL -AC_C_INLINE -AC_TYPE_INT32_T -AC_TYPE_INT64_T -AC_TYPE_MODE_T -AC_TYPE_PID_T -AC_TYPE_SIZE_T -AC_TYPE_SSIZE_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T - -# Checks for library functions. -AC_FUNC_FORK -AC_FUNC_GETMNTENT -AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK -AC_FUNC_MKTIME -AC_FUNC_REALLOC -AC_CHECK_FUNCS([dup2 getmntent gettimeofday localtime_r memset mkdir rmdir strchr strcspn strdup strndup strrchr strspn]) - -AC_CHECK_TOOL(GPERF, gperf) -if test -z "$GPERF" ; then - AC_MSG_ERROR([*** gperf not found]) -fi - -# ------------------------------------------------------------------------------ -our_cflags=" \ - -g -O2 \ - -Werror \ - -fpie" - -our_ldflags=" \ - -Wl,--as-needed \ - -Wl,--no-undefined \ - -Wl,--gc-sections \ - -Wl,-z,relro \ - -Wl,-z,now \ - -pie" - -our_cflags=$(echo $our_cflags |sed 's/\t/ /g' | sed 's/ / /g') -our_ldflags=$(echo $our_ldflags | sed 's/\t/ /g' | sed 's/ / /g') - -AC_SUBST([OUR_CFLAGS], "$our_cflags") -AC_SUBST([OUR_LDFLAGS], "$our_ldflags") - -# ------------------------------------------------------------------------------ -PKG_CHECK_MODULES(GLIB, [glib-2.0]) -PKG_CHECK_MODULES(GIO, [gio-2.0]) -PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0]) - -# ------------------------------------------------------------------------------ -AC_SUBST([LIBGDBUS_PC_REQUIRES], "libgdbus") -AC_SUBST([LIBGDBUS_PC_CFLAGS], "") -AC_SUBST([LIBGDBUS_PC_LIBS], "-L${libdir} -lgdbus") - -AC_SUBST([LIBGDBUS_PC_REQUIRES], "${LIBGDBUS_PC_REQUIRES} ${DBUS_REQUIRES}") -AC_SUBST([LIBGDBUS_PC_CFLAGS], "${LIBGDBUS_PC_CFLAGS} ${DBUS_CFLAGS}") -AC_SUBST([LIBGDBUS_PC_LIBS], "${LIBGDBUS_PC_LIBS} ${DBUS_LIBS}") - -AC_SUBST([LIBGDBUS_PC_REQUIRES], "${LIBGDBUS_PC_REQUIRES} ${GIO_REQUIRES}") -AC_SUBST([LIBGDBUS_PC_CFLAGS], "${LIBGDBUS_PC_CFLAGS} ${GIO_CFLAGS}") -AC_SUBST([LIBGDBUS_PC_LIBS], "${LIBGDBUS_PC_LIBS} ${GIO_LIBS}") - -AC_SUBST([LIBGDBUS_PC_REQUIRES], "${LIBGDBUS_PC_REQUIRES} ${GIO_UNIX_REQUIRES}") -AC_SUBST([LIBGDBUS_PC_CFLAGS], "${LIBGDBUS_PC_CFLAGS} ${GIO_UNIX_CFLAGS}") -AC_SUBST([LIBGDBUS_PC_LIBS], "${LIBGDBUS_PC_LIBS} ${GIO_UNIX_LIBS}") - -# ------------------------------------------------------------------------------ -AC_CONFIG_FILES([Makefile - src/Makefile]) -AC_OUTPUT -AC_MSG_RESULT([ - $PACKAGE_NAME $VERSION - - prefix: ${prefix} - rootprefix: ${with_rootprefix} - datarootdir: ${datarootdir} - lib dir: ${libdir} - rootlib dir: ${with_rootlibdir} - - OUR CFLAGS: ${OUR_CFLAGS} - CFLAGS: ${CFLAGS} - OUR LDFLAGS: ${OUR_LDFLAGS} - LDFLAGS: ${LDFLAGS} -]) diff --git a/packaging/libsyscommon.spec b/packaging/libsyscommon.spec index 45c24c5..3dc79ff 100644 --- a/packaging/libsyscommon.spec +++ b/packaging/libsyscommon.spec @@ -9,13 +9,10 @@ Source: %{name}-%{version}.tar.gz Source1001: %{name}.manifest %endif -BuildRequires: autoconf -BuildRequires: automake -BuildRequires: libtool BuildRequires: pkgconfig(glib-2.0) >= 2.44 BuildRequires: pkgconfig(gio-2.0) >= 2.44 BuildRequires: pkgconfig(gio-unix-2.0) -BuildRequires: gperf +BuildRequires: cmake Requires: /bin/cp @@ -26,14 +23,14 @@ Requires(postun): /sbin/ldconfig System utility libraries. %package -n libgdbus -Summary: Dbus library +Summary: Dbus library License: Apache-2.0 %description -n libgdbus Internal dbus library %package -n libgdbus-devel -Summary: Header files for dbus library +Summary: Header files for dbus library License: Apache-2.0 Requires: libgdbus = %{version} Requires: pkgconfig(gio-2.0) @@ -49,30 +46,16 @@ cp %{SOURCE1001} . %endif %build -%if 0%{?debug_enable} -export CFLAGS=$(echo $CFLAGS | sed -e 's/^-g / /g' | sed -e 's/ -g / /g') -export CFLAGS=$(echo $CFLAGS | sed -e 's/^-O[0-9] / /g' | sed -e 's/ $-O[0-9] / /g') -export CFLAGS=$(echo $CFLAGS | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2 / /g') -export CFLAGS="-O0 -g $CFLAGS" -%endif - -./autogen.sh -%configure - +%cmake . make %{?_smp_mflags} %install %make_install -rm -f %{buildroot}%{_libdir}/*.la - # make sure debugsources.list exist, it used by rpm macro in %file # section. touch debugsources.list -%check -make check - %post /sbin/ldconfig diff --git a/src/libgdbus/CMakeLists.txt b/src/libgdbus/CMakeLists.txt new file mode 100644 index 0000000..327ea2b --- /dev/null +++ b/src/libgdbus/CMakeLists.txt @@ -0,0 +1,55 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(libgdbus C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "${PREFIX}/include") +SET(VERSION 4.1) + +SET(libgdbus_SRCS + dbus-system.c +) +SET(HEADERS + dbus-system.h +) + +# CHECK PKG +INCLUDE(FindPkgConfig) +pkg_check_modules(gdbus REQUIRED + glib-2.0 + gio-2.0 + gio-unix-2.0) + +FOREACH(flag ${gdbus_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +# LIBRARY +ADD_LIBRARY(${PROJECT_NAME} SHARED ${libgdbus_SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gdbus_LDFLAGS} "-ldl" pthread) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fPIC") +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME gdbus) + +# INSTALL +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) + +# CONGIFURE FILE +FOREACH(flag ${gdbus_INCLUDE_DIRS}) + SET(GDBUS_INCLUDEDIR "${GDBUS_INCLUDEDIR} -I${flag}") +ENDFOREACH(flag) + +FOREACH(flag ${gdbus_LIBRARIES}) + SET(GDBUS_LIBS "${GDBUS_LIBS} -l${flag}") +ENDFOREACH(flag) + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + +# HEADER +FOREACH(hfile ${HEADERS}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME}) +ENDFOREACH(hfile) diff --git a/src/libgdbus/libgdbus.pc.in b/src/libgdbus/libgdbus.pc.in index 58569e6..5616aac 100644 --- a/src/libgdbus/libgdbus.pc.in +++ b/src/libgdbus/libgdbus.pc.in @@ -4,14 +4,14 @@ # All rights reserved. # -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ Name: libgdbus Description: Dbus library -Version: @PACKAGE_VERSION@ -Requires.private: @LIBGDBUS_PC_REQUIRES@ -Cflags: @LIBGDBUS_PC_CFLAGS@ -Libs: @LIBGDBUS_PC_LIBS@ +Version: @VERSION@ +Requires.private: libgdbus +Cflags: -I${includedir} @GDBUS_INCLUDEDIR@ +Libs: -L${libdir} -lgdbus @GDBUS_LIBS@ -- 2.7.4