c - Makefile : Parameterize so that it compiles the highest numbered file -
im building create file, , want tolerant of fact have multiple main methods, , perchance consider file highest alphabetical value entrypoint.
is there way or similar?
there few ways that, depending on level want or need create decision. here 3 know of:
find out build before building calling$(shell find | grep)
or $(shell grep -r ...)
identify files built (inclusion) or filter-out files not built (exclusion). use objdump
analyze object files , filter-out have main()
function except lastly one. utilize $(shell sort ...)
helper or $(sort ...)
. if know objects can contain make
, , using compiler / linker combination allows weak declarations can shadowed away, utilize $(sort)
on list of objects, $(lastword)
1 "highest name", , set first (or last, depending on how linker resolves) in list of linker files. c function make main
No comments:
Post a Comment