From c6e89377cd981f9be1f18a6be334fbcfebb0c16e Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Mon, 16 Mar 2015 17:34:13 +0100 Subject: [PATCH] Build working `make install` target Should install the frida binary and the libraries into appropriate places using the Cmake GNUInstallDirs module. Included is some cleanup in the guile module. --- CMakeLists.txt | 18 ++++++++++++++---- src/bindings/Guile.cxx | 20 ++++++-------------- src/main.cxx | 2 ++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f9689..242fbfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.8.9) PROJECT(frida) set(CMAKE_VERBOSE_MAKEFILE on) - set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules") +include(GNUInstallDirs) find_package(Qt5Widgets) find_package(Qt5 CONFIG REQUIRED Widgets Gui) @@ -28,6 +28,7 @@ separate_arguments(LLVM_LDFLAGS) separate_arguments(LLVM_LIBS) INCLUDE_DIRECTORIES("src") +include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) ##################### # Language Bindings # @@ -37,8 +38,8 @@ SET(CMAKE_SWIG_FLAGS -Linkage passive) #FIND_PACKAGE(PythonLibs) #INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) SET_SOURCE_FILES_PROPERTIES(src/bindings/guile/frida.i PROPERTIES CPLUSPLUS ON) -SWIG_ADD_MODULE(frida-guile guile src/bindings/guile/frida.i) -SWIG_LINK_LIBRARIES(frida-guile ${GUILE_LDFLAGS}) +SWIG_ADD_MODULE(guile-frida-binding guile src/bindings/guile/frida.i) +SWIG_LINK_LIBRARIES(guile-frida-binding ${GUILE_LDFLAGS}) ################# @@ -82,7 +83,7 @@ SET(frida_HEADERS ) ADD_EXECUTABLE(frida src/main.cxx ${frida_SOURCES} ${frida_HEADERS_MOC}) -#ADD_LIBRARY(llvm SHARED ) + ADD_DEFINITIONS(${QT_DEFINITIONS}) @@ -96,6 +97,7 @@ TARGET_LINK_LIBRARIES(frida ${LOG4CXX_LDFLAGS} ${QUAZIP_LIBRARIES}) +configure_file(src/Config.hxx.in src/Config.hxx @ONLY) ########### # Plugins # @@ -134,3 +136,11 @@ ADD_SUBDIRECTORY(/usr/src/gmock gmock) enable_testing() target_link_libraries(fridatest gmock gtest ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES}) add_test(NAME fridatest COMMAND fridatest ${CMAKE_SOURCE_DIR}) + + + +install(TARGETS frida + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(TARGETS guilePlugin guile-frida-binding + DESTINATION ${CMAKE_INSTALL_LIBDIR}/frida/plugins/Interpreter) diff --git a/src/bindings/Guile.cxx b/src/bindings/Guile.cxx index fcc1083..86ab6dd 100644 --- a/src/bindings/Guile.cxx +++ b/src/bindings/Guile.cxx @@ -1,4 +1,5 @@ #include "Guile.hxx" +#include "Config.hxx" namespace { SCM handler (void*, SCM tag, SCM throw_args) { @@ -10,18 +11,10 @@ namespace { GuileInterpreter::GuileInterpreter() { scm_init_guile(); - scm_internal_catch(SCM_BOOL_T, - (SCM (*)(void *))scm_c_eval_string, - (void*)"(use-modules (system repl server))", - handler, NULL); - scm_internal_catch(SCM_BOOL_T, - (SCM (*)(void *))scm_c_eval_string, - (void*)"(spawn-server)", - handler, NULL); - scm_internal_catch(SCM_BOOL_T, - (SCM (*)(void *))scm_c_eval_string, - (void*)"(load-extension \"libfrida-guile\" \"scm_init_frida_module\")", - handler, NULL); + scm_c_use_module("system repl server"); + scm_call_0(scm_c_public_ref("system repl server", "spawn-server")); + scm_c_load_extension(CMAKE_INSTALL_FULL_LIBDIR "/frida/plugins/Interpreter/libguile-frida-binding", + "scm_init_frida_module"); guile_output_port = scm_open_output_string(); guile_error_port = scm_open_output_string(); @@ -59,6 +52,5 @@ int GuileInterpreter::loadFile(const std::string& filename, std::ostream& stdout, std::ostream& stderr, std::string& result) { - return evaluate("(load \"" + filename + "\")", - stdout, stderr, result); + scm_c_primitive_load(filename.c_str()); } diff --git a/src/main.cxx b/src/main.cxx index 8c0916c..a627b61 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -18,6 +18,7 @@ #include "gui/Mainwindow.hxx" #include "core/InformationManager.hxx" #include "disassembler/llvm/LLVMDisassembler.hxx" +#include "Config.hxx" int main(int argc, char** argv) { @@ -32,6 +33,7 @@ int main(int argc, char** argv) QApplication::setApplicationName("frida"); QApplication::setApplicationVersion("0.0"); + QApplication::addLibraryPath(CMAKE_INSTALL_FULL_LIBDIR "/frida/plugins/Interpreter"); #ifdef ARGPARSE parser.addHelpOption(); parser.addVersionOption(); -- 2.39.5