我不确定最好的方法是什么,这方面的一些指示会有所帮助
代码:
#Else where in different file and included in this makefile i have
LIBRARY_LIST := CONFIG_MTS_PTHREADS
CONFIG_MTS_PTHREADS := y
collect-compilation:
if [ $(strip $(CONFIG_MTS_PTHREADS)) == y ]; then \
echo "ok"; \
fi;
for compile in $(LIBRARY_LIST) ; do \
if [ $(strip $$compile) == y ]; then \
echo "ok"; \
fi; \
done
所以从上面的代码片段中,'IF'循环的顶部按预期工作,我看到'OK'。显示。
现在对于第二个 for 循环,我在将 $$compile 替换为“IF”时遇到了一些问题。最终我希望 $$compile 被 CONFIG_MTS_PTHREADS 取代,表达式应该评估为 y == y 并显示“OK”,但对我来说。,
输出:
make -C ./Dev2.0.1/OSX
if [ y == y ]; then \
echo "ok"; \
fi;
ok <----- fine and expected
for compile in CONFIG_MTS_PTHREADS ; do \
if [ $compile == y ]; then \
echo "ok"; \
fi; \
done <------ Here it skips the then part and proceeds further, i expect 'OK' after this though.