3 ms·
Seems like a reasonable article. But that Makefile is a disaster: 1. The clean rule doesn't delete the generated .html file. 2. The clean rule returns an erro
by abainbridge 9y ago
Seems like a reasonable article. But that Makefile is a disaster:
1. The clean rule doesn't delete the generated .html file.
2. The clean rule returns an error if some of the output files are missing. It needs a -f adding.
3. It doesn't implement dependency tracking of the header files or the Makefile itself.
4. On my clean Ubuntu 16 LTS install, the .o:.c rule doesn't get called. Instead Make uses its built-in rule which doesn't include -fPIC, so the build fails. I guess it is missing some % symbols.
More controversially, I think Makefiles for simple purposes like this are a form of premature optimization. It would be simpler to create a bash script called build.sh containing:
CFLAGS="-Wall -Werror -fpic"
gcc $CFLAGS -shared Point.c Line.c -o libline.so
gcc $CFLAGS -shared Point.c -o libpoint.so
./testPoint.py
./testWrappedPoint.py
./testLine.py
That's much easier to understand, doesn't depend on Make being installed, rebuilds when a header is changed and doesn't generate .o file litter. The price is that it takes 0.1 seconds longer to run in the case where there's no building to be done and there's no "clean". I think it is a net win.