From 4836850bf9f4a1b98f88155a26689bbf09f4649b Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Mon, 3 Apr 2017 12:12:50 +0800 Subject: [PATCH 1/7] modify for merging to upstream fix issues TingPing suggests replace add_global_arguments() with add_project_arguments() demo/miracle-wfdctl: maintain DBus interfaces by .vala files instead of generate from .xml which have only sync methods remove headers from source list some minor identation tweaks complete migrate from cmake to meson mirage to meson, not yet completed --- CMakeLists.txt | 33 -------------- cmake/FindReadline.cmake | 29 ------------ config.h.cmake | 8 ---- meson.build | 38 ++++++++++++++++ meson_options.txt | 16 +++++++ res/CMakeLists.txt | 12 ----- res/meson-install-scripts.sh | 8 ++++ res/meson.build | 6 +++ src/CMakeLists.txt | 38 ---------------- src/ctl/CMakeLists.txt | 86 ------------------------------------ src/ctl/meson.build | 24 ++++++++++ src/dhcp/CMakeLists.txt | 62 -------------------------- src/dhcp/meson.build | 11 +++++ src/meson.build | 11 +++++ src/shared/CMakeLists.txt | 53 ---------------------- src/shared/meson.build | 22 +++++++++ src/uibc/CMakeLists.txt | 10 ----- src/uibc/meson.build | 5 +++ src/wifi/CMakeLists.txt | 59 ------------------------- src/wifi/meson.build | 14 ++++++ test/meson.build | 33 ++++++++++++++ 21 files changed, 188 insertions(+), 390 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 cmake/FindReadline.cmake delete mode 100644 config.h.cmake create mode 100644 meson.build create mode 100644 meson_options.txt delete mode 100644 res/CMakeLists.txt create mode 100755 res/meson-install-scripts.sh create mode 100644 res/meson.build delete mode 100644 src/CMakeLists.txt delete mode 100644 src/ctl/CMakeLists.txt create mode 100644 src/ctl/meson.build delete mode 100644 src/dhcp/CMakeLists.txt create mode 100644 src/dhcp/meson.build create mode 100644 src/meson.build delete mode 100644 src/shared/CMakeLists.txt create mode 100644 src/shared/meson.build delete mode 100644 src/uibc/CMakeLists.txt create mode 100644 src/uibc/meson.build delete mode 100644 src/wifi/CMakeLists.txt create mode 100644 src/wifi/meson.build create mode 100644 test/meson.build diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 6aea926..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(Miraclecast) - -SET(PACKAGE_NAME miraclecast) -SET(PACKAGE_VERSION 1) -SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") - -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake - ${CMAKE_MODULE_PATH}) - -set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}") -add_definitions(-D_GNU_SOURCE) - -SET(BUILD_BINDIR "${CMAKE_INSTALL_PREFIX}/bin") -OPTION(BUILD_ENABLE_DEBUG "Enable Debug" ON ) -OPTION(RELY_UDEV "Rely in udev tag to select device" OFF ) -OPTION(BUILD_TESTS "Enable TEST" ON ) - -if(BUILD_ENABLE_DEBUG) - add_definitions(-DBUILD_ENABLE_DEBUG) -endif() - -find_package(PkgConfig) -pkg_check_modules (GLIB2 REQUIRED glib-2.0) -pkg_check_modules (UDEV REQUIRED libudev) -pkg_check_modules (SYSTEMD REQUIRED libsystemd) - -CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h) - -add_subdirectory(src) -add_subdirectory(res) -add_subdirectory(test) - diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake deleted file mode 100644 index 1d4cc55..0000000 --- a/cmake/FindReadline.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# from http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/FindReadline.cmake -# http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/COPYING-CMAKE-SCRIPTS -# --> BSD licensed -# -# GNU Readline library finder -if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY) - set(READLINE_FOUND TRUE) -else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY) - FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h - /usr/include/readline - ) - -# 2008-04-22 The next clause used to read like this: -# -# FIND_LIBRARY(READLINE_LIBRARY NAMES readline) -# FIND_LIBRARY(NCURSES_LIBRARY NAMES ncurses ) -# include(FindPackageHandleStandardArgs) -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG NCURSES_LIBRARY READLINE_INCLUDE_DIR READLINE_LIBRARY ) -# -# I was advised to modify it such that it will find an ncurses library if -# required, but not if one was explicitly given, that is, it allows the -# default to be overridden. PH - - FIND_LIBRARY(READLINE_LIBRARY NAMES readline) - include(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY ) - - MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY) -endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY) diff --git a/config.h.cmake b/config.h.cmake deleted file mode 100644 index ddc0cd1..0000000 --- a/config.h.cmake +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#cmakedefine BUILD_BINDIR "@BUILD_BINDIR@" - -#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" - -#endif // CONFIG_H diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..c21167e --- /dev/null +++ b/meson.build @@ -0,0 +1,38 @@ +project('Miraclecast', + 'c', + version: '1', + meson_version: '>=0.39', + default_options: ['buildtype=debugoptimized', 'c_std=gnu11'] +) + +add_project_arguments('-D_GNU_SOURCE', language: 'c') + +conf_data = configuration_data() +conf_data.set('BUILD_BINDIR', + '"' + join_paths(get_option('prefix'), get_option('bindir')) + '"' +) +conf_data.set('PACKAGE_STRING', + '"@0@ @1@"'.format(meson.project_name(), meson.project_version()) +) +configure_file(output: 'config.h', + configuration: conf_data +) + +c_compiler = meson.get_compiler('c') +readline = c_compiler.find_library('readline', required: false) +if readline.found() + add_project_arguments('-DHAVE_READLINE', language: 'c') +endif + +if get_option('build-enable-debug') + add_project_arguments('-DBUILD_ENABLE_DEBUG', language: 'c') +endif + +glib2 = dependency('glib-2.0') +udev = dependency('libudev') +libsystemd = dependency('libsystemd') + +subdir('src') +subdir('res') +subdir('test') + diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..0f4eaee --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,16 @@ +option('build-enable-debug', + type: 'boolean', + value: true, + description: 'Enable Debug') +option('rely-udev', + type: 'boolean', + value: false, + description: 'Rely in udev tag to select device') +option('build-tests', + type: 'boolean', + value: true, + description: 'Enable TEST') +option('build-demo', + type: 'boolean', + value: false, + description: 'Enable DEMO') diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt deleted file mode 100644 index 4cb3f19..0000000 --- a/res/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ - -########### install files ############### - -install( - PROGRAMS miracle-gst gstplayer uibc-viewer - DESTINATION bin - ) - -INSTALL( - FILES org.freedesktop.miracle.conf - DESTINATION /etc/dbus-1/system.d - ) diff --git a/res/meson-install-scripts.sh b/res/meson-install-scripts.sh new file mode 100755 index 0000000..d18a1f2 --- /dev/null +++ b/res/meson-install-scripts.sh @@ -0,0 +1,8 @@ +#!/bin/sh +RESDIR="${MESON_SOURCE_ROOT}/res" +BINDIR="${MESON_INSTALL_DESTDIR_PREFIX}/$1" + +install -dv "$BINDIR" +install -v "$RESDIR"/miracle-gst "$BINDIR" +install -v "$RESDIR"/gstplayer "$BINDIR" +install -v "$RESDIR"/uibc-viewer "$BINDIR" diff --git a/res/meson.build b/res/meson.build new file mode 100644 index 0000000..d63d753 --- /dev/null +++ b/res/meson.build @@ -0,0 +1,6 @@ +meson.add_install_script('meson-install-scripts.sh', get_option('bindir')) + +install_data( + 'org.freedesktop.miracle.conf', + install_dir: join_paths('/', get_option('sysconfdir'), 'dbus-1', 'system.d') +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 96fe570..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}") - -add_subdirectory(shared) -add_subdirectory(wifi) -add_subdirectory(dhcp) -add_subdirectory(ctl) -add_subdirectory(uibc) - -set(miracled_SRCS miracled.h miracled.c) -add_executable(miracled ${miracled_SRCS}) -target_link_libraries(miracled miracle-shared) -install(TARGETS miracled DESTINATION bin) - -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) - - -########### install files ############### - - - - -#original Makefile.am contents follow: - -#include $(top_srcdir)/common.am -#SUBDIRS = shared wifi dhcp ctl -# -#bin_PROGRAMS = miracled -# -#miracled_SOURCES = \ -# miracled.h \ -# miracled.c -#miracled_CPPFLAGS = \ -# $(AM_CPPFLAGS) \ -# $(DEPS_CFLAGS) -#miracled_LDADD = \ -# shared/libmiracle-shared.la \ -# $(DEPS_LIBS) -# diff --git a/src/ctl/CMakeLists.txt b/src/ctl/CMakeLists.txt deleted file mode 100644 index d6d98e4..0000000 --- a/src/ctl/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ - -find_package(Readline) -########### next target ############### - -set(miracle-wifictl_SRCS ctl.h - ctl-cli.c - ctl-wifi.c - wifictl.c) - -add_executable(miracle-wifictl ${miracle-wifictl_SRCS}) - -install(TARGETS miracle-wifictl DESTINATION bin) - -if(READLINE_FOUND) - message(STATUS "Compiling with Readline support") - set_property(TARGET miracle-wifictl - APPEND - PROPERTY COMPILE_DEFINITIONS HAVE_READLINE) - target_link_libraries(miracle-wifictl ${READLINE_LIBRARY}) -endif(READLINE_FOUND) - -target_link_libraries(miracle-wifictl miracle-shared) -########### next target ############### - -set(miracle-sinkctl_SRCS ctl.h - ctl-cli.c - ctl-sink.h - ctl-sink.c - ctl-wifi.c - sinkctl.c - wfd.c) - -add_executable(miracle-sinkctl ${miracle-sinkctl_SRCS}) - -install(TARGETS miracle-sinkctl DESTINATION bin) - -if(READLINE_FOUND) - message(STATUS "Compiling with Readline support") - set_property(TARGET miracle-sinkctl - APPEND - PROPERTY COMPILE_DEFINITIONS HAVE_READLINE) - target_link_libraries(miracle-sinkctl ${READLINE_LIBRARY}) -endif(READLINE_FOUND) - -target_link_libraries(miracle-sinkctl miracle-shared) - -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) - -########### install files ############### - - - - -#original Makefile.am contents follow: - -#include $(top_srcdir)/common.am -#bin_PROGRAMS = miracle-wifictl miracle-sinkctl -# -#miracle_wifictl_SOURCES = \ -# ctl.h \ -# ctl-cli.c \ -# ctl-wifi.c \ -# wifictl.c -#miracle_wifictl_CPPFLAGS = \ -# $(AM_CPPFLAGS) \ -# $(DEPS_CFLAGS) -#miracle_wifictl_LDADD = \ -# ../shared/libmiracle-shared.la \ -# -lreadline \ -# $(DEPS_LIBS) -# -#miracle_sinkctl_SOURCES = \ -# ctl.h \ -# ctl-cli.c \ -# ctl-sink.c \ -# ctl-wifi.c \ -# sinkctl.c -#miracle_sinkctl_CPPFLAGS = \ -# $(AM_CPPFLAGS) \ -# $(DEPS_CFLAGS) -#miracle_sinkctl_LDADD = \ -# ../shared/libmiracle-shared.la \ -# -lreadline \ -# $(DEPS_LIBS) -# -# diff --git a/src/ctl/meson.build b/src/ctl/meson.build new file mode 100644 index 0000000..f3e6800 --- /dev/null +++ b/src/ctl/meson.build @@ -0,0 +1,24 @@ +inc = include_directories('../..') +deps = [libsystemd, libmiracle_shared_dep] +if readline.found() + deps += readline +endif + +miracle_wifictl_srcs = ['ctl-cli.c', 'ctl-wifi.c', 'wifictl.c'] +executable('miracle-wifictl', miracle_wifictl_srcs, + install: true, + include_directories: inc, + dependencies: deps +) + +miracle_sinkctl_srcs = ['ctl-cli.c', + 'ctl-sink.c', + 'ctl-wifi.c', + 'sinkctl.c', + 'wfd.c' +] +executable('miracle-sinkctl', miracle_sinkctl_srcs, + install: true, + include_directories: inc, + dependencies: deps +) diff --git a/src/dhcp/CMakeLists.txt b/src/dhcp/CMakeLists.txt deleted file mode 100644 index 7935d68..0000000 --- a/src/dhcp/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ - -########### next target ############### - -set(miracle-dhcp_SRCS dhcp.c - gdhcp.h - unaligned.h - common.h - common.c - ipv4ll.h - ipv4ll.c - client.c - server.c) - -add_executable(miracle-dhcp ${miracle-dhcp_SRCS}) - -find_package(PkgConfig) -pkg_check_modules (GLIB2 REQUIRED glib-2.0) -pkg_check_modules (UDEV REQUIRED libudev) -link_directories( ${UDEV_LIBRARY_DIRS}) -include_directories( ${UDEV_INCLUDE_DIRS}) -target_link_libraries(miracle-dhcp ${UDEV_LIBRARIES}) -link_directories( ${GLIB2_LIBRARY_DIRS}) -include_directories( ${GLIB2_INCLUDE_DIRS}) -target_link_libraries(miracle-dhcp ${GLIB2_LIBRARIES}) - -target_link_libraries(miracle-dhcp miracle-shared) - -install(TARGETS miracle-dhcp DESTINATION bin) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) - - -########### install files ############### - - - - -#original Makefile.am contents follow: - -#include $(top_srcdir)/common.am -#bin_PROGRAMS = miracle-dhcp -# -#miracle_dhcp_SOURCES = \ -# dhcp.c \ -# gdhcp.h \ -# unaligned.h \ -# common.h \ -# common.c \ -# ipv4ll.h \ -# ipv4ll.c \ -# client.c \ -# server.c -#miracle_dhcp_CPPFLAGS = \ -# $(AM_CPPFLAGS) \ -# $(DEPS_CFLAGS) \ -# $(GDHCP_CFLAGS) -#miracle_dhcp_LDADD = \ -# ../shared/libmiracle-shared.la \ -# $(DEPS_LIBS) \ -# $(GDHCP_LIBS) -# -# -# diff --git a/src/dhcp/meson.build b/src/dhcp/meson.build new file mode 100644 index 0000000..1dce905 --- /dev/null +++ b/src/dhcp/meson.build @@ -0,0 +1,11 @@ +miracle_dhcp_srcs = ['dhcp.c', + 'common.c', + 'ipv4ll.c', + 'client.c', + 'server.c' +] +executable('miracle-dhcp', miracle_dhcp_srcs, + install: true, + include_directories: include_directories('../..'), + dependencies: [glib2, udev, libmiracle_shared_dep] +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..1179ab3 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,11 @@ +subdir('shared') +subdir('wifi') +subdir('dhcp') +subdir('ctl') +subdir('uibc') + +executable('miracled', 'miracled.c', + dependencies: libmiracle_shared_dep, + include_directories: include_directories('..'), + install: true +) diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt deleted file mode 100644 index f757fba..0000000 --- a/src/shared/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -set(CMAKE_C_FLAGS "-std=gnu11") - -find_package(PkgConfig) -pkg_check_modules (SYSTEMD REQUIRED systemd>=213) -set(miracle-shared_SOURCES rtsp.h - rtsp.c - shl_dlist.h - shl_htable.h - shl_htable.c - shl_log.h - shl_log.c - shl_macro.h - shl_ring.h - shl_ring.c - shl_util.h - shl_util.c - util.h - wpas.h - wpas.c) -add_library(miracle-shared STATIC ${miracle-shared_SOURCES}) -target_link_libraries (miracle-shared systemd) - - -########### install files ############### - - - - -#original Makefile.am contents follow: - -#include $(top_srcdir)/common.am -#noinst_LTLIBRARIES = libmiracle-shared.la -# -#libmiracle_shared_la_SOURCES = \ -# rtsp.h \ -# rtsp.c \ -# shl_dlist.h \ -# shl_htable.h \ -# shl_htable.c \ -# shl_log.h \ -# shl_log.c \ -# shl_macro.h \ -# shl_ring.h \ -# shl_ring.c \ -# shl_util.h \ -# shl_util.c \ -# util.h \ -# wpas.h \ -# wpas.c -#libmiracle_shared_la_LIBADD = -lsystemd -# -# -# diff --git a/src/shared/meson.build b/src/shared/meson.build new file mode 100644 index 0000000..4af9e34 --- /dev/null +++ b/src/shared/meson.build @@ -0,0 +1,22 @@ +libmiracle_shared = static_library('miracle-shared', + 'rtsp.h', + 'rtsp.c', + 'shl_dlist.h', + 'shl_htable.h', + 'shl_htable.c', + 'shl_log.h', + 'shl_log.c', + 'shl_macro.h', + 'shl_ring.h', + 'shl_ring.c', + 'shl_util.h', + 'shl_util.c', + 'util.h', + 'wpas.h', + 'wpas.c', + dependencies: [libsystemd] +) +libmiracle_shared_dep = declare_dependency( + include_directories: include_directories('.'), + link_with: libmiracle_shared +) diff --git a/src/uibc/CMakeLists.txt b/src/uibc/CMakeLists.txt deleted file mode 100644 index ac81904..0000000 --- a/src/uibc/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(miracle-uibcctl_SRCS miracle-uibcctl.h - miracle-uibcctl.c) - -add_executable(miracle-uibcctl ${miracle-uibcctl_SRCS}) -target_link_libraries(miracle-uibcctl PRIVATE miracle-shared) -target_link_libraries(miracle-uibcctl PUBLIC m) - -install(TARGETS miracle-uibcctl DESTINATION bin) - -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) diff --git a/src/uibc/meson.build b/src/uibc/meson.build new file mode 100644 index 0000000..17a06db --- /dev/null +++ b/src/uibc/meson.build @@ -0,0 +1,5 @@ +m = c_compiler.find_library('m', required: false) +executable('miracle-uibcctl', 'miracle-uibcctl.h', 'miracle-uibcctl.c', + install: true, + dependencies: [m, libmiracle_shared_dep] +) diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt deleted file mode 100644 index c041e34..0000000 --- a/src/wifi/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ - -########### next target ############### - -set(miracle-wifid_SRCS wifid.h - wifid.c - wifid-dbus.c - wifid-link.c - wifid-peer.c - wifid-supplicant.c) - -add_executable(miracle-wifid ${miracle-wifid_SRCS}) - -target_link_libraries(miracle-wifid ${KDE4_KDECORE_LIBS}) - -cmake_policy(SET CMP0015 NEW) -include_directories(shared) -link_directories(shared) -target_link_libraries(miracle-wifid miracle-shared) - -find_package(PkgConfig) -pkg_check_modules (GLIB2 REQUIRED glib-2.0) -pkg_check_modules (UDEV REQUIRED libudev) -#link_directories( ${UDEV_LIBRARY_DIRS}) -#include_directories( ${UDEV_INCLUDE_DIRS}) -target_link_libraries(miracle-wifid ${UDEV_LIBRARIES}) -#link_directories( ${GLIB2_LIBRARY_DIRS}) -#include_directories( ${GLIB2_INCLUDE_DIRS}) -target_link_libraries(miracle-wifid ${GLIB2_LIBRARIES}) - -install(TARGETS miracle-wifid DESTINATION bin) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) - -########### install files ############### - -#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-extensions/ ) - - - - - -#original Makefile.am contents follow: - -#include $(top_srcdir)/common.am -#bin_PROGRAMS = miracle-wifid -# -#miracle_wifid_SOURCES = \ -# wifid.h \ -# wifid.c \ -# wifid-dbus.c \ -# wifid-link.c \ -# wifid-peer.c \ -# wifid-supplicant.c -#miracle_wifid_CPPFLAGS = \ -# $(AM_CPPFLAGS) \ -# $(DEPS_CFLAGS) -#miracle_wifid_LDADD = \ -# ../shared/libmiracle-shared.la \ -# $(DEPS_LIBS) -# diff --git a/src/wifi/meson.build b/src/wifi/meson.build new file mode 100644 index 0000000..e0176f4 --- /dev/null +++ b/src/wifi/meson.build @@ -0,0 +1,14 @@ +inc = include_directories('../..') +miracle_wifid_src = ['wifid.h', + 'wifid.c', + 'wifid-dbus.c', + 'wifid-link.c', + 'wifid-peer.c', + 'wifid-supplicant.c' +] +executable('miracle-wifid', miracle_wifid_src, + include_directories: inc, + install: true, + dependencies: [udev, glib2, libsystemd, libmiracle_shared_dep] +) + diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..b2feb2a --- /dev/null +++ b/test/meson.build @@ -0,0 +1,33 @@ +check = dependency('check', required: false) +deps = [udev, glib2, check, libsystemd, libmiracle_shared_dep] + +if check.found() + test_rtsp = executable('test_rtsp', 'test_rtsp.c', dependencies: deps) + + test_wpas = executable('test_wpas', 'test_wpas.c', dependencies: deps) + + test_valgrind = executable('test_valgrind', + 'test_valgrind.c', + dependencies: deps + ) + + valgrind = find_program('valgrind') + +# set(VALGRIND CK_FORK=no valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --leak-resolution=high --error-exitcode=1 --suppressions=${CMAKE_SOURCE_DIR}/test.supp) +# +# add_custom_target(memcheck-verify +# DEPENDS test_rtsp test_wpas test_valgrind +# COMMAND ${VALGRIND} --log-file=/dev/null ./test_valgrind >/dev/null | +# test 1 = $$? +# COMMENT "verify memcheck") +# +# add_custom_target(memcheck +# DEPENDS memcheck-verify +# COMMAND for i in $(MEMTESTS) | +# do | +# ${VALGRIND} --log-file=${CMAKE_SOURCE_DIR}/$$i.memlog | +# ${CMAKE_SOURCE_DIR}/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; | +# done +# SOURCES test_rtsp test_valgrind test_wpas +# COMMENT "verify memcheck") +endif From 92312fd4e7c61a3748279dfeeade062cffafdfc0 Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Thu, 6 Apr 2017 22:13:31 +0800 Subject: [PATCH 2/7] put back cmake files --- CMakeLists.txt | 33 +++++++++++++++ cmake/FindReadline.cmake | 29 +++++++++++++ config.h.cmake | 8 ++++ res/CMakeLists.txt | 12 ++++++ src/CMakeLists.txt | 38 +++++++++++++++++ src/ctl/CMakeLists.txt | 86 +++++++++++++++++++++++++++++++++++++++ src/dhcp/CMakeLists.txt | 62 ++++++++++++++++++++++++++++ src/shared/CMakeLists.txt | 53 ++++++++++++++++++++++++ src/uibc/CMakeLists.txt | 10 +++++ src/wifi/CMakeLists.txt | 59 +++++++++++++++++++++++++++ 10 files changed, 390 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/FindReadline.cmake create mode 100644 config.h.cmake create mode 100644 res/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/ctl/CMakeLists.txt create mode 100644 src/dhcp/CMakeLists.txt create mode 100644 src/shared/CMakeLists.txt create mode 100644 src/uibc/CMakeLists.txt create mode 100644 src/wifi/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6aea926 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 2.8) +project(Miraclecast) + +SET(PACKAGE_NAME miraclecast) +SET(PACKAGE_VERSION 1) +SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake + ${CMAKE_MODULE_PATH}) + +set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}") +add_definitions(-D_GNU_SOURCE) + +SET(BUILD_BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +OPTION(BUILD_ENABLE_DEBUG "Enable Debug" ON ) +OPTION(RELY_UDEV "Rely in udev tag to select device" OFF ) +OPTION(BUILD_TESTS "Enable TEST" ON ) + +if(BUILD_ENABLE_DEBUG) + add_definitions(-DBUILD_ENABLE_DEBUG) +endif() + +find_package(PkgConfig) +pkg_check_modules (GLIB2 REQUIRED glib-2.0) +pkg_check_modules (UDEV REQUIRED libudev) +pkg_check_modules (SYSTEMD REQUIRED libsystemd) + +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h) + +add_subdirectory(src) +add_subdirectory(res) +add_subdirectory(test) + diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake new file mode 100644 index 0000000..1d4cc55 --- /dev/null +++ b/cmake/FindReadline.cmake @@ -0,0 +1,29 @@ +# from http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/FindReadline.cmake +# http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/COPYING-CMAKE-SCRIPTS +# --> BSD licensed +# +# GNU Readline library finder +if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY) + set(READLINE_FOUND TRUE) +else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY) + FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h + /usr/include/readline + ) + +# 2008-04-22 The next clause used to read like this: +# +# FIND_LIBRARY(READLINE_LIBRARY NAMES readline) +# FIND_LIBRARY(NCURSES_LIBRARY NAMES ncurses ) +# include(FindPackageHandleStandardArgs) +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG NCURSES_LIBRARY READLINE_INCLUDE_DIR READLINE_LIBRARY ) +# +# I was advised to modify it such that it will find an ncurses library if +# required, but not if one was explicitly given, that is, it allows the +# default to be overridden. PH + + FIND_LIBRARY(READLINE_LIBRARY NAMES readline) + include(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY ) + + MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY) +endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY) diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..ddc0cd1 --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,8 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#cmakedefine BUILD_BINDIR "@BUILD_BINDIR@" + +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" + +#endif // CONFIG_H diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt new file mode 100644 index 0000000..4cb3f19 --- /dev/null +++ b/res/CMakeLists.txt @@ -0,0 +1,12 @@ + +########### install files ############### + +install( + PROGRAMS miracle-gst gstplayer uibc-viewer + DESTINATION bin + ) + +INSTALL( + FILES org.freedesktop.miracle.conf + DESTINATION /etc/dbus-1/system.d + ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..96fe570 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,38 @@ +set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}") + +add_subdirectory(shared) +add_subdirectory(wifi) +add_subdirectory(dhcp) +add_subdirectory(ctl) +add_subdirectory(uibc) + +set(miracled_SRCS miracled.h miracled.c) +add_executable(miracled ${miracled_SRCS}) +target_link_libraries(miracled miracle-shared) +install(TARGETS miracled DESTINATION bin) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) + + +########### install files ############### + + + + +#original Makefile.am contents follow: + +#include $(top_srcdir)/common.am +#SUBDIRS = shared wifi dhcp ctl +# +#bin_PROGRAMS = miracled +# +#miracled_SOURCES = \ +# miracled.h \ +# miracled.c +#miracled_CPPFLAGS = \ +# $(AM_CPPFLAGS) \ +# $(DEPS_CFLAGS) +#miracled_LDADD = \ +# shared/libmiracle-shared.la \ +# $(DEPS_LIBS) +# diff --git a/src/ctl/CMakeLists.txt b/src/ctl/CMakeLists.txt new file mode 100644 index 0000000..d6d98e4 --- /dev/null +++ b/src/ctl/CMakeLists.txt @@ -0,0 +1,86 @@ + +find_package(Readline) +########### next target ############### + +set(miracle-wifictl_SRCS ctl.h + ctl-cli.c + ctl-wifi.c + wifictl.c) + +add_executable(miracle-wifictl ${miracle-wifictl_SRCS}) + +install(TARGETS miracle-wifictl DESTINATION bin) + +if(READLINE_FOUND) + message(STATUS "Compiling with Readline support") + set_property(TARGET miracle-wifictl + APPEND + PROPERTY COMPILE_DEFINITIONS HAVE_READLINE) + target_link_libraries(miracle-wifictl ${READLINE_LIBRARY}) +endif(READLINE_FOUND) + +target_link_libraries(miracle-wifictl miracle-shared) +########### next target ############### + +set(miracle-sinkctl_SRCS ctl.h + ctl-cli.c + ctl-sink.h + ctl-sink.c + ctl-wifi.c + sinkctl.c + wfd.c) + +add_executable(miracle-sinkctl ${miracle-sinkctl_SRCS}) + +install(TARGETS miracle-sinkctl DESTINATION bin) + +if(READLINE_FOUND) + message(STATUS "Compiling with Readline support") + set_property(TARGET miracle-sinkctl + APPEND + PROPERTY COMPILE_DEFINITIONS HAVE_READLINE) + target_link_libraries(miracle-sinkctl ${READLINE_LIBRARY}) +endif(READLINE_FOUND) + +target_link_libraries(miracle-sinkctl miracle-shared) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) + +########### install files ############### + + + + +#original Makefile.am contents follow: + +#include $(top_srcdir)/common.am +#bin_PROGRAMS = miracle-wifictl miracle-sinkctl +# +#miracle_wifictl_SOURCES = \ +# ctl.h \ +# ctl-cli.c \ +# ctl-wifi.c \ +# wifictl.c +#miracle_wifictl_CPPFLAGS = \ +# $(AM_CPPFLAGS) \ +# $(DEPS_CFLAGS) +#miracle_wifictl_LDADD = \ +# ../shared/libmiracle-shared.la \ +# -lreadline \ +# $(DEPS_LIBS) +# +#miracle_sinkctl_SOURCES = \ +# ctl.h \ +# ctl-cli.c \ +# ctl-sink.c \ +# ctl-wifi.c \ +# sinkctl.c +#miracle_sinkctl_CPPFLAGS = \ +# $(AM_CPPFLAGS) \ +# $(DEPS_CFLAGS) +#miracle_sinkctl_LDADD = \ +# ../shared/libmiracle-shared.la \ +# -lreadline \ +# $(DEPS_LIBS) +# +# diff --git a/src/dhcp/CMakeLists.txt b/src/dhcp/CMakeLists.txt new file mode 100644 index 0000000..7935d68 --- /dev/null +++ b/src/dhcp/CMakeLists.txt @@ -0,0 +1,62 @@ + +########### next target ############### + +set(miracle-dhcp_SRCS dhcp.c + gdhcp.h + unaligned.h + common.h + common.c + ipv4ll.h + ipv4ll.c + client.c + server.c) + +add_executable(miracle-dhcp ${miracle-dhcp_SRCS}) + +find_package(PkgConfig) +pkg_check_modules (GLIB2 REQUIRED glib-2.0) +pkg_check_modules (UDEV REQUIRED libudev) +link_directories( ${UDEV_LIBRARY_DIRS}) +include_directories( ${UDEV_INCLUDE_DIRS}) +target_link_libraries(miracle-dhcp ${UDEV_LIBRARIES}) +link_directories( ${GLIB2_LIBRARY_DIRS}) +include_directories( ${GLIB2_INCLUDE_DIRS}) +target_link_libraries(miracle-dhcp ${GLIB2_LIBRARIES}) + +target_link_libraries(miracle-dhcp miracle-shared) + +install(TARGETS miracle-dhcp DESTINATION bin) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) + + +########### install files ############### + + + + +#original Makefile.am contents follow: + +#include $(top_srcdir)/common.am +#bin_PROGRAMS = miracle-dhcp +# +#miracle_dhcp_SOURCES = \ +# dhcp.c \ +# gdhcp.h \ +# unaligned.h \ +# common.h \ +# common.c \ +# ipv4ll.h \ +# ipv4ll.c \ +# client.c \ +# server.c +#miracle_dhcp_CPPFLAGS = \ +# $(AM_CPPFLAGS) \ +# $(DEPS_CFLAGS) \ +# $(GDHCP_CFLAGS) +#miracle_dhcp_LDADD = \ +# ../shared/libmiracle-shared.la \ +# $(DEPS_LIBS) \ +# $(GDHCP_LIBS) +# +# +# diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt new file mode 100644 index 0000000..f757fba --- /dev/null +++ b/src/shared/CMakeLists.txt @@ -0,0 +1,53 @@ +set(CMAKE_C_FLAGS "-std=gnu11") + +find_package(PkgConfig) +pkg_check_modules (SYSTEMD REQUIRED systemd>=213) +set(miracle-shared_SOURCES rtsp.h + rtsp.c + shl_dlist.h + shl_htable.h + shl_htable.c + shl_log.h + shl_log.c + shl_macro.h + shl_ring.h + shl_ring.c + shl_util.h + shl_util.c + util.h + wpas.h + wpas.c) +add_library(miracle-shared STATIC ${miracle-shared_SOURCES}) +target_link_libraries (miracle-shared systemd) + + +########### install files ############### + + + + +#original Makefile.am contents follow: + +#include $(top_srcdir)/common.am +#noinst_LTLIBRARIES = libmiracle-shared.la +# +#libmiracle_shared_la_SOURCES = \ +# rtsp.h \ +# rtsp.c \ +# shl_dlist.h \ +# shl_htable.h \ +# shl_htable.c \ +# shl_log.h \ +# shl_log.c \ +# shl_macro.h \ +# shl_ring.h \ +# shl_ring.c \ +# shl_util.h \ +# shl_util.c \ +# util.h \ +# wpas.h \ +# wpas.c +#libmiracle_shared_la_LIBADD = -lsystemd +# +# +# diff --git a/src/uibc/CMakeLists.txt b/src/uibc/CMakeLists.txt new file mode 100644 index 0000000..ac81904 --- /dev/null +++ b/src/uibc/CMakeLists.txt @@ -0,0 +1,10 @@ +set(miracle-uibcctl_SRCS miracle-uibcctl.h + miracle-uibcctl.c) + +add_executable(miracle-uibcctl ${miracle-uibcctl_SRCS}) +target_link_libraries(miracle-uibcctl PRIVATE miracle-shared) +target_link_libraries(miracle-uibcctl PUBLIC m) + +install(TARGETS miracle-uibcctl DESTINATION bin) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt new file mode 100644 index 0000000..c041e34 --- /dev/null +++ b/src/wifi/CMakeLists.txt @@ -0,0 +1,59 @@ + +########### next target ############### + +set(miracle-wifid_SRCS wifid.h + wifid.c + wifid-dbus.c + wifid-link.c + wifid-peer.c + wifid-supplicant.c) + +add_executable(miracle-wifid ${miracle-wifid_SRCS}) + +target_link_libraries(miracle-wifid ${KDE4_KDECORE_LIBS}) + +cmake_policy(SET CMP0015 NEW) +include_directories(shared) +link_directories(shared) +target_link_libraries(miracle-wifid miracle-shared) + +find_package(PkgConfig) +pkg_check_modules (GLIB2 REQUIRED glib-2.0) +pkg_check_modules (UDEV REQUIRED libudev) +#link_directories( ${UDEV_LIBRARY_DIRS}) +#include_directories( ${UDEV_INCLUDE_DIRS}) +target_link_libraries(miracle-wifid ${UDEV_LIBRARIES}) +#link_directories( ${GLIB2_LIBRARY_DIRS}) +#include_directories( ${GLIB2_INCLUDE_DIRS}) +target_link_libraries(miracle-wifid ${GLIB2_LIBRARIES}) + +install(TARGETS miracle-wifid DESTINATION bin) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared) + +########### install files ############### + +#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-extensions/ ) + + + + + +#original Makefile.am contents follow: + +#include $(top_srcdir)/common.am +#bin_PROGRAMS = miracle-wifid +# +#miracle_wifid_SOURCES = \ +# wifid.h \ +# wifid.c \ +# wifid-dbus.c \ +# wifid-link.c \ +# wifid-peer.c \ +# wifid-supplicant.c +#miracle_wifid_CPPFLAGS = \ +# $(AM_CPPFLAGS) \ +# $(DEPS_CFLAGS) +#miracle_wifid_LDADD = \ +# ../shared/libmiracle-shared.la \ +# $(DEPS_LIBS) +# From 1e9180a44adb0431ef31a541a30fef17e9a1cf32 Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Mon, 3 Apr 2017 22:08:51 +0800 Subject: [PATCH 3/7] remove install script and install scripts with install_data() --- res/meson-install-scripts.sh | 8 -------- res/meson.build | 6 ++++-- 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100755 res/meson-install-scripts.sh diff --git a/res/meson-install-scripts.sh b/res/meson-install-scripts.sh deleted file mode 100755 index d18a1f2..0000000 --- a/res/meson-install-scripts.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -RESDIR="${MESON_SOURCE_ROOT}/res" -BINDIR="${MESON_INSTALL_DESTDIR_PREFIX}/$1" - -install -dv "$BINDIR" -install -v "$RESDIR"/miracle-gst "$BINDIR" -install -v "$RESDIR"/gstplayer "$BINDIR" -install -v "$RESDIR"/uibc-viewer "$BINDIR" diff --git a/res/meson.build b/res/meson.build index d63d753..3325bc5 100644 --- a/res/meson.build +++ b/res/meson.build @@ -1,6 +1,8 @@ -meson.add_install_script('meson-install-scripts.sh', get_option('bindir')) - install_data( 'org.freedesktop.miracle.conf', install_dir: join_paths('/', get_option('sysconfdir'), 'dbus-1', 'system.d') ) + +install_data('miracle-gst', 'gstplayer', 'uibc-viewer', + install_dir: get_option('bindir'), + install_mode: 'rwxr-xr-x') From 2a0435d5e42bf362acb9e04f26ca3db9ccb29b57 Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Mon, 3 Apr 2017 22:16:29 +0800 Subject: [PATCH 4/7] handle meson optoins properly --- meson.build | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index c21167e..74adfaa 100644 --- a/meson.build +++ b/meson.build @@ -28,11 +28,18 @@ if get_option('build-enable-debug') add_project_arguments('-DBUILD_ENABLE_DEBUG', language: 'c') endif +if get_option('rely-udev') + add_project_arguments('-DRELY_UDEV', language: 'c') +endif + glib2 = dependency('glib-2.0') udev = dependency('libudev') libsystemd = dependency('libsystemd') subdir('src') subdir('res') -subdir('test') + +if get_option('build-tests') + subdir('test') +endif From 20cd06ca825077f1481f1fac099fd77563af30bb Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Mon, 3 Apr 2017 22:18:52 +0800 Subject: [PATCH 5/7] remove unused option build-demo --- meson_options.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 0f4eaee..34002ff 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,7 +10,3 @@ option('build-tests', type: 'boolean', value: true, description: 'Enable TEST') -option('build-demo', - type: 'boolean', - value: false, - description: 'Enable DEMO') From bb7de63bdc4aea9c607398495083e4aef3ab830e Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Mon, 3 Apr 2017 23:12:53 +0800 Subject: [PATCH 6/7] quote string entries with configuration_data.set_quoted() instead of by ourself with configureation_data.set() --- meson.build | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 74adfaa..1e88906 100644 --- a/meson.build +++ b/meson.build @@ -8,11 +8,11 @@ project('Miraclecast', add_project_arguments('-D_GNU_SOURCE', language: 'c') conf_data = configuration_data() -conf_data.set('BUILD_BINDIR', - '"' + join_paths(get_option('prefix'), get_option('bindir')) + '"' +conf_data.set_quoted('BUILD_BINDIR', + join_paths(get_option('prefix'), get_option('bindir')) ) -conf_data.set('PACKAGE_STRING', - '"@0@ @1@"'.format(meson.project_name(), meson.project_version()) +conf_data.set_quoted('PACKAGE_STRING', + '@0@ @1@'.format(meson.project_name(), meson.project_version()) ) configure_file(output: 'config.h', configuration: conf_data From 2a580f0dbbfc00dc90c326a9a8338a9321b13947 Mon Sep 17 00:00:00 2001 From: Derek Dai Date: Tue, 4 Apr 2017 08:51:43 +0800 Subject: [PATCH 7/7] remove starting `/` in front of installation path of DBus policy file --- res/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/meson.build b/res/meson.build index 3325bc5..1b331ad 100644 --- a/res/meson.build +++ b/res/meson.build @@ -1,6 +1,6 @@ install_data( 'org.freedesktop.miracle.conf', - install_dir: join_paths('/', get_option('sysconfdir'), 'dbus-1', 'system.d') + install_dir: join_paths(get_option('sysconfdir'), 'dbus-1', 'system.d') ) install_data('miracle-gst', 'gstplayer', 'uibc-viewer',