Porting to OS/2: First port #1 basic

Many open source projects provide typical procedures to build. That is,

  1. ./configure
  2. make
  3. make install

Out of these, let's see the first step, ./configure.

As you know now, many open source projects use autotools to support cross-platforms. And they also provide their own configure script. Of course, there are projects which do not use autotools. However, how to configure is not different much. Here, we'll see how to configure with autotools.

For pratice, let's download FLAC v1.3.0.


Then, extract it into somewhere where you want. It's .tar.xz, so use xvJf option.

  • tar xvJf flac-1.3.0.tar.xz

Now, you can see flac-1.3.0 directory. CD into flac-1.3.0, and setup for gcc calling gcc4.cmd. When bulding DLLs of flac, gcc335 does not work as expected.

// ----- 2014/10/16
This is due to GCCOPT. If you want to use g++ of gcc335, then clear GCCOPT before configure.
//

At last, it's the time to try to configure. Do the following.

  • sh ./configure

On unixish systems, a current directory is not in PATH unlike OS/2. So prepending './' to the executables including scripts of a current directory, is a good habit. In practice, some configure scripts assume that it is called this way.

While configuring, you may encounter an error like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
configure: creating cache /dev/null
checking for a BSD-compatible install... ./install-sh -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... no
checking whether make sets $(MAKE)... yes
checking how to create a pax tar archive... gnutar
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `F:/lang/work/flac/flac-1.3.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log'
 for more details


Even if you can find your gcc in PATH, this error occurs. This is due to the executable extensions. Unixish systems recognize the executables with mode bits. Where as, dosish system such as OS/2, Windows and DOS, do with extensions. So we should set the extensions for the executables before configuring with setting ac_executable_extensions. By the way, OS/2 batch file or rexx scripts do not support lower-cased env vars. Use unixish shell scripts. Create configure.sh like this.

1
2
3
4
5
#! /bin/sh

export ac_executable_extensions=".exe"

./configure


Then execute it.

  • sh ./configure.sh

If configuring finishes, then execute make.

  • make

This may succeed, or you may encounter the following error.
 
1
2
3
4
5
Making all in share
make.exe[3]: Entering directory `F:/lang/work/flac/flac-1.3.0/src/share'
/bin/sh: f:Srbin/mkdir: No such file or directory
make.exe[3]: *** [getopt/.dirstamp] Error 1
make.exe[3]: Leaving directory `F:/lang/work/flac/flac-1.3.0/src/share'


This is '\' problem. Some shells such as ksh, treat '\' as an escape character when echoing strings. If you're using pdksh, you may encounter these errors. To fix these errors, we should convert all '\' of PATH env var to '/' before configuring. Here are the codes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# convert backslashes of PATH to slashes
OLD_IFS="$IFS"
IFS="\\"
TEMP_PATH=
for dir in $PATH; do
    if test -z "$TEMP_PATH"; then
        TEMP_PATH="$dir"
    else
        TEMP_PATH="$TEMP_PATH/$dir"
    fi
done
export PATH="$TEMP_PATH"
unset TEMP_PATH
IFS="$OLD_IFS"
unset OLD_IFS


Put the above codes into configure.sh like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh

# convert backslashes of PATH to slashes
OLD_IFS="$IFS"
IFS="\\"
TEMP_PATH=
for dir in $PATH; do
    if test -z "$TEMP_PATH"; then
        TEMP_PATH="$dir"
    else
        TEMP_PATH="$TEMP_PATH/$dir"
    fi
done
export PATH="$TEMP_PATH"
unset TEMP_PATH
IFS="$OLD_IFS"
unset OLD_IFS

export ac_executable_extensions=".exe"

./configure


Then, configure and make, again. If it succeeds, try to install.

  • make install

Now, you can see that flac is installed in /usr/local.

Congratulations!!! You did port to OS/2 for the first time.

댓글

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷