From 3b8bb6504df754ff6ecf0ea3ec980438c07130da Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 20:03:54 +0000 Subject: libproxy-0.4.15 base --- diff --git a/bindings/csharp/libproxy-sharp-1.0.pc.cmake b/bindings/csharp/libproxy-sharp-1.0.pc.cmake new file mode 100644 index 0000000..5e2f4a4 --- /dev/null +++ b/bindings/csharp/libproxy-sharp-1.0.pc.cmake @@ -0,0 +1,5 @@ + +Name: Libproxy# +Description: Libproxy# - .NET Binding to libproxy +Version: 0.4.6 +Libs: -r:@assembly@ diff --git a/bindings/perl/lib/Libproxy.pm b/bindings/perl/lib/Libproxy.pm new file mode 100644 index 0000000..67670fe --- /dev/null +++ b/bindings/perl/lib/Libproxy.pm @@ -0,0 +1,75 @@ +package Net::Libproxy; +use 5.008000; +use warnings; +our $VERSION = '0.04'; + +require Exporter; +require DynaLoader; +@ISA = qw(Exporter DynaLoader); +@EXPORT = qw(proxy_factory_new proxy_factory_get_proxies); + +bootstrap Net::Libproxy; + +sub new { + my $self; + + $self->{pf} = Net::Libproxy::proxy_factory_new(); + + bless $self; +} + +sub getProxies { + my ($self, $url) = @_; + + return Net::Libproxy::proxy_factory_get_proxies($self->{pf}, $url); +} + +1; + + +=head1 NAME + +Net::Libproxy - Perl binding for libproxy ( http://code.google.com/p/libproxy/ ) + +=head1 SYNOPSIS + + use Net::Libproxy; + + $p = new Net::Libproxy; + $proxies = $p->getProxies('http://code.google.com/p/libproxy/'); + + foreach my $proxy (@$proxies) { + print $proxy."\n"; + } + +=head1 DESCRIPTION + +libproxy is a lightweight library which makes it easy to develop +applications proxy-aware with a simple and stable API. + +=head2 EXPORT + +These two functions are also exported. +proxy_factory_new() +proxy_factory_get_proxies() + +=head1 SEE ALSO + +Libproxy homepage: http://code.google.com/p/libproxy/ +Net::Libproxy on Gitorious: http://gitorious.org/net-libproxy +You can also read proxy.h and Net/Libproxy.pm + +=head1 AUTHOR + +Goneri Le Bouder, Egoneri@rulezlan.orgE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2009 by Goneri Le Bouder + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.10.0 or, +at your option, any later version of Perl 5 you may have available. + + +=cut diff --git a/cmake/CMakeCSharpInformation.cmake b/cmake/CMakeCSharpInformation.cmake new file mode 100644 index 0000000..2331ccf --- /dev/null +++ b/cmake/CMakeCSharpInformation.cmake @@ -0,0 +1,379 @@ +# copyright (c) 2007, 2009 Arno Rehn arno@arnorehn.de +# copyright (c) 2008 Helio castro helio@kde.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# This file adds support for the C# language to cmake. +# +# It adds the following functions: +# +# csharp_add_executable ( [UNSAFE] [WINEXE] [REFERENCES ] +# [COMPILE_FLAGS ] +# [COMPILE_DEFINITIONS ] ) +# +# csharp_add_library ( [UNSAFE] [REFERENCES ] +# [COMPILE_FLAGS ] +# [COMPILE_DEFINITIONS ] ) +# +# install_assembly ( [NO_GAC] DESTINATION +# [PACKAGE ] ) +# The assembly destination directory is only used if we compile with Visual C# and thus can't use gacutil. +# If a package is specified and a file called .pc.cmake exists in the current source directory, +# this function will configure the template file. All occurences of @assembly@ will be replaced with +# the path to the assembly. The resulting .pc file will be installed to +# /lib/pkgconfig/ . If you want to have a different basename for the template file, +# set the 'pkg-config_template_basename' property of the target with set_property. +# +# Example: +# ------------------------------ +# cmake code: +# ------------------------------ +# csharp_add_library(foo foo.cs) +# install_assembly(foo DESTINATION lib) +# +# ------------------------------ +# contents of foo.pc.cmake file: +# ------------------------------ +# Name: Foo +# Description: Foo library +# Version: 1.0 +# Libs: -r:@assembly@ + +# ----- support macros ----- +macro(GET_LIBRARY_OUTPUT_DIR var) + if (NOT LIBRARY_OUTPUT_PATH) + set(${var} ${CMAKE_CURRENT_BINARY_DIR}) + else (NOT LIBRARY_OUTPUT_PATH) + set(${var} ${LIBRARY_OUTPUT_PATH}) + endif (NOT LIBRARY_OUTPUT_PATH) +endmacro(GET_LIBRARY_OUTPUT_DIR) + +macro(GET_EXECUTABLE_OUTPUT_DIR var) + if (NOT EXECUTABLE_OUTPUT_PATH) + set(${var} ${CMAKE_CURRENT_BINARY_DIR}) + else (NOT EXECUTABLE_OUTPUT_PATH) + set(${var} ${EXECUTABLE_OUTPUT_PATH}) + endif (NOT EXECUTABLE_OUTPUT_PATH) +endmacro(GET_EXECUTABLE_OUTPUT_DIR) + +# This does just not always work... why?! +# macro(MAKE_PROPER_FILE_LIST var) +# foreach(file ${ARGN}) +# if (IS_ABSOLUTE "${file}") +# file(GLOB globbed "${file}") +# else (IS_ABSOLUTE "${file}") +# file(GLOB globbed "${CMAKE_CURRENT_SOURCE_DIR}/${file}") +# endif (IS_ABSOLUTE "${file}") +# +# foreach (glob ${globbed}) +# file(TO_NATIVE_PATH "${glob}" native) +# list(APPEND proper_file_list "${native}") +# endforeach (glob ${globbed}) +# endforeach(file ${ARGN}) +# endmacro(MAKE_PROPER_FILE_LIST) + +# ----- actual functions ----- + +# ----- add an executable ----- +function(csharp_add_executable target) + set(current "s") + set(dotnet_target "exe") + + foreach (arg ${ARGN}) + file(TO_NATIVE_PATH ${arg} native_path) + + if (arg STREQUAL "UNSAFE") + set (unsafe "/unsafe") + elseif (arg STREQUAL "WINEXE") + set (dotnet_target "winexe") + elseif (arg STREQUAL "REFERENCES") + set (current "r") + elseif (arg STREQUAL "COMPILE_FLAGS") + set (current "flags") + elseif (arg STREQUAL "COMPILE_DEFINITIONS") + set (current "defs") + else (arg STREQUAL "UNSAFE") + if (current STREQUAL "s") + # source file + list(APPEND sources ${native_path}) + elseif (current STREQUAL "r") + # reference + if (TARGET ${arg}) + # this is an existing target - get the target assembly + get_property(prop TARGET ${arg} PROPERTY _assembly) + list(APPEND references "/r:${prop}") + list(APPEND deps ${arg}) + else (TARGET ${arg}) + # something different (e.g. assembly name in the gac) + list(APPEND references "/r:${native_path}") + endif (TARGET ${arg}) + elseif (current STREQUAL "flags") + list(APPEND _csc_opts "${arg}") + elseif (current STREQUAL "defs") + list(APPEND _csc_opts "/define:${arg}") + endif (current STREQUAL "s") + endif (arg STREQUAL "UNSAFE") + endforeach (arg ${ARGN}) + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + list(APPEND _csc_opts "/define:DEBUG") + list(APPEND _csc_opts "/debug") + endif (CMAKE_BUILD_TYPE STREQUAL "Debug") + + get_executable_output_dir(outdir) + if (NOT IS_ABSOLUTE "${outdir}") + message(FATAL_ERROR "Directory \"${outdir}\" is not an absolute path!") + endif (NOT IS_ABSOLUTE "${outdir}") + + file(RELATIVE_PATH relative_path "${CMAKE_BINARY_DIR}" "${outdir}/${target}.exe") + file(TO_NATIVE_PATH "${outdir}/${target}" native_target) + + # inlined - this doesn't work as a macro :( + foreach(file ${sources}) + file(TO_CMAKE_PATH "${file}" cmake_file) + + if (IS_ABSOLUTE "${cmake_file}") + file(GLOB globbed "${cmake_file}") + else (IS_ABSOLUTE "${cmake_file}") + file(GLOB globbed "${CMAKE_CURRENT_SOURCE_DIR}/${cmake_file}") + endif (IS_ABSOLUTE "${cmake_file}") + + foreach (glob ${globbed}) + file(TO_CMAKE_PATH "${glob}" cmake_path) + list(APPEND cmake_file_list "${cmake_path}") + endforeach (glob ${globbed}) + if (NOT globbed) + list(APPEND cmake_file_list "${cmake_file}") + endif (NOT globbed) + list(APPEND compiler_file_list ${file}) + endforeach(file ${sources}) + + get_directory_property(compile_definitions COMPILE_DEFINITIONS) + foreach (def ${compile_definitions}) + # macros with values aren't supported by C# + if (NOT def MATCHES ".*=.*") + list(APPEND _csc_opts "/define:${def}") + endif (NOT def MATCHES ".*=.*") + endforeach (def ${compile_definitions}) + + get_directory_property(link_dirs LINK_DIRECTORIES) + foreach (dir ${link_dirs}) + list(APPEND _csc_opts "/lib:${dir}") + endforeach (dir ${link_dirs}) + + add_custom_command(OUTPUT "${outdir}/${target}.stubexe" + COMMAND "${CMAKE_COMMAND}" -E make_directory "${outdir}" # create the output dir + COMMAND "${CMAKE_CSharp_COMPILER}" /nologo /target:${dotnet_target} "/out:${native_target}.exe" # build the executable + ${_csc_opts} ${unsafe} ${references} ${compiler_file_list} + COMMAND "${CMAKE_COMMAND}" -E touch "${outdir}/${target}.stubexe" # create the stub so that DEPENDS will work + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" # working directory is the source directory, so we don't have to care about relative paths + DEPENDS ${cmake_file_list} + COMMENT "Building ${relative_path}" VERBATIM) # nice comment + add_custom_target(${target} ALL DEPENDS "${outdir}/${target}.stubexe" SOURCES ${cmake_file_list}) # create the actual target + set_property(TARGET ${target} PROPERTY _assembly "${native_target}.exe") + set_property(TARGET ${target} PROPERTY _assembly_type "exe") + if (deps) + add_dependencies(${target} ${deps}) + endif(deps) +endfunction(csharp_add_executable) + +# ----- add a library ----- +function(csharp_add_library target) + set(current "s") + + foreach (arg ${ARGN}) + file(TO_NATIVE_PATH ${arg} native_path) + + if (arg STREQUAL "UNSAFE") + set (unsafe "/unsafe") + elseif (arg STREQUAL "REFERENCES") + set (current "r") + elseif (arg STREQUAL "COMPILE_FLAGS") + set (current "flags") + elseif (arg STREQUAL "COMPILE_DEFINITIONS") + set (current "defs") + else (arg STREQUAL "UNSAFE") + if (current STREQUAL "s") + # source file + list(APPEND sources ${native_path}) + elseif (current STREQUAL "r") + # reference + if (TARGET ${arg}) + # this is an existing target - get the target assembly + get_property(prop TARGET ${arg} PROPERTY _assembly) + list(APPEND references "/r:${prop}") + list(APPEND deps ${arg}) + else (TARGET ${arg}) + # something different (e.g. assembly name in the gac) + list(APPEND references "/r:${native_path}") + endif (TARGET ${arg}) + elseif (current STREQUAL "flags") + list(APPEND _csc_opts "${arg}") + elseif (current STREQUAL "defs") + list(APPEND _csc_opts "/define:${arg}") + endif (current STREQUAL "s") + endif (arg STREQUAL "UNSAFE") + endforeach (arg ${ARGN}) + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + list(APPEND _csc_opts "/define:DEBUG") + list(APPEND _csc_opts "/debug") + endif (CMAKE_BUILD_TYPE STREQUAL "Debug") + + get_library_output_dir(outdir) + if (NOT IS_ABSOLUTE "${outdir}") + message(FATAL_ERROR "Directory \"${outdir}\" is not an absolute path!") + endif (NOT IS_ABSOLUTE "${outdir}") + + file(RELATIVE_PATH relative_path "${CMAKE_BINARY_DIR}" "${outdir}/${target}.dll") + file(TO_NATIVE_PATH "${outdir}/${target}" native_target) + + # inlined - this doesn't work as a macro :( + foreach(file ${sources}) + file(TO_CMAKE_PATH "${file}" cmake_file) + + if (IS_ABSOLUTE "${cmake_file}") + file(GLOB globbed "${cmake_file}") + else (IS_ABSOLUTE "${cmake_file}") + file(GLOB globbed "${CMAKE_CURRENT_SOURCE_DIR}/${cmake_file}") + endif (IS_ABSOLUTE "${cmake_file}") + + foreach (glob ${globbed}) + file(TO_CMAKE_PATH "${glob}" cmake_path) + list(APPEND cmake_file_list "${cmake_path}") + endforeach (glob ${globbed}) + if (NOT globbed) + list(APPEND cmake_file_list "${cmake_file}") + endif (NOT globbed) + list(APPEND compiler_file_list ${file}) + endforeach(file ${sources}) + +# message("CMake File List for target ${target}: ${cmake_file_list}") + + get_directory_property(compile_definitions COMPILE_DEFINITIONS) + foreach (def ${compile_definitions}) + # macros with values aren't supported by C# + if (NOT def MATCHES ".*=.*") + list(APPEND _csc_opts "/define:${def}") + endif (NOT def MATCHES ".*=.*") + endforeach (def ${compile_definitions}) + + get_directory_property(link_dirs LINK_DIRECTORIES) + foreach (dir ${link_dirs}) + list(APPEND _csc_opts "/lib:${dir}") + endforeach (dir ${link_dirs}) + + add_custom_command(OUTPUT "${outdir}/${target}.dll" + COMMAND "${CMAKE_COMMAND}" -E make_directory "${outdir}" # create the output dir + COMMAND "${CMAKE_CSharp_COMPILER}" /nologo /target:library "/out:${native_target}.dll" # build the library + ${_csc_opts} ${unsafe} ${references} ${compiler_file_list} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" # working directory is the source directory, so we don't have to care about relative paths + DEPENDS ${cmake_file_list} + COMMENT "Building ${relative_path}" VERBATIM) # nice comment + add_custom_target(${target} ALL DEPENDS "${outdir}/${target}.dll" SOURCES ${cmake_file_list}) # create the actual target + set_property(TARGET ${target} PROPERTY _assembly "${native_target}.dll") + set_property(TARGET ${target} PROPERTY _assembly_type "dll") + if (deps) + add_dependencies(${target} ${deps}) + endif(deps) +endfunction(csharp_add_library) + +# ----- install an assembly ----- +function(install_assembly) + set (current "t") + + foreach (arg ${ARGN}) + # flag handling + if (arg STREQUAL "NO_GAC") + set(no_gac TRUE) + # option handling + elseif (arg STREQUAL DESTINATION) + set (current "d") + elseif (arg STREQUAL "PACKAGE") + set (current "p") + # value handling + elseif (current STREQUAL "t") + set (target ${arg}) + elseif (current STREQUAL "d") + if (IS_ABSOLUTE "${arg}") + set (destination_dir "${arg}") + else (IS_ABSOLUTE "${arg}") + set (destination_dir "${CMAKE_INSTALL_PREFIX}/${arg}") + endif (IS_ABSOLUTE "${arg}") + elseif (current STREQUAL "p") + set (package ${arg}) + endif (arg STREQUAL "NO_GAC") + endforeach (arg) + + if (NOT destination_dir) + message(FATAL_ERROR "The destination directory is mandatory, even if the assembly is installed into the GAC.") + elseif (NOT target) + message(FATAL_ERROR "No target given.") + endif (NOT destination_dir) + + # retrieve the absolute path of the generated assembly + get_property(filename TARGET ${target} PROPERTY _assembly) + get_property(type TARGET ${target} PROPERTY _assembly_type) + get_property(pc_file TARGET ${target} PROPERTY pkg-config_template_basename) + + if (NOT pc_file) + set (pc_file ${target}) + endif (NOT pc_file) + + # default assembly location (for pkg-config) + set(assembly "${GAC_DIR}/${package}/${target}.dll") + + if (NOT filename) + message(FATAL_ERROR "Couldn't retrieve the assembly filename for target ${target}! Are you sure the target is a .NET library assembly?") + endif (NOT filename) + + if (package) + set (package_option "-package ${package}") + endif (package) + + if (NOT MONO_FOUND OR no_gac OR type STREQUAL "exe") + install(FILES "${filename}" DESTINATION ${destination_dir}) + if (EXISTS "${filename}.config") + install(FILES "${filename}.config" DESTINATION ${destination_dir}) + endif (EXISTS "${filename}.config") + + # don't install anything into the GAC + set (no_gac TRUE) + # set new assembly location for pkg-config + set(assembly "${destination_dir}/${target}.${type}") + endif (NOT MONO_FOUND OR no_gac OR type STREQUAL "exe") + + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${pc_file}.pc.cmake") + configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/${pc_file}.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${pc_file}.pc" @ONLY) + + if (NOT LIB_INSTALL_DIR) + set (LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib) + endif (NOT LIB_INSTALL_DIR) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${pc_file}.pc" DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) + endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${pc_file}.pc.cmake") + + if (no_gac) + return() + endif (no_gac) + + # So we have the mono runtime and we can use gacutil (it has the -root option, which the MS version doesn't have). + install(CODE "execute_process(COMMAND ${GACUTIL_EXECUTABLE} -i ${filename} ${package_option} -root ${CMAKE_CURRENT_BINARY_DIR}/tmp_gac)") + file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/tmp_gac/mono) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp_gac/mono) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp_gac/mono/ DESTINATION ${GAC_DIR} ) +endfunction(install_assembly) + +set(CMAKE_CSharp_INFORMATION_LOADED 1) + diff --git a/cmake/CMakeDetermineCSharpCompiler.cmake b/cmake/CMakeDetermineCSharpCompiler.cmake new file mode 100644 index 0000000..86532eb --- /dev/null +++ b/cmake/CMakeDetermineCSharpCompiler.cmake @@ -0,0 +1,102 @@ +# copyright (c) 2007, 2009 Arno Rehn arno@arnorehn.de +# copyright (c) 2008 Helio castro helio@kde.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# determine the compiler to use for C# programs +# NOTE, a generator may set CMAKE_CSharp_COMPILER before +# loading this file to force a compiler. + +if(NOT CMAKE_CSharp_COMPILER) + # prefer the environment variable CSC + if($ENV{CSC} MATCHES ".+") + if (EXISTS $ENV{CSC}) + message(STATUS "Found compiler set in environment variable CSC: $ENV{CSC}.") + set(CMAKE_CSharp_COMPILER $ENV{CSC}) + else (EXISTS $ENV{CSC}) + message(SEND_ERROR "Could not find compiler set in environment variable CSC:\n$ENV{CSC}.") + endif (EXISTS $ENV{CSC}) + endif($ENV{CSC} MATCHES ".+") + + # if no compiler has been specified yet, then look for one + if (NOT CMAKE_CSharp_COMPILER) + find_package(Mono) + set (CMAKE_CSharp_COMPILER "${GMCS_EXECUTABLE}") + + # still not found, try csc.exe + if (NOT CMAKE_CSharp_COMPILER) + get_filename_component(dotnet_path "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework;InstallRoot]" PATH) + find_program(CMAKE_CSharp_COMPILER NAMES csc PATHS "${dotnet_path}/Framework/v2.0.50727") + file(TO_NATIVE_PATH "${dotnet_path}/Framework/v2.0.50727" native_path) + message(STATUS "Looking for csc: ${CMAKE_CSharp_COMPILER}") + + # give up + if (NOT CMAKE_CSharp_COMPILER) + message (STATUS "Couldn't find a valid C# compiler. Set either CMake_CSharp_COMPILER or the CSC environment variable to a valid path.") + endif (NOT CMAKE_CSharp_COMPILER) + endif (NOT CMAKE_CSharp_COMPILER) + endif (NOT CMAKE_CSharp_COMPILER) + +endif(NOT CMAKE_CSharp_COMPILER) + +# now try to find the gac location +if (CMAKE_CSharp_COMPILER AND NOT GAC_DIR AND MONO_FOUND) + find_package(PkgConfig) + + if (PKG_CONFIG_FOUND) + pkg_search_module(MONO_CECIL mono-cecil) + if(MONO_CECIL_FOUND) + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} mono-cecil --variable=assemblies_dir OUTPUT_VARIABLE GAC_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + endif(MONO_CECIL_FOUND) + + pkg_search_module(CECIL cecil) + if(CECIL_FOUND) + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} cecil --variable=assemblies_dir OUTPUT_VARIABLE GAC_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + endif(CECIL_FOUND) + + if (NOT GAC_DIR) + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} mono --variable=libdir OUTPUT_VARIABLE MONO_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + if (MONO_LIB_DIR) + set (GAC_DIR "${MONO_LIB_DIR}/mono") + message (STATUS "Could not find cecil, guessing GAC dir from mono prefix: ${GAC_DIR}") + endif (MONO_LIB_DIR) + endif (NOT GAC_DIR) + endif (PKG_CONFIG_FOUND) + + if (NOT GAC_DIR) + set (GAC_DIR "/usr/lib/mono") + message(STATUS "Could not find cecil or mono. Using default GAC dir: ${GAC_DIR}") + endif (NOT GAC_DIR) +endif (CMAKE_CSharp_COMPILER AND NOT GAC_DIR AND MONO_FOUND) + +# Create a cache entry so the user can modify this. +set(GAC_DIR "${GAC_DIR}" CACHE PATH "Location of the GAC") +message(STATUS "Using GAC dir: ${GAC_DIR}") + +mark_as_advanced(CMAKE_CSharp_COMPILER) + +if (CMAKE_CSharp_COMPILER) + set (CMAKE_CSharp_COMPILER_LOADED 1) +endif (CMAKE_CSharp_COMPILER) + +# configure variables set in this file for fast reload later on +if(NOT CMAKE_PLATFORM_INFO_DIR) # pre-2.8.10 + set(CMAKE_PLATFORM_INFO_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) +endif() + +configure_file(${CMAKE_SOURCE_DIR}/cmake/CMakeCSharpCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCSharpCompiler.cmake IMMEDIATE @ONLY) +set(CMAKE_CSharp_COMPILER_ENV_VAR "CSC") + diff --git a/cmake/CMakeTestCSharpCompiler.cmake b/cmake/CMakeTestCSharpCompiler.cmake new file mode 100644 index 0000000..8b0e9a2 --- /dev/null +++ b/cmake/CMakeTestCSharpCompiler.cmake @@ -0,0 +1,2 @@ +SET(CMAKE_CSharp_COMPILER_WORKS 1 CACHE INTERNAL "") + diff --git a/cmake/FindMono.cmake b/cmake/FindMono.cmake new file mode 100644 index 0000000..d4aa0ca --- /dev/null +++ b/cmake/FindMono.cmake @@ -0,0 +1,37 @@ +# - Try to find the mono, mcs, gmcs and gacutil +# +# defines +# +# MONO_FOUND - system has mono, mcs, gmcs and gacutil +# MONO_PATH - where to find 'mono' +# GMCS_PATH - where to find 'gmcs' +# GACUTIL_PATH - where to find 'gacutil' +# +# copyright (c) 2007 Arno Rehn arno@arnorehn.de +# +# Redistribution and use is allowed according to the terms of the GPL license. + +FIND_PROGRAM (MONO_EXECUTABLE mono) +FIND_PROGRAM (GMCS_EXECUTABLE NAMES gmcs mcs) +FIND_PROGRAM (GACUTIL_EXECUTABLE gacutil) + +SET (MONO_FOUND FALSE CACHE INTERNAL "") + +IF (MONO_EXECUTABLE AND GMCS_EXECUTABLE AND GACUTIL_EXECUTABLE) + SET (MONO_FOUND TRUE CACHE INTERNAL "") +ENDIF (MONO_EXECUTABLE AND GMCS_EXECUTABLE AND GACUTIL_EXECUTABLE) + +IF (NOT Mono_FIND_QUIETLY) + MESSAGE(STATUS "Path of mono: ${MONO_EXECUTABLE}") + MESSAGE(STATUS "Path of gmcs: ${GMCS_EXECUTABLE}") + MESSAGE(STATUS "Path of gacutil: ${GACUTIL_EXECUTABLE}") +ENDIF (NOT Mono_FIND_QUIETLY) + +IF (NOT MONO_FOUND) + IF (Mono_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find one or more of the following programs: mono, gmcs, gacutil") + ENDIF (Mono_FIND_REQUIRED) +ENDIF (NOT MONO_FOUND) + +MARK_AS_ADVANCED(MONO_EXECUTABLE GMCS_EXECUTABLE GACUTIL_EXECUTABLE) + diff --git a/cmake/FindPython2Interp.cmake b/cmake/FindPython2Interp.cmake new file mode 100644 index 0000000..fbece44 --- /dev/null +++ b/cmake/FindPython2Interp.cmake @@ -0,0 +1,145 @@ +#.rst: +# FindPython2Interp +# ---------------- +# +# Find python 3 interpreter (based on original FindPythonInterp from cmake) +# +# This module finds if Python interpreter is installed and determines +# where the executables are. This code sets the following variables: +# +# :: +# +# PYTHON2INTERP_FOUND - Was the Python executable found +# PYTHON2_EXECUTABLE - path to the Python interpreter +# +# +# +# :: +# +# PYTHON2_VERSION_STRING - Python version found e.g. 2.5.1 +# PYTHON2_VERSION_MAJOR - Python major version found e.g. 1 +# PYTHON2_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON2_VERSION_PATCH - Python patch version found e.g. 1 +# +#============================================================================= +# Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks +# Copyright 2012 Rolf Eike Beer +# Copyright 2016 Dominique Leuenberger +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +unset(_Python2_NAMES) + +set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) + +if(Python2Interp_FIND_VERSION) + if(Python2Interp_FIND_VERSION_COUNT GREATER 1) + set(_PYTHON2_FIND_MAJ_MIN "${Python2Interp_FIND_VERSION_MAJOR}.${Python2Interp_FIND_VERSION_MINOR}") + list(APPEND _Python2_NAMES + python${_PYTHON2_FIND_MAJ_MIN} + python${Python2Interp_FIND_VERSION_MAJOR}) + unset(_PYTHON2_FIND_OTHER_VERSIONS) + if(NOT Python2Interp_FIND_VERSION_EXACT) + foreach(_PYTHON2_V ${_PYTHON${Python2Interp_FIND_VERSION_MAJOR}_VERSIONS}) + if(NOT _PYTHON2_V VERSION_LESS _PYTHON2_FIND_MAJ_MIN) + list(APPEND _PYTHON2_FIND_OTHER_VERSIONS ${_PYTHON2_V}) + endif() + endforeach() + endif() + unset(_PYTHON2_FIND_MAJ_MIN) + else() + list(APPEND _Python2_NAMES python${Python2Interp_FIND_VERSION_MAJOR}) + set(_PYTHON2_FIND_OTHER_VERSIONS ${_PYTHON${Python2Interp_FIND_VERSION_MAJOR}_VERSIONS}) + endif() +else() + set(_PYTHON2_FIND_OTHER_VERSIONS ${_PYTHON2_VERSIONS}) +endif() +find_program(PYTHON2_EXECUTABLE NAMES ${_Python2_NAMES}) + +# If FindPythonInterp has already found the major and minor version, +# insert that version next to get consistent versions of the interpreter and +# library. +if(DEFINED PYTHON2LIBS_VERSION_STRING) + string(REPLACE "." ";" _PYTHON2LIBS_VERSION "${PYTHON2LIBS_VERSION_STRING}") + list(GET _PYTHON2LIBS_VERSION 0 _PYTHON2LIBS_VERSION_MAJOR) + list(GET _PYTHON2LIBS_VERSION 1 _PYTHON2LIBS_VERSION_MINOR) + list(APPEND _Python2_VERSIONS ${_PYTHON2LIBS_VERSION_MAJOR}.${_PYTHON2LIBS_VERSION_MINOR}) +endif() +# Search for the current active python version first +list(APPEND _Python2_VERSIONS ";") + +unset(_PYTHON2_VERSIONS) + +# Search for newest python version if python executable isn't found +if(NOT PYTHON2_EXECUTABLE) + foreach(_CURRENT_VERSION IN LISTS _Python2_VERSIONS) + set(_Python2_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python2_NAMES python) + endif() + find_program(PYTHON2_EXECUTABLE + NAMES ${_Python2_NAMES} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + ) + endforeach() +endif() + +# determine python version string +if(PYTHON2_EXECUTABLE) + execute_process(COMMAND "${PYTHON2_EXECUTABLE}" -c + "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON2_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON2_VERSION_RESULT) + string(REPLACE ";" "." PYTHON2_VERSION_STRING "${_VERSION}") + list(GET _VERSION 0 PYTHON2_VERSION_MAJOR) + list(GET _VERSION 1 PYTHON2_VERSION_MINOR) + list(GET _VERSION 2 PYTHON2_VERSION_PATCH) + if(PYTHON2_VERSION_PATCH EQUAL 0) + # it's called "Python 3.1", not "3.1.0" + string(REGEX REPLACE "\\.0$" "" PYTHON2_VERSION_STRING "${PYTHON2_VERSION_STRING}") + endif() + else() + # sys.version predates sys.version_info, so use that + execute_process(COMMAND "${PYTHON2_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON2_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON2_VERSION_RESULT) + string(REGEX REPLACE " .*" "" PYTHON2_VERSION_STRING "${_VERSION}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON2_VERSION_MAJOR "${PYTHON2_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON2_VERSION_MINOR "${PYTHON2_VERSION_STRING}") + if(PYTHON2_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)") + set(PYTHON2_VERSION_PATCH "${CMAKE_MATCH_1}") + else() + set(PYTHON2_VERSION_PATCH "0") + endif() + else() + # sys.version was first documented for Python 1.5, so assume + # this is older. + set(PYTHON2_VERSION_STRING "1.4") + set(PYTHON2_VERSION_MAJOR "1") + set(PYTHON2_VERSION_MINOR "4") + set(PYTHON2_VERSION_PATCH "0") + endif() + endif() + unset(_PYTHON2_VERSION_RESULT) + unset(_VERSION) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PYTHON2INTERP_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python2Interp REQUIRED_VARS PYTHON2_EXECUTABLE VERSION_VAR PYTHON2_VERSION_STRING) + +mark_as_advanced(PYTHON2_EXECUTABLE) diff --git a/cmake/FindPython3Interp.cmake b/cmake/FindPython3Interp.cmake new file mode 100644 index 0000000..c6cbe3d --- /dev/null +++ b/cmake/FindPython3Interp.cmake @@ -0,0 +1,145 @@ +#.rst: +# FindPython3Interp +# ---------------- +# +# Find python 3 interpreter (based on original FindPythonInterp from cmake) +# +# This module finds if Python interpreter is installed and determines +# where the executables are. This code sets the following variables: +# +# :: +# +# PYTHON3INTERP_FOUND - Was the Python executable found +# PYTHON3_EXECUTABLE - path to the Python interpreter +# +# +# +# :: +# +# PYTHON3_VERSION_STRING - Python version found e.g. 3.5.1 +# PYTHON3_VERSION_MAJOR - Python major version found e.g. 3 +# PYTHON3_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON3_VERSION_PATCH - Python patch version found e.g. 1 +# +#============================================================================= +# Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks +# Copyright 2012 Rolf Eike Beer +# Copyright 2016 Dominique Leuenberger +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +unset(_Python3_NAMES) + +set(_Python3_VERSIONS 3.6 3.5 3.4 3.3 3.2 3.1 3.0) + +if(Python3Interp_FIND_VERSION) + if(Python3Interp_FIND_VERSION_COUNT GREATER 1) + set(_PYTHON3_FIND_MAJ_MIN "${Python3Interp_FIND_VERSION_MAJOR}.${Python3Interp_FIND_VERSION_MINOR}") + list(APPEND _Python3_NAMES + python${_PYTHON3_FIND_MAJ_MIN} + python${Python3Interp_FIND_VERSION_MAJOR}) + unset(_PYTHON3_FIND_OTHER_VERSIONS) + if(NOT Python3Interp_FIND_VERSION_EXACT) + foreach(_PYTHON3_V ${_PYTHON${Python3Interp_FIND_VERSION_MAJOR}_VERSIONS}) + if(NOT _PYTHON3_V VERSION_LESS _PYTHON3_FIND_MAJ_MIN) + list(APPEND _PYTHON3_FIND_OTHER_VERSIONS ${_PYTHON3_V}) + endif() + endforeach() + endif() + unset(_PYTHON3_FIND_MAJ_MIN) + else() + list(APPEND _Python3_NAMES python${Python3Interp_FIND_VERSION_MAJOR}) + set(_PYTHON3_FIND_OTHER_VERSIONS ${_PYTHON${Python3Interp_FIND_VERSION_MAJOR}_VERSIONS}) + endif() +else() + set(_PYTHON3_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS}) +endif() +find_program(PYTHON3_EXECUTABLE NAMES ${_Python3_NAMES}) + +# If FindPythonInterp has already found the major and minor version, +# insert that version next to get consistent versions of the interpreter and +# library. +if(DEFINED PYTHON3LIBS_VERSION_STRING) + string(REPLACE "." ";" _PYTHON3LIBS_VERSION "${PYTHON3LIBS_VERSION_STRING}") + list(GET _PYTHON3LIBS_VERSION 0 _PYTHON3LIBS_VERSION_MAJOR) + list(GET _PYTHON3LIBS_VERSION 1 _PYTHON3LIBS_VERSION_MINOR) + list(APPEND _Python3_VERSIONS ${_PYTHON3LIBS_VERSION_MAJOR}.${_PYTHON3LIBS_VERSION_MINOR}) +endif() +# Search for the current active python version first +list(APPEND _Python3_VERSIONS ";") + +unset(_PYTHON3_VERSIONS) + +# Search for newest python version if python executable isn't found +if(NOT PYTHON3_EXECUTABLE) + foreach(_CURRENT_VERSION IN LISTS _Python3_VERSIONS) + set(_Python3_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python3_NAMES python3) + endif() + find_program(PYTHON3_EXECUTABLE + NAMES ${_Python3_NAMES} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + ) + endforeach() +endif() + +# determine python version string +if(PYTHON3_EXECUTABLE) + execute_process(COMMAND "${PYTHON3_EXECUTABLE}" -c + "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" + OUTPUT_VARIABLE _VERSION3 + RESULT_VARIABLE _PYTHON3_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON3_VERSION_RESULT) + string(REPLACE ";" "." PYTHON3_VERSION_STRING "${_VERSION3}") + list(GET _VERSION3 0 PYTHON3_VERSION_MAJOR) + list(GET _VERSION3 1 PYTHON3_VERSION_MINOR) + list(GET _VERSION3 2 PYTHON3_VERSION_PATCH) + if(PYTHON3_VERSION_PATCH EQUAL 0) + # it's called "Python 3.1", not "3.1.0" + string(REGEX REPLACE "\\.0$" "" PYTHON3_VERSION_STRING "${PYTHON3_VERSION_STRING}") + endif() + else() + # sys.version predates sys.version_info, so use that + execute_process(COMMAND "${PYTHON3_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + OUTPUT_VARIABLE _VERSION3 + RESULT_VARIABLE _PYTHON3_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON3_VERSION_RESULT) + string(REGEX REPLACE " .*" "" PYTHON3_VERSION_STRING "${_VERSION3}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON3_VERSION_MAJOR "${PYTHON3_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON3_VERSION_MINOR "${PYTHON3_VERSION_STRING}") + if(PYTHON3_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)") + set(PYTHON3_VERSION_PATCH "${CMAKE_MATCH_1}") + else() + set(PYTHON3_VERSION_PATCH "0") + endif() + else() + # sys.version was first documented for Python 1.5, so assume + # this is older. + set(PYTHON3_VERSION_STRING "1.4") + set(PYTHON3_VERSION_MAJOR "1") + set(PYTHON3_VERSION_MINOR "4") + set(PYTHON3_VERSION_PATCH "0") + endif() + endif() + unset(_PYTHON3_VERSION_RESULT) + unset(_VERSION3) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PYTHON3INTERP_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Python3Interp REQUIRED_VARS PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING) + +mark_as_advanced(PYTHON3_EXECUTABLE) diff --git a/cmake/mingw32.cmake b/cmake/mingw32.cmake new file mode 100644 index 0000000..9f04ebf --- /dev/null +++ b/cmake/mingw32.cmake @@ -0,0 +1,19 @@ +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER i686-pc-mingw32-gcc) +SET(CMAKE_CXX_COMPILER i686-pc-mingw32-g++) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32 ) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# We want libgcc being statically linked. Everything else is annoying +set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -static-libgcc") diff --git a/samples/dotnet/Makefile b/samples/dotnet/Makefile new file mode 100644 index 0000000..587f83b --- /dev/null +++ b/samples/dotnet/Makefile @@ -0,0 +1,8 @@ + +all: proxy.exe + +proxy.exe: proxy.cs + gmcs -pkg:libproxy-sharp-1.0 proxy.cs + +clean: + rm proxy.exe diff --git a/samples/libcurl/Makefile b/samples/libcurl/Makefile new file mode 100644 index 0000000..35b4597 --- /dev/null +++ b/samples/libcurl/Makefile @@ -0,0 +1,9 @@ + + +all: curlget + +curlget: curlget.c + gcc curlget.c -o curlget -Wall -lcurl -std=c99 $(shell pkg-config --libs libproxy-1.0) + +clean: + rm curlget diff --git a/samples/vala/Makefile b/samples/vala/Makefile new file mode 100644 index 0000000..3e42a34 --- /dev/null +++ b/samples/vala/Makefile @@ -0,0 +1,7 @@ +all: sample + +sample: sample.vala + valac --pkg libproxy-1.0 sample.vala + +clean: + rm sample