2018-03-20 23:20:10 +08:00
|
|
|
function __fish_print_make_targets --argument-names directory file
|
2016-12-07 18:05:14 +08:00
|
|
|
# Since we filter based on localized text, we need to ensure the
|
|
|
|
# text will be using the correct locale.
|
|
|
|
set -lx LC_ALL C
|
|
|
|
|
|
|
|
if test -z "$directory"
|
|
|
|
set directory '.'
|
|
|
|
end
|
|
|
|
|
2018-03-20 23:20:10 +08:00
|
|
|
if test -z "$file"
|
|
|
|
for standard_file in $directory/{GNUmakefile,Makefile,makefile}
|
|
|
|
if test -f $standard_file
|
|
|
|
set file $standard_file
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-07 18:05:14 +08:00
|
|
|
set -l bsd_make
|
2018-05-11 22:16:14 +08:00
|
|
|
if make --version 2>/dev/null | string match -q 'GNU*'
|
2016-12-07 18:05:14 +08:00
|
|
|
set bsd_make 0
|
|
|
|
else
|
|
|
|
set bsd_make 1
|
|
|
|
end
|
|
|
|
|
2018-03-20 23:20:10 +08:00
|
|
|
if test "$bsd_make" = 0
|
|
|
|
# https://stackoverflow.com/a/26339924
|
2018-04-02 04:42:38 +08:00
|
|
|
make -C "$directory" -f "$file" -pRrq : 2>/dev/null | awk -v RS= -F: '/^# Files/,/^# Finished Make data base/ {if ($1 !~ "^[#.]") {print $1}}' 2>/dev/null
|
2018-03-20 23:20:10 +08:00
|
|
|
else
|
2018-04-02 04:42:38 +08:00
|
|
|
make -C "$directory" -f "$file" -d g1 -rn >/dev/null 2>| awk -F, '/^#\*\*\* Input graph:/,/^$/ {if ($1 !~ "^#... ") {gsub(/# /,"",$1); print $1}}' 2>/dev/null
|
2016-11-28 13:27:22 +08:00
|
|
|
end
|
2007-09-22 05:04:01 +08:00
|
|
|
end
|
2014-01-30 07:42:52 +08:00
|
|
|
|