gimptool-1.3.in 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. #! /bin/sh
  2. prefix=@prefix@
  3. exec_prefix=@exec_prefix@
  4. exec_prefix_set=no
  5. bindir=@bindir@
  6. sbindir=@sbindir@
  7. libexecdir=@libexecdir@
  8. datadir=@datadir@
  9. sysconfdir=@sysconfdir@
  10. sharedstatedir=@sharedstatedir@
  11. localstatedir=@localstatedir@
  12. libdir=@libdir@
  13. infodir=@infodir@
  14. mandir=@mandir@
  15. includedir=@includedir@
  16. gimpplugindir=@gimpplugindir@
  17. gimpdatadir=@gimpdatadir@
  18. usage()
  19. {
  20. cat <<EOF
  21. Usage: gimptool-1.3 [OPTION]...
  22. General options:
  23. --help print this message
  24. --quiet, --silent don't echo build commands
  25. --version print the version of GIMP associated with this script
  26. -n, --just-print, --dry-run, --recon
  27. don't actually run any commands; just print them
  28. Developer options:
  29. --cflags print the compiler flags that are necessary to
  30. compile a plug-in
  31. --libs print the linker flags that are necessary to link a
  32. plug-in
  33. --prefix=PREFIX use PREFIX instead of the installation prefix that
  34. GIMP was built when computing the output for --cflags
  35. and --libs
  36. --exec-prefix=PREFIX use PREFIX instead of the installation exec prefix
  37. that GIMP was built when computing the output for
  38. --cflags and --libs
  39. Installation directory options:
  40. --prefix --exec-prefix --bindir --sbindir --libexecdir --datadir --sysconfdir
  41. --sharedstatedir --localstatedir --libdir --infodir --mandir --includedir
  42. --gimpplugindir --gimpdatadir
  43. The --cflags and --libs options can be appended with -noui to get appropriate
  44. settings for plug-ins which do not use GTK+.
  45. User options:
  46. --build plug-in.c build a plug-in from a source file
  47. --install plug-in.c same as --build, but installs the built
  48. plug-in as well
  49. --install-bin plug-in install a compiled plug-in
  50. --install-script script.scm install a script-fu script
  51. --uninstall-bin plug-in remove a plug-in again
  52. --uninstall-script plug-in remove a script-fu script
  53. The --install and --uninstall options have "admin" counterparts (with
  54. prefix --install-admin instead of --install) that can be used instead to
  55. install/uninstall a plug-in or script in the site directory instead of a
  56. user directory.
  57. For plug-ins which do not use GTK+, the --build and --install options can be
  58. appended with -noui for appropriate settings. For plug-ins that use GTK+ but
  59. not libgimpui, append -nogimpui.
  60. All binary build and install options can be appended with -strip to discard
  61. debugging information.
  62. EOF
  63. exit $1
  64. }
  65. noarg="\
  66. Error: Need a plug-in source file to build"
  67. notfound="\
  68. Error: Couldn't find file to build/install/uninstall"
  69. quiet=no
  70. donothing=no
  71. if test $# -eq 0; then
  72. usage 1
  73. fi
  74. if test x${PKG_CONFIG+set} != xset ; then
  75. gtk_cflags='@GTK_CFLAGS@'
  76. gtk_libs='@GTK_LIBS@'
  77. glib_cflags='@GLIB_CFLAGS@'
  78. glib_libs='@GLIB_LIBS@'
  79. else
  80. gtk_cflags=`$PKG_CONFIG --cflags gtk+-2.0`
  81. gtk_libs=`$PKG_CONFIG --libs gtk+-2.0`
  82. glib_cflags=`$PKG_CONFIG --cflags glib-2.0`
  83. glib_libs=`$PKG_CONFIG --libs glib-2.0`
  84. fi
  85. if test x${INSTALL+set} != xset ; then
  86. INSTALL='@INSTALL@'
  87. if test "$INSTALL" = "./install-sh -c"; then
  88. mydirname=`echo $0 | sed -e 's#\(.*\)/[^/].*$#\1#'`
  89. INSTALL="$mydirname/gimpinstall"
  90. fi
  91. fi
  92. if test x${CC+set} != xset ; then
  93. cc='@CC@'
  94. else
  95. cc="$CC"
  96. fi
  97. if test x${CFLAGS+set} != xset ; then
  98. cflags='@CFLAGS@'
  99. else
  100. cflags="$CFLAGS"
  101. fi
  102. if test x${LDFLAGS+set} != xset ; then
  103. ldflags='@LDFLAGS@'
  104. else
  105. ldflags="$LDFLAGS"
  106. fi
  107. if test x${LIBS+set} != xset ; then
  108. libs=""
  109. else
  110. libs="$LIBS"
  111. fi
  112. while test $# -gt 0; do
  113. case "$1" in
  114. -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  115. *) optarg= ;;
  116. esac
  117. case $1 in
  118. --version)
  119. echo @GIMP_VERSION@
  120. exit 0
  121. ;;
  122. --help)
  123. usage 0
  124. ;;
  125. --quiet | --silent)
  126. quiet=yes
  127. ;;
  128. -n | --just-print | --dry-run | --recon)
  129. donothing=yes
  130. ;;
  131. --prefix=*)
  132. prefix=$optarg
  133. if test $exec_prefix_set = no ; then
  134. exec_prefix=$optarg
  135. fi
  136. ;;
  137. --prefix)
  138. echo $prefix
  139. ;;
  140. --exec-prefix=*)
  141. exec_prefix=$optarg
  142. exec_prefix_set=yes
  143. ;;
  144. --exec-prefix)
  145. echo $exec_prefix
  146. ;;
  147. --*dir)
  148. dirname=\$`echo $1 | sed -e 's,^--,,'`
  149. dirname=`eval echo $dirname`
  150. test -z "$dirname" && exit 1
  151. echo $dirname
  152. exit 0
  153. ;;
  154. --cflags | --cflags-noui | --cflags-nogimpui)
  155. case $1 in
  156. --cflags | --cflags-nogimpui)
  157. my_gtk_cflags=$gtk_cflags ;;
  158. --cflags-noui)
  159. my_gtk_cflags=$glib_cflags ;;
  160. esac
  161. includes=-I@includedir@/gimp-@LT_RELEASE@
  162. echo $includes $my_gtk_cflags
  163. ;;
  164. --libs | --libs-nogimpui)
  165. my_gtk_libs=
  166. libdirs=-L@libdir@
  167. for i in $gtk_libs ; do
  168. if test $i != -L@libdir@ ; then
  169. if test -z "$my_gtk_libs" ; then
  170. my_gtk_libs="$i"
  171. else
  172. my_gtk_libs="$my_gtk_libs $i"
  173. fi
  174. fi
  175. done
  176. case $1 in
  177. --libs)
  178. echo $libdirs -lgimpui-@LT_RELEASE@ -lgimpwidgets-@LT_RELEASE@ -lgimp-@LT_RELEASE@ -lgimpcolor-@LT_RELEASE@ -lgimpmath-@LT_RELEASE@ -lgimpbase-@LT_RELEASE@ $my_gtk_libs ;;
  179. --libs-nogimpui)
  180. echo $libdirs -lgimp-@LT_RELEASE@ -lgimpcolor-@LT_RELEASE@ -lgimpmath-@LT_RELEASE@ -lgimpbase-@LT_RELEASE@ $my_gtk_libs ;;
  181. esac
  182. ;;
  183. --libs-noui)
  184. echo -L@libdir@ -lgimp-@LT_RELEASE@ -lgimpcolor-@LT_RELEASE@ -lgimpmath-@LT_RELEASE@ -lgimpbase-@LT_RELEASE@ $glib_libs
  185. ;;
  186. --install-bin | --install-admin-bin \
  187. | --install-bin-strip | --install-admin-bin-strip \
  188. | --install-script | --install-admin-script \
  189. | --uninstall-bin | --uninstall-admin-bin \
  190. | --uninstall-script | --uninstall-admin-script )
  191. case $1 in
  192. --*install-bin)
  193. install_cmd="@INSTALL_PROGRAM@"
  194. install_dir="$HOME/@gimpdir@/plug-ins"
  195. ;;
  196. --install-bin-strip)
  197. install_cmd="@INSTALL_PROGRAM@ -s"
  198. install_dir="$HOME/@gimpdir@/plug-ins"
  199. ;;
  200. --*install-admin-bin)
  201. install_cmd="@INSTALL_PROGRAM@"
  202. install_dir="$gimpplugindir/plug-ins"
  203. ;;
  204. --install-admin-bin-strip)
  205. install_cmd="@INSTALL_PROGRAM@ -s"
  206. install_dir="$gimpplugindir/plug-ins"
  207. ;;
  208. --*install-script)
  209. install_cmd="@INSTALL_DATA@"
  210. install_dir="$HOME/@gimpdir@/scripts"
  211. ;;
  212. --*install-admin-script)
  213. install_cmd="@INSTALL_DATA@"
  214. install_dir="$gimpdatadir/scripts"
  215. ;;
  216. esac
  217. case $1 in
  218. --uninstall-* )
  219. shift
  220. if test "x$1" != "x"; then
  221. dest=`echo $1 | sed -e 's#.*/\([^/].*\)$#\1#'`
  222. if test -f "$DESTDIR$install_dir/$dest"; then
  223. cmd="rm -f $DESTDIR$install_dir/$dest"
  224. test $quiet = "yes" || echo $cmd
  225. test $donothing = "yes" || exec $cmd
  226. else
  227. echo "${notfound}" 1>&2
  228. exit 1
  229. fi
  230. else
  231. echo "${noarg}" 1>&2
  232. exit 1
  233. fi
  234. ;;
  235. *)
  236. shift
  237. if test "x$1" != "x"; then
  238. if test -r "$1"; then
  239. dest=`echo $1 | sed -e 's#.*/\([^/].*\)$#\1#'`
  240. cmd="$install_cmd $1 $DESTDIR$install_dir/$dest"
  241. test $quiet = "yes" || echo $cmd
  242. test $donothing = "yes" || exec $cmd
  243. else
  244. echo "${notfound}" 1>&2
  245. exit 1
  246. fi
  247. else
  248. echo "${noarg}" 1>&2
  249. exit 1
  250. fi
  251. ;;
  252. esac
  253. ;;
  254. --build | --install | --install-admin | --build-strip | --install-strip \
  255. | --install-admin-strip | --build-nogimpui | --install-nogimpui \
  256. | --install-admin-nogimpui | --build-nogimpui-strip \
  257. | --install-nogimpui-strip | --install-admin-nogimpui-strip \
  258. | --build-noui | --install-noui | --install-admin-noui \
  259. | --build-noui-strip | --install-noui-strip | --install-admin-noui-strip)
  260. opt=`echo $1 | sed 's/-strip$//'`
  261. if test "x$opt" != "x$1" ; then
  262. cflags=`echo $cflags | sed -e 's/-g //g' -e 's/ -g//g'`
  263. fi
  264. case $opt in
  265. --build | --build-noui | --build-nogimpui)
  266. install_dir=. ;;
  267. --install | --install-noui | --install-nogimpui)
  268. install_dir="$HOME/@gimpdir@/plug-ins" ;;
  269. --install-admin | --install-admin-noui | --install-admin-nogimpui)
  270. install_dir="$gimpplugindir/plug-ins" ;;
  271. esac
  272. noui=`echo $opt | sed 's/^.*\(noui\)$/\1/'`
  273. nogimpui=`echo $opt | sed 's/^.*\(nogimpui\)$/\1/'`
  274. if test "$noui" = "noui" ; then
  275. gimp_cflags=`$0 --cflags-noui`
  276. gimp_libs=`$0 --libs-noui`
  277. elif test "$nogimpui" = "nogimpui" ; then
  278. gimp_cflags=`$0 --cflags-nogimpui`
  279. gimp_libs=`$0 --libs-nogimpui`
  280. else
  281. gimp_cflags=`$0 --cflags`
  282. gimp_libs=`$0 --libs`
  283. fi
  284. shift
  285. if test "x$1" != "x"; then
  286. if test -r "$1"; then
  287. dest=`echo $1 | sed -e 's#.*/\([^/].*\)$#\1#' -e 's/\.[^.]*$//'`
  288. cmd="$cc $cflags $gimp_cflags -o $install_dir/$dest $1 $ldflags $gimp_libs $libs"
  289. test $quiet = "yes" || echo $cmd
  290. test $donothing = "yes" || exec $cmd
  291. else
  292. echo "${notfound}" 1>&2
  293. exit 1
  294. fi
  295. else
  296. echo "${noarg}" 1>&2
  297. exit 1
  298. fi
  299. ;;
  300. *)
  301. usage 1
  302. ;;
  303. esac
  304. shift
  305. done