From patchwork Tue Dec 12 22:59:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10108431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5CA46032B for ; Tue, 12 Dec 2017 22:59:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA7F20246 for ; Tue, 12 Dec 2017 22:59:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96D881FF41; Tue, 12 Dec 2017 22:59:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A62261FF41 for ; Tue, 12 Dec 2017 22:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbdLLW7s (ORCPT ); Tue, 12 Dec 2017 17:59:48 -0500 Received: from mail-eopbgr40049.outbound.protection.outlook.com ([40.107.4.49]:27771 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752679AbdLLW7q (ORCPT ); Tue, 12 Dec 2017 17:59:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=n4oNtNYvlloLDUc/DYbn28ggHTyPfRLjIdM5CmJ9jJc=; b=fZgLcfGjsej0oppEN0KJHRLKX7BUuLEOmbD/TQ60fC7fn/XreV6JY8B0xmJYReuAxOlgqZOGT685kBp7mjiHzknR+BuSgvcaCLY9oCvSYGlBx5g8rAvbinJZ52SWCcB3/Eb7xnCIPxY1BoYxxSns6prO8uCjFAPdVR4+JpyW2EQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (70.74.179.152) by HE1PR0501MB2858.eurprd05.prod.outlook.com (2603:10a6:3:c1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Tue, 12 Dec 2017 22:59:42 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eOtWS-0007zj-Im for linux-rdma@vger.kernel.org; Tue, 12 Dec 2017 15:59:36 -0700 Date: Tue, 12 Dec 2017 15:59:36 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Subject: [PATCH rdma-core] Support writing man pages in MarkDown Message-ID: <20171212225936.GA29558@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [70.74.179.152] X-ClientProxiedBy: DB6PR1001CA0032.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::18) To HE1PR0501MB2858.eurprd05.prod.outlook.com (2603:10a6:3:c1::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dc5805a9-04d8-40d6-c194-08d541b40839 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307); SRVR:HE1PR0501MB2858; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2858; 3:YdMtOxWvORTbIg6m1f8nKg3MOErkOu8usfL041dLhnpdPHzAjI9FFEvv3QTECPoxRR+g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5ZTxzybN1fj31qxgCU0VMM4pxi5yNEGtYYcmFf5Sbtq+OOU9bdM8Y9ejx6+bPhAn+YkYcx1Yv8kpri+TzXcfn0YW+s7Ge750zHJwhN8WDAcbdB5Lzo9NZ254aP9MmeG7nL2b4fuPVyYxpm2wsMHyqIUcqnYwiatEteyDby41VmxA2MeNossUHrWlg0Q5fF6IVNy7X1FuTBJfrTOSG1TPL1BWei+zEZnf3Ox7hcfjQUFBcz9BjPgonqFl22URpMxut0mqibGQhWtNIjWJKLxPgqPtEydFjonZ0j+xAqxbTnRGHD+DqgVKR/YvGVRc; 4:Z57k2zhukC82e4RMeXrpXescinzJUPiL4UMoTXa5lmH/Wc+BuL5mcN9NJB3yLxKGgr42ir22sFU+iOz0m5LSdaPAmfn9R7cGrBfAP7ggwPO6vdXLSnPr6P/Jl0P675rCu+VazGnzULb9yvduGxAVCwavLSHHNY3SqC8b2J+TYn6Xe/8jSghwyM1fXapbFvTjqu1TMntI02lJ4QRuDg8Kk3n8VarHU70apwAovJiG3QefmQynZ0d59SO94oooRsFsyLk8vGlAkfL5oI2O0bEtxMcr9stbpxwZMSbrZfvNR1IVCz76l1gj+PvANOCnQDcIjUnuvckv9Jd1ffjIOYi0wA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(166708455590820)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(3231023)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR0501MB2858; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR0501MB2858; X-Forefront-PRVS: 051900244E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(376002)(366004)(189003)(199004)(2906002)(6116002)(3846002)(1076002)(33656002)(23726003)(9686003)(57986006)(9746002)(9786002)(2361001)(106356001)(2351001)(68736007)(105586002)(83796002)(305945005)(69596002)(7736002)(83506002)(6916009)(6306002)(97736004)(8676002)(81156014)(81166006)(5660300001)(58126008)(122856001)(86362001)(66066001)(16586007)(316002)(46656002)(50466002)(33896004)(575784001)(8936002)(478600001)(47776003)(36756003)(53936002)(966005)(386003)(52116002)(18370500001)(24400500001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2858; H:mlx.ziepe.ca; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2858; 23:Azz27EMVd5EMpPM8rFiBsCOB3DE2yvTBVj1BbJa?= =?us-ascii?Q?/Mcom2FfLYehnagtEL1jxr0136/rOJ+C+mKWSRgE3PcDj3VlDNwpVzx64uPg?= =?us-ascii?Q?+rKLFYJRlh3XlfCp7ggefra6ZfZ6HeuaVAQkbvPiPbzR+t0Ay7Uuw+Lj6VHr?= =?us-ascii?Q?ut9GiHOW631oWg6rzeXikBklMFeLGNZWzSKEczfjXYI2Da4NrrErLkVaY31O?= =?us-ascii?Q?SSlzzVK0kQr0iCJ+sGAVVRsttT+PwBGwMKj8lazCM5ldu2jcMsQkOzZjiTJF?= =?us-ascii?Q?TKndtIB5RrpW2P0vMnyl1a6/wDLon1ixFHz5wrVSnWBMwlqKw/t2jsooYYMu?= =?us-ascii?Q?nCRXv2XuJ+rBUGuCh4jKZSIgpX1PtwLyLWcEQ+lvDfm4rntha+AGdhGXGCh5?= =?us-ascii?Q?E+vPBqUDjDsrJhR53SxtQXnxPNRblrdoMfqcpoPPogAlDTMn7kRFN5WYAxj3?= =?us-ascii?Q?sJP83+5+2fGaQ3YhE7p3JdVVxnNM/594BxcWnHbYwyj/ekT0Xo/40pYsCWt7?= =?us-ascii?Q?zfMovBuysbHnMEUwHG2mv5R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7/ND05fYEL1OegdsAU5k2bH8LSaEebESy/9lLT+CiBlonfbtTCPXR5moKVJOgxObUyywqzaQ+Soxhoe8krjBlJZkhksiFeR3NM+m92z2wd8xrPtRuYWBXxqtbi1rsR51wfuJH6vPHvMVgidZuJdtncAyuVzrfStX6m6B3CwbRJhsqV73Y4/bCRoFfs8uJNNZBSeSgXUwEpsdkdy1UA=; 5:M2/4fT6IKR36VIHDWL2on6j8bUyGW+yeVy60Ud9dWdj2XWAVza2ql1EH8ieYW2s9+kFu0gqoBX4RBRcElP39FTpwFdk6czu1gpZM7A505BkXkQBVAMtyYg7jXvfP8kIx7HHonuSPn/lgcyb2DzygUV8S5xuJ1+4NNmuPo8AUdOE=; 24:xArJngBgH6DEA+gyiGRrhq3DEHzAn99UbIKg7cXoeW7E/VRkJnK3/lg6CpP28zOxZEssSMOjE9/+QM34kzzydrj0BNlWlPWhmfPixXHUZ8I=; 7:7jO0DYEk17U8lNDpkethbAz2H8+rJzwZwAv+q748cE3YGdZoa4MDTvsEEPgP66msFs12GI7KEUgmSUdm7+sxXZbdXZlVwElhDHp+H9yr0+2WJeD5zuJO0/CmSS5U94Ov12q+vwnBegYXXDEdnKWt1eV11nAfsYIjJg/gE3uE0y1KjTg4mBAHP9094kyqyHFOchnzvAvRX9EEnoJIVD3lNj85T4Sv46BRnjvNUfeSkp6hBdAb/OvcI47/xZz1wytw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2017 22:59:42.8527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc5805a9-04d8-40d6-c194-08d541b40839 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2858 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The pages are converted during the build into *roff mdoc using the pandoc tool. Signed-off-by: Jason Gunthorpe --- .travis.yml | 1 + CMakeLists.txt | 4 +++ buildlib/Findpandoc.cmake | 21 +++++++++++++ buildlib/cbuild | 3 ++ buildlib/rdma_functions.cmake | 33 -------------------- buildlib/rdma_man.cmake | 70 +++++++++++++++++++++++++++++++++++++++++++ debian/control | 1 + 7 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 buildlib/Findpandoc.cmake create mode 100644 buildlib/rdma_man.cmake This is a very big series, I am only sending the first patch to the mailing list. The whole series is on github here: https://github.com/linux-rdma/rdma-core/pull/274 Overall, I'd like to see the man pages be more editable and viewable when in patch format. Longer term I'd like to see them all rendered to HTML and hosted on the web as libfabric and systemd are doing successfully. While some of this can be done with the classic roff format, it feels very painful. Markdown was selected because we are already using it successfully for other documentation, and libfabric has already demonstrated using it for man pages. github will natively render the markdown documentation internally for instance: https://github.com/jgunthorpe/rdma-plumbing/blob/ea581c2d3d99d69083a8f4eaa9e55ae7ae233246/libibverbs/man/ibv_alloc_mw.3.md Although some places are using features specific to the 'pandoc' flavour of markdown, github still renders them in a readable format. The next most popular choice is docbook XML, which I suspect would not be well liked (and it is very baroque as well, just in a more modern way) The actual conversion of the man pages was done largely by script, with some manual fixes and post-inspection. There doesn't seem to be a useful mdoc to markdown conversion script, so I built a quick and dirty one that works on our .3 man page style. The converter is here: https://github.com/jgunthorpe/rdma-plumbing/blob/migration-tooling/buildlib/man2md.py I'm no mdoc expert, but it sure looks to me like there are many markup problems in our man pages, even if they happen to render mostly properly. Overall the conversion to markdown is very good in terms of resulting 'man ibv_foo' display with a few notable variances: - The 'synopsis' is shifted right by 8 spaces and isn't bolded in quite the same way - I ran all the C code through clang-format and asked it fit it to the standard 80 col terminal. Some of the results are 'interesting' to say the least. Others are much better than before. - Some of the hypenation choices are a little different pandoc is fairly widely available in the distros with the notable problem that centos 6 and 7 can only get it from EPEL. Since this may be a problem, I am thinking about following the libfabric approach and either including the precompiled man pages in the source tree, or just providing a framework for downstream to add-on precompiled files (with a cbuild command to make them) Looking for feedback on what path is best.. diff --git a/.travis.yml b/.travis.yml index 7af2aeb9072db5..b7723f38295bc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ addons: - libudev-dev - make - ninja-build + - pandoc - pkg-config - python - valgrind diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c5d6b7c539515..42fc5db0523687 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,7 @@ include(RDMA_BuildType) include(RDMA_DoFixup) include(publish_headers) include(rdma_functions) +include(rdma_man) if (NOT DEFINED ENABLE_STATIC) set(ENABLE_STATIC "OFF" CACHE BOOL "Produce static linking libraries as well as shared libraries.") @@ -282,6 +283,9 @@ endif() # Look for Python FIND_PACKAGE (PythonInterp) +# Look for pandoc +FIND_PACKAGE(pandoc REQUIRED) + #------------------------- # Find libraries # pthread diff --git a/buildlib/Findpandoc.cmake b/buildlib/Findpandoc.cmake new file mode 100644 index 00000000000000..f753165a7b6593 --- /dev/null +++ b/buildlib/Findpandoc.cmake @@ -0,0 +1,21 @@ +# COPYRIGHT (c) 2017 Mellanox Technologies Ltd +# Licensed under BSD (MIT variant) or GPLv2. See COPYING. +find_program(PANDOC_EXECUTABLE NAMES pandoc) + +if(PANDOC_EXECUTABLE) + execute_process(COMMAND "${PANDOC_EXECUTABLE}" -v + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _VERSION_RESULT + ERROR_QUIET) + + if(NOT _PYTHON_VERSION_RESULT) + string(REGEX REPLACE "^pandoc ([^\n]+)\n.*" "\\1" PANDOC_VERSION_STRING "${_VERSION}") + endif() + unset(_VERSION_RESULT) + unset(_VERSION) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(pandoc REQUIRED_VARS PANDOC_EXECUTABLE PANDOC_VERSION_STRING VERSION_VAR PANDOC_VERSION_STRING) + +mark_as_advanced(PANDOC_EXECUTABLE) diff --git a/buildlib/cbuild b/buildlib/cbuild index 29c5b4b87d9548..92672a20dafc54 100755 --- a/buildlib/cbuild +++ b/buildlib/cbuild @@ -98,6 +98,7 @@ class centos6(YumEnvironment): 'libnl3-devel', 'libudev-devel', 'make', + 'pandoc', 'pkgconfig', 'python', 'rpm-build', @@ -164,6 +165,7 @@ class trusty(APTEnvironment): 'libudev-dev', 'make', 'ninja-build', + 'pandoc', 'pkg-config', 'python', 'valgrind', @@ -309,6 +311,7 @@ class leap(ZypperEnvironment): 'udev', 'make', 'ninja', + 'pandoc', 'pkg-config', 'python3', 'rpm-build', diff --git a/buildlib/rdma_functions.cmake b/buildlib/rdma_functions.cmake index 53a978e896acfa..0d858c56eee696 100644 --- a/buildlib/rdma_functions.cmake +++ b/buildlib/rdma_functions.cmake @@ -229,39 +229,6 @@ function(rdma_test_executable EXEC) set_target_properties(${EXEC} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_BIN}") endfunction() -# Install man pages. This deduces the section from the trailing integer in the -# filename -function(rdma_man_pages) - foreach(I ${ARGN}) - if ("${I}" MATCHES "\\.in$") - string(REGEX REPLACE "^.+[.](.+)\\.in$" "\\1" MAN_SECT "${I}") - string(REGEX REPLACE "^(.+)\\.in$" "\\1" BASE_NAME "${I}") - get_filename_component(BASE_NAME "${BASE_NAME}" NAME) - rdma_subst_install(FILES "${I}" - DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/" - RENAME "${BASE_NAME}") - else() - string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT "${I}") - install(FILES "${I}" DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/") - endif() - endforeach() -endfunction() - -# Create an alias for a man page, using a symlink. -# Input is a list of pairs of names (MAN_PAGE ALIAS) -# NOTE: The section must currently be the same for both. -function(rdma_alias_man_pages) - list(LENGTH ARGN LEN) - math(EXPR LEN ${LEN}-1) - foreach(I RANGE 0 ${LEN} 2) - list(GET ARGN ${I} FROM) - math(EXPR I ${I}+1) - list(GET ARGN ${I} TO) - string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT ${FROM}) - rdma_install_symlink("${FROM}" "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/${TO}") - endforeach() -endfunction() - # Finalize the setup of the static libraries by copying the meta information # from the shared and setting up the libtool .la files. function(rdma_finalize_libs) diff --git a/buildlib/rdma_man.cmake b/buildlib/rdma_man.cmake new file mode 100644 index 00000000000000..83d7745ab0d608 --- /dev/null +++ b/buildlib/rdma_man.cmake @@ -0,0 +1,70 @@ +# COPYRIGHT (c) 2017 Mellanox Technologies Ltd +# Licensed under BSD (MIT variant) or GPLv2. See COPYING. + +function(rdma_md_man_page SRC MAN_SECT MANFN) + set(OBJ "${CMAKE_CURRENT_BINARY_DIR}/${MANFN}") + + add_custom_command( + OUTPUT "${OBJ}" + COMMAND "${PANDOC_EXECUTABLE}" -s -t man "${SRC}" -o "${OBJ}" + MAIN_DEPENDENCY "${SRC}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Creating man page ${MANFN}" + VERBATIM) + + add_custom_target("man-${MANFN}.${MAN_SECT}" ALL DEPENDS "${OBJ}") + install(FILES "${OBJ}" + DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/") +endfunction() + +# Install man pages. This deduces the section from the trailing integer in the +# filename +function(rdma_man_pages) + foreach(I ${ARGN}) + if ("${I}" MATCHES "\\.md.in$") + string(REGEX REPLACE "^.+[.](.+)\\.md.in$" "\\1" MAN_SECT "${I}") + string(REGEX REPLACE "^(.+)\\.md.in$" "\\1" BASE_NAME "${I}") + get_filename_component(BASE_NAME "${BASE_NAME}" NAME) + + configure_file("${I}" "${CMAKE_CURRENT_BINARY_DIR}/sub-${BASE_NAME}" @ONLY) + rdma_md_man_page( + "${CMAKE_CURRENT_BINARY_DIR}/sub-${BASE_NAME}" + "${MAN_SECT}" + "${BASE_NAME}") + elseif ("${I}" MATCHES "\\.md$") + string(REGEX REPLACE "^.+[.](.+)\\.md$" "\\1" MAN_SECT "${I}") + string(REGEX REPLACE "^(.+)\\.md$" "\\1" BASE_NAME "${I}") + get_filename_component(BASE_NAME "${BASE_NAME}" NAME) + + rdma_md_man_page( + "${I}" + "${MAN_SECT}" + "${BASE_NAME}") + elseif ("${I}" MATCHES "\\.in$") + string(REGEX REPLACE "^.+[.](.+)\\.in$" "\\1" MAN_SECT "${I}") + string(REGEX REPLACE "^(.+)\\.in$" "\\1" BASE_NAME "${I}") + get_filename_component(BASE_NAME "${BASE_NAME}" NAME) + rdma_subst_install(FILES "${I}" + DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/" + RENAME "${BASE_NAME}") + else() + string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT "${I}") + install(FILES "${I}" DESTINATION "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/") + endif() + endforeach() +endfunction() + +# Create an alias for a man page, using a symlink. +# Input is a list of pairs of names (MAN_PAGE ALIAS) +# NOTE: The section must currently be the same for both. +function(rdma_alias_man_pages) + list(LENGTH ARGN LEN) + math(EXPR LEN ${LEN}-1) + foreach(I RANGE 0 ${LEN} 2) + list(GET ARGN ${I} FROM) + math(EXPR I ${I}+1) + list(GET ARGN ${I} TO) + string(REGEX REPLACE "^.+[.](.+)$" "\\1" MAN_SECT ${FROM}) + rdma_install_symlink("${FROM}" "${CMAKE_INSTALL_MANDIR}/man${MAN_SECT}/${TO}") + endforeach() +endfunction() diff --git a/debian/control b/debian/control index 451b379f01ae92..cfcdcc4e22884d 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,7 @@ Build-Depends: cmake (>= 2.8.11), libsystemd-dev, libudev-dev, ninja-build, + pandoc, pkg-config, python, valgrind [!alpha !armel !hppa !m68k !powerpcspe !sh4 !sparc64 !x32]