문제

Consider the following example, how to print some text when the make reaches those #Print lines

lib: $(LIBOBJ)
if [ -n "$(SHARED_LIBS)" ]; then \
    #Print some stuff here
    $(MAKE) -f $(TOP)/Makefile.shared -e \
        LIBNAME=$(LIBNAME) \
        LIBEXTRAS='$(LIBOBJ)' \
        LIBDEPS='-L$(TOP) -lcrypto' \
        link_o.$(SHLIB_TARGET); \
else \
    #Print some stuff here
    $(AR) $(LIB) $(LIBOBJ); \
fi
@touch lib
도움이 되었습니까?

해결책

Simply use the echo or print command. Don't forget to finish the line with a semi-colon and a backslash in your case.

echo "Print something";

lib: $(LIBOBJ)
if [ -n "$(SHARED_LIBS)" ]; then \
    echo "Print some stuff here"; \
    $(MAKE) -f $(TOP)/Makefile.shared -e \
        LIBNAME=$(LIBNAME) \
        LIBEXTRAS='$(LIBOBJ)' \
        LIBDEPS='-L$(TOP) -lcrypto' \
        link_o.$(SHLIB_TARGET); \
else \
    echo "Print some stuff here"; \
    $(AR) $(LIB) $(LIBOBJ); \
fi
@touch lib

다른 팁

I think @sehe's (edited) answer should work.

Another useful technique for debugging makefile recipes is to define SHELL='bash -x' which tells the shell to print out each command as it executes it, so you can see which branch of the condition is taken.

You can do that either in the makefile, or just when running make:

make SHELL='bash -x' lib
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top