Percent symbol not getting evaluated in makefile -
i'm new makefiles etc.
the file looks this:
compiler_name = gcc compiler_flags = path_objects = ./obj path_sources = ./src $(path_objects)/%.o: $(path_sources)/%.c $(info generating object files...) @$(compiler_name) $(compiler_flags) -c $< -o $@ cleanup: $(path_objects)/%.o $(info final cleanup...) @rm -rf $<
when try make project error: make: *** no rule make target 'obj/%.o', needed 'cleanup'. stop.
it's % wildcard not getting evaluated correctly. please me.
a pattern rule has '%' in target, , maybe in 1 or more of prerequisites. have:
cleanup: $(path_objects)/%.o ...
is not pattern rule, , '%' not wildcard, it's character. that's ordinary rule looks file called "./obj/%" prerequisite, , there's no such file.
if want cleanup
remove of object files in directory, there's no need of complication. this:
cleanup: @echo final cleanup... @rm -rf $(path_objects)/*.o
note uses shell command echo
, not make command info
, , shell wildcard '*', not make wildcard '%'.
if want target depend on object files can build, must construct list yourself; it's not difficult, doesn't need here.
Comments
Post a Comment