make: Add __BASH_MAKE_COMPLETION__ variable
This variable is there so that makefiles can avoid adding targets that shouldn't be offered. A typical example would be targets added to dependency files by the -MP option to gcc.
This commit is contained in:
parent
80c2bb6964
commit
f9115ce0bb
@ -144,7 +144,8 @@ _make()
|
||||
|
||||
local reset=$( set +o | command grep -F posix ); set +o posix # <(...)
|
||||
COMPREPLY=( $( LC_ALL=C \
|
||||
make -npq "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \
|
||||
make -npq __BASH_MAKE_COMPLETION__=1 \
|
||||
"${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \
|
||||
sed -nf <(_make_target_extract_script $mode "$cur") ) )
|
||||
$reset
|
||||
|
||||
|
5
test/fixtures/make/Makefile
vendored
5
test/fixtures/make/Makefile
vendored
@ -1,5 +1,6 @@
|
||||
$(info confuse: make)
|
||||
|
||||
CFLAGS=-MMD -MP
|
||||
NAME := sample
|
||||
|
||||
.PHONY: all
|
||||
@ -16,3 +17,7 @@ install: all
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -f $(NAME)
|
||||
|
||||
ifndef __BASH_MAKE_COMPLETION__
|
||||
-include sample.d
|
||||
endif
|
||||
|
1
test/fixtures/make/sample.c
vendored
1
test/fixtures/make/sample.c
vendored
@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include "sample.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
3
test/fixtures/make/sample.d
vendored
Normal file
3
test/fixtures/make/sample.d
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
sample.o: sample.c sample.h
|
||||
|
||||
sample.h:
|
0
test/fixtures/make/sample.h
vendored
Normal file
0
test/fixtures/make/sample.h
vendored
Normal file
Loading…
x
Reference in New Issue
Block a user