1 --------------------------------------------
2 Building a Japanese Environment from Scratch
3 £Ì£Æ£Ó¤ÎÆüËܸì´Ä¶¤Î¹½ÃÛ
4 --------------------------------------------
6 AUTHOR: Dan Bernard <dan.bernard@cwru.edu>
10 LICENSE: GNU Free Documentation License v1.2
12 Other versions of this document may be released under the
13 BSD Documentation License (FreeBSD sample license below)
14 http://www.freebsd.org/doc/en/books/handbook/ln16.html
16 SYNOPSIS: Setting up Japanese input and output for terminals and applications
18 --------------------------------------------------------------------------
20 --------------------------------------------------------------------------
22 A number of applications and libraries are required for practical support
23 of the Japanese language in a UNIX-based environment. There is no single
24 standard for any of them. This hint will cover the basics for setting up
25 a working Japanese environment that supports input and output of standard
26 Japanese characters. Localization and specialized applications should be
29 --------------------------------------------------------------------------
31 --------------------------------------------------------------------------
33 Depending on what you may have already installed with regard to general
34 libraries and applications from Beyond Linux from Scratch (BLFS), and
35 which optional programs you choose to install, you could require
36 between 60 MB and 200 MB of free hard disk space for retrieving,
37 unpacking, building, and installing this software. In any event,
38 The build should require less than five static Binutils units (SBU)
41 This hint is good for any build of LFS with either framebuffer
42 support or X windowing system.
44 --------------------------------------------------------------------------
46 --------------------------------------------------------------------------
49 --------------------------------------------
51 The de-facto standard for setting up Japanese language support in Unix-based
52 environments today is package management. Either scripted builds with auto-
53 mated dependency resolution or strictly managed binary package distributions
54 are the only documented ways of making your Linux machine capable of reading
55 and writing Japanese text in a way that you can use. However, such packages
56 can not reasonably be managed in a scratch-built Linux environment. Because
57 building from scratch is the only feasible and desirable way to achieve this
58 interaction in such an environment, it helps to have proper documentation on
59 the subject. Unfortunately, due to the prevalence of package management and
60 fully localized distributions, no complete documentation exists publicly for
61 those who may want or need to make a Japanese Linux environment from scratch
62 without any sort of package management. It requires many different programs
63 and libraries, a good deal of configuration, and a fundamental understanding
64 of client-server models for input and conversion, which is largely different
65 from simply installing certain applications which may have their own methods
66 for input and conversion. The purpose of this document is to provide anyone
67 the basic knowledge and guidance necessary to install complete support for a
68 Japanese environment. This document will not demonstrate how to install any
69 other applications that may use Japanese input as supported by the Japanese
70 environment, but only the underlying utilities that allow such applications
71 to function properly with Japanese input and output.
74 --------------------------------------------
76 The following software may have X11 dependencies (X11R4 or later), so it
77 is best to install X11 first before attempting to install programs that
78 have X11 dependencies.
89 kinput2 (requires any version of X)
90 Eterm (optional in XFree86 4.4 or later)
92 FreeWnn and Canna are some of many kana-kanji conversion servers. Only one
93 is absolutely needed, although some applications prefer FreeWnn or Canna.
95 For most applications, kinput2 is a general input and conversion client
96 which connects to conversion servers and provides input to applications
97 whose interfaces do not support Japanese input by default. Even without
98 a conversion server, kinput2 can still input kana and convert from romaji.
100 Eterm is a versatile terminal emulator for X11 with many graphical features.
101 Eterm supports many languages in addition to having full CJK support.
104 --------------------------------------------
106 The following links point to places on the Internet where the latest
107 versions of the required software can be found.
110 http://freetype.sf.net/
113 http://ijg.org/files/
116 http://sourceforge.net/projects/libpng/
119 http://freshmeat.net/projects/imlib2/
122 http://site.n.ml.org/info/libast/
125 http://download.sourceforge.jp/canna/
128 ftp://ftp.freewnn.org/pub/FreeWnn/alpha/
131 ftp://ftp.sra.co.jp/pub/x11/kinput2/
134 http://www.eterm.org/download/
137 http://jfbterm.sourceforge.jp/
139 If any of the above links happen to be inaccessible when you attempt to
140 connect, try doing a Google search for the name of the given project.
141 I found each of these links from Google, and there are many more
142 sites that distribute these popular sources.
145 --------------------------------------------
147 Now that you have all the source tarballs unpacked in their appropriate
148 directories, it is time to commence the build. Make sure that you know
149 your installation paths before installation. I am assuming PREFIX=/usr
150 as that is for compatibility with the official BLFS documentation, but
151 of course any location should work fine. I use /usr/local personally.
152 If you install any of the libraries in a non-default directory, be sure
153 to run ldconfig after each build and installation.
157 FreeType is a portable ANSI C-based TrueType font rendering library.
161 Last checked against version 2.1.5
163 This library is a part of the BLFS CVS.
164 For more details, look at the latest BLFS.
166 ./configure --prefix=/usr &&
172 This library only needs to be installed if your system cannot
173 use the FreeType2 library. If you already have the above
174 library installed, then skip this part.
176 Last checked against version 1.3.1
178 Download size: 1.4 MB
179 Estimated disk space required: 9.3 MB
180 Estimated build time: 0.19 SBU
182 ./configure --prefix=/usr &&
188 libjpeg is a package of libraries that handle image compression based on
189 the standard of the Joint Photographic Experts Group (JPEG standard).
191 Last checked against version 6b (IJG)
193 This library is a part of the BLFS CVS.
194 For more details, look at the latest BLFS.
196 ./configure --enable-static --enable-shared --prefix=/usr &&
202 libpng is the official library that support all features of
203 the Portable Network Graphics format.
205 Last checked against version 1.2.5
207 This library is a part of the BLFS CVS.
208 For more details, look at the latest BLFS.
210 make prefix=/usr ZLIBINC=/usr/include \
211 ZLIBLIB=/usr/lib -f scripts/makefile.linux &&
212 make prefix=/usr install -f scripts/makefile.linux
216 Imlib2 is an image library for X11 that transparently handles
217 multiple image formats in a number of applications.
219 Last checked against version 1.1.0
221 This library is a part of the BLFS CVS.
222 For more details, look at the latest BLFS.
224 ./configure --prefix=/usr &&
230 libast stands for "Library of Assorted Spiffy Things."
231 It handles string manipulation, text parsing, and memory
232 tracking, among other things. libast was originally libmej.
234 Last checked against version 0.5
236 Download size: 270 kB
237 Estimated disk space required: 9.7 MB
238 Estimated build time: 0.24 SBU
240 ./configure --prefix=/usr &&
246 Canna is a popular kana-kanji conversion server made by NEC.
247 Canna is formerly known as Iroha, but the protocol is still the same.
249 Canna requires that your system have a user and group named 'bin' for
250 the ownership of certain files. On a default LFS install, the group
251 bin should already exist with gid=1. Therefore, I suggest that user
252 bin have uid=1. This, however is arbitrary. Popular uid's for user
253 bin also include 2 and 3 on other UNIX systems where 1 may already be
256 Last checked against version 3.6p3
258 Download size: 1.4 MB
259 Estimated disk space required: 28.8 MB
260 Estimated build time: 0.69 SBU
262 useradd -u 1 -g 1 -d / -s /bin/false bin &&
268 cp -a /usr/local/canna/include/canna/ /usr/include/
272 FreeWnn is a popular kana-kanji conversion server based on Wnn.
273 Wnn was developed jointly by Kyoto University, ASTEC Incorporated,
274 and Tateishi Electronics Company (now OMRON Corporation). Wnn was
275 the first full-featured kana-kanji conversion server available to
276 the public. The latest version (Wnn6) is proprietary.
278 FreeWnn also comes with uum, although it has to be built separately.
279 Uum is a Japanese input method for any terminal, which means X is
280 not necessary. This is thus especially handy on consoles, including
281 jfbterm on Linux framebuffer consoles.
283 Take note now that this package is optional, especially if you are
284 running low on available hard disk space. I recommend installing
285 FreeWnn only if you know that you need a third-party application
286 that prefers interfacing with a Wnn server, or if you need uum.
288 FreeWnn requires that your system have a user and group named 'wnn'
289 in order to install and run. Therefore, I suggest that user wnn have
290 uid=22273 and gid=22273. This is because the standard TCP/UDP port
291 number for Wnn's Japanese kanji conversion server is 22273. This is
292 arbitrary, however. Popular uid's for user wnn also include 49 and
293 69 on other UNIX systems where other versions of Wnn may be used.
295 Last checked against version 1.1.1-a020
297 Download size: 2.9 MB
298 Estimated disk space required: 61.8 MB
299 Estimated build time: 0.93 SBU
300 Estimated build time with uum: 0.99 SBU
302 groupadd -g 22273 wnn &&
303 useradd -u 22273 -g 22273 -d / -s /bin/false wnn &&
304 ./configure --prefix=/usr --sysconfdir=/etc &&
309 To compile and install uum, it will be necessary to run the following:
312 sed -e 's/termcap/curses/g' ../../makerule.mk > makerule.mk.bak &&
313 mv makerule.mk.bak ../../makerule.mk &&
319 kinput2 is a Japanese input method for X11. It can interface
320 with a variety of kana-kanji conversion servers and input
321 Japanese text into any kinput2 client. Supported input
322 styles include on-the-spot, off-the-spot, over-the-spot,
323 and root-window styles. kinput2 supports the new XIM
324 Protocol. By default, kinput2 is configured to connect
325 to Canna (Iroha) and Sj3 for kana-kanji conversion, and
326 does not, by default, interface with any Wnn servers.
328 This hint disables Sj3 support, leaving only support for
329 a Canna server. If you wish for kinput2 to interface with
330 Wnn or Sj3 or not to interface with Canna, simply edit the
331 Kinput2.conf file in the root of the kinput2 source tree.
333 Last checked against version 3.1
335 Download size: 500 kB
336 Estimated disk space required: 19.7 MB
337 Estimated build time: 0.17 SBU
339 cp Kinput2.conf Kinput2.conf.bak &&
340 sed 's%#define\ UseSj3%\/\*\ #define\ UseSj3\ \*\/%' \
341 Kinput2.conf.bak > Kinput2.conf &&
350 Eterm is a full-featured VT102 terminal emulator.
352 Last checked against version 0.9.2
354 Download size: 647 kB
355 Estimated disk space required: 3.4 MB
356 Estimated build time: 0.58 SBU
358 ./configure --prefix=/usr --sysconfdir=/etc --without-terminfo \
359 --with-backspace=bs --enable-utmp --enable-auto-encoding \
360 --enable-multi-charset=kanji --enable-xim --enable-trans &&
366 Jfbterm is a terminal emulator capable of displaying Japanese character
367 sets (and other multibyte character sets) on a Linux framebuffer console.
369 First off, while this can work (working version released right after I
370 tested the buggy one that didn't make it into my original hint!), it can
371 still be very touchy depending on what else is on your system. While it
372 is not absolutely required to have X installed, it does depend on a lot
373 of fonts that would usually be bundled with an X11 install. It may not
374 look clean, but the easiest way I got this to build and run on a machine
375 without X was to copy /usr/X11R6 from another machine and keep the fonts.
376 You may also need to create a fonts directory in your $PREFIX/share for
377 whatever reason if you do not already have it.
379 There may also be a very annoying dependency on automake-1.4, which may
380 require you to have another local install of automake if you already use
381 another version. I tried many things to rectify this, but always came
382 up short, and did not want to learn more about automake/autoconf given
383 that they are both more trouble than they are worth. The least painful
384 measure I can recommend is installing automake-1.4 locally, compiling
385 jfbterm, and then deleting automake-1.4 if no longer necessary.
387 Another important thing that may not be present on a default LFS system
388 is a framebuffer device node. If `ls /dev/fb*` comes up blank, you'll
389 need to make one. If you have a script in your /dev directory, you can
390 modify that and run it appropriately, or just use the appropriate mknod
391 command depending on your system, e.g. `mknod /dev/fb0 c 29 0`. This
392 would also be a good time to check the permissions on your device nodes
393 and set them accordingly.
395 Last checked against version 0.4.6
397 Download size: 121 kB
398 Estimated disk space required: 1.78 MB
399 Estimated build time: 0.05 SBU
401 ./configure --prefix=/usr --enable-reverse-video --enable-color-gamma \
403 sed -e 's/utmp/root/' Makefile > Makefile.bak &&
404 mv Makefile.bak Makefile &&
405 chmod 755 configure &&
409 Now, make sure that the jfbterm terminfo exists.
414 --------------------------------------------
416 After all the necessary software libraries and programs have been installed,
417 there still remains some configuration that must be done in order for the
418 Japanese environment to work.
420 Conversion Servers and Scripts:
424 It is necessary first to start your kana-kanji conversion server. It is
425 easy to start Canna, but an adjustment needs to be made first. Because
426 all Canna programs are located in /usr/local/canna/bin by default, they
427 need to be added to the default PATH. In a csh-compatible shell, run
429 setenv PATH `echo $PATH`:/usr/local/canna/bin
431 If you use a Bourne-compatible shell, then you can run
433 export PATH=`echo $PATH`:/usr/local/canna/bin
435 Since you must run cannaserver as root, then you will be setting environment
436 variables quite often. To modify your default PATH so that it contains the
437 Canna programs each time you log in, then you can change the PATH settings
438 in your login scripts, preferably the global /etc/login.defs file, and be
439 sure to include that path in the superuser settings.
441 To start the Canna conversion server, become root, verify that your PATH
442 environment variable is correct, and then run
446 To make sure that your Canna server is running, run cannastat (as any user),
447 and you should see something resembling
450 Canna Server (Ver. 3.6)
452 followed by the number of clients connected to the server, of which there
453 should be none at this point.
457 If you wish to invoke FreeWnn at this point, it is best that you use
458 a simple init script. However, if you do not need to start it right
459 away, then it would probably be better to wait until you need it.
460 Because the script handles most of the crucial Wnn operations, it
461 is not necessary to modify the default path. FreeWnn, by default,
462 has its programs in the /usr/bin/Wnn4 directory. If this is not
463 the case on your system, then modify your script accordingly.
465 To make the script, create a file in your default PATH and give it
466 a descriptive name such as FreeWnn. Set permissions accordingly
467 for an init script on your system. Keep in mind that the Wnn
468 server does not need to be started as root. Once the file
469 is created, then copy the following twenty lines into it:
474 if [ -x /usr/bin/Wnn4/jserver ]; then
475 /usr/bin/Wnn4/wnnstat localhost > /dev/null 2>&1
476 if [ $? = 255 ]; then
478 /usr/bin/Wnn4/jserver > /dev/null
483 /usr/bin/Wnn4/wnnkill localhost
486 echo "Usage: $0 {start|stop}" >&2
492 Also note that if this script is run more than once by a non-privileged
493 user to start the Wnn server, it may not work if /tmp/jd_sockV4 can not
494 be deleted. This is why it is still usually a good idea to run this as
495 root and to retain executable privileges for the superuser. When Wnn is
496 running, /usr/bin/Wnn4/wnnstat can be used to retrieve its information.
498 Input Method Environment:
502 While the main configuration file for uum is located in a /usr/lib/wnn
503 subdirectory, it can be regarded as independent of wnn for configuring
504 the input method itself. As uum is essentially a shell environment, no
505 configuration is necessary just to get it to run. However, the default
506 settings can be annoying if you are used to other UNIX input methods.
507 The file to modify for changing Japanese input settings is ja_JP/uumkey
508 ignoring other files with similar filenames.
510 The following parameters represent escape sequences that can be changed
511 to resemble, say, kinput2, as I have done on my setup.
519 There are other configuration options specifically regarding conversion
520 that are good to get familiar with, given that such options may be more
521 intuitive within other conversion environments, although some shortcuts
522 therein can be quite useful.
526 Append the following six lines to your Xresources file if you intend
527 to take advantage of Japanese Eterm sessions:
530 Eterm*InputMethod: kinput2
531 Eterm*allowSendEvents: true
532 Eterm*VT100*translations:
533 Shiftspace: begin-conversion(_JAPANESE_CONVERSION)
536 Your global Xresources file could be in any of the following locations:
538 /etc/X11/xdm/Xresources
539 /etc/X11/xinit/Xresources
540 /usr/X11R6/lib/X11/xdm/Xresources
541 /usr/X11R6/lib/X11/xinit/Xresources
543 or if you would rather add it on a per-user basis, use
547 This may or may not be necessary depending on your X11 settings.
548 However, it is not likely to cause problems if it is not necessary.
552 For the sake of convenience, it helps to invoke your input server upon
553 starting your X server. While this is not essential, bear in mind that
554 kinput2 will need to be started at some point during your X11 session,
555 and it is highly advisable that it run in the background.
557 Depending on the configuration of your X server, startup commands will
558 be invoked from a file either named Xsession or xinitrc. The global
559 settings for xinit are located either in /usr/X11R6/lib/X11/xinit or
560 /etc/X11/xinit by default. The global Xsession files are also likely
561 to be found in one of the X11 configuration directories. These settings
562 may also be specified locally in ~/.Xsession or ~/.xinitrc for a given
563 user. Add the following line to any of these files:
567 When kinput2 is running, an entry should appear in the server statistics
568 report from cannastat or wnnstat.
570 Environment Variables:
572 When you have X running, as well as all your other servers, you must
573 now establish an interface with the input method. That must usually
574 be defined as an environment variable upon the invocation of the
575 input method client program. For example, if you are running
576 X and open an Eterm from an xterm, that Eterm will not be able
577 to handle Japanese input unless the environment variable for the
578 input method was set properly in the xterm. To accomplish this, run
580 setenv XMODIFIERS "@im=kinput2"
584 export XMODIFIERS="@im=kinput2"
586 according to your shell's specifications, and then start an Eterm.
590 If your libc locale is not set to a Japanese setting at the time an
591 application is invoked, it can possibly be set locally afterward.
592 However, in the case of Eterm, for example, this also needs to be
593 set in the parent application beforehand, as it determines the
594 resulting execution in the same manner as the XMODIFIERS variable
595 concerning the input method. Different systems use different ways
596 of specifying locales. The first thing you should do is run
598 setenv LANG ja_JP.EUC
602 export LANG=ja_JP.EUC
604 according to your shell's specifications. If for some reason, you
605 have an application that utilizes JIS as its primary encoding, then
606 simply substitute JIS for EUC in the above environment variables.
607 Most UNIX applications these days, however, use EUC.
609 If your system uses other language and locale settings as environment
610 variables, then it is a good idea to set those too. If you run
612 echo $LANGUAGE ; echo $LC_ALL
614 and see two undefined variables, then you are okay and should not worry
615 about them. If LANGUAGE is defined and is not Japanese, then run
623 If you LC_ALL is defined and is not Japanese, then you should run
625 setenv LANGUAGE ja_JP
631 After all environment variables are properly set, then start Eterm with
635 This Eterm should have everything you need for proper Japanese input
636 and output. The environment variables will be the same as in the parent
637 application, so you can start more Eterms from this one and not have to
638 readjust environment variables every time. Nevertheless, there is one
639 last trick that can remove all the worry about environment variables
640 from the simple invocation of a Japanese-enabled terminal emulator.
644 If you use a window manager, as most X11 users do, you may be able to
645 simplify the process of invoking an Eterm with all the correct settings.
646 If you happen to use TWM like I do, then the process is straightforward,
647 because it is just another menu entry in the system.twmrc file. Simply
648 add the following line in the appropriate part of your TWM main menu:
650 "Eterm" f.exec "XMODIFIERS='@im=kinput2' LANG=ja_JP Eterm &"
652 Add more environment variable settings as necessary. The system.twmrc
653 file is located in either /etc/X11/twm or /usr/X11R6/lib/X11/twm by
654 default. Once this is set and TWM is restarted, you'll see an extra
655 "Eterm" entry in the main menu, and if you select it, it will start
656 an Eterm with all the environment variables already set. Of course,
657 Eterm can also be invoked with arguments just as if it were run from
658 another shell, but those are spared here for concision.
660 I have also gotten a similar setup in WindowMaker/GNUstep by adding a
661 line in the appropriate place in the ~/GNUstep/Defaults/WMRootMenu file
662 such as the following:
664 ("ETerm [JP]", SHEXEC, "XMODIFIERS='@im=kinput2' LANG=ja_JP.EUC Eterm"),
666 This also allows for additional arguments to Eterm.
668 Other window managers may be more complicated, but there are probably a
669 number of analogous options therein to provide for quick execution of
670 your favorite localized terminal emulator.
672 --------------------------------------------------------------------------
674 --------------------------------------------------------------------------
676 * New in This Version
677 --------------------------------------------
679 Followers of the original hint may have noticed some things that
680 did not quite match up with the current situation soon after that
681 hint was released. Unfortunately, my testing occured right before
682 a new working release of jfbterm, after which I became far too busy
683 to update this hint accordingly. All should be well now regarding
684 console support with jfbterm+uum.
686 Additionally, I did get some feedback via e-mail with suggestions to
687 improving utilization options. While these suggestions were well taken,
688 the cumulative effect of all of them was that my suggestions were too
689 specific, and that the real implementation of the Japanese environment
690 should be left to the users, since they should know what is best for
691 their preferences. As a side note, the settings I suggested did not
692 even relate to what I personally use, but were what I thought would
693 be easy for an absolute beginner. From now on, I will defer to the
694 individual user's preferences and omit explicit suggestions for how
695 to use the installed software mentioned in this hint.
697 I may also see if it would be good to have an addendum to this hint
698 specifically regarding Japanese keyboards with relation to Japanese
699 LFS setups. I have literally hundreds of Japanese keyboards at my
700 disposal, although lately no desire to mess around with them. If,
701 however, at any point I should try to find relevant applications in
702 a JLFS environment, it may merit some documentation here.
705 --------------------------------------------
707 Not for this hint specifically, but for other projects as well, I
708 am stating here what I would like to do or have done in the future.
709 First with regard to documentation, I believe that this hint itself
710 fulfills its purpose in simply setting up a localized environment.
711 There are many other things that pertain to Japanese computing,
712 however, and those could be addressed in separate hints.
714 Another particular thing I was interested in was updating uum.
715 This would be a larger-scale project, but there are a few things
716 that would really be nice if they were supported by uum, namely
717 Unix98 and UTF-8. Maybe I can devote some time to hacking uum
721 --------------------------------------------
723 Given my the complexity of this project, the comprehensiveness
724 of this document, and my busy schedule, it is worth noting that
725 a number of the libraries and programs that I compiled when I
726 first tested my methods for this hint (18 January 2005) may
727 be outdated. I may update this hint if there are any significant
728 changes in the sources for this Japanese environment. However, if
729 you notice a new version of some software mentioned above, go ahead
730 and try to substitute it in for the older versions that I may have
731 used. Unless a major version change has occurred, there should not
732 be any problems with a minor upgrade. If, however, any problems
733 should arise out of any newer versions, then I would recommend
734 reverting back to the versions I last compiled against, unless,
735 of course, any security vulnerabilities were to have been found
736 in said software after I release this hint. Install software
737 at your own risk, and please use common sense. The author
738 of this hint is not liable for any problems you may incur!
741 --------------------------------------------
743 Special thanks go to Kazunari Manabe for sparing extra hardware
744 for testing, as well as assisting in translations of this text.
746 * Document Formatting
747 --------------------------------------------
749 This document exists in plain text, pLaTeX source, DVI, and maybe
750 other document formats as markup or portable compiled documents.
751 While the organizational layout may change with formatting, the
752 content will remain the same. The reason for this is not only
753 to make this document easy to maintain, but also so that it may
754 be read on systems with or without Japanese language support.
755 This issue of compatibility will be even more important if this
756 document is ever translated to Japanese, as that translation will
757 be useless if it cannot be read due to incompatibility of formats.
758 See the notes below for the status of this document's translation.
760 Alternately formatted documents should be temporarily hosted at the
763 http://vorlon.cwru.edu/~djb29/
765 Should any new servers be added, or the above removed, this hint will
766 be updated and changes noted in the changelog at the very end of this
769 --------------------------------------------------------------------------
771 --------------------------------------------------------------------------
777 * Upgraded SBU's from Static Bash Units to Static Binutils Units.
778 * Added new proposals for future related projects.
779 * Added (overdue) sections for jfbterm and uum.
780 * Changed mirror sites for other formats.
781 * Removed unnecessary utilization hints.
782 * Removed alternative suggestions.
783 * Removed request for assistance.
784 * Updated notes on dated material.
785 * Reduced prerequisites.
786 * Improved introduction.