For compile mode, mode-args is a compiler command to be used in creating a “standard” object file. These arguments should begin with the name of the C compiler, and contain the -c compiler flag so that only an object file is created.
Libtool determines the name of the output file by removing the directory component from the source file name, then substituting the source code suffix (e.g. ‘.c’ for C source code) with the library object suffix, ‘.lo’.
If shared libraries are being built, any necessary PIC generation flags are substituted into the compilation command.
The following components of mode-args are treated specially:
libtool --mode=compile gcc -c foo/x.c -o foo/x.lo
will do what you expect.
Note, however, that, if the compiler does not support -c and -o, it is impossible to compile foo/x.c without overwriting an existing ./x.o. Therefore, if you do have a source file ./x.c, make sure you introduce dependencies in your Makefile to make sure ./x.o (or ./x.lo) is re-created after any sub-directory's x.lo:
x.o x.lo: foo/x.lo bar/x.lo
This will also ensure that make won't try to use a temporarily corrupted
x.o to create a program or library. It may cause needless
recompilation on platforms that support -c and -o
together, but it's the only way to make it safe for those that don't.
-Wc,, multiple flags may be separated by commas, whereas
-Xcompilerpasses through commas unchanged.