Original author: Juan Jose Garcia Ripoll
Modified by Hung-Chi Chu
What I've found that makes porting more difficult is sometimes building all those makefiles and configuration headers. Under Linux and most Unix like O.S. you would run a configure script that guesses most of your system peculiarities (Name of the C/C++ compiler, which headers and libraries are present, whether a function is broken...). But OS/2 is not Unix --nor even similar-- and there are enough differences to break up those configuration scripts, even if you already have a good sh-like shell.
OK, it was the state of the question until now. This port of Autoconf introduces a set of scripts and macro files able to build scripts that work well under OS/2 with EMX using all those wonderful ports of GNU utilities. But hey, that's not all. Now those scripts will work under unix as well!
SET AC_MACRODIR=e:/unix/share/autoconfBeware with slashes: you must use `/', not `\'.
set AWK=e:/usr/bin/gawk.exe
[From within CMD.EXE] sh -c "autoconf --help" [From within SH.EXE] autoconf --help
del config.cacheThis should be done every time configure is rebuilt or after anything in your system changed (new programs installed, new PATH, etc) so that configure finds out those changes.
autoconf
Alternatively, you can export environment variables before using configure overriding the checks it could do. See Tips and Tricks for more about this.
configure --helpwill inform you about the available options (programs to build, extensions, checks to avoid or include, etc), whereas
configure --prefix=d:/usrwill configure using default options and defining the root directory to be /usr.
In the configuration process Autoconf may introduce absolute pathnames in the code of your program. This will typically happen, either when config.h is created, or by explicit defines when compiling. You might have to add code to let the user override these paths.
OTOH, you might find hand-made rules in aclocal.m4 or in configure.in that check whether a path reference is absolute or not. Typically it looks like in this example:
... case "$LD" in /*) ac_program_LD="$LD";; *) #some other stuff ...This must be fixed in the following compatible mode:
... case "$LD" in changequote(, )dnl /* | [a-zA-Z]:*) ac_program_LD="$LD";; changequote([, ])dnl *) #some other stuff ...The fixed rule recognizes drive unit names. Also, as the colon ":" is not a valid path character under unix, it causes no big harm.
CC=gcc.exe MAKE=make CXX=gcc.exe CPP="gcc.exe -E" CFLAGS="-O2 -Zmt" CXXFLAGS="-O2 -Zmt" LDFLAGS="-Zmt -Zcrtdll -Zsysv-signals -Zbin-files" CONFIG_SHELL=sh.exe
The flags can be overriden. Either edit the generated configure file or set environment variables
[From within CMD.EXE] set MAKE=x11make.exe set CFLAGS=-O2 set CFLAGS=-O2 set LDFLAGS=-Zexe -Zcrtdll -Zsysv-signals [From within SH.EXE] export MAKE=x11make.exe export CFLAGS=-O2 export CFLAGS=-O2 export LDFLAGS="-Zexe -Zcrtdll -Zsysv-signals"or let the configure program run and, at the end, edit config.status changing the variables to suit your needs. (See below)
The default settings are good for X11 programs and won't harm when porting any other kind of application. If you opt to use them, please follow these two rules (extracted from the XFree86/OS2 porting guide):
extern int errno;Autoconf-ready code shouldn't cause this problem but if it does, enclose the sentence with a
#ifdef __EMX__
, and make sure the program
or library includes #include <errno.h>
. This is a temporary
solution: you should tell the author of the application about this
unportable feature (we are not only speaking about OS/2) and recommend
him/her to check the existence of <errno.h>
with an
appropiate rule.
O_BINARY, O_TEXT, "t", "b"
) in
the code. If you do so, use #ifdef __EMX__
to selectively
introduce the patches.
[From within CMD.EXE] sh config.status [From within SH.EXE] config.statuswill reprocess all af the *.in files. This is useful when you want to discard changes introduced in the makefiles or in config.h.
s%@CFLAGS@%-O2 -Zmt%g s%@CXXFLAGS@%-O2 -Zmt%g s%@LDFLAGS@%-Zmt -Zcrtdll -Zsysv-signals -Zbinfiles%gto
s%@CFLAGS@%-O2%g s%@CXXFLAGS@%-O2%g s%@LDFLAGS@%-Zexe -Zcrtdll -Zsysv-signals%gthus removing the already commented flags (See above).
The following sections explain how rules are to be modified in order to make them OS/2 compatible. These changes are simple ones and should be notified to the maintainers together with an explanation of where to get this port of Autoconf and its compatible nature.
An example shows how to modify aclocal.m4 is following:
[case "$LD" in /*) ac_cv_path_LD="$LD" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/ld"; then ... fi done IFS="$ac_save_ifs" ;; esac])The fixed version is
[case "$LD" in changequote(, )dnl /*|[a-zA-Z]:*) changequote([, ])dnl ac_cv_path_LD="$LD" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${PATH_IFS}" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/ld$ac_cv_exeext"; then ... fi done IFS="$ac_save_ifs" ;; esac])
When reporting bugs, follow these steps:
[From CMD.EXE and SH.EXE:] sh -x d:/usr/local/bin/autoconf 2>&1 1>error0.logto invoke it and e-mail me the error0.log file. Notice the use of Autoconf's full path name and the lack of the -c option.
autoconf --debugto rebuild the configure script that doesn't seem to work.
configure 2>&1 error.logand e-mail me the error.log, config.log, config.status and config.cache files. You should also send me any *.in and *.m4 files. You can pack them with ZIP archiver.
Remember: