+" Generate a command to generate a list of files. Return a dictionary
+" containing two entries:
+" source - The source of the files (generated by executing the sourcecmd)
+" sourcecmd - The system command to use to generate the list of files
+"
+" The source command returned will output files from one of 4 locations,
+" searched in priority order:
+" 1. All filelist files found in the same directory(ies) vim looks for tags
+" files. Files are extracted from the contents of these files.
+" 2. Any tags files found in &tags. The file is parsed to get filenames.
+" 3. The tracked files in the current git repository, and/or the tracked files
+" in those valid git repositories named in the 'extrefs' file, if present.
+" 4. Perform a 'find . -type f' in the current directory.
+function! mkbuild#flcmd()
+ let files = s:filelists()
+ if empty(files)
+ let tags = s:tagfiles()
+ if empty(tags)
+ let gitdirs = s:gitdirs()
+ if empty(gitdirs)
+ let source = 'find'
+ let sourcecmd = 'find . -type f'
+ else " gitdirs
+ let source = 'git|extrefs'
+ let sourcecmd = '(true'
+ for g in gitdirs
+ let sourcecmd = sourcecmd . '; ' . s:gitls(g)
+ endfor
+ let sourcecmd = sourcecmd . ')'
+ endif
+ else " tags
+ let source = 'tags'
+ let sourcecmd = '(true'
+ for t in tags
+ let sourcecmd = sourcecmd . '; ' . s:tagls(t)
+ endfor
+ let sourcecmd = sourcecmd . ')'
+ endif
+ else " filelists
+ let source = 'filelists'
+ let sourcecmd = '(true'
+ for f in files
+ let sourcecmd = sourcecmd . '; ' . s:filels(f)
+ endfor
+ let sourcecmd = sourcecmd . ')'
+ endif
+ return { 'source': source, 'sourcecmd': sourcecmd }
+endfunction
+
+" Generate a list of files using mkbuild#flcmd()
+function! mkbuild#filelist()
+ let flcmdres = mkbuild#flcmd()
+ return s:chompsys(flcmdres['sourcecmd'] . ' | cat')
+endfunction
+