diff --git a/GDALmake.opt.in b/GDALmake.opt.in index fd8e8f374d..655c004c56 100644 --- a/GDALmake.opt.in +++ b/GDALmake.opt.in @@ -63,6 +63,7 @@ INST_INCLUDE = @includedir@ INST_DATA = @datadir@ INST_LIB = @libdir@ INST_BIN = @bindir@ +INST_BASH_COMPLETION = @bashcompdir@ INST_PYMOD = @pymoddir@ INST_DOCS = @exec_prefix@/doc INST_MAN = @mandir@ diff --git a/GNUmakefile b/GNUmakefile index 92467d6cf6..6d5e7d9fc0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -229,7 +229,9 @@ endif ifneq ($(BINDINGS),) (cd swig; $(MAKE) install) endif +ifdef INST_BASH_COMPLETION (cd scripts; $(MAKE) install) +endif for f in LICENSE.TXT data/*.* ; do $(INSTALL_DATA) $$f $(DESTDIR)$(INST_DATA) ; done $(LIBTOOL_FINISH) $(DESTDIR)$(INST_LIB) $(INSTALL_DIR) $(DESTDIR)$(INST_LIB)/pkgconfig diff --git a/configure.ac b/configure.ac index 93ddca84d9..5d0e7ab8be 100644 --- a/configure.ac +++ b/configure.ac @@ -1187,6 +1187,24 @@ if test "$am_func_iconv" = "yes"; then AC_DEFINE_UNQUOTED(ICONV_CPP_CONST,$ICONV_CPP_CONST, [For.cpp files, define as const if the declaration of iconv() needs const.]) fi +dnl --------------------------------------------------------------------------- +dnl Bash completions +dnl --------------------------------------------------------------------------- + +AC_ARG_WITH([bash-completion], + AS_HELP_STRING([--with-bash-completion[=ARG]], + [Install Bash completions (ARG=yes or path)]),,) + +if test "x$with_bash_completion" = "xno" -o "x$with_bash_completion" = "x"; then + AC_MSG_NOTICE([Bash completions not requested]) +elif test "x$with_bash_completion" = "xyes"; then + PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], , + bashcompdir="${sysconfdir}/bash_completion.d") + AC_SUBST(bashcompdir) +else + AC_SUBST(bashcompdir, $with_bash_completion) +fi + dnl --------------------------------------------------------------------------- dnl PROJ.6 related stuff dnl --------------------------------------------------------------------------- diff --git a/scripts/GNUmakefile b/scripts/GNUmakefile index 8f039e469a..511fbb499c 100644 --- a/scripts/GNUmakefile +++ b/scripts/GNUmakefile @@ -1,10 +1,20 @@ include ../GDALmake.opt +PROGRAMS := gdal2tiles.py gdal2xyz.py gdaladdo gdalbuildvrt gdal_calc.py \ + gdalchksum.py gdalcompare.py gdal-config gdal_contour gdaldem \ + gdal_edit.py gdalenhance gdal_fillnodata.py gdal_grid \ + gdalident.py gdalimport.py gdallocationinfo gdalmanage \ + gdal_merge.py gdalmove.py gdal_polygonize.py gdal_proximity.py \ + gdal_rasterize gdal_retile.py gdalserver gdal_sieve.py \ + gdalsrsinfo gdaltindex gdaltransform gdal_translate gdalwarp \ + ogr2ogr ogrinfo ogrlineref ogrmerge.py ogrtindex + completion: PATH=$(GDAL_ROOT)/swig/python/scripts:$(GDAL_ROOT)/apps:$(PATH) python completionFinder.py gdal-bash-completion.sh install: - if test "x`pkg-config --version 2>/dev/null`" != "x" -a "x`pkg-config --variable=compatdir bash-completion`" != "x"; then \ - $(INSTALL_DIR) $(DESTDIR)${prefix}`pkg-config --variable=compatdir bash-completion` ; \ - cp gdal-bash-completion.sh $(DESTDIR)${prefix}`pkg-config --variable=compatdir bash-completion`; \ - fi + $(INSTALL_DIR) $(DESTDIR)$(INST_BASH_COMPLETION) ; \ + $(INSTALL_DATA) gdal-bash-completion.sh $(DESTDIR)$(INST_BASH_COMPLETION)/gdalinfo; \ + for p in $(PROGRAMS); do \ + ln -rs $(DESTDIR)$(INST_BASH_COMPLETION)/gdalinfo $(DESTDIR)$(INST_BASH_COMPLETION)/$$p; \ + done