I am stumped as to why when I do a gnumake from the parent directory it behaves incorrectly, whereas, if I cd to the subdirectory and do gnumake it works correctly.
In the parent makefile, I have a rule like this:
.PHONY: zlib-1.2.5
zlib-1.2.5:
@ echo Issuing $(MAKE) in $@ ...
pushd zlib-1.2.5; make; popd
Which gives different result than doing the same from the toplevel
pushd zlib-1.2.5; make; popd
There is a something from the parent makefile that is making its way into the subdirectory makefile and causing it to behave incorrectly, but I don't know how to find it.
The symptom I see is that the subdirectory config generated makefile rule for zlib misses the dependencies and I get this result going straight to the ar without generating the .o(s) first:
cd ~/src; make zlib-1.2.5
CPPFLAGS_AUTO = < >
Issuing make in zlib-1.2.5 ...
pushd zlib-1.2.5; make; popd
~/src/zlib-1.2.5 ~/src
make[1]: Entering directory `/disk2/user/src/zlib-1.2.5'
ar rc libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
ar: adler32.o: No such file or directory
make[1]: *** [libz.a] Error 1
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -L. libz.a
gcc: adler32.lo: No such file or directory
gcc: compress.lo: No such file or directory
gcc: crc32.lo: No such file or directory
gcc: deflate.lo: No such file or directory
[...]
make[1]: *** [libz.so.1.2.5] Error 1
make[1]: Target `all' not remade because of errors.
make[1]: Leaving directory `/disk2/user/src/zlib-1.2.5'
~/src
Versus from the zlib directory where it works correctly:
cd ~/src/zlib-1.2.5; make
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o example.o example.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o adler32.o adler32.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o compress.o compress.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o crc32.o crc32.c
[...]
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o zutil.o zutil.c
ar rc libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
(ranlib libz.a || true) >/dev/null 2>&1
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o example example.o -L. libz.a
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o minigzip.o minigzip.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzip minigzip.o -L. libz.a
mkdir objs 2>/dev/null || test -d objs
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/adler32.o adler32.c
mv objs/adler32.o adler32.lo
mkdir objs 2>/dev/null || test -d objs
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/compress.o compress.c
mv objs/compress.o compress.lo
[...]
mkdir objs 2>/dev/null || test -d objs
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/zutil.o zutil.c
mv objs/zutil.o zutil.lo
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -L. libz.a
rm -f libz.so libz.so.1
ln -s libz.so.1.2.5 libz.so
ln -s libz.so.1.2.5 libz.so.1
rmdir objs
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o examplesh example.o -L. libz.so.1.2.5
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzipsh minigzip.o -L. libz.so.1.2.5
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o example64 example64.o -L. libz.a
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzip64 minigzip64.o -L. libz.a