यदि कुछ पूर्व शर्त पूरी नहीं हुई हैं तो मैं अपनी मेक प्रक्रिया को रद्द करने के लिए $(error ...)
का उपयोग करना चाहता हूं। test -d /foobar
विफल होने पर लक्ष्य निरस्त होना चाहिए।
BAD.mk
all: this_works fails_to_work
this_works:
@echo echo works...
@test -d ~ || echo ~ is not a directory
@test -d /foobar || echo /foobar is not a directory
fails_to_work:
@echo error does not work...
@test -d ~ || $(error ~ is not a directory)
@test -d /foobar || $(error /foobar is not a directory)
$ बनाने BAD.mk
echo works...
/foobar is not a directory
BAD.mk:9: *** ~ is not a directory. Stop.
-f आप देख सकते हैं, यहां तक कि नहीं "त्रुटि काम नहीं करता है ..." स्क्रीन पर गूँजती है। fails_to_work
के लिए नुस्खा शुरू होने से पहले विफल रहता है। मैं इसे कैसे हल करूं? मेरे उपयोग मामलों में से एक @test -d $(MY_ENV_VAR)
है, लेकिन मुझे नहीं लगता कि उदाहरण में दिए गए हार्ड-कोड किए गए पथ से अलग है।
अद्यतन (संस्करण जानकारी)
$ बनाने --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
धन्यवाद। आपका पहला सुझाव काम करता है (जिसे मैं इस तरह अपना रहा हूं: 'if! Test -d/foobar; फिर गूंजें "/ foobar निर्देशिका नहीं है"; बाहर निकलें 1; fi'), लेकिन आपका दूसरा नहीं है। एक वैध निर्देशिका के साथ, त्रुटि अभी भी हिट है। –