When trying to use autotools (autoconf, automake,
libtool), the autoconf macro AC_PROG_CC
causes "./configure --build=`./config.guess` --
host=m68k-palmos" to generate this error:
/usr/m68k-plamos/lib/crt0.o: In function 'start':
crt0.c: undefined reference to 'PilotMain'
AC_PROG_CC tries to compile a program with a 'main'
entry point to test if the compiler works, but, crt0.o
requires 'PilotMain'. 'PilotMain' is a stupid artifact of the
PalmOS. I consider this a bug because regardless of OS
requirements, a 'C/C++' toolchain SHOULD be able to
create an executable with a 'main' entry point. Whether
that executable will actually RUN on a defective OS
(i.e. 'main' vs. 'PilotMain') is another story, and should be
verified with another tool (maybe modify build-prc)
outside of the 'C/C++' toolchain.
MS Windows has a similar stupid requirement
for 'WinMain' for GUI applications. Cygwin gets around
this by supplying a crt0.o that eventually calls 'main',
and a library version of 'main' that calls 'WinMain'.
Executables that have a 'main' function get linked with
the executable's version of 'main'. Executables that
don't have a 'main' function get linked with the library
version of 'main' that calls 'WinMain'. Download cygwin-
1.3.22-1-src.tar.bz2 from a cygwin mirror and have a
look at [srcdir]/winsup/cygwin/lib/libcmain.c.
It seems to me that it should be fairly easy to add
similar functionality to prc-tools. Making prc-tools
compatible with autotools would make it much easier to
maintain complex projects, and, would make an already
good project (prc-tools) even better.
config.log from a dummy project
Logged In: YES
user_id=4669
Your assumptions about what a C/C++ tool chain should
understand about a function named "main" are incorrect. A
function named "main" is only special in a *hosted*
environment (see C99 5.1.2 ff); but prc-tools does not claim
to provide a hosted environment, and it has always been clear
about that.
Nonetheless, it would be nice if the autoconf probe you
describe could be made to work. I would be most interested if
it could be done in a way that had no effect on "proper" Palm
OS appliations. (The method you suggest would reserve the
name "main" and introduce a wasted function call and stack
frame in the startup sequence. Cygwin might not care about
that, but we do.) For example, something involving making
main a weak alias for PilotMain in a linker script might be
viable. Perhaps you want to investigate this and suggest a
patch.
Logged In: YES
user_id=19874
add -Dmain=PilotMain to your CFLAGS before attempting to
execute the AC_PROG_CC