I'm trying to generate header file dependencies with SDCC on Windows, the command line is
sdcc -c -mmcs51 --model-small --xram-size 0x0100 --xram-loc 0x0100 --code-size 0x2800 -Iinclude/ -oobj/ -DFREQ_SYS=12000000 --std-c23 -MMD -MT 'obj/main.rel' -MF 'obj/main.d' src/main.c
Which gives me this error:
at 1: error 119: don't know what to do with file 'obj/main.d'. file extension unsupported
The SDCC manual says: "SDCC uses sdcpp, an adapted version of the GNU Compiler Collection preprocessor cpp (gcc gcc. gnu.org/). If you need more dedicated options than those listed below please refer to the GCC CPP Manual at gnu.org/software/gcc/onlinedocs."
Is it possible the -MT
and -MF
options not supported?
The GCC docs mention these options but perhaps they're not passed through? In which case, does anyone have any good ideas about how to generate dependencies with SDCC without resorting to grep and sed etc?
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Preprocessor-Options.html
Using the -MMD option on its own generates a rule which uses a backslash for the target which then is interpreted as an escape, so the rule never fires.
e.g.
obj\main.rel: src/main.c include/ch554.h include/ch554_usb.h include/debug.h
I think the target is being interpreted as objmain.rel
because it never fires
Confirmed the backslash was the problem, now I have this sed expression in the rule which makes me sad but does work
sed -r -i 's#^(.*)\\\\(.*)\\:#\\1\\/\\2:#' $(OBJ)$(basename $(@F)).d
There is no space between MF
and filename.
-MFobj/main.d
I think in sdcc you should do like, idea from https://sourceforge.net/p/sdcc/bugs/3551/ :
sdcc -Wp,-MMD,-MTobj/main.rel,-MFmain.d ./main.c