Windows 10のWindows Subsystem for Linux(WSL)でKali Linuxをインストールして、いろいろ試しています。
今回はgcc,makeなどをインストールしてnkfをコンパイルしてみました。
Debian Linux Install GNU GCC Compiler and Development Environment
https://www.cyberciti.biz/faq/debian-linux-install-gnu-gcc-compiler/
You need to install the following packages on a Debian and Ubuntu Linux:
build-essential package – Installs the following collection to compile c/c++ program on Debian/Ubuntu Linux:
Kali LinuxはDebian-basedなので同じパッケージを探したらありました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
rootlinks@Win10:~$ apt show build-essential Package: build-essential Version: 12.4 Priority: optional Build-Essential: yes Section: devel Maintainer: Matthias Klose <doko@debian.org> Installed-Size: 20.5 kB Depends: libc6-dev | libc-dev, gcc (>= 4:7.2), g++ (>= 4:7.2), make, dpkg-dev (>= 1.17.11) Tag: devel::packaging, interface::commandline, role::data, suite::debian Download-Size: 7,394 B APT-Sources: http://http.kali.org/kali kali-rolling/main amd64 Packages Description: Informational list of build-essential packages If you do not plan to build Debian packages, you don't need this package. Starting with dpkg (>= 1.14.18) this package is required for building Debian packages. . This package contains an informational list of packages which are considered essential for building Debian packages. This package also depends on the packages on that list, to make it easy to have the build-essential packages installed. . If you have this package installed, you only need to install whatever a package specifies as its build-time dependencies to build the package. Conversely, if you are determining what your package needs to build-depend on, you can always leave out the packages this package depends on. . This package is NOT the definition of what packages are build-essential; the real definition is in the Debian Policy Manual. This package contains merely an informational list, which is all most people need. However, if this package and the manual disagree, the manual is correct. |
- build-essentialのインストール
- 確認
- nkf git clone
- コンパイル
1 2 3 4 5 6 7 8 9 10 11 |
rootlinks@Win10:~$ sudo apt -y install build-essential Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: javascript-common libjs-excanvas Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libcc1-0 libfakeroot make (snip) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
rootlinks@Win10:~$ which gcc make /usr/bin/gcc /usr/bin/make rootlinks@Win10:~$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 7.3.0-5' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.3.0 (Debian 7.3.0-5) rootlinks@Win10:~$ make -v GNU Make 4.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. |
nkfはこちらでメンテナンスされています。有り難いことです。
nkf Network Kanji Filter プロジェクト日本語トップページ – OSDN
https://ja.osdn.net/projects/nkf/
昔はEUC,UTF,SJISで大変お世話になりました。
1 2 3 4 5 6 7 8 9 |
rootlinks@Win10:~$ sudo apt -y install git rootlinks@Win10:~$ git clone https://scm.osdn.net/gitroot/nkf/nkf.git Cloning into 'nkf'... remote: Counting objects: 1525, done. remote: Compressing objects: 100% (472/472), done. remote: Total 1525 (delta 1052), reused 1525 (delta 1052) Receiving objects: 100% (1525/1525), 578.69 KiB | 4.19 MiB/s, done. Resolving deltas: 100% (1052/1052), done. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
rootlinks@Win10:~$ cd nkf rootlinks@Win10:~/nkf$ make cc -g -O2 -Wall -pedantic -c nkf.c cc -g -O2 -Wall -pedantic -c utf8tbl.c cc -g -O2 -Wall -pedantic -o nkf nkf.o utf8tbl.o rootlinks@Win10:~/nkf$ ./nkf -v Network Kanji Filter Version 2.1.4 (2015-12-12) Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa). Copyright (C) 1996-2015, The nkf Project. rootlinks@Win10:~/nkf$ ./nkf --help Usage: nkf -[flags] [--] [in file] .. [out file for -O flag] j/s/e/w Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP UTF options is -w[8[0],{16,32}[{B,L}[0]]] J/S/E/W Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP UTF option is -W[8,[16,32][B,L]] m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:nonstrict,0:no decode] M[BQ] MIME encode [B:base64 Q:quoted] f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl Z[0-4] Default/0: Convert JISX0208 Alphabet to ASCII 1: Kankaku to one space 2: to two spaces 3: HTML Entity 4: JISX0208 Katakana to JISX0201 Katakana X,x Convert Halfwidth Katakana to Fullwidth or preserve it O Output to File (DEFAULT 'nkf.out') L[uwm] Line mode u:LF w:CRLF m:CR (DEFAULT noconversion) --ic=<encoding> Specify the input encoding --oc=<encoding> Specify the output encoding --hiragana --katakana Hiragana/Katakana Conversion --katakana-hiragana Converts each other --{cap, url}-input Convert hex after ':' or '%' --numchar-input Convert Unicode Character Reference --fb-{skip, html, xml, perl, java, subchar} Specify unassigned character's replacement --in-place[=SUF] Overwrite original files --overwrite[=SUF] Preserve timestamp of original files -g --guess Guess the input code -v --version Print the version --help/-V Print this help / configuration Network Kanji Filter Version 2.1.4 (2015-12-12) Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa). Copyright (C) 1996-2015, The nkf Project. |
あとはnkfをパスの通ったところにコピーして下さい。
これでビルド環境が整ったので簡単なものならコンパイルできます。
ちなみにnkf-2.1.4.tar.gz(2015-12-12 22:53)をダウンロードしてmakeしたところwarningがでました。
ソースが読めないのですが、調べたらgcc 6以降だとこのwarningが出るみたいですね。
一応、コンパイルできて動くようですが、最新のgitソースの方だとwarningは表示されませんでした。
1 2 3 4 5 6 7 8 9 10 11 |
rootlinks@Win10:~/nkf-2.1.4$ make cc -g -O2 -Wall -pedantic -c nkf.c nkf.c: In function ‘module_connection’: nkf.c:5710:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] if (nkf_enc_unicode_p(output_encoding)) ^~ nkf.c:5713:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ if (x0201_f == NKF_UNSPECIFIED) { ^~ cc -g -O2 -Wall -pedantic -c utf8tbl.c cc -g -O2 -Wall -pedantic -o nkf nkf.o utf8tbl.o |
あれ? パッケージがあるじゃん(笑
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
rootlinks@Win10:~$ apt show nkf Package: nkf Version: 1:2.1.4-1+b2 Priority: optional Section: text Source: nkf (1:2.1.4-1) Maintainer: NOKUBI Takatsugu <knok@daionet.gr.jp> Installed-Size: 355 kB Depends: libc6 (>= 2.2.5) Homepage: https://osdn.net/projects/nkf/ Download-Size: 132 kB APT-Sources: http://http.kali.org/kali kali-rolling/main amd64 Packages Description: Network Kanji code conversion Filter Nkf is yet another kanji code converter among networks, hosts and terminals. It converts input kanji code to designated kanji code such as 7-bit JIS, MS-kanji (Shifted-JIS) or EUC. |