OK, now I understand some points with respect to dynamic libraries linking in Mac OS X
1) The only default directories are /usr/lib and /usr/local/lib, and there is nothing like /etc/ld.so.conf to register other default libraries. Your X11 libraries/header files being below the non standard /usr/X11 directory, it is mandatory to use -L parameters, i.e. $(X11LIBS) and -I parameters $(X11INCS) to locate them. This was provided in other makefiles, probably as a leftover of old times when both X11R5 and X11R6 systems coexisted. (In my linux systems, they are moved into standard locations below /usr, so that this is not really necessary).
2) due to two level namespaces, it is mandatory to give addons -lpng, etc when compiling the dynamic grx library, which is not necessary in linux which search/locate these libraries only at runtime, and do not need them at such compile time.
3) but I do not understand the need to give the location of these addon libraries with -L , and the location of their header files with -I : they are not in standard /usr/lib and /usr/include locations ? (or /usr/local..), at least symlinked from these standard locations (it seems usual practice to install them elsewhere, and to put symlinks to them in standard directories) ?
./configure --target=osx
Is there a reason using --target=osx, rather than e.g. --target=i686-apple-darwin ? I assume the --target line is needed for a cross build only, because config can "guess" it ?
GRX configure script is not made with standard GNU autotools. It was written by hand by Frank Heckenbach ih8mj@fjf.gnu.de, and I have only added some targets/options without changing the structure. Target names are short hands valids for native buildings. There is a possibility to use standard triplets, but they where intended for cross building from linux to DOS/Windows targets djgpp/mingw, for people which did not have full systems. I have modified configure to enable Mac OS X triplets, but probably this is not the good way to go. There is nothing like fat binaries in other systems. For double systems like 32bits / 64 bits, common nowadays, they are compiled separately and installed in different directories, and configure provides options to do this easily.
There is a tool named lipo https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/lipo.1.html that combines multiple architectures into one binary. Apple gcc https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/gcc.1.html has this ability built-in
-arch arch Compile for the specified target architecture arch. The allowable values are i386, x86_64, ppc and ppc64. Multiple options work, and direct the compiler to produce "universal" binaries including object code for each architecture specified with -arch. This option only works if assembler and libraries are available for each architecture specified. (APPLE ONLY)
We will have to think to that in a second step.
+# the apple linker ld has no option -s
The option was removed, but there are other options, see http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/ld.1.html and there is a separate strip tool https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/strip.1.html.
However, one wouldn't want to remove all symbol info from a dynamic library, as at least the entry points must have their name saved. For a dynamic lib e.g. strip -x - r -u could be used.
OK I have introduced that in osx makefiles
Also, Apple ld can do smart linking, which dramatically reduces the size of binaries
-dead_strip Remove functions and data that are unreachable by the
entry point or exported symbols.
Same here
The modified macosx.diff has been uploaded to the "more things" section of grx.
Maurice