Porting to OS/2: First port #2 configure script

We did first port. Now step forward more.

We execute a script with sh whenever configuring. Sometimes this is uncomfortable. Fortunately, OS/2 provides an option to pass a script to the external processor. That is, extproc. Using this, there is no need to run a script with sh.

It's very simple. Rename its extension to .cmd, and replace [#! /bin/sh] at first line with [extproc sh]. Then your configure.cmd will be like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
extproc 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 "$@"


Now, just call configure.cmd to configure.

  • configure

You can see something different at line 21. That is, "$@". This is a parameter variable. Using "$@", you can pass parameters for configure.cmd to ./configure as is.

By the way, these workarounds are not only for FLAC. All the projects using autotools, can take advantage of these. Of course, you can copy this configure.cmd to the projects. But autotools provides a convenient way to do this. If you remember, we set CONFIG_SITE when modifying CONFIG.SYS. CONFIG_SITE is for this task. We set CONFIG_SITE to x:/usr/etc/config.site. This site script is always loaded before loading the body of configure scripts. So if you put these workarounds or the common parts which have to be loaded all the time, you don't have to repeat this task. Let's create config.site in x:/usr/etc like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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"


In practice, I recommend to add [export COMSPEC="/bin/sh"] because sometimes configure fails due to some shell scripts executed by CMD which does not understand unixish shell scripts. And add [export MKDIR_P="mkdir -p"] as well. Without this, installation sometimes fails due to install-sh script. Of course, if proper mkdir was installed, you don't have to add this. The following is my config.site.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export COMSPEC="/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"

export MKDIR_P="mkdir -p"


Then your configure.cmd can be simplified.

1
2
3
extproc sh

./configure "$@"



댓글

이 블로그의 인기 게시물

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

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

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