Revision: 7456 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7456 Author: zmatsuo Date: 2019-03-03 01:18:47 +0900 (Sun, 03 Mar 2019) Log Message: ----------- cmakeを使用したビルドを追加(experimental) Modified Paths: -------------- trunk/doc/convtext.bat Added Paths: ----------- trunk/CMakeLists.txt trunk/TTProxy/CMakeLists.txt trunk/TTXKanjiMenu/CMakeLists.txt trunk/TTXSamples/CMakeLists.txt trunk/TTXSamples/TTXAdditionalTitle/CMakeLists.txt trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt trunk/TTXSamples/TTXCallSysMenu/CMakeLists.txt trunk/TTXSamples/TTXCommandLineOpt/CMakeLists.txt trunk/TTXSamples/TTXCopyIniFile/CMakeLists.txt trunk/TTXSamples/TTXFixedWinSize/CMakeLists.txt trunk/TTXSamples/TTXKcodeChange/CMakeLists.txt trunk/TTXSamples/TTXOutputBuffering/CMakeLists.txt trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt trunk/TTXSamples/TTXResizeMenu/CMakeLists.txt trunk/TTXSamples/TTXResizeWin/CMakeLists.txt trunk/TTXSamples/TTXShowCommandLine/CMakeLists.txt trunk/TTXSamples/TTXViewMode/CMakeLists.txt trunk/TTXSamples/TTXttyrec/CMakeLists.txt trunk/TTXSamples/ttxtest/CMakeLists.txt trunk/doc/Markdown_1.0.1/ trunk/doc/Markdown_1.0.1/License.text trunk/doc/Markdown_1.0.1/Markdown Readme.text trunk/doc/Markdown_1.0.1/Markdown.pl trunk/doc/ja/html/reference/build_with_cmake.md trunk/libs/.gitignore trunk/libs/SFMT.cmake trunk/libs/VSToolchain.cmake trunk/libs/build_library_with_cmake.md trunk/libs/buildall.cmake trunk/libs/buildall_cmake.bat trunk/libs/getcmake.bat trunk/libs/getcmake.ps1 trunk/libs/lib_SFMT.cmake trunk/libs/lib_oniguruma.cmake trunk/libs/lib_openssl.cmake trunk/libs/lib_zlib.cmake trunk/libs/oniguruma.cmake trunk/libs/openssl.cmake trunk/libs/putty.cmake trunk/libs/script_support.cmake trunk/libs/zlib.cmake trunk/mingw.toolchain.cmake trunk/teraterm/CMakeLists.txt trunk/teraterm/keycode/CMakeLists.txt trunk/teraterm/svnrev/CMakeLists.txt trunk/teraterm/teraterm/CMakeLists.txt trunk/teraterm/ttpcmn/CMakeLists.txt trunk/teraterm/ttpdlg/CMakeLists.txt trunk/teraterm/ttpdlg/svnversion.h.in trunk/teraterm/ttpfile/CMakeLists.txt trunk/teraterm/ttpmacro/CMakeLists.txt trunk/teraterm/ttpset/CMakeLists.txt trunk/teraterm/ttptek/CMakeLists.txt trunk/ttpmenu/CMakeLists.txt trunk/ttssh2/CMakeLists.txt trunk/ttssh2/matcher/CMakeLists.txt trunk/ttssh2/putty/CMakeLists.txt trunk/ttssh2/puttyrev/CMakeLists.txt trunk/ttssh2/ttssh/CMakeLists.txt trunk/ttssh2/ttxssh/CMakeLists.txt trunk/version_info.h.in -------------- next part -------------- Added: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt (rev 0) +++ trunk/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,87 @@ + +cmake_minimum_required(VERSION 3.6) + +project(teraterm_all) + +option(ENABLE_TTXSAMPLES "TTXSamples" ON) +option(USE_UNICODE_API "unicode" OFF) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +set(CMAKE_CONFIGURATION_TYPES "Debug;Release") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +# _WIN32_WINNT_WIN10 0x0a00 +set(_WIN32_WINNT "0x0a00") +if(MSVC) + # https://www.leeholmes.com/blog/2017/02/27/differences-between-visual-studio-2012-2013-and-2015/ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN32_WINNT=${_WIN32_WINNT}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_WIN32_WINNT=${_WIN32_WINNT}") + string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) + string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /W3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_DEPRECATE /W3") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GF /Gy") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GF /Gy") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /ZI") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") + endif() +elseif(MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=${_WIN32_WINNT}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WIN32_WINNT=${_WIN32_WINNT}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra " + "-Wno-unused-parameter -static -ffunction-sections -fdata-sections ${C_ONLY_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra " + "-Wno-unused-parameter -static -ffunction-sections -fdata-sections") + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") + endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections") +endif() + +### create version_info.h +if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + # git-svn + find_package(Git) + if(Git_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} svn log --oneline -1 + OUTPUT_VARIABLE ov) + string(REGEX MATCH "[0-9]+" SVNVERSION ${ov}) + endif() +elseif(EXISTS "${CMAKE_SOURCE_DIR}/.svn") + # svn + find_package(Subversion) + if(SUBVERSION_FOUND) + Subversion_WC_INFO(${CMAKE_SOURCE_DIR} TT) + set(SVNVERSION "${TT_WC_REVISION}") + endif() +else() + # build without svn,git? + #set(SVNVERSION "0000") +endif() +configure_file( + version_info.h.in + version_info.h + @ONLY) +message("revision=\"${SVNVERSION}\"") + +#### +add_subdirectory(teraterm) +add_subdirectory(ttpmenu) +add_subdirectory(TTProxy) +add_subdirectory(ttssh2) +add_subdirectory(TTXKanjiMenu) +if(${ENABLE_TTXSAMPLES}) + add_subdirectory(TTXSamples) +endif() Added: trunk/TTProxy/CMakeLists.txt =================================================================== --- trunk/TTProxy/CMakeLists.txt (rev 0) +++ trunk/TTProxy/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,111 @@ +project(ttproxy) + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../libs/lib_openssl.cmake) + +set(COMMON_SRC + ../teraterm/common/ttlib.h + ../teraterm/common/ttlib.c + ../teraterm/common/i18n.h + ../teraterm/common/ttplugin.h + ../teraterm/common/tttypes.h + ../teraterm/common/tt-version.h + ../teraterm/common/codeconv.h + ../teraterm/common/codeconv.cpp + ../teraterm/common/dlglib.h + ../teraterm/common/dlglib.c + ../teraterm/teraterm/ttdialog.h + ../teraterm/teraterm/ttfileio.h + ../teraterm/teraterm/ttsetup.h + ../teraterm/teraterm/ttwsk.h + ) +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(YCL_SRC + YCL/include/YCL/Array.h + YCL/include/YCL/ComboBoxCtrl.h + YCL/include/YCL/common.h + YCL/include/YCL/Dialog.h + YCL/include/YCL/DynamicLinkLibrary.h + YCL/include/YCL/EditBoxCtrl.h + YCL/include/YCL/Enumeration.h + YCL/include/YCL/FileVersion.h + YCL/include/YCL/HASHCODE.h + YCL/include/YCL/Hashtable.h + YCL/include/YCL/IniFile.h + YCL/include/YCL/Integer.h + YCL/include/YCL/Object.h + YCL/include/YCL/Pointer.h + YCL/include/YCL/Resource.h + YCL/include/YCL/String.h + YCL/include/YCL/StringBuffer.h + YCL/include/YCL/StringUtil.h + YCL/include/YCL/ValueCtrl.h + YCL/include/YCL/Vector.h + YCL/include/YCL/Window.h + ) +source_group( + "YCL" + FILES + ${YCL_SRC} + ) + +set(SRC + Hooker.h + Logger.h + ProxyWSockHook.h + resource.h + SSLLIB.h + SSLSocket.h + StdAfx.cpp + StdAfx.h + TTProxy.cpp + TTProxy.h + TTProxy.rc + TTX.def + ) + +include_directories( + ../teraterm/teraterm + ../teraterm/common + YCL/include + ${OPENSSL_INCLUDE_DIRS} + . + ) + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-uTTXBind @ 8") + +add_library( + ttproxy SHARED + ${SRC} + ${COMMON_SRC} + ${YCL_SRC} + ) + +if(MINGW) + set_target_properties( + ttproxy + PROPERTIES + PREFIX "" + OUTPUT_NAME "TTXProxy" + ) +endif() + +target_link_libraries( + ttproxy + ttpcmn + # + ws2_32 + version + gdi32 + comdlg32 + ) Added: trunk/TTXKanjiMenu/CMakeLists.txt =================================================================== --- trunk/TTXKanjiMenu/CMakeLists.txt (rev 0) +++ trunk/TTXKanjiMenu/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,34 @@ +project(ttxkanjimenu) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(SRC + resource.h + ttxkanjimenu.c + ttxkanjimenu.rc + ) + +include_directories( + ../teraterm/teraterm + ../teraterm/common + ../libs/openssl/inc32 + . + ) + +add_library( + ttxkanjimenu SHARED + ${SRC} + ) + +target_link_libraries( + ttxkanjimenu + ttpcmn + # + ws2_32 + ) + + Added: trunk/TTXSamples/CMakeLists.txt =================================================================== --- trunk/TTXSamples/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,48 @@ + +add_subdirectory(TTXAdditionalTitle) +set_target_properties(TTXAdditionalTitle PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXAlwaysOnTop) +set_target_properties(TTXAlwaysOnTop PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXCallSysMenu) +set_target_properties(TTXCallSysMenu PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXCommandLineOpt) +set_target_properties(TTXCommandLineOpt PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXCopyIniFile) +set_target_properties(TTXCopyIniFile PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXFixedWinSize) +set_target_properties(TTXFixedWinSize PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXKcodeChange) +set_target_properties(TTXKcodeChange PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXOutputBuffering) +set_target_properties(TTXOutputBuffering PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXRecurringCommand) +set_target_properties(TTXRecurringCommand PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXResizeMenu) +set_target_properties(TTXResizeMenu PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXResizeWin) +set_target_properties(TTXResizeWin PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXShowCommandLine) +set_target_properties(TTXShowCommandLine PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXtest) +set_target_properties(TTXtest PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXttyrec) +set_target_properties(TTXttyrec PROPERTIES FOLDER TTXSamples) +set_target_properties(TTXttyplay PROPERTIES FOLDER TTXSamples) + +add_subdirectory(TTXViewMode) +set_target_properties(TTXViewMode PROPERTIES FOLDER TTXSamples) + + Added: trunk/TTXSamples/TTXAdditionalTitle/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXAdditionalTitle/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXAdditionalTitle/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,26 @@ +project(TTXAdditionalTitle) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXAdditionalTitle.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXAdditionalTitle SHARED + ${SRC} + ) + +target_link_libraries( + TTXAdditionalTitle + ttpcmn + ) + + Added: trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXAlwaysOnTop/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,30 @@ +project(TTXAlwaysOnTop) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(SRC + TTXAlwaysOnTop.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXAlwaysOnTop SHARED + ${SRC} + ) + +target_link_libraries( + TTXAlwaysOnTop + ttpcmn + ) + + Added: trunk/TTXSamples/TTXCallSysMenu/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCallSysMenu/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXCallSysMenu/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,19 @@ +project(TTXCallSysMenu) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXCallSysMenu.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXCallSysMenu SHARED + ${SRC} + ) Added: trunk/TTXSamples/TTXCommandLineOpt/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCommandLineOpt/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXCommandLineOpt/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,26 @@ +project(TTXCommandLineOpt) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXCommandLineOpt.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXCommandLineOpt SHARED + ${SRC} + ) + +target_link_libraries( + TTXCommandLineOpt + ttpcmn + ) + + Added: trunk/TTXSamples/TTXCopyIniFile/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXCopyIniFile/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXCopyIniFile/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,21 @@ +project(TTXCopyIniFile) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXCopyIniFile.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXCopyIniFile SHARED + ${SRC} + ) + + Added: trunk/TTXSamples/TTXFixedWinSize/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXFixedWinSize/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXFixedWinSize/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,21 @@ +project(TTXFixedWinSize) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXFixedWinSize.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXFixedWinSize SHARED + ${SRC} + ) + + Added: trunk/TTXSamples/TTXKcodeChange/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXKcodeChange/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXKcodeChange/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,21 @@ +project(TTXKcodeChange) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXKcodeChange.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXKcodeChange SHARED + ${SRC} + ) + + Added: trunk/TTXSamples/TTXOutputBuffering/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXOutputBuffering/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXOutputBuffering/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,21 @@ +project(TTXOutputBuffering) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXOutputBuffering.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXOutputBuffering SHARED + ${SRC} + ) + + Added: trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXRecurringCommand/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,42 @@ +project(TTXRecurringCommand) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(COMMON_SRC + ../../teraterm/common/dlglib.h + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + TTXRecurringCommand.c + TTXRecurringCommand.rc + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXRecurringCommand SHARED + ${SRC} + ${COMMON_SRC} + ) + +target_link_libraries( + TTXRecurringCommand + ttpcmn + # + gdi32 + ) Added: trunk/TTXSamples/TTXResizeMenu/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXResizeMenu/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXResizeMenu/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,31 @@ +project(TTXResizeMenu) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXResizeMenu.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +if (MSVC) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:user32.dll") +endif() + +add_library( + TTXResizeMenu SHARED + ${SRC} + ) + +target_link_libraries( + TTXResizeMenu + ttpcmn + delayimp + ) + + Added: trunk/TTXSamples/TTXResizeWin/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXResizeWin/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXResizeWin/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,21 @@ +project(TTXResizeWin) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXResizeWin.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXResizeWin SHARED + ${SRC} + ) + + Added: trunk/TTXSamples/TTXShowCommandLine/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXShowCommandLine/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXShowCommandLine/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,21 @@ +project(TTXShowCommandLine) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + TTXShowCommandLine.c + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXShowCommandLine SHARED + ${SRC} + ) + + Added: trunk/TTXSamples/TTXViewMode/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXViewMode/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXViewMode/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,22 @@ +project(TTXViewMode) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + resource.h + TTXViewMode.c + TTXViewMode.h + TTXViewMode.rc + ReadMe.txt + ReadMe-ja.txt + ) + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXViewMode SHARED + ${SRC} + ) Added: trunk/TTXSamples/TTXttyrec/CMakeLists.txt =================================================================== --- trunk/TTXSamples/TTXttyrec/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/TTXttyrec/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,45 @@ +project(TTXttyrec) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXttyplay SHARED + TTXttyplay.c + gettimeofday.c + gettimeofday.h + ReadMe.txt + ReadMe-ja.txt + ) + +target_link_libraries( + TTXttyplay + ttpcmn + # + comdlg32 + ) + +add_library( + TTXttyrec SHARED + TTXttyrec.c + gettimeofday.c + gettimeofday.h + ReadMe.txt + ReadMe-ja.txt + ) + +target_link_libraries( + TTXttyrec + ttpcmn + comdlg32 + ) + +set_target_properties( + TTXttyrec TTXttyplay + PROPERTIES + PREFIX "" + ) Added: trunk/TTXSamples/ttxtest/CMakeLists.txt =================================================================== --- trunk/TTXSamples/ttxtest/CMakeLists.txt (rev 0) +++ trunk/TTXSamples/ttxtest/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,13 @@ +project(TTXtest) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ) + +add_library( + TTXtest SHARED + TTXtest.c + ) Added: trunk/doc/Markdown_1.0.1/License.text =================================================================== --- trunk/doc/Markdown_1.0.1/License.text (rev 0) +++ trunk/doc/Markdown_1.0.1/License.text 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,30 @@ +Copyright (c) 2004, John Gruber +<http://daringfireball.net/> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name "Markdown" nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as +is" and any express or implied warranties, including, but not limited +to, the implied warranties of merchantability and fitness for a +particular purpose are disclaimed. In no event shall the copyright owner +or contributors be liable for any direct, indirect, incidental, special, +exemplary, or consequential damages (including, but not limited to, +procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. Added: trunk/doc/Markdown_1.0.1/Markdown Readme.text =================================================================== --- trunk/doc/Markdown_1.0.1/Markdown Readme.text (rev 0) +++ trunk/doc/Markdown_1.0.1/Markdown Readme.text 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,341 @@ +Markdown +======== + +Version 1.0.1 - Tue 14 Dec 2004 + +by John Gruber +<http://daringfireball.net/> + + +Introduction +------------ + +Markdown is a text-to-HTML conversion tool for web writers. Markdown +allows you to write using an easy-to-read, easy-to-write plain text +format, then convert it to structurally valid XHTML (or HTML). + +Thus, "Markdown" is two things: a plain text markup syntax, and a +software tool, written in Perl, that converts the plain text markup +to HTML. + +Markdown works both as a Movable Type plug-in and as a standalone Perl +script -- which means it can also be used as a text filter in BBEdit +(or any other application that supporst filters written in Perl). + +Full documentation of Markdown's syntax and configuration options is +available on the web: <http://daringfireball.net/projects/markdown/>. +(Note: this readme file is formatted in Markdown.) + + + +Installation and Requirements +----------------------------- + +Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century. +Markdown also requires the standard Perl library module `Digest::MD5`. + + +### Movable Type ### + +Markdown works with Movable Type version 2.6 or later (including +MT 3.0 or later). + +1. Copy the "Markdown.pl" file into your Movable Type "plugins" + directory. The "plugins" directory should be in the same directory + as "mt.cgi"; if the "plugins" directory doesn't already exist, use + your FTP program to create it. Your installation should look like + this: + + (mt home)/plugins/Markdown.pl + +2. Once installed, Markdown will appear as an option in Movable Type's + Text Formatting pop-up menu. This is selectable on a per-post basis. + Markdown translates your posts to HTML when you publish; the posts + themselves are stored in your MT database in Markdown format. + +3. If you also install SmartyPants 1.5 (or later), Markdown will offer + a second text formatting option: "Markdown with SmartyPants". This + option is the same as the regular "Markdown" formatter, except that + automatically uses SmartyPants to create typographically correct + curly quotes, em-dashes, and ellipses. See the SmartyPants web page + for more information: <http://daringfireball.net/projects/smartypants/> + +4. To make Markdown (or "Markdown with SmartyPants") your default + text formatting option for new posts, go to Weblog Config -> + Preferences. + +Note that by default, Markdown produces XHTML output. To configure +Markdown to produce HTML 4 output, see "Configuration", below. + + +### Blosxom ### + +Markdown works with Blosxom version 2.x. + +1. Rename the "Markdown.pl" plug-in to "Markdown" (case is + important). Movable Type requires plug-ins to have a ".pl" + extension; Blosxom forbids it. + +2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder. + If you're not sure where your Blosxom plug-ins folder is, see the + Blosxom documentation for information. + +3. That's it. The entries in your weblog will now automatically be + processed by Markdown. + +4. If you'd like to apply Markdown formatting only to certain posts, + rather than all of them, see Jason Clark's instructions for using + Markdown in conjunction with Blosxom's Meta plugin: + + <http://jclark.org/weblog/WebDev/Blosxom/Markdown.html> + + +### BBEdit ### + +Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works +with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.) + +1. Copy the "Markdown.pl" file to appropriate filters folder in your + "BBEdit Support" folder. On Mac OS X, this should be: + + BBEdit Support/Unix Support/Unix Filters/ + + See the BBEdit documentation for more details on the location of + these folders. + + You can rename "Markdown.pl" to whatever you wish. + +2. That's it. To use Markdown, select some text in a BBEdit document, + then choose Markdown from the Filters sub-menu in the "#!" menu, or + the Filters floating palette + + + +Configuration +------------- + +By default, Markdown produces XHTML output for tags with empty elements. +E.g.: + + <br /> + +Markdown can be configured to produce HTML-style tags; e.g.: + + <br> + + +### Movable Type ### + +You need to use a special `MTMarkdownOptions` container tag in each +Movable Type template where you want HTML 4-style output: + + <MTMarkdownOptions output='html4'> + ... put your entry content here ... + </MTMarkdownOptions> + +The easiest way to use MTMarkdownOptions is probably to put the +opening tag right after your `<body>` tag, and the closing tag right +before `</body>`. + +To suppress Markdown processing in a particular template, i.e. to +publish the raw Markdown-formatted text without translation into +(X)HTML, set the `output` attribute to 'raw': + + <MTMarkdownOptions output='raw'> + ... put your entry content here ... + </MTMarkdownOptions> + + +### Command-Line ### + +Use the `--html4tags` command-line switch to produce HTML output from a +Unix-style command line. E.g.: + + % perl Markdown.pl --html4tags foo.text + +Type `perldoc Markdown.pl`, or read the POD documentation within the +Markdown.pl source code for more information. + + + +Bugs +---- + +To file bug reports or feature requests please send email to: +<markd****@darin*****>. + + + +Version History +--------------- + +1.0.1 (14 Dec 2004): + ++ Changed the syntax rules for code blocks and spans. Previously, + backslash escapes for special Markdown characters were processed + everywhere other than within inline HTML tags. Now, the contents + of code blocks and spans are no longer processed for backslash + escapes. This means that code blocks and spans are now treated + literally, with no special rules to worry about regarding + backslashes. + + **NOTE**: This changes the syntax from all previous versions of + Markdown. Code blocks and spans involving backslash characters + will now generate different output than before. + ++ Tweaked the rules for link definitions so that they must occur + within three spaces of the left margin. Thus if you indent a link + definition by four spaces or a tab, it will now be a code block. + + [a]: /url/ "Indented 3 spaces, this is a link def" + + [b]: /url/ "Indented 4 spaces, this is a code block" + + **IMPORTANT**: This may affect existing Markdown content if it + contains link definitions indented by 4 or more spaces. + ++ Added `>`, `+`, and `-` to the list of backslash-escapable + characters. These should have been done when these characters + were added as unordered list item markers. + ++ Trailing spaces and tabs following HTML comments and `<hr/>` tags + are now ignored. + ++ Inline links using `<` and `>` URL delimiters weren't working: + + like [this](<http://example.com/>) + ++ Added a bit of tolerance for trailing spaces and tabs after + Markdown hr's. + ++ Fixed bug where auto-links were being processed within code spans: + + like this: `<http://example.com/>` + ++ Sort-of fixed a bug where lines in the middle of hard-wrapped + paragraphs, which lines look like the start of a list item, + would accidentally trigger the creation of a list. E.g. a + paragraph that looked like this: + + I recommend upgrading to version + 8. Oops, now this line is treated + as a sub-list. + + This is fixed for top-level lists, but it can still happen for + sub-lists. E.g., the following list item will not be parsed + properly: + + + I recommend upgrading to version + 8. Oops, now this line is treated + as a sub-list. + + Given Markdown's list-creation rules, I'm not sure this can + be fixed. + ++ Standalone HTML comments are now handled; previously, they'd get + wrapped in a spurious `<p>` tag. + ++ Fix for horizontal rules preceded by 2 or 3 spaces. + ++ `<hr>` HTML tags in must occur within three spaces of left + margin. (With 4 spaces or a tab, they should be code blocks, but + weren't before this fix.) + ++ Capitalized "With" in "Markdown With SmartyPants" for + consistency with the same string label in SmartyPants.pl. + (This fix is specific to the MT plug-in interface.) + ++ Auto-linked email address can now optionally contain + a 'mailto:' protocol. I.e. these are equivalent: + + <mailto:user****@examp*****> + <user****@examp*****> + ++ Fixed annoying bug where nested lists would wind up with + spurious (and invalid) `<p>` tags. + ++ You can now write empty links: + + [like this]() + + and they'll be turned into anchor tags with empty href attributes. + This should have worked before, but didn't. + ++ `***this***` and `___this___` are now turned into + + <strong><em>this</em></strong> + + Instead of + + <strong><em>this</strong></em> + + which isn't valid. (Thanks to Michel Fortin for the fix.) + ++ Added a new substitution in `_EncodeCode()`: s/\$/$/g; This + is only for the benefit of Blosxom users, because Blosxom + (sometimes?) interpolates Perl scalars in your article bodies. + ++ Fixed problem for links defined with urls that include parens, e.g.: + + [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky) + + "Chomsky" was being erroneously treated as the URL's title. + ++ At some point during 1.0's beta cycle, I changed every sub's + argument fetching from this idiom: + + my $text = shift; + + to: + + my $text = shift || return ''; + + The idea was to keep Markdown from doing any work in a sub + if the input was empty. This introduced a bug, though: + if the input to any function was the single-character string + "0", it would also evaluate as false and return immediately. + How silly. Now fixed. + + + +Donations +--------- + +Donations to support Markdown's development are happily accepted. See: +<http://daringfireball.net/projects/markdown/> for details. + + + +Copyright and License +--------------------- + +Copyright (c) 2003-2004 John Gruber +<http://daringfireball.net/> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name "Markdown" nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as +is" and any express or implied warranties, including, but not limited +to, the implied warranties of merchantability and fitness for a +particular purpose are disclaimed. In no event shall the copyright owner +or contributors be liable for any direct, indirect, incidental, special, +exemplary, or consequential damages (including, but not limited to, +procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. Added: trunk/doc/Markdown_1.0.1/Markdown.pl =================================================================== --- trunk/doc/Markdown_1.0.1/Markdown.pl (rev 0) +++ trunk/doc/Markdown_1.0.1/Markdown.pl 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,1450 @@ +#!/usr/bin/perl + +# +# Markdown -- A text-to-HTML conversion tool for web writers +# +# Copyright (c) 2004 John Gruber +# <http://daringfireball.net/projects/markdown/> +# + + +package Markdown; +require 5.006_000; +use strict; +use warnings; + +use Digest::MD5 qw(md5_hex); +use vars qw($VERSION); +$VERSION = '1.0.1'; +# Tue 14 Dec 2004 + +## Disabled; causes problems under Perl 5.6.1: +use utf8; +#binmode( STDOUT, ":utf8" ); # c.f.: http://acis.openlib.org/dev/perl-unicode-struggle.html + + +# +# Global default settings: +# +my $g_empty_element_suffix = " />"; # Change to ">" for HTML output +my $g_tab_width = 4; + + +# +# Globals: +# + +# Regex to match balanced [brackets]. See Friedl's +# "Mastering Regular Expressions", 2nd Ed., pp. 328-331. +my $g_nested_brackets; +$g_nested_brackets = qr{ + (?> # Atomic matching + [^\[\]]+ # Anything other than brackets + | + \[ + (??{ $g_nested_brackets }) # Recursive set of nested brackets + \] + )* +}x; + + +# Table of hash values for escaped characters: +my %g_escape_table; +foreach my $char (split //, '\\`*_{}[]()>#+-.!') { + $g_escape_table{$char} = md5_hex($char); +} + + +# Global hashes, used by various utility routines +my %g_urls; +my %g_titles; +my %g_html_blocks; + +# Used to track when we're inside an ordered or unordered list +# (see _ProcessListItems() for details): +my $g_list_level = 0; + + +#### Blosxom plug-in interface ########################################## + +# Set $g_blosxom_use_meta to 1 to use Blosxom's meta plug-in to determine +# which posts Markdown should process, using a "meta-markup: markdown" +# header. If it's set to 0 (the default), Markdown will process all +# entries. +my $g_blosxom_use_meta = 0; + +sub start { 1; } +sub story { + my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; + + if ( (! $g_blosxom_use_meta) or + (defined($meta::markup) and ($meta::markup =~ /^\s*markdown\s*$/i)) + ){ + $$body_ref = Markdown($$body_ref); + } + 1; +} + + +#### Movable Type plug-in interface ##################################### +eval {require MT}; # Test to see if we're running in MT. +unless ($@) { + require MT; + import MT; + require MT::Template::Context; + import MT::Template::Context; + + eval {require MT::Plugin}; # Test to see if we're running >= MT 3.0. + unless ($@) { + require MT::Plugin; + import MT::Plugin; + my $plugin = new MT::Plugin({ + name => "Markdown", + description => "A plain-text-to-HTML formatting plugin. (Version: $VERSION)", + doc_link => 'http://daringfireball.net/projects/markdown/' + }); + MT->add_plugin( $plugin ); + } + + MT::Template::Context->add_container_tag(MarkdownOptions => sub { + my $ctx = shift; + my $args = shift; + my $builder = $ctx->stash('builder'); + my $tokens = $ctx->stash('tokens'); + + if (defined ($args->{'output'}) ) { + $ctx->stash('markdown_output', lc $args->{'output'}); + } + + defined (my $str = $builder->build($ctx, $tokens) ) + or return $ctx->error($builder->errstr); + $str; # return value + }); + + MT->add_text_filter('markdown' => { + label => 'Markdown', + docs => 'http://daringfireball.net/projects/markdown/', + on_format => sub { + my $text = shift; + my $ctx = shift; + my $raw = 0; + if (defined $ctx) { + my $output = $ctx->stash('markdown_output'); + if (defined $output && $output =~ m/^html/i) { + $g_empty_element_suffix = ">"; + $ctx->stash('markdown_output', ''); + } + elsif (defined $output && $output eq 'raw') { + $raw = 1; + $ctx->stash('markdown_output', ''); + } + else { + $raw = 0; + $g_empty_element_suffix = " />"; + } + } + $text = $raw ? $text : Markdown($text); + $text; + }, + }); + + # If SmartyPants is loaded, add a combo Markdown/SmartyPants text filter: + my $smartypants; + + { + no warnings "once"; + $smartypants = $MT::Template::Context::Global_filters{'smarty_pants'}; + } + + if ($smartypants) { + MT->add_text_filter('markdown_with_smartypants' => { + label => 'Markdown With SmartyPants', + docs => 'http://daringfireball.net/projects/markdown/', + on_format => sub { + my $text = shift; + my $ctx = shift; + if (defined $ctx) { + my $output = $ctx->stash('markdown_output'); + if (defined $output && $output eq 'html') { + $g_empty_element_suffix = ">"; + } + else { + $g_empty_element_suffix = " />"; + } + } + $text = Markdown($text); + $text = $smartypants->($text, '1'); + }, + }); + } +} +else { +#### BBEdit/command-line text filter interface ########################## +# Needs to be hidden from MT (and Blosxom when running in static mode). + + # We're only using $blosxom::version once; tell Perl not to warn us: + no warnings 'once'; + unless ( defined($blosxom::version) ) { + use warnings; + + #### Check for command-line switches: ################# + my %cli_opts; + use Getopt::Long; + Getopt::Long::Configure('pass_through'); + GetOptions(\%cli_opts, + 'version', + 'shortversion', + 'html4tags', + ); + if ($cli_opts{'version'}) { # Version info + print "\nThis is Markdown, version $VERSION.\n"; + print "Copyright 2004 John Gruber\n"; + print "http://daringfireball.net/projects/markdown/\n\n"; + exit 0; + } + if ($cli_opts{'shortversion'}) { # Just the version number string. + print $VERSION; + exit 0; + } + if ($cli_opts{'html4tags'}) { # Use HTML tag style instead of XHTML + $g_empty_element_suffix = ">"; + } + + + #### Process incoming text: ########################### + my $text; + { + local $/; # Slurp the whole file + $text = <>; + } + print Markdown($text); + } +} + + + +sub Markdown { +# +# Main function. The order in which other subs are called here is +# essential. Link and image substitutions need to happen before +# _EscapeSpecialChars(), so that any *'s or _'s in the <a> +# and <img> tags get encoded. +# + my $text = shift; + + # Clear the global hashes. If we don't clear these, you get conflicts + # from other articles when generating a page which contains more than + # one article (e.g. an index page that shows the N most recent + # articles): + %g_urls = (); + %g_titles = (); + %g_html_blocks = (); + + + # Standardize line endings: + $text =~ s{\r\n}{\n}g; # DOS to Unix + $text =~ s{\r}{\n}g; # Mac to Unix + + # Make sure $text ends with a couple of newlines: + $text .= "\n\n"; + + # Convert all tabs to spaces. + $text = _Detab($text); + + # Strip any lines consisting only of spaces and tabs. + # This makes subsequent regexen easier to write, because we can + # match consecutive blank lines with /\n+/ instead of something + # contorted like /[ \t]*\n+/ . + $text =~ s/^[ \t]+$//mg; + + # Turn block-level HTML blocks into hash entries + $text = _HashHTMLBlocks($text); + + # Strip link definitions, store in hashes. + $text = _StripLinkDefinitions($text); + + $text = _RunBlockGamut($text); + + $text = _UnescapeSpecialChars($text); + + return $text . "\n"; +} + + +sub _StripLinkDefinitions { +# +# Strips link definitions from text, stores the URLs and titles in +# hash references. +# + my $text = shift; + my $less_than_tab = $g_tab_width - 1; + + # Link defs are in the form: ^[id]: url "optional title" + while ($text =~ s{ + ^[ ]{0,$less_than_tab}\[(.+)\]: # id = $1 + [ \t]* + \n? # maybe *one* newline + [ \t]* + <?(\S+?)>? # url = $2 + [ \t]* + \n? # maybe one newline + [ \t]* + (?: + (?<=\s) # lookbehind for whitespace + ["(] + (.+?) # title = $3 + [")] + [ \t]* + )? # title is optional + (?:\n+|\Z) + } + {}mx) { + $g_urls{lc $1} = _EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive + if ($3) { + $g_titles{lc $1} = $3; + $g_titles{lc $1} =~ s/"/"/g; + } + } + + return $text; +} + + +sub _HashHTMLBlocks { + my $text = shift; + my $less_than_tab = $g_tab_width - 1; + + # Hashify HTML blocks: + # We only want to do this for block-level HTML tags, such as headers, + # lists, and tables. That's because we still want to wrap <p>s around + # "paragraphs" that are wrapped in non-block-level tags, such as anchors, + # phrase emphasis, and spans. The list of tags we're looking for is + # hard-coded: + my $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/; + my $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/; + + # First, look for nested blocks, e.g.: + # <div> + # <div> + # tags for inner block must be indented. + # </div> + # </div> + # + # The outermost tags must start at the left margin for this to match, and + # the inner nested divs must be indented. + # We need to do this before the next, more liberal match, because the next + # match will start at the first `<div>` and stop at the first `</div>`. + $text =~ s{ + ( # save in $1 + ^ # start of line (with /m) + <($block_tags_a) # start tag = $2 + \b # word break + (.*\n)*? # any number of lines, minimally matching + </\2> # the matching end tag + [ \t]* # trailing spaces/tabs + (?=\n+|\Z) # followed by a newline or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egmx; + + + # + # Now match more liberally, simply from `\n<tag>` to `</tag>\n` + # + $text =~ s{ + ( # save in $1 + ^ # start of line (with /m) + <($block_tags_b) # start tag = $2 + \b # word break + (.*\n)*? # any number of lines, minimally matching + .*</\2> # the matching end tag + [ \t]* # trailing spaces/tabs + (?=\n+|\Z) # followed by a newline or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egmx; + # Special case just for <hr />. It was easier to make a special case than + # to make the other regex more complicated. + $text =~ s{ + (?: + (?<=\n\n) # Starting after a blank line + | # or + \A\n? # the beginning of the doc + ) + ( # save in $1 + [ ]{0,$less_than_tab} + <(hr) # start tag = $2 + \b # word break + ([^<>])*? # + /?> # the matching end tag + [ \t]* + (?=\n{2,}|\Z) # followed by a blank line or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egx; + + # Special case for standalone HTML comments: + $text =~ s{ + (?: + (?<=\n\n) # Starting after a blank line + | # or + \A\n? # the beginning of the doc + ) + ( # save in $1 + [ ]{0,$less_than_tab} + (?s: + <! + (--.*?--\s*)+ + > + ) + [ \t]* + (?=\n{2,}|\Z) # followed by a blank line or end of document + ) + }{ + my $key = md5_hex($1); + $g_html_blocks{$key} = $1; + "\n\n" . $key . "\n\n"; + }egx; + + + return $text; +} + + +sub _RunBlockGamut { +# +# These are all the transformations that form block-level +# tags like paragraphs, headers, and list items. +# + my $text = shift; + + $text = _DoHeaders($text); + + # Do Horizontal Rules: + $text =~ s{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx; + $text =~ s{^[ ]{0,2}([ ]? -[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx; + $text =~ s{^[ ]{0,2}([ ]? _[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx; + + $text = _DoLists($text); + + $text = _DoCodeBlocks($text); + + $text = _DoBlockQuotes($text); + + # We already ran _HashHTMLBlocks() before, in Markdown(), but that + # was to escape raw HTML in the original Markdown source. This time, + # we're escaping the markup we've just created, so that we don't wrap + # <p> tags around block-level tags. + $text = _HashHTMLBlocks($text); + + $text = _FormParagraphs($text); + + return $text; +} + + +sub _RunSpanGamut { +# +# These are all the transformations that occur *within* block-level +# tags like paragraphs, headers, and list items. +# + my $text = shift; + + $text = _DoCodeSpans($text); + + $text = _EscapeSpecialChars($text); + + # Process anchor and image tags. Images must come first, + # because ![foo][f] looks like an anchor. + $text = _DoImages($text); + $text = _DoAnchors($text); + + # Make links out of things like `<http://example.com/>` + # Must come after _DoAnchors(), because you can use < and > + # delimiters in inline links like [this](<url>). + $text = _DoAutoLinks($text); + + $text = _EncodeAmpsAndAngles($text); + + $text = _DoItalicsAndBold($text); + + # Do hard breaks: + $text =~ s/ {2,}\n/ <br$g_empty_element_suffix\n/g; + + return $text; +} + + +sub _EscapeSpecialChars { + my $text = shift; + my $tokens ||= _TokenizeHTML($text); + + $text = ''; # rebuild $text from the tokens +# my $in_pre = 0; # Keep track of when we're inside <pre> or <code> tags. +# my $tags_to_skip = qr!<(/?)(?:pre|code|kbd|script|math)[\s>]!; + + foreach my $cur_token (@$tokens) { + if ($cur_token->[0] eq "tag") { + # Within tags, encode * and _ so they don't conflict + # with their use in Markdown for italics and strong. + # We're replacing each such character with its + # corresponding MD5 checksum value; this is likely + # overkill, but it should prevent us from colliding + # with the escape values by accident. + $cur_token->[1] =~ s! \* !$g_escape_table{'*'}!gx; + $cur_token->[1] =~ s! _ !$g_escape_table{'_'}!gx; + $text .= $cur_token->[1]; + } else { + my $t = $cur_token->[1]; + $t = _EncodeBackslashEscapes($t); + $text .= $t; + } + } + return $text; +} + + +sub _DoAnchors { +# +# Turn Markdown link shortcuts into XHTML <a> tags. +# + my $text = shift; + + # + # First, handle reference-style links: [link text] [id] + # + $text =~ s{ + ( # wrap whole match in $1 + \[ + ($g_nested_brackets) # link text = $2 + \] + + [ ]? # one optional space + (?:\n[ ]*)? # one optional newline followed by spaces + + \[ + (.*?) # id = $3 + \] + ) + }{ + my $result; + my $whole_match = $1; + my $link_text = $2; + my $link_id = lc $3; + + if ($link_id eq "") { + $link_id = lc $link_text; # for shortcut links like [this][]. + } + + if (defined $g_urls{$link_id}) { + my $url = $g_urls{$link_id}; + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<a href=\"$url\""; + if ( defined $g_titles{$link_id} ) { + my $title = $g_titles{$link_id}; + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + $result .= ">$link_text</a>"; + } + else { + $result = $whole_match; + } + $result; + }xsge; + + # + # Next, inline-style links: [link text](url "optional title") + # + $text =~ s{ + ( # wrap whole match in $1 + \[ + ($g_nested_brackets) # link text = $2 + \] + \( # literal paren + [ \t]* + <?(.*?)>? # href = $3 + [ \t]* + ( # $4 + (['"]) # quote char = $5 + (.*?) # Title = $6 + \5 # matching quote + )? # title is optional + \) + ) + }{ + my $result; + my $whole_match = $1; + my $link_text = $2; + my $url = $3; + my $title = $6; + + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<a href=\"$url\""; + + if (defined $title) { + $title =~ s/"/"/g; + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + + $result .= ">$link_text</a>"; + + $result; + }xsge; + + return $text; +} + + +sub _DoImages { +# +# Turn Markdown image shortcuts into <img> tags. +# + my $text = shift; + + # + # First, handle reference-style labeled images: ![alt text][id] + # + $text =~ s{ + ( # wrap whole match in $1 + !\[ + (.*?) # alt text = $2 + \] + + [ ]? # one optional space + (?:\n[ ]*)? # one optional newline followed by spaces + + \[ + (.*?) # id = $3 + \] + + ) + }{ + my $result; + my $whole_match = $1; + my $alt_text = $2; + my $link_id = lc $3; + + if ($link_id eq "") { + $link_id = lc $alt_text; # for shortcut links like ![this][]. + } + + $alt_text =~ s/"/"/g; + if (defined $g_urls{$link_id}) { + my $url = $g_urls{$link_id}; + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<img src=\"$url\" alt=\"$alt_text\""; + if (defined $g_titles{$link_id}) { + my $title = $g_titles{$link_id}; + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + $result .= $g_empty_element_suffix; + } + else { + # If there's no such link ID, leave intact: + $result = $whole_match; + } + + $result; + }xsge; + + # + # Next, handle inline images: ![alt text](url "optional title") + # Don't forget: encode * and _ + + $text =~ s{ + ( # wrap whole match in $1 + !\[ + (.*?) # alt text = $2 + \] + \( # literal paren + [ \t]* + <?(\S+?)>? # src url = $3 + [ \t]* + ( # $4 + (['"]) # quote char = $5 + (.*?) # title = $6 + \5 # matching quote + [ \t]* + )? # title is optional + \) + ) + }{ + my $result; + my $whole_match = $1; + my $alt_text = $2; + my $url = $3; + my $title = ''; + if (defined($6)) { + $title = $6; + } + + $alt_text =~ s/"/"/g; + $title =~ s/"/"/g; + $url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid + $url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold. + $result = "<img src=\"$url\" alt=\"$alt_text\""; + if (defined $title) { + $title =~ s! \* !$g_escape_table{'*'}!gx; + $title =~ s! _ !$g_escape_table{'_'}!gx; + $result .= " title=\"$title\""; + } + $result .= $g_empty_element_suffix; + + $result; + }xsge; + + return $text; +} + + +sub _DoHeaders { + my $text = shift; + + # Setext-style headers: + # Header 1 + # ======== + # + # Header 2 + # -------- + # + $text =~ s{ ^(.+)[ \t]*\n=+[ \t]*\n+ }{ + "<h1>" . _RunSpanGamut($1) . "</h1>\n\n"; + }egmx; + + $text =~ s{ ^(.+)[ \t]*\n-+[ \t]*\n+ }{ + "<h2>" . _RunSpanGamut($1) . "</h2>\n\n"; + }egmx; + + + # atx-style headers: + # # Header 1 + # ## Header 2 + # ## Header 2 with closing hashes ## + # ... + # ###### Header 6 + # + $text =~ s{ + ^(\#{1,6}) # $1 = string of #'s + [ \t]* + (.+?) # $2 = Header text + [ \t]* + \#* # optional closing #'s (not counted) + \n+ + }{ + my $h_level = length($1); + "<h$h_level>" . _RunSpanGamut($2) . "</h$h_level>\n\n"; + }egmx; + + return $text; +} + + +sub _DoLists { +# +# Form HTML ordered (numbered) and unordered (bulleted) lists. +# + my $text = shift; + my $less_than_tab = $g_tab_width - 1; + + # Re-usable patterns to match list item bullets and number markers: + my $marker_ul = qr/[*+-]/; + my $marker_ol = qr/\d+[.]/; + my $marker_any = qr/(?:$marker_ul|$marker_ol)/; + + # Re-usable pattern to match any entirel ul or ol list: + my $whole_list = qr{ + ( # $1 = whole list + ( # $2 + [ ]{0,$less_than_tab} + (${marker_any}) # $3 = first list item marker + [ \t]+ + ) + (?s:.+?) + ( # $4 + \z + | + \n{2,} + (?=\S) + (?! # Negative lookahead for another list item marker + [ \t]* + ${marker_any}[ \t]+ + ) + ) + ) + }mx; + + # We use a different prefix before nested lists than top-level lists. + # See extended comment in _ProcessListItems(). + # + # Note: There's a bit of duplication here. My original implementation + # created a scalar regex pattern as the conditional result of the test on + # $g_list_level, and then only ran the $text =~ s{...}{...}egmx + # substitution once, using the scalar as the pattern. This worked, + # everywhere except when running under MT on my hosting account at Pair + # Networks. There, this caused all rebuilds to be killed by the reaper (or + # perhaps they crashed, but that seems incredibly unlikely given that the + # same script on the same server ran fine *except* under MT. I've spent + # more time trying to figure out why this is happening than I'd like to + # admit. My only guess, backed up by the fact that this workaround works, + # is that Perl optimizes the substition when it can figure out that the + # pattern will never change, and when this optimization isn't on, we run + # afoul of the reaper. Thus, the slightly redundant code to that uses two + # static s/// patterns rather than one conditional pattern. + + if ($g_list_level) { + $text =~ s{ + ^ + $whole_list + }{ + my $list = $1; + my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol"; + # Turn double returns into triple returns, so that we can make a + # paragraph for the last item in a list, if necessary: + $list =~ s/\n{2,}/\n\n\n/g; + my $result = _ProcessListItems($list, $marker_any); + $result = "<$list_type>\n" . $result . "</$list_type>\n"; + $result; + }egmx; + } + else { + $text =~ s{ + (?:(?<=\n\n)|\A\n?) + $whole_list + }{ + my $list = $1; + my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol"; + # Turn double returns into triple returns, so that we can make a + # paragraph for the last item in a list, if necessary: + $list =~ s/\n{2,}/\n\n\n/g; + my $result = _ProcessListItems($list, $marker_any); + $result = "<$list_type>\n" . $result . "</$list_type>\n"; + $result; + }egmx; + } + + + return $text; +} + + +sub _ProcessListItems { +# +# Process the contents of a single ordered or unordered list, splitting it +# into individual list items. +# + + my $list_str = shift; + my $marker_any = shift; + + + # The $g_list_level global keeps track of when we're inside a list. + # Each time we enter a list, we increment it; when we leave a list, + # we decrement. If it's zero, we're not in a list anymore. + # + # We do this because when we're not inside a list, we want to treat + # something like this: + # + # I recommend upgrading to version + # 8. Oops, now this line is treated + # as a sub-list. + # + # As a single paragraph, despite the fact that the second line starts + # with a digit-period-space sequence. + # + # Whereas when we're inside a list (or sub-list), that line will be + # treated as the start of a sub-list. What a kludge, huh? This is + # an aspect of Markdown's syntax that's hard to parse perfectly + # without resorting to mind-reading. Perhaps the solution is to + # change the syntax rules such that sub-lists must start with a + # starting cardinal number; e.g. "1." or "a.". + + $g_list_level++; + + # trim trailing blank lines: + $list_str =~ s/\n{2,}\z/\n/; + + + $list_str =~ s{ + (\n)? # leading line = $1 + (^[ \t]*) # leading whitespace = $2 + ($marker_any) [ \t]+ # list marker = $3 + ((?s:.+?) # list item text = $4 + (\n{1,2})) + (?= \n* (\z | \2 ($marker_any) [ \t]+)) + }{ + my $item = $4; + my $leading_line = $1; + my $leading_space = $2; + + if ($leading_line or ($item =~ m/\n{2,}/)) { + $item = _RunBlockGamut(_Outdent($item)); + } + else { + # Recursion for sub-lists: + $item = _DoLists(_Outdent($item)); + chomp $item; + $item = _RunSpanGamut($item); + } + + "<li>" . $item . "</li>\n"; + }egmx; + + $g_list_level--; + return $list_str; +} + + + +sub _DoCodeBlocks { +# +# Process Markdown `<pre><code>` blocks. +# + + my $text = shift; + + $text =~ s{ + (?:\n\n|\A) + ( # $1 = the code block -- one or more lines, starting with a space/tab + (?: + (?:[ ]{$g_tab_width} | \t) # Lines must start with a tab or a tab-width of spaces + .*\n+ + )+ + ) + ((?=^[ ]{0,$g_tab_width}\S)|\Z) # Lookahead for non-space at line-start, or end of doc + }{ + my $codeblock = $1; + my $result; # return value + + $codeblock = _EncodeCode(_Outdent($codeblock)); + $codeblock = _Detab($codeblock); + $codeblock =~ s/\A\n+//; # trim leading newlines + $codeblock =~ s/\s+\z//; # trim trailing whitespace + + $result = "\n\n<pre><code>" . $codeblock . "\n</code></pre>\n\n"; + + $result; + }egmx; + + return $text; +} + + +sub _DoCodeSpans { +# +# * Backtick quotes are used for <code></code> spans. +# +# * You can use multiple backticks as the delimiters if you want to +# include literal backticks in the code span. So, this input: +# +# Just type ``foo `bar` baz`` at the prompt. +# +# Will translate to: +# +# <p>Just type <code>foo `bar` baz</code> at the prompt.</p> +# +# There's no arbitrary limit to the number of backticks you +# can use as delimters. If you need three consecutive backticks +# in your code, use four for delimiters, etc. +# +# * You can use spaces to get literal backticks at the edges: +# +# ... type `` `bar` `` ... +# +# Turns to: +# +# ... type <code>`bar`</code> ... +# + + my $text = shift; + + $text =~ s@ + (`+) # $1 = Opening run of ` + (.+?) # $2 = The code block + (?<!`) + \1 # Matching closer + (?!`) + @ + my $c = "$2"; + $c =~ s/^[ \t]*//g; # leading whitespace + $c =~ s/[ \t]*$//g; # trailing whitespace + $c = _EncodeCode($c); + "<code>$c</code>"; + @egsx; + + return $text; +} + + +sub _EncodeCode { +# +# Encode/escape certain characters inside Markdown code runs. +# The point is that in code, these characters are literals, +# and lose their special Markdown meanings. +# + local $_ = shift; + + # Encode all ampersands; HTML entities are not + # entities within a Markdown code span. + s/&/&/g; + + # Encode $'s, but only if we're running under Blosxom. + # (Blosxom interpolates Perl variables in article bodies.) + { + no warnings 'once'; + if (defined($blosxom::version)) { + s/\$/$/g; + } + } + + + # Do the angle bracket song and dance: + s! < !<!gx; + s! > !>!gx; + + # Now, escape characters that are magic in Markdown: + s! \* !$g_escape_table{'*'}!gx; + s! _ !$g_escape_table{'_'}!gx; + s! { !$g_escape_table{'{'}!gx; + s! } !$g_escape_table{'}'}!gx; + s! \[ !$g_escape_table{'['}!gx; + s! \] !$g_escape_table{']'}!gx; + s! \\ !$g_escape_table{'\\'}!gx; + + return $_; +} + + +sub _DoItalicsAndBold { + my $text = shift; + + # <strong> must go first: + $text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 } + {<strong>$2</strong>}gsx; + + $text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 } + {<em>$2</em>}gsx; + + return $text; +} + + +sub _DoBlockQuotes { + my $text = shift; + + $text =~ s{ + ( # Wrap whole match in $1 + ( + ^[ \t]*>[ \t]? # '>' at the start of a line + .+\n # rest of the first line + (.+\n)* # subsequent consecutive lines + \n* # blanks + )+ + ) + }{ + my $bq = $1; + $bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting + $bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines + $bq = _RunBlockGamut($bq); # recurse + + $bq =~ s/^/ /g; + # These leading spaces screw with <pre> content, so we need to fix that: + $bq =~ s{ + (\s*<pre>.+?</pre>) + }{ + my $pre = $1; + $pre =~ s/^ //mg; + $pre; + }egsx; + + "<blockquote>\n$bq\n</blockquote>\n\n"; + }egmx; + + + return $text; +} + + +sub _FormParagraphs { +# +# Params: +# $text - string to process with html <p> tags +# + my $text = shift; + + # Strip leading and trailing lines: + $text =~ s/\A\n+//; + $text =~ s/\n+\z//; + + my @grafs = split(/\n{2,}/, $text); + + # + # Wrap <p> tags. + # + foreach (@grafs) { + unless (defined( $g_html_blocks{$_} )) { + $_ = _RunSpanGamut($_); + s/^([ \t]*)/<p>/; + $_ .= "</p>"; + } + } + + # + # Unhashify HTML blocks + # + foreach (@grafs) { + if (defined( $g_html_blocks{$_} )) { + $_ = $g_html_blocks{$_}; + } + } + + return join "\n\n", @grafs; +} + + +sub _EncodeAmpsAndAngles { +# Smart processing for ampersands and angle brackets that need to be encoded. + + my $text = shift; + + # Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: + # http://bumppo.net/projects/amputator/ + $text =~ s/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/&/g; + + # Encode naked <'s + $text =~ s{<(?![a-z/?\$!])}{<}gi; + + return $text; +} + + +sub _EncodeBackslashEscapes { +# +# Parameter: String. +# Returns: The string, with after processing the following backslash +# escape sequences. +# + local $_ = shift; + + s! \\\\ !$g_escape_table{'\\'}!gx; # Must process escaped backslashes first. + s! \\` !$g_escape_table{'`'}!gx; + s! \\\* !$g_escape_table{'*'}!gx; + s! \\_ !$g_escape_table{'_'}!gx; + s! \\\{ !$g_escape_table{'{'}!gx; + s! \\\} !$g_escape_table{'}'}!gx; + s! \\\[ !$g_escape_table{'['}!gx; + s! \\\] !$g_escape_table{']'}!gx; + s! \\\( !$g_escape_table{'('}!gx; + s! \\\) !$g_escape_table{')'}!gx; + s! \\> !$g_escape_table{'>'}!gx; + s! \\\# !$g_escape_table{'#'}!gx; + s! \\\+ !$g_escape_table{'+'}!gx; + s! \\\- !$g_escape_table{'-'}!gx; + s! \\\. !$g_escape_table{'.'}!gx; + s{ \\! }{$g_escape_table{'!'}}gx; + + return $_; +} + + +sub _DoAutoLinks { + my $text = shift; + + $text =~ s{<((https?|ftp):[^'">\s]+)>}{<a href="$1">$1</a>}gi; + + # Email addresses: <addre****@domai*****> + $text =~ s{ + < + (?:mailto:)? + ( + [-.\w]+ + \@ + [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ + ) + > + }{ + _EncodeEmailAddress( _UnescapeSpecialChars($1) ); + }egix; + + return $text; +} + + +sub _EncodeEmailAddress { +# +# Input: an email address, e.g. "foo****@examp*****" +# +# Output: the email address as a mailto link, with each character +# of the address encoded as either a decimal or hex entity, in +# the hopes of foiling most address harvesting spam bots. E.g.: +# +# <a href="mailto:foo@e +# xample.com">foo +# @example.com</a> +# +# Based on a filter by Matthew Wickline, posted to the BBEdit-Talk +# mailing list: <http://tinyurl.com/yu7ue> +# + + my $addr = shift; + + srand; + my @encode = ( + sub { '&#' . ord(shift) . ';' }, + sub { '&#x' . sprintf( "%X", ord(shift) ) . ';' }, + sub { shift }, + ); + + $addr = "mailto:" . $addr; + + $addr =~ s{(.)}{ + my $char = $1; + if ( $char eq '@' ) { + # this *must* be encoded. I insist. + $char = $encode[int rand 1]->($char); + } elsif ( $char ne ':' ) { + # leave ':' alone (to spot mailto: later) + my $r = rand; + # roughly 10% raw, 45% hex, 45% dec + $char = ( + $r > .9 ? $encode[2]->($char) : + $r < .45 ? $encode[1]->($char) : + $encode[0]->($char) + ); + } + $char; + }gex; + + $addr = qq{<a href="$addr">$addr</a>}; + $addr =~ s{">.+?:}{">}; # strip the mailto: from the visible part + + return $addr; +} + + +sub _UnescapeSpecialChars { +# +# Swap back in all the special characters we've hidden. +# + my $text = shift; + + while( my($char, $hash) = each(%g_escape_table) ) { + $text =~ s/$hash/$char/g; + } + return $text; +} + + +sub _TokenizeHTML { +# +# Parameter: String containing HTML markup. +# Returns: Reference to an array of the tokens comprising the input +# string. Each token is either a tag (possibly with nested, +# tags contained therein, such as <a href="<MTFoo>">, or a +# run of text between tags. Each element of the array is a +# two-element array; the first is either 'tag' or 'text'; +# the second is the actual value. +# +# +# Derived from the _tokenize() subroutine from Brad Choate's MTRegex plugin. +# <http://www.bradchoate.com/past/mtregex.php> +# + + my $str = shift; + my $pos = 0; + my $len = length $str; + my @tokens; + + my $depth = 6; + my $nested_tags = join('|', ('(?:<[a-z/!$](?:[^<>]') x $depth) . (')*>)' x $depth); + my $match = qr/(?s: <! ( -- .*? -- \s* )+ > ) | # comment + (?s: <\? .*? \?> ) | # processing instruction + $nested_tags/ix; # nested tags + + while ($str =~ m/($match)/g) { + my $whole_tag = $1; + my $sec_start = pos $str; + my $tag_start = $sec_start - length $whole_tag; + if ($pos < $tag_start) { + push @tokens, ['text', substr($str, $pos, $tag_start - $pos)]; + } + push @tokens, ['tag', $whole_tag]; + $pos = pos $str; + } + push @tokens, ['text', substr($str, $pos, $len - $pos)] if $pos < $len; + \@tokens; +} + + +sub _Outdent { +# +# Remove one level of line-leading tabs or spaces +# + my $text = shift; + + $text =~ s/^(\t|[ ]{1,$g_tab_width})//gm; + return $text; +} + + +sub _Detab { +# +# Cribbed from a post by Bart Lateur: +# <http://www.nntp.perl.org/group/perl.macperl.anyperl/154> +# + my $text = shift; + + $text =~ s{(.*?)\t}{$1.(' ' x ($g_tab_width - length($1) % $g_tab_width))}ge; + return $text; +} + + +1; + +__END__ + + +=pod + +=head1 NAME + +B<Markdown> + + +=head1 SYNOPSIS + +B<Markdown.pl> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ] + [ I<file> ... ] + + +=head1 DESCRIPTION + +Markdown is a text-to-HTML filter; it translates an easy-to-read / +easy-to-write structured text format into HTML. Markdown's text format +is most similar to that of plain text email, and supports features such +as headers, *emphasis*, code blocks, blockquotes, and links. + +Markdown's syntax is designed not as a generic markup language, but +specifically to serve as a front-end to (X)HTML. You can use span-level +HTML tags anywhere in a Markdown document, and you can use block level +HTML tags (like <div> and <table> as well). + +For more information about Markdown's syntax, see: + + http://daringfireball.net/projects/markdown/ + + +=head1 OPTIONS + +Use "--" to end switch parsing. For example, to open a file named "-z", use: + + Markdown.pl -- -z + +=over 4 + + +=item B<--html4tags> + +Use HTML 4 style for empty element tags, e.g.: + + <br> + +instead of Markdown's default XHTML style tags, e.g.: + + <br /> + + +=item B<-v>, B<--version> + +Display Markdown's version number and copyright information. + + +=item B<-s>, B<--shortversion> + +Display the short-form version number. + + +=back + + + +=head1 BUGS + +To file bug reports or feature requests (other than topics listed in the +Caveats section above) please send email to: + + suppo****@darin***** + +Please include with your report: (1) the example input; (2) the output +you expected; (3) the output Markdown actually produced. + + +=head1 VERSION HISTORY + +See the readme file for detailed release notes for this version. + +1.0.1 - 14 Dec 2004 + +1.0 - 28 Aug 2004 + + +=head1 AUTHOR + + John Gruber + http://daringfireball.net + + PHP port and other contributions by Michel Fortin + http://michelf.com + + +=head1 COPYRIGHT AND LICENSE + +Copyright (c) 2003-2004 John Gruber +<http://daringfireball.net/> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name "Markdown" nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +This software is provided by the copyright holders and contributors "as +is" and any express or implied warranties, including, but not limited +to, the implied warranties of merchantability and fitness for a +particular purpose are disclaimed. In no event shall the copyright owner +or contributors be liable for any direct, indirect, incidental, special, +exemplary, or consequential damages (including, but not limited to, +procurement of substitute goods or services; loss of use, data, or +profits; or business interruption) however caused and on any theory of +liability, whether in contract, strict liability, or tort (including +negligence or otherwise) arising in any way out of the use of this +software, even if advised of the possibility of such damage. + +=cut Modified: trunk/doc/convtext.bat =================================================================== --- trunk/doc/convtext.bat 2019-03-01 10:20:20 UTC (rev 7455) +++ trunk/doc/convtext.bat 2019-03-02 16:18:47 UTC (rev 7456) @@ -16,3 +16,7 @@ %TOSJIS% -i ..\cygterm\COPYING -o %REF_J%\CygTerm+-LICENSE.txt -l unix %ZLIBCP% -i ..\libs\zlib\README -o %REF_E%\zlib-LICENSE.txt -l unix %ZLIBCP% -i ..\libs\zlib\README -o %REF_J%\zlib-LICENSE.txt -l unix + +sed -e '1s/^\xef\xbb\xbf//' < ja/html/reference/build_with_cmake.md > ja/html/reference/build_with_cmake_without_bom.md +perl Markdown_1.0.1/Markdown.pl ja/html/reference/build_with_cmake_without_bom.md > ja/html/reference/build_with_cmake_utf8.html +%TOSJIS% -i ja/html/reference/build_with_cmake_utf8.html -o ja/html/reference/build_with_cmake.html -c utf8 Added: trunk/doc/ja/html/reference/build_with_cmake.md =================================================================== --- trunk/doc/ja/html/reference/build_with_cmake.md (rev 0) +++ trunk/doc/ja/html/reference/build_with_cmake.md 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,32 @@ +# cmakeを使ったビルド + +- 実験的に cmake を使用してビルドすることができます +- cmake https://cmake.org/ + +## cmakeのバージョン + +- Visual Studio 2005 をサポートしている cmake の最後のバージョンは 3.11.4 です +- 2005 以外の Visual Studio を使用する場合は特に制限はありません +- Visual Studio 2017 インストーラーで、オプションを選べば cmake をインストールできます + +## ライブラリのビルド + +- teraterm が使用するライブラリをビルドして準備しておきます +- `lib/build_library_with_cmake.md` を参照してください +- ライブラリは `develop.txt` を参照してください + +## teratermのビルド + +- ソースツリーのトップから、次のようにコマンドを実行します + ``` + mkdir build_vs2005 + cd build_vs2005 + "c:\Program Files (x86)\CMake-3.11.4\bin\cmake.exe" .. -G "Visual Studio 8 2005" + ``` + - パスが通っていれば cmake はフルパスで書く必要はありません + - `-G` オプションの後ろは使用する Visual Studio のバージョンに合わせて調整します +- sln ファイルが生成されるので Visual Studio で開くことができます +- cmakeを使ってビルドする場合は次のコマンドを実行します + ``` + cmake --build . --config release + ``` Added: trunk/libs/.gitignore =================================================================== --- trunk/libs/.gitignore (rev 0) +++ trunk/libs/.gitignore 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1 @@ +*/ Added: trunk/libs/SFMT.cmake =================================================================== --- trunk/libs/SFMT.cmake (rev 0) +++ trunk/libs/SFMT.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,171 @@ +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P SFMT.cmake +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P SFMT.cmake + +#### +if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "")) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # multi-configuration + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Release + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P SFMT.cmake + ) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P SFMT.cmake + ) + return() + elseif("$ENV{MSYSTEM}" MATCHES "MINGW") + # mingw on msys2 + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + # mingw + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") + # VS nmake + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + else() + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + endif() +endif() + +include(script_support.cmake) + +set(SRC_DIR_BASE "SFMT-src-1.5.1") +set(SRC_ARC "SFMT-1.5.1.zip") +set(SRC_URL "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/SFMT-src-1.5.1.zip") +set(SRC_ARC_HASH_SHA256 630d1dfa6b690c30472f75fa97ca90ba62f9c13c5add6c264fdac2c1d3a878f4) + +set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/SFMT") +set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/src") +set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/src/${SRC_DIR_BASE}") +set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/SFMT/build_${TOOLSET}") +set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/SFMT_${TOOLSET}") +if(("${CMAKE_GENERATOR}" MATCHES "Win64") OR ("$ENV{MSYSTEM_CHOST}" STREQUAL "x86_64-w64-mingw32")) + set(BUILD_DIR "${BUILD_DIR}_x64") + set(INSTALL_DIR "${INSTALL_DIR}_x64") +endif() + +######################################## + +if(NOT EXISTS ${SRC_DIR}/README.txt) + + file(DOWNLOAD + ${SRC_URL} + ${DOWN_DIR}/${SRC_ARC} + EXPECTED_HASH SHA256=${SRC_ARC_HASH_SHA256} + SHOW_PROGRESS + ) + + file(MAKE_DIRECTORY ${EXTRACT_DIR}) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC} + WORKING_DIRECTORY ${EXTRACT_DIR} + ) + +endif() + +######################################## + +if(NOT EXISTS ${SRC_DIR}/CMakeLists.txt) + file(WRITE "${SRC_DIR}/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.4.4)\n" + "project(SFMT C)\n" + "\n" + "if(MSVC)\n" + " set(CMAKE_DEBUG_POSTFIX \"d\")\n" + "endif()\n" + "\n" + "add_library(\n" + " sfmt STATIC\n" + " SFMT.c\n" + " )\n" + "\n" + "install(\n" + " TARGETS sfmt\n" + " ARCHIVE DESTINATION \${CMAKE_INSTALL_PREFIX}/lib\n" + " )\n" + "install(\n" + " FILES SFMT.h SFMT-params.h SFMT-params19937.h\n" + " DESTINATION \${CMAKE_INSTALL_PREFIX}/include\n" + " )\n" + ) +endif() + +######################################## + +file(MAKE_DIRECTORY "${BUILD_DIR}") + +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + + ######################################## multi configuration + + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + ${TOOLCHAINFILE} + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake generate fail ${rv}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_CONFIGURATION_TYPE} --target install + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() + +else() + ######################################## single configuration + + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --target install + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() + +endif() Added: trunk/libs/VSToolchain.cmake =================================================================== --- trunk/libs/VSToolchain.cmake (rev 0) +++ trunk/libs/VSToolchain.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,5 @@ +# write to CMakeCache.txt +set(CMAKE_C_FLAGS_DEBUG "/DWIN32 /D_WINDOWS /W3 /MTd /Zi /Ob0 /Od /RTC1" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "/DWIN32 /D_WINDOWS /W3 /MTd /Zi /Ob0 /Od /RTC1" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "/DWIN32 /D_WINDOWS /W3 /MT /O2 /Ob2 /DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "/DWIN32 /D_WINDOWS /W3 /MT /O2 /Ob2 /DNDEBUG" CACHE STRING "" FORCE) Added: trunk/libs/build_library_with_cmake.md =================================================================== --- trunk/libs/build_library_with_cmake.md (rev 0) +++ trunk/libs/build_library_with_cmake.md 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,76 @@ + +# libフォルダ + +- teratermが利用する外部のライブラリをビルドするためのフォルダ +- コンパイラ向けに各々ビルド +- 1度ビルドしてライブラリを生成しておく + +# 準備 + +## Visual Studio + +- cmake + - PATHが通してあればok + - cygwinのcmakeはつかえない(Visual Studioをサポートしていない) + - Visual Studio 2005 を使う場合は cmake 3.11.4 を使用する必要がある +- perl + - OpenSSL のコンパイル、ドキュメントファイルの文字コード・改行コード変換に必要 + - ActivePerl 5.8 以上、または cygwin perl + - PATHが通っていなければ自動で探す + +## MinGW 共通 (experimental) + +- Cygwin,MSYS2,linux(wsl)上のMinGWでビルド可能 +- 各環境で動作するcmake,make,(MinGW)gcc,perlが必要 + +# ビルド手順 + +必要なアーカイブを自動的にダウンロードするので、 +インターネットが利用できる環境でビルドする必要がある + +## Visual Studioの場合 + +### batファイルを使用する場合 + +- 自動的にビルド +- buildall_cmake.bat を実行 +- コンパイルに使用する Visual Studioを選ぶ +- VS2005の場合はcmake 3.11.4 をダウンロードして + libs\cmake-3.11.4-win32-x86 にインストールする + +### cmakeを使用する場合 + +- cmakeを使える状態にしてcmakeを実行 + - `cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P buildall.cmake` + - `cmake -DCMAKE_GENERATOR="Visual Studio 15 2017 Win64" -P buildall.cmake` +- Visual Studio 2005の場合は、cmakeのバージョン3.11.4以前を使用する + - cmake が libs\cmake-3.11.4-win32-x86 にインストールしてある場合 + `"libs\cmake-3.11.4-win32-x86\bin\cmake.exe" -DCMAKE_GENERATOR="Visual Studio 8 2005" -P buildall.cmake` + +## MinGW 共通 + +- 各々の環境のcmakeを使って + `cmake -DCMAKE_GENERATOR="Unix Makefiles" -P buildall.cmake` を実行 + +# 各フォルダについて + +## 生成されるライブラリフォルダ + +- 次のフォルダにライブラリの`*.h`,`*.lib`が生成される + - oniguruma_{compiler} + - openssl_{compiler} + - putty + - SFMT_{compiler} + - zlib_{compiler} + +## download アーカイブダウンロードフォルダ + +- ダウンロードしたアーカイブファイルが置かれる +- 自動でダウンロードされる +- ダウンロードされていると再利用する +- ビルド後、参照する必要がなければ削除できる + +## build ビルドフォルダ + +- build/oniguruma_{compiler}/ などの下でビルドされる +- ビルド後、参照する必要がなければ削除できる Added: trunk/libs/buildall.cmake =================================================================== --- trunk/libs/buildall.cmake (rev 0) +++ trunk/libs/buildall.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,23 @@ +# cmake -DCMAKE_GENERATOR="Vsual Studio 15 2017" -P buildall.cmake +# cmake -DCMAKE_GENERATOR="Unix Makefiles" -P buildall.cmake -DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake + +if("${CMAKE_GENERATOR}" STREQUAL "") + message(FATAL_ERROR "set CMAKE_GENERATOR!") +endif() + +# build +execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P oniguruma.cmake + ) +execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P zlib.cmake + ) +execute_process( + COMMAND ${CMAKE_COMMAND} -P putty.cmake + ) +execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P SFMT.cmake + ) +execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P openssl.cmake + ) Added: trunk/libs/buildall_cmake.bat =================================================================== --- trunk/libs/buildall_cmake.bat (rev 0) +++ trunk/libs/buildall_cmake.bat 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,75 @@ + @ echo off +setlocal +cd /d %~dp0 + +set CMAKE="cmake.exe2" +set opt= + +:retry_vs +echo 1. Visual Studio 15 2017 +echo 2. Visual Studio 14 2015 +echo 3. Visual Studio 12 2013 +echo 4. Visual Studio 11 2012 +echo 5. Visual Studio 10 2010 +echo 6. Visual Studio 9 2008 +echo 7. Visual Studio 8 2005 +rem echo 9. Visual Studio NMake (experimental) +rem echo z. Cygwin MinGW Release + Unix Makefiles (experimental) +set /p no="select no " + +echo %no% +if "%no%" == "1" set GENERATOR="Visual Studio 15 2017" & goto build_all +if "%no%" == "2" set GENERATOR="Visual Studio 14 2015" & goto build_all +if "%no%" == "3" set GENERATOR="Visual Studio 12 2013" & goto build_all +if "%no%" == "4" set GENERATOR="Visual Studio 11 2012" & goto build_all +if "%no%" == "5" set GENERATOR="Visual Studio 10 2010" & goto build_all +if "%no%" == "6" set GENERATOR="Visual Studio 9 2008" & goto build_all +if "%no%" == "7" set GENERATOR="Visual Studio 8 2005" & call :cmake_3_11_4 & goto build_all_2 +if "%no%" == "9" set GENERATOR="NMake Makefiles" & set OPT=-DCMAKE_BUILD_TYPE=Release & goto build_all +if "%no%" == "z" set GENERATOR="Unix Makefiles" & set OPT=-DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake & goto build_all +echo ? retry +goto retry_vs + +:build_all +where %CMAKE% +if %errorlevel% == 0 goto build_all_2 +set CMAKE="C:\Program Files\CMake\bin\cmake.exe" +if exist %CMAKE% echo %CMAKE% \x82\xF0\x8Eg\x97p & goto build_all_2 +echo cmake\x82\xAA\x8C\xA9\x82\xA9\x82\xE8\x82܂\xB9\x82\xF1 +pause +exit + +:build_all_2 +set C=%CMAKE% -DCMAKE_GENERATOR=%GENERATOR% %OPT% -P buildall.cmake +echo %C% +title %C% +pause +%C% + +:finish +echo build complete +endlocal +pause +exit + +:cmake_3_11_4 +set CMAKE=%~dp0cmake-3.11.4-win32-x86\bin\cmake.exe +echo 1. \x8E\xA9\x95\xAA\x82\xCCcmake.exe\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9(PATH\x82\xF0\x92ʂ\xB5\x82Ă\xA0\x82\xE9) +echo 2. VS2005\x82ł\xE0\x8Eg\x97p\x82ł\xAB\x82\xE9cmake\x8Eg\x97p\x82\xB7\x82\xE9 +echo (\x95K\x97v\x82Ȃ玩\x93\xAE\x82Ń_\x83E\x83\x93\x83\x8D\x81[\x83h\x82\xB5\x82āA\x82\xB1\x82̃t\x83H\x83\x8B\x83_\x82ɃC\x83\x93\x83X\x83g\x81[\x83\x8B\x82\xB7\x82\xE9) +if exist %CMAKE% echo \x83C\x83\x93\x83X\x83g\x81[\x83\x8B\x8Dς\xDD(%CMAKE%) + +set /p no="select no " +echo %no% +if "%no%" == "2" goto download + +set CMAKE="cmake.exe" +where %CMAKE% +goto finish_cmake + +:download +if exist %CMAKE% goto finish_cmake +call getcmake.bat + +:finish_cmake +exit /b Added: trunk/libs/getcmake.bat =================================================================== --- trunk/libs/getcmake.bat (rev 0) +++ trunk/libs/getcmake.bat 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,8 @@ + @ echo off +setlocal +cd /d %~dp0 +echo cmake\x82\xF0\x83_\x83E\x83\x93\x83\x8D\x81[\x83h\x82\xB5\x82\xC4lib/cmake\x82ɓW\x8AJ\x82\xB5\x82܂\xB7 +pause +powershell -NoProfile -ExecutionPolicy Unrestricted .\getcmake.ps1 +endlocal +pause Added: trunk/libs/getcmake.ps1 =================================================================== --- trunk/libs/getcmake.ps1 (rev 0) +++ trunk/libs/getcmake.ps1 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,33 @@ +$CMAKE_URL = "https://cmake.org/files/v3.11/cmake-3.11.4-win32-x86.zip" +$CMAKE_ZIP = ($CMAKE_URL -split "/")[-1] +$CMAKE_DIR = [System.IO.Path]::GetFileNameWithoutExtension($CMAKE_ZIP) + +$CMAKE_ZIP = "download\cmake\" + $CMAKE_ZIP + +echo $CMAKE_URL +echo $CMAKE_ZIP +echo $CMAKE_DIR + +# TLS1.2 \x82\xF0\x97L\x8C\xF8\x82ɂ\xB7\x82\xE9 (cmake.org\x82\xCD TLS1.2) +# [Net.ServicePointManager]::SecurityProtocol +# \x82\xF0\x8E\xC0\x8Ds\x82\xB5\x82\xC4 "Ssl3, Tls" \x82Əo\x82\xBD\x8Fꍇ\x81ATLS1.2\x82͖\xB3\x8C\xF8\x82ƂȂ\xC1\x82Ă\xA2\x82\xE9 +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; + +# \x93W\x8AJ\x8Dς݃t\x83H\x83\x8B\x83_\x82\xAA\x82\xA0\x82\xE9? +if((Test-Path $CMAKE_DIR) -eq $true) { + # \x8D폜\x82\xB7\x82\xE9 + Remove-Item -Recurse -Force $CMAKE_DIR + # \x8FI\x97\xB9\x82\xB7\x82\xE9 + #exit +} + +# \x83_\x83E\x83\x93\x83\x8D\x81[\x83h\x82\xB7\x82\xE9 +if((Test-Path $CMAKE_ZIP) -eq $false) { + if((Test-Path "download\cmake") -ne $true) { + mkdir "download\cmake" + } + wget $CMAKE_URL -Outfile $CMAKE_ZIP +} + +# \x93W\x8AJ\x82\xB7\x82\xE9 +Expand-Archive $CMAKE_ZIP -DestinationPath . Added: trunk/libs/lib_SFMT.cmake =================================================================== --- trunk/libs/lib_SFMT.cmake (rev 0) +++ trunk/libs/lib_SFMT.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,15 @@ + +include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake) + +set(SFMT_ROOT ${CMAKE_CURRENT_LIST_DIR}/SFMT_${TOOLSET}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(SFMT_ROOT "${SFMT_ROOT}_x64") +endif() + +set(SFMT_INCLUDE_DIRS + "${SFMT_ROOT}/include" + ) + +set(SFMT_LIBRARY_DIRS + "${SFMT_ROOT}/lib" + ) Added: trunk/libs/lib_oniguruma.cmake =================================================================== --- trunk/libs/lib_oniguruma.cmake (rev 0) +++ trunk/libs/lib_oniguruma.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,13 @@ + +include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake) + +set(ONIGURUMA_ROOT ${CMAKE_CURRENT_LIST_DIR}/oniguruma_${TOOLSET}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ONIGURUMA_ROOT "${ONIGURUMA_ROOT}_x64") +endif() + +#set(ONIGURUMA_DIR "${ONIGURUMA_ROOT}/lib/cmake/oniguruma") +#find_package(ONIGURUMA REQUIRED) +set(ONIGURUMA_INCLUDE_DIRS ${ONIGURUMA_ROOT}/include) +set(ONIGURUMA_LIBRARY_DIRS ${ONIGURUMA_ROOT}/lib) + Added: trunk/libs/lib_openssl.cmake =================================================================== --- trunk/libs/lib_openssl.cmake (rev 0) +++ trunk/libs/lib_openssl.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,27 @@ + +include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake) + +set(OPENSSL_ROOT ${CMAKE_CURRENT_LIST_DIR}/openssl_${TOOLSET}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(OPENSSL_ROOT "${OPENSSL_ROOT}_x64") +endif() + +if(MINGW) + set(OPENSSL_INCLUDE_DIRS + ${OPENSSL_ROOT}/include + ) + + set(OPENSSL_LIB + ${OPENSSL_ROOT}/lib/libcrypto.a + ) +else() + set(OPENSSL_INCLUDE_DIRS + "$<$<CONFIG:Debug>:${OPENSSL_ROOT}_debug/include>" + "$<$<CONFIG:Release>:${OPENSSL_ROOT}/include>" + ) + + set(OPENSSL_LIB + debug ${OPENSSL_ROOT}_debug/lib/libeay32.lib + optimized ${OPENSSL_ROOT}/lib/libeay32.lib + ) +endif() Added: trunk/libs/lib_zlib.cmake =================================================================== --- trunk/libs/lib_zlib.cmake (rev 0) +++ trunk/libs/lib_zlib.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,10 @@ + +include(${CMAKE_CURRENT_LIST_DIR}/script_support.cmake) + +set(ZLIB_ROOT ${CMAKE_CURRENT_LIST_DIR}/zlib_${TOOLSET}) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ZLIB_ROOT "${ZLIB_ROOT}_x64") +endif() + +set(ZLIB_INCLUDE_DIRS ${ZLIB_ROOT}/include) +set(ZLIB_LIBRARY_DIRS ${ZLIB_ROOT}/lib) Added: trunk/libs/oniguruma.cmake =================================================================== --- trunk/libs/oniguruma.cmake (rev 0) +++ trunk/libs/oniguruma.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,147 @@ +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P oniguruma.cmake +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P oniguruma.cmake + +#### +if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "")) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # multi-configuration + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Release + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P oniguruma.cmake + ) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P oniguruma.cmake + ) + return() + elseif("$ENV{MSYSTEM}" MATCHES "MINGW") + # mingw on msys2 + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + # mingw + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") + # VS nmake + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + else() + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + endif() +endif() + +include(script_support.cmake) + +set(SRC_DIR_BASE "onig-6.9.0") +set(SRC_ARC "onig-6.9.0.tar.gz") +set(SRC_URL "https://github.com/kkos/oniguruma/releases/download/v6.9.0/onig-6.9.0.tar.gz") +set(SRC_ARC_HASH_SHA1 8e3e39e8e92f040939922ddc367a56c12bd4c4c3) + +set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/oniguruma") +set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/src") +set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/src/${SRC_DIR_BASE}") +set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/oniguruma/build_${TOOLSET}") +set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/oniguruma_${TOOLSET}") +if(("${CMAKE_GENERATOR}" MATCHES "Win64") OR ("$ENV{MSYSTEM_CHOST}" STREQUAL "x86_64-w64-mingw32")) + set(BUILD_DIR "${BUILD_DIR}_x64") + set(INSTALL_DIR "${INSTALL_DIR}_x64") +endif() + +######################################## + +if(NOT EXISTS ${SRC_DIR}/README.md) + + file(DOWNLOAD + ${SRC_URL} + ${DOWN_DIR}/${SRC_ARC} + EXPECTED_HASH SHA1=${SRC_ARC_HASH_SHA1} + SHOW_PROGRESS + ) + + file(MAKE_DIRECTORY ${EXTRACT_DIR}) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC} + WORKING_DIRECTORY ${EXTRACT_DIR} + ) + +endif() + +######################################## + +file(MAKE_DIRECTORY "${BUILD_DIR}") + +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + + ######################################## multi configuration + + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + ${TOOLCHAINFILE} + -DCMAKE_DEBUG_POSTFIX=d + -DBUILD_SHARED_LIBS=OFF + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake generate fail ${rv}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_CONFIGURATION_TYPE} --target install + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() + +else() + ######################################## single configuration + + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + -DBUILD_SHARED_LIBS=OFF + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --target install + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() + +endif() Added: trunk/libs/openssl.cmake =================================================================== --- trunk/libs/openssl.cmake (rev 0) +++ trunk/libs/openssl.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,304 @@ +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P openssl.cmake +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P openssl.cmake + +#### +if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "")) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # multi-configuration + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Release + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P openssl.cmake + ) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P openssl.cmake + ) + return() + elseif("$ENV{MSYSTEM}" MATCHES "MINGW32") + # mingw on msys2 + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + # mingw + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") + # VS nmake + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + else() + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + endif() +endif() + +include(script_support.cmake) + +set(SRC_DIR_BASE "openssl-1.0.2q") +set(SRC_ARC "openssl-1.0.2q.tar.gz") +set(SRC_URL "https://www.openssl.org/source/openssl-1.0.2q.tar.gz") +set(SRC_ARC_HASH_SHA256 5744cfcbcec2b1b48629f7354203bc1e5e9b5466998bbccc5b5fcde3b18eb684) + +set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/openssl") + +set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/openssl/src_${TOOLSET}") +set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/openssl_${TOOLSET}") +if(("${CMAKE_GENERATOR}" MATCHES "Win64") OR ("$ENV{MSYSTEM_CHOST}" STREQUAL "x86_64-w64-mingw32")) + set(EXTRACT_DIR "${EXTRACT_DIR}_x64") + set(INSTALL_DIR "${INSTALL_DIR}_x64") +endif() +if((${CMAKE_GENERATOR} MATCHES "Visual Studio") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "Debug")) + set(EXTRACT_DIR "${EXTRACT_DIR}_debug") + set(INSTALL_DIR "${INSTALL_DIR}_debug") +endif() +set(SRC_DIR "${EXTRACT_DIR}/${SRC_DIR_BASE}") + +######################################## + +file(DOWNLOAD + ${SRC_URL} + ${DOWN_DIR}/${SRC_ARC} + EXPECTED_HASH SHA256=${SRC_ARC_HASH_SHA256} + SHOW_PROGRESS + ) + +######################################## + +if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") + find_program( + PERL perl + ) +else() + # CYGWIN / Active Perl + find_program( + PERL perl.exe + HINTS c:/Perl64/bin + HINTS c:/Perl/bin + HINTS c:/cygwin/usr/bin + HINTS c:/cygwin64/usr/bin + ) +endif() + +if(${PERL} STREQUAL "PERL-NOTFOUND") + message(FATAL_ERROR "perl not found") +endif() + +######################################## + +if(NOT EXISTS ${SRC_DIR}/README) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${EXTRACT_DIR} + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC} + WORKING_DIRECTORY ${EXTRACT_DIR} + ) + +endif() + +######################################## + +if((${CMAKE_GENERATOR} MATCHES "Visual Studio") OR + (${CMAKE_GENERATOR} MATCHES "NMake Makefiles")) + ######################################## VS + if(${CMAKE_GENERATOR} MATCHES "NMake Makefiles") + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") + find_program( + VCVARS32 vcvarsall.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build" + HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Auxiliary/Build" + HINTS "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 14 2015") + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 12 2013") + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 11 2012") + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 10 2010") + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 9 2008") + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 8 2005") + find_program( + VCVARS32 vcvars32.bat + HINTS "C:/Program Files (x86)/Microsoft Visual Studio 8/VC/bin" + ) + else() + message(FATAL_ERROR "CMAKE_GENERATOR ${CMAKE_GENERATOR} not supported") + endif() + if(VCVARS32-NOTFOUND) + message(FATAL_ERROR "vcvars32.bat not found") + endif() + + if(${CMAKE_GENERATOR} MATCHES "Win64") + set(CONFIG_TARGET "VC-WIN64A") + set(DO_MS "ms\\do_win64a.bat") + else() + set(CONFIG_TARGET "VC-WIN32") + set(DO_MS "ms\\do_ms.bat") + endif() + if(("${CMAKE_BUILD_TYPE}" STREQUAL "Release") OR ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "Release")) + else() + set(CONFIG_TARGET "debug-${CONFIG_TARGET}") + endif() + + file(WRITE "${SRC_DIR}/build_cmake.bat" + "cd %~dp0\n" + "setlocal\n" + ) + file(TO_NATIVE_PATH ${PERL} PERL_N) + file(TO_NATIVE_PATH ${INSTALL_DIR} INSTALL_DIR_N) + file(TO_NATIVE_PATH ${VCVARS32} VCVARS32_N) + string(REGEX REPLACE [[^(.*)\\.*$]] [[\1]] PERL_N_PATH ${PERL_N}) + file(APPEND "${SRC_DIR}/build_cmake.bat" + "del crypto\\buildinf.h\n" + "setlocal\n" + "set PATH=${PERL_N_PATH}\n" + "perl Configure no-asm ${CONFIG_TARGET} --prefix=${INSTALL_DIR_N}\n" + "call ${DO_MS}\n" + "endlocal\n" + ) + if(${CMAKE_GENERATOR} MATCHES "Visual Studio 8 2005") + ## Visual Studio 2005 特別処理 + # include,libパスの設定 + file(APPEND "${SRC_DIR}/build_cmake.bat" + "set SDK=C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\n" + "set INCLUDE=%SDK%\\Include;%INCLUDE%\n" + "set LIB=%SDK%\\lib;%LIB%\n" + ) + endif() + if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017 Win64") + file(APPEND "${SRC_DIR}/build_cmake.bat" + "call \"${VCVARS32_N}\" x86_amd64 10.0.17134.0\n" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") + file(APPEND "${SRC_DIR}/build_cmake.bat" + "call \"${VCVARS32_N}\" x86 10.0.17134.0\n" + ) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio") + file(APPEND "${SRC_DIR}/build_cmake.bat" + "call \"${VCVARS32_N}\"\n" + ) + endif() + file(APPEND "${SRC_DIR}/build_cmake.bat" + "set PATH=${PERL_N_PATH};%PATH%\n" + "nmake -f ms\\nt.mak install ${NMAKE_OPTION}\n" + ) + + set(BUILD_CMAKE_BAT "${SRC_DIR}/build_cmake.bat") + file(TO_NATIVE_PATH ${BUILD_CMAKE_BAT} BUILD_CMAKE_BAT_N) + execute_process( + COMMAND cmd /c ${BUILD_CMAKE_BAT_N} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() +else() + ######################################## MinGW + execute_process( + COMMAND "uname" -s + OUTPUT_VARIABLE ov) + string(REGEX MATCH "[A-Za-z0-9]+" UNAME_S ${ov}) + if("${UNAME_S}" STREQUAL "CYGWIN") + find_program( + MAKE make.exe + HINTS c:/cygwin/usr/bin + HINTS c:/cygwin64/usr/bin + ) + elseif(("${UNAME_S}" STREQUAL "MINGW32") OR ("${UNAME_S}" STREQUAL "MINGW64")) + find_program( + MAKE make + ) + elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") + find_program( + MAKE make + ) + else() + message(FATAL_ERROR "unsported") + endif() + set(ENV{PATH} "/usr/bin;/bin") + if("${UNAME_S}" STREQUAL "MINGW32") + set(CMAKE_C_COMPILER "cc") + set(PATH "/mingw32/bin:/usr/local/bin:/usr/bin:/bin") + elseif("${UNAME_S}" STREQUAL "MINGW64") + set(CMAKE_C_COMPILER "cc") + set(PATH "/mingw64/bin:/usr/local/bin:/usr/bin:/bin") + else() + include(${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake) + set(ENV{PREFIX} i686-w64-mingw32) + set(ENV{CC} ${CMAKE_C_COMPILER}) + set(ENV{AR} "i686-w64-mingw32-ar") + set(ENV{RANLIB} "i686-w64-mingw32-ranlib") + set(PATH "/usr/bin:/bin") + endif() + if("${UNAME_S}" STREQUAL "MINGW64") + set(CONFIG_NAME "mingw64") + else() + set(CONFIG_NAME "mingw") + endif() + execute_process( + COMMAND ${CMAKE_COMMAND} -E env "PATH=/usr/bin:/bin" ${PERL} ./Configure ${CONFIG_NAME} --prefix=${INSTALL_DIR} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake configure fail ${rv}") + endif() + execute_process( + COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} CC=${CMAKE_C_COMPILER} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() + execute_process( + COMMAND ${CMAKE_COMMAND} -E env "PATH=${PATH}" ${MAKE} install + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() +endif() + Added: trunk/libs/putty.cmake =================================================================== --- trunk/libs/putty.cmake (rev 0) +++ trunk/libs/putty.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,33 @@ +# cmake -P putty.cmake + +set(SRC_DIR_BASE "putty-0.70") +set(SRC_ARC "putty-0.70.tar.gz") +set(SRC_URL "https://the.earth.li/~sgtatham/putty/0.70/putty-0.70.tar.gz") +set(SRC_ARC_HASH_SHA256 bb8aa49d6e96c5a8e18a057f3150a1695ed99a24eef699e783651d1f24e7b0be) + +set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/putty") +set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/putty/src") +set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/putty/src/${SRC_DIR_BASE}") +set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/putty") + +if(NOT EXISTS ${INSTALL_DIR}/README) + + file(DOWNLOAD + ${SRC_URL} + ${DOWN_DIR}/${SRC_ARC} + EXPECTED_HASH SHA256=${SRC_ARC_HASH_SHA256} + SHOW_PROGRESS + ) + + file(MAKE_DIRECTORY ${EXTRACT_DIR}) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC} + WORKING_DIRECTORY ${EXTRACT_DIR} + ) + + file(REMOVE_RECURSE ${INSTALL_DIR}) + file(RENAME ${SRC_DIR} ${INSTALL_DIR}) + file(REMOVE_RECURSE ${EXTRACT_DIR}) + +endif() Added: trunk/libs/script_support.cmake =================================================================== --- trunk/libs/script_support.cmake (rev 0) +++ trunk/libs/script_support.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,31 @@ +# TOOLSET ツールセット名 +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017") + set(MSVC_TOOLSET_VERSION 141) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 14 2015") + set(MSVC_TOOLSET_VERSION 140) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 12 2013") + set(MSVC_TOOLSET_VERSION 120) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 11 2012") + set(MSVC_TOOLSET_VERSION 110) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 10 2010") + set(MSVC_TOOLSET_VERSION 100) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 9 2008") + set(MSVC_TOOLSET_VERSION 90) + elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio 8 2005") + set(MSVC_TOOLSET_VERSION 80) + else() + set(MSVC_TOOLSET_VERSION "Unknown") + message(FATAL_ERROR "unknown Visual Studio ${CMAKE_GENERATOR}") + endif() + set(TOOLSET "VS_${MSVC_TOOLSET_VERSION}") +elseif((${CMAKE_GENERATOR} MATCHES "Unix Makefiles") OR + (${CMAKE_GENERATOR} MATCHES "MSYS Makefiles") OR + (${CMAKE_GENERATOR} MATCHES "MinGW Makefiles") OR + (${CMAKE_GENERATOR} MATCHES "Ninja")) + set(TOOLSET "mingw") +elseif(${CMAKE_GENERATOR} MATCHES "NMake Makefiles") + set(TOOLSET "VS_NMake") +else() + message(FATAL_ERROR "unknown GENERATOR ${CMAKE_GENERATOR}") +endif() Added: trunk/libs/zlib.cmake =================================================================== --- trunk/libs/zlib.cmake (rev 0) +++ trunk/libs/zlib.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,144 @@ +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -P zlib.cmake +# cmake -DCMAKE_GENERATOR="Visual Studio 15 2017" -DCMAKE_CONFIGURATION_TYPE=Release -P zlib.cmake + +#### +if(("${CMAKE_BUILD_TYPE}" STREQUAL "") AND ("${CMAKE_CONFIGURATION_TYPE}" STREQUAL "")) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # multi-configuration + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Release + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P zlib.cmake + ) + execute_process( + COMMAND ${CMAKE_COMMAND} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_CONFIGURATION_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/VSToolchain.cmake + -P zlib.cmake + ) + return() + elseif("$ENV{MSYSTEM}" MATCHES "MINGW") + # mingw on msys2 + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") + # mingw + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/../mingw.toolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "NMake Makefiles") + # VS nmake + # single-configuration + if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/VSToolchain.cmake") + endif() + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + else() + # single-configuration + if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE Release) + endif() + endif() +endif() + +include(script_support.cmake) + +set(SRC_DIR_BASE "zlib-1.2.11") +set(SRC_ARC "zlib-1.2.11.tar.xz") +set(SRC_URL "https://zlib.net/zlib-1.2.11.tar.xz") +set(SRC_ARC_HASH_SHA256 4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066) + +set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/zlib") +set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/zlib/src") +set(SRC_DIR "${CMAKE_SOURCE_DIR}/build/zlib/src/${SRC_DIR_BASE}") +set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build/zlib/build_${TOOLSET}") +set(INSTALL_DIR "${CMAKE_SOURCE_DIR}/zlib_${TOOLSET}") +if(("${CMAKE_GENERATOR}" MATCHES "Win64") OR ("$ENV{MSYSTEM_CHOST}" STREQUAL "x86_64-w64-mingw32")) + set(BUILD_DIR "${BUILD_DIR}_x64") + set(INSTALL_DIR "${INSTALL_DIR}_x64") +endif() + +######################################## + +if(NOT EXISTS ${SRC_DIR}/README) + + file(DOWNLOAD + ${SRC_URL} + ${DOWN_DIR}/${SRC_ARC} + EXPECTED_HASH SHA256=${SRC_ARC_HASH_SHA256} + SHOW_PROGRESS + ) + + file(MAKE_DIRECTORY ${EXTRACT_DIR}) + + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${DOWN_DIR}/${SRC_ARC} + WORKING_DIRECTORY ${EXTRACT_DIR} + ) + +endif() + +######################################## + +file(MAKE_DIRECTORY "${BUILD_DIR}") + +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + + ######################################## multi configuration + + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + ${TOOLCHAINFILE} + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake generate fail ${rv}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_CONFIGURATION_TYPE} --target install + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() + +else() + ######################################## single configuration + + execute_process( + COMMAND ${CMAKE_COMMAND} ${SRC_DIR} -G ${CMAKE_GENERATOR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake build fail ${rv}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --target install + WORKING_DIRECTORY ${BUILD_DIR} + RESULT_VARIABLE rv + ) + if(NOT rv STREQUAL "0") + message(FATAL_ERROR "cmake install fail ${rv}") + endif() + +endif() Added: trunk/mingw.toolchain.cmake =================================================================== --- trunk/mingw.toolchain.cmake (rev 0) +++ trunk/mingw.toolchain.cmake 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,35 @@ +# how to build: +# mkdir build; cd build +# cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../mingw.toolchain.cmake +# cmake --build . + +# target +set(CMAKE_SYSTEM_NAME Windows) + +# option +option(USE_CLANG "use clang compiler" OFF) + +# mingw on msys +#set(CMAKE_SYSROOT /mingw32/i686-w64-mingw32) +#set(CMAKE_FIND_ROOT_PATH /mingw32/i686-w64-mingw32) + +# mingw +set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) +#set(CMAKE_SYSROOT /usr/i686-w64-mingw32) + +if(USE_CLANG) + set(CMAKE_C_COMPILER i686-w64-mingw32-clang) + set(CMAKE_CXX_COMPILER i686-w64-mingw32-clang++) +else() + set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) + set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) +endif() +set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE PATH "toolchain file") + Added: trunk/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/CMakeLists.txt (rev 0) +++ trunk/teraterm/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,43 @@ + +add_subdirectory(ttpcmn) +set_target_properties( + ttpcmn + PROPERTIES FOLDER teraterm) + +add_subdirectory(ttpdlg) +set_target_properties( + ttpdlg + PROPERTIES FOLDER teraterm) + +add_subdirectory(ttpfile) +set_target_properties( + ttpfile + PROPERTIES FOLDER teraterm) + +add_subdirectory(ttpset) +set_target_properties( + ttpset + PROPERTIES FOLDER teraterm) + +add_subdirectory(ttpmacro) +set_target_properties( + ttpmacro + PROPERTIES FOLDER teraterm) + +add_subdirectory(ttptek) +set_target_properties( + ttptek + PROPERTIES FOLDER teraterm) + +add_subdirectory(teraterm) +set_target_properties( + teraterm + PROPERTIES FOLDER teraterm) + +add_subdirectory(keycode) +set_target_properties( + keycode + PROPERTIES FOLDER teraterm) + +# ttpdlg内でconfig時 svnversion.h を生成 +#add_subdirectory(svnrev) Added: trunk/teraterm/keycode/CMakeLists.txt =================================================================== --- trunk/teraterm/keycode/CMakeLists.txt (rev 0) +++ trunk/teraterm/keycode/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,30 @@ +project(keycode) + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + keycode.c + keycode.ico + keycode-version.rc + keycode.rc + kc_res.h + ) + +include_directories( + ../common + ../ttpfile + . + ) + +add_executable( + keycode WIN32 + ${SRC} + ) + +target_link_libraries( + keycode + ) Added: trunk/teraterm/svnrev/CMakeLists.txt =================================================================== --- trunk/teraterm/svnrev/CMakeLists.txt (rev 0) +++ trunk/teraterm/svnrev/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,23 @@ +project(svnrev) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + svnrev.cpp + svnrev.h + ) + +include_directories( + ../common + ../ttpfile + . + ) + +add_executable( + svnrev + ${SRC} + ) + +target_link_libraries( + svnrev + ) Added: trunk/teraterm/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/teraterm/CMakeLists.txt (rev 0) +++ trunk/teraterm/teraterm/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,174 @@ +project(teraterm) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../common/tt_res.h + ../common/ttcommon.h + ../common/ttddecmnd.h + ../common/tttypes.h + ../common/tektypes.h + ../common/ttftypes.h + ../common/ttplugin.h + ../common/tt-version.h + ../common/teraterm.h + ../common/ttlib.c + ../common/ttlib.h + ../common/dlglib.c + ../common/dlglib.h + ../common/win16api.h + ../common/win16api.c + ../common/codemap.h + ../common/compat_w95.h + ../common/i18n.h + ../ttpcmn/language.h + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + addsetting.cpp + addsetting.h + buffer.c + buffer.h + clipboar.c + clipboar.h + commlib.c + commlib.h + dnddlg.cpp + dnddlg.h + filesys.cpp + filesys.h + ftdlg.cpp + ftdlg.h + keyboard.c + keyboard.h + prnabort.cpp + prnabort.h + protodlg.cpp + protodlg.h + sizetip.c + sizetip.h + teklib.c + teklib.h + tekwin.cpp + tekwin.h + telnet.c + telnet.h + teraapp.h + teraprn.cpp + teraprn.h + teraterm.cpp + ttdde.c + ttdde.h + ttdialog.c + ttdialog.h + ttermpro.rc + ttfileio.c + ttfileio.h + ttime.c + ttime.h + ttplug.c + ttplug.h + ttsetup.c + ttsetup.h + tt-version.rc + ttwinman.c + ttwinman.h + ttwsk.c + ttwsk.h + vtdisp.c + vtdisp.h + vtterm.c + vtterm.h + vtwin.cpp + vtwin.h + winjump.c + winjump.h + WSAAsyncGetAddrInfo.c + WSAAsyncGetAddrInfo.h + # + uni2sjis.map + unisym2decsp.map + uni_combining.map + # + teraterm.manifest + # + ${COMMON_SRC} + ) + +include_directories( + ../common + ../ttpfile + ${SFMT_INCLUDE_DIRS} + ${ONIGURUMA_INCLUDE_DIRS} + . + ${CMAKE_CURRENT_BINARY_DIR} + ) + +link_directories( + ${ONIGURUMA_LIBRARY_DIRS} + ${SFMT_LIBRARY_DIRS} + ) + +set(CMAKE_MFC_FLAG 1) + +if (MSVC) + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:imagehlp.dll /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll") +endif() + +add_executable( + teraterm WIN32 + ${SRC} + ) + +set_target_properties( + teraterm + PROPERTIES + OUTPUT_NAME "ttermpro" + ) + +target_link_libraries( + teraterm + ttpcmn + ttpdlg + ttpfile + ttpset + ttptek + optimized nafxcw.lib + debug nafxcwd.lib + optimized LIBCMT.lib + debug LIBCMTD.lib + optimized onig.lib + debug onigd.lib + # + gdi32 + comctl32 + ws2_32 + imm32 + imagehlp + delayimp + oleaut32 + uuid + ) + +add_dependencies( + teraterm + ttpcmn + ttpdlg + ttpfile + ttpset + ttptek + ) Added: trunk/teraterm/ttpcmn/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpcmn/CMakeLists.txt (rev 0) +++ trunk/teraterm/ttpcmn/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,73 @@ +project(ttpcmn) + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../common/teraterm.h + ../common/tttypes.h + ../common/i18n.c + ../common/i18n.h + ../common/ttlib.c + ../common/ttlib.h + ../common/servicenames.c + ../common/servicenames.h + ../common/tt-version.h + ../common/ttftypes.h + ../common/ttcommon.h + ../common/tt_res.h + ../common/codeconv.h + ../common/codeconv.cpp + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + ttpcmn.def + cmn_res.h + language.c + language.h + ttcmn.c + ttpcmn-version.rc + ttpcmn.rc + ${COMMON_SRC} + ) + +include_directories( + ../common + ../ttpfile + . + ) + +if (MSVC) + set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:setupapi.dll /DELAYLOAD:user32.dll") +endif() + +add_library( + ttpcmn + SHARED + ${SRC} + ) + +if(MINGW) + set_target_properties( + ttpcmn + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) +endif() + +target_link_libraries( + ttpcmn + ole32 + setupapi + delayimp + ) Added: trunk/teraterm/ttpdlg/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpdlg/CMakeLists.txt (rev 0) +++ trunk/teraterm/ttpdlg/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,78 @@ +project(ttpdlg) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +if(MINGW) + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -I ${CMAKE_CURRENT_SOURCE_DIR}/../common") +else() + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /i ${CMAKE_CURRENT_SOURCE_DIR}/../common") +endif() + +set(COMMON_SRC + ../common/dlglib.c + ../common/dlglib.h + ../common/ttlib.c + ../common/ttlib.h + ../common/teraterm.ico + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + dlg_res.h + ttdlg.c + ttpdlg.def + ttpdlg.rc + ttpdlg-version.rc + ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h + ${COMMON_SRC} + ) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../common + ${CMAKE_CURRENT_BINARY_DIR} + ${ONIGURUMA_INCLUDE_DIRS} + ) + +link_directories( + ${ONIGURUMA_LIBRARY_DIRS} + ) + +add_library( + ttpdlg SHARED + ${SRC} + ) + +if(MINGW) + set_target_properties( + ttpdlg + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) +endif() + +target_link_libraries( + ttpdlg + ttpcmn + optimized onig.lib + debug onigd.lib + ) + +add_dependencies( + ttpdlg + ttpcmn + ) + +configure_file( + svnversion.h.in + svnversion.h @ONLY) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/svnversion.h") + file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/svnversion.h") +endif() Added: trunk/teraterm/ttpdlg/svnversion.h.in =================================================================== --- trunk/teraterm/ttpdlg/svnversion.h.in (rev 0) +++ trunk/teraterm/ttpdlg/svnversion.h.in 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1 @@ +#cmakedefine SVNVERSION @SVNVERSION@ Added: trunk/teraterm/ttpfile/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpfile/CMakeLists.txt (rev 0) +++ trunk/teraterm/ttpfile/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,71 @@ +project(ttpfile) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../common/dlglib.c + ../common/dlglib.h + ../common/ttlib.c + ../common/ttlib.h + ../common/win16api.h + ../common/win16api.c + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + bplus.c + bplus.h + ftlib.c + ftlib.h + kermit.c + kermit.h + quickvan.c + quickvan.h + ttfile.c + xmodem.c + xmodem.h + ymodem.c + ymodem.h + zmodem.c + zmodem.h + file_res.h + ttpfile-version.rc + ttpfile.rc + ttpfile.def + ${COMMON_SRC} + ) + +include_directories( + ../common + ) + +add_library( + ttpfile SHARED + ${SRC} + ) + +if(MINGW) + set_target_properties( + ttpfile + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) +endif() + +target_link_libraries( + ttpfile + ttpcmn + # + gdi32 + comdlg32 + ) + +add_dependencies( + ttpfile + ttpcmn + ) Added: trunk/teraterm/ttpmacro/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpmacro/CMakeLists.txt (rev 0) +++ trunk/teraterm/ttpmacro/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,127 @@ +project(ttpmacro) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake) + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../common/teraterm.h + ../common/ttcommon.h + ../common/ttddecmnd.h + ../common/tttypes.h + ../common/tt-version.h + ../common/i18n.c + ../common/i18n.h + ../common/ttlib.c + ../common/ttlib.h + ../common/compat_w95.h + ../common/win16api.h + ../common/win16api.c + ../common/codeconv.h + ../common/codeconv.cpp + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + ttm_res.h + errdlg.cpp + errdlg.h + inpdlg.cpp + inpdlg.h + ListDlg.cpp + ListDlg.h + msgdlg.cpp + msgdlg.h + statdlg.cpp + statdlg.h + stdafx.h + ttl.c + ttl.h + ttm_res.h + ttmacro.cpp + ttmacro.h + ttmbuff.c + ttmbuff.h + ttmdde.c + ttmdde.h + ttmdef.h + ttmdlg.cpp + ttmdlg.h + ttmenc.c + ttmenc.h + ttmlib.c + ttmlib.h + ttmmain.cpp + ttmmain.h + ttmmsg.h + ttmonig.h + ttmparse.c + ttmparse.h + wait4all.c + wait4all.h + + ttpmacro.rc + ttm-version.rc + fileread.h + fileread.cpp + ${COMMON_SRC} + ) + +include_directories( + ${ONIGURUMA_INCLUDE_DIRS} + ${SFMT_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/../common + ) + +link_directories( + ${ONIGURUMA_LIBRARY_DIRS} + ${SFMT_LIBRARY_DIRS} + ) + +set(CMAKE_MFC_FLAG 1) + +if (MSVC) + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll") +endif() + +add_executable( + ttpmacro WIN32 + ${SRC} + ) + +target_link_libraries( + ttpmacro + ttpcmn + optimized nafxcw.lib + debug nafxcwd.lib + optimized LIBCMT.lib + debug LIBCMTD.lib + optimized onig.lib + debug onigd.lib + optimized sfmt.lib + debug sfmtd.lib + # + iphlpapi + delayimp + ws2_32 + comctl32 + gdi32 + comdlg32 + ) + +add_dependencies( + ttpmacro + ttpcmn + ) Added: trunk/teraterm/ttpset/CMakeLists.txt =================================================================== --- trunk/teraterm/ttpset/CMakeLists.txt (rev 0) +++ trunk/teraterm/ttpset/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,52 @@ +project(ttpset) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../common/tttypes.h + ../common/ttlib.c + ../common/ttlib.h + ../common/servicenames.h + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + ttset.c + ttpset-version.rc + ttpset.def + ${COMMON_SRC} + ) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../common + ) + +add_library( + ttpset SHARED + ${SRC} + ) + +if(MINGW) + set_target_properties( + ttpset + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) +endif() + +target_link_libraries( + ttpset + ttpcmn + # + gdi32 + ) + +add_dependencies( + ttpset + ttpcmn + ) Added: trunk/teraterm/ttptek/CMakeLists.txt =================================================================== --- trunk/teraterm/ttptek/CMakeLists.txt (rev 0) +++ trunk/teraterm/ttptek/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,69 @@ +project(ttptek) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_oniguruma.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_SFMT.cmake) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../common/tttypes.h + ../common/i18n.c + ../common/i18n.h + ../common/ttlib.c + ../common/ttlib.h + ) +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + tek_res.h + tekesc.c + tekesc.h + ttptek.def + ttptek.rc + ttptek-version.rc +# tttek.h + tttek.c + ${COMMON_SRC} + ) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../common + ${ONIGURUMA_INCLUDE} + ${SFMT_INCLUDE_DIR} + ) + +link_directories( + ${SFMT_LIBRARY_DIRS} + ) + +add_library( + ttptek SHARED + ${SRC} + ) + +if(MINGW) + set_target_properties( + ttptek + PROPERTIES PREFIX "" + SUFFIX ".dll" + ) +endif() + +target_link_libraries( + ttptek + ttpcmn + debug sfmtd.lib + optimized sfmt.lib + # + iphlpapi + gdi32 + ) + +add_dependencies( + ttptek + ttpcmn + ) Added: trunk/ttpmenu/CMakeLists.txt =================================================================== --- trunk/ttpmenu/CMakeLists.txt (rev 0) +++ trunk/ttpmenu/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,50 @@ +project(ttpmenu) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(COMMON_SRC + ../teraterm/common/ttlib.c + ../teraterm/common/ttlib.h + ../teraterm/common/i18n.c + ../teraterm/common/i18n.h + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + resource.h + registry.cpp + ttpmenu.cpp + winmisc.cpp + left.ico + right.ico + teraterm.ico + ttpmenu.rc + ) + + +include_directories( + ../teraterm/common + . + ) + +add_executable( + ttpmenu WIN32 + ${SRC} + ${COMMON_SRC} + ) + +target_link_libraries( + ttpmenu + version + comctl32 + user32 + gdi32 + comdlg32 + ) + + Added: trunk/ttssh2/CMakeLists.txt =================================================================== --- trunk/ttssh2/CMakeLists.txt (rev 0) +++ trunk/ttssh2/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,16 @@ +add_subdirectory(ttxssh) +set_target_properties(ttxssh PROPERTIES FOLDER ttssh2) + +add_subdirectory(ttssh) +set_target_properties(ttssh PROPERTIES FOLDER ttssh2) + +add_subdirectory(matcher) +set_target_properties(matcher PROPERTIES FOLDER ttssh2) + +# config時に cmake で puttyversion.h を生成するようにした +#add_subdirectory(puttyrev) +#set_target_properties(puttyrev PROPERTIES FOLDER ttssh2) + +add_subdirectory(putty) +set_target_properties(libputty PROPERTIES FOLDER ttssh2) + Added: trunk/ttssh2/matcher/CMakeLists.txt =================================================================== --- trunk/ttssh2/matcher/CMakeLists.txt (rev 0) +++ trunk/ttssh2/matcher/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,13 @@ +project(matcher) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + matcher.c + test.c + ) + +add_executable( + matcher + ${SRC} + ) Added: trunk/ttssh2/putty/CMakeLists.txt =================================================================== --- trunk/ttssh2/putty/CMakeLists.txt (rev 0) +++ trunk/ttssh2/putty/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,30 @@ +project(libputty) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +if(MINGW) + add_definitions("-D_WINDOWS") +endif() + +set(SRC + ../../libs/putty/conf.c + ../../libs/putty/misc.c + ../../libs/putty/tree234.c + ../../libs/putty/version.c + ../../libs/putty/windows/winmisc.c + ../../libs/putty/windows/winpgntc.c + ../../libs/putty/windows/winsecur.c + libputty.c + libputty.h + ) + +include_directories( + ../../libs/putty + ../../libs/putty/windows + . + ) + +add_library( + libputty + ${SRC} + ) Added: trunk/ttssh2/puttyrev/CMakeLists.txt =================================================================== --- trunk/ttssh2/puttyrev/CMakeLists.txt (rev 0) +++ trunk/ttssh2/puttyrev/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,13 @@ +project(puttyrev) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + puttyrev.h + puttyrev.cpp + ) + +add_executable( + puttyrev + ${SRC} + ) Added: trunk/ttssh2/ttssh/CMakeLists.txt =================================================================== --- trunk/ttssh2/ttssh/CMakeLists.txt (rev 0) +++ trunk/ttssh2/ttssh/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,15 @@ +project(ttssh) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +set(SRC + resource.h + ttsecure.ico + ttssh.c + ttssh.rc + ) + +add_executable( + ttssh WIN32 + ${SRC} + ) Added: trunk/ttssh2/ttxssh/CMakeLists.txt =================================================================== --- trunk/ttssh2/ttxssh/CMakeLists.txt (rev 0) +++ trunk/ttssh2/ttxssh/CMakeLists.txt 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,150 @@ +project(ttxssh) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_zlib.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/../../libs/lib_openssl.cmake) + +if(USE_UNICODE_API) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +set(COMMON_SRC + ../../teraterm/teraterm/WSAAsyncGetAddrInfo.c + ../../teraterm/common/ttcommon.h + ../../teraterm/common/i18n.h + ../../teraterm/common/ttlib.h + ../../teraterm/common/dlglib.h + ../../teraterm/common/servicenames.h + ../../teraterm/common/codeconv.cpp + ../../teraterm/common/codeconv.h + ) + +source_group( + "common" + FILES + ${COMMON_SRC} + ) + +set(SRC + ${CMAKE_CURRENT_BINARY_DIR}/puttyversion.h + ../matcher/matcher.c + arc4random.c + arc4random.h + auth.c + auth.h + buffer.c + buffer.h + chacha.c + chacha.h + cipher.h + cipher-ctr.c + config.h + crypt.c + crypt.h + dns.c + dns.h + ed25519.c + ed25519_bcrypt_pbkdf.c + ed25519_blf.h + ed25519_blocks.c + ed25519_blowfish.c + ed25519_crypto_api.h + ed25519_fe25519.c + ed25519_fe25519.h + ed25519_ge25519.c + ed25519_ge25519.h + ed25519_hash.c + ed25519_sc25519.c + ed25519_sc25519.h + ed25519_verify.c + fwd.c + fwd.h + fwd-socks.c + fwd-socks.h + fwdui.c + fwdui.h + hosts.c + hosts.h + kex.c + kex.h + key.c + key.h + keyfiles.c + keyfiles.h + pkt.c + pkt.h + resource.h + sftp.c + sftp.h + ssh.c + ssh.h + ttxssh.c + ttxssh.def + ttxssh.h + ttxssh.rc + ttxssh-version.h + ttxssh-version.rc + util.c + util.h + x11util.c + x11util.h + ${COMMON_SRC} + ) + + +include_directories( + ../../teraterm/teraterm + ../../teraterm/common + ../matcher + ../putty + ${OPENSSL_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} + ) + +link_directories( + ${ZLIB_LIBRARY_DIRS} + ) + +if (MSVC) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:dnsapi.dll") +endif() + +add_library( + ttxssh SHARED + ${SRC} + ) + +target_link_libraries( + ttxssh + libputty + ttpcmn + debug zlibstaticd + optimized zlibstatic + ${OPENSSL_LIB} + # + ws2_32 + dnsapi + gdi32 + comdlg32 + delayimp + ) + +### create puttyversion.h + +file(READ "${CMAKE_SOURCE_DIR}/libs/putty/windows/putty.iss" iis) + +string(REGEX MATCH "VersionInfoTextVersion=([^\n]+)\n" _ ${iis}) +set(version_str ${CMAKE_MATCH_1}) +if("${version_str}" STREQUAL "") + string(REGEX MATCH "AppVerName=([^\n]+)\n" _ ${iis}) + set(version_str ${CMAKE_MATCH_1}) +endif() +if("${version_str}" STREQUAL "") + set(version_str "unknown") +endif() +message("putty version=\"${version_str}\"") +FILE( + WRITE ${CMAKE_CURRENT_BINARY_DIR}/puttyversion.h + "#define PUTTYVERSION \"${version_str}\"\n" + ) Added: trunk/version_info.h.in =================================================================== --- trunk/version_info.h.in (rev 0) +++ trunk/version_info.h.in 2019-03-02 16:18:47 UTC (rev 7456) @@ -0,0 +1,42 @@ + +#cmakedefine USE_UNICODE_API +#cmakedefine SVNVERSION @SVNVERSION@ + +// infos when generated +#cmakedefine MSVC +#cmakedefine MINGW +// CMAKE_GENERATOR +// @CMAKE_GENERATOR@ +// CMAKE_COMMAND +// @CMAKE_COMMAND@ +// CMAKE_C_COMPILER +// @CMAKE_C_COMPILER@ +// CMAKE_CXX_COMPILER +// @CMAKE_CXX_COMPILER@ +// CMAKE_C_FLAGS +// @CMAKE_C_FLAGS@ +// CMAKE_C_FLAGS_RELEASE +// @CMAKE_C_FLAGS_RELEASE@ +// CMAKE_C_FLAGS_DEBUG +// @CMAKE_C_FLAGS_DEBUG@ +// CMAKE_CXX_FLAGS +// @CMAKE_CXX_FLAGS@ +// CMAKE_CXX_FLAGS_RELEASE +// @CMAKE_CXX_FLAGS_RELEASE@ +// CMAKE_CXX_FLAGS_DEBUG +// @CMAKE_CXX_FLAGS_DEBUG@ +// CMAKE_EXE_LINKER_FLAGS +// @CMAKE_EXE_LINKER_FLAGS@ +// CMAKE_EXE_LINKER_FLAGS_RELEASE +// @CMAKE_EXE_LINKER_FLAGS_RELEASE@ +// CMAKE_EXE_LINKER_FLAGS_DEBUG +// @CMAKE_EXE_LINKER_FLAGS_DEBUG@ +// CMAKE_SHARED_LINKER_FLAGS +// @CMAKE_SHARED_LINKER_FLAGS@ +// CMAKE_SHARED_LINKER_FLAGS_RELEASE +// @CMAKE_SHARED_LINKER_FLAGS_RELEASE@ +// CMAKE_SHARED_LINKER_FLAGS_DEBUG +// @CMAKE_SHARED_LINKER_FLAGS_DEBUG@ +// +// see CMakeCache.txt for more details +