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:
Tristan Wibberley 2015-04-05 04:44:06 +01:00 committed by Ville Skyttä
parent 80c2bb6964
commit f9115ce0bb
5 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,5 @@
#include <stdio.h>
#include "sample.h"
int main(void)
{

3
test/fixtures/make/sample.d vendored Normal file
View File

@ -0,0 +1,3 @@
sample.o: sample.c sample.h
sample.h:

0
test/fixtures/make/sample.h vendored Normal file
View File