gimptool.c 20.1 KB
Newer Older
1
/* gimptool in C
2
 * Copyright (C) 2001-2007 Tor Lillqvist
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18
 */

/*
19 20 21 22 23
 * Gimptool rewritten in C, originally for Win32, where end-users who
 * might want to build and install a plug-in from source don't
 * necessarily have any Bourne-compatible shell to run the gimptool
 * script in. Later fixed up to replace the gimptool script on all
 * platforms.
24 25 26 27 28 29 30 31 32
 *
 * Yes, this program leaks dynamically allocated strings without
 * hesitation. So what, it runs only for a minimal time.
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

33 34
#include <sys/stat.h>

35
#include <glib-object.h>
36

37
#include "libgimpbase/gimpbase.h"
38

39 40 41 42
#ifdef G_OS_WIN32
#include "libgimpbase/gimpwin32-io.h"
#endif

43

Michael Natterer's avatar
Michael Natterer committed
44 45 46 47
static gboolean     silent  = FALSE;
static gboolean     dry_run = FALSE;
static gchar       *prefix;
static const gchar *exec_prefix;
48

Michael Natterer's avatar
Michael Natterer committed
49 50 51 52 53
static gboolean     msvc_syntax = FALSE;
static const gchar *env_cc;
static const gchar *env_cflags;
static const gchar *env_ldflags;
static const gchar *env_libs;
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

#ifdef G_OS_WIN32
#define EXEEXT ".exe"
#else
#define EXEEXT ""
#endif

#ifdef G_OS_WIN32
#define COPY win32_command ("copy")
#define REMOVE win32_command ("del")
#else
#define COPY "cp"
#define REMOVE "rm -f"
#endif

static struct {
71
  const gchar *option;
Michael Natterer's avatar
Michael Natterer committed
72
  const gchar *value;
73
} dirs[] = {
74 75 76 77 78 79 80 81
  { "prefix",         PREFIX         },
  { "exec-prefix",    EXEC_PREFIX    },
  { "bindir",         BINDIR         },
  { "sbindir",        SBINDIR        },
  { "libexecdir",     LIBEXECDIR     },
  { "datadir",        DATADIR        },
  { "datarootdir",    DATAROOTDIR    },
  { "sysconfdir",     SYSCONFDIR     },
82
  { "sharedstatedir", SHAREDSTATEDIR },
83 84 85 86
  { "localstatedir",  LOCALSTATEDIR  },
  { "libdir",         LIBDIR         },
  { "infodir",        INFODIR        },
  { "mandir",         MANDIR         },
87 88 89 90
#if 0
  /* For --includedir we want the includedir of the developer package,
   * not an includedir under the runtime installation prefix.
   */
91
  { "includedir",     INCLUDEDIR     },
92
#endif
93 94
  { "gimpplugindir",  GIMPPLUGINDIR  },
  { "gimpdatadir",    GIMPDATADIR    }
95 96
};

97 98 99 100

static void  usage (int exit_status) G_GNUC_NORETURN;


101 102 103
#ifdef G_OS_WIN32

static gchar *
104
win32_command (const gchar *command)
105
{
106
  const gchar *comspec = getenv ("COMSPEC");
107 108

  if (!comspec)
109
    comspec = "cmd.exe";
110 111 112 113 114 115 116

  return g_strdup_printf ("%s /c %s", comspec, command);
}

#endif

static gboolean
Michael Natterer's avatar
Michael Natterer committed
117 118
starts_with_dir (const gchar *string,
		 const gchar *test)
119
{
120
  return g_str_has_prefix (string, g_strconcat (test, "/", NULL)) ||
121 122 123 124
    strcmp (string, test) == 0;
}

static gchar *
Michael Natterer's avatar
Michael Natterer committed
125 126
one_line_output (const gchar *program,
		 const gchar *args)
127 128
{
  gchar *command = g_strconcat (program, " ", args, NULL);
129 130
  FILE  *pipe    = popen (command, "r");
  gchar  line[1000];
131 132 133

  if (pipe == NULL)
    {
134 135
      g_printerr ("Cannot run '%s'\n", command);
      exit (EXIT_FAILURE);
136 137 138 139 140 141 142 143 144 145 146 147 148 149
    }

  if (fgets (line, sizeof (line), pipe) == NULL)
    line[0] = '\0';

  if (strlen (line) > 0 && line [strlen (line) - 1] == '\n')
    line [strlen (line) - 1] = '\0';
  if (strlen (line) > 0 && line [strlen (line) - 1] == '\r')
    line [strlen (line) - 1] = '\0';

  pclose (pipe);

  if (strlen (line) == 0)
    {
150 151
      g_printerr ("No output from '%s'\n", command);
      exit (EXIT_FAILURE);
152 153 154 155 156 157
    }

  return g_strdup (line);
}

static gchar *
Michael Natterer's avatar
Michael Natterer committed
158
pkg_config (const gchar *args)
159
{
160
#ifdef G_OS_WIN32
161 162
  if (msvc_syntax)
    return one_line_output ("pkg-config --msvc-syntax", args);
163 164 165
#endif

  return one_line_output ("pkg-config", args);
166 167
}

Michael Natterer's avatar
Michael Natterer committed
168
static const gchar *
169
get_runtime_prefix (gchar slash)
170 171
{
#ifdef G_OS_WIN32
172 173 174

  /* Don't use the developer package prefix, but deduce the
   * installation-time prefix from where gimp-x.y.exe can be found.
175 176
   */

177
  gchar *path;
178
  gchar *p, *r;
179

180
  path = g_find_program_in_path ("gimp-" GIMP_APP_VERSION ".exe");
181

182 183
  if (path == NULL)
    path = g_find_program_in_path ("gimp.exe");
184

185
  if (path != NULL)
186
    {
187 188
      r = strrchr (path, G_DIR_SEPARATOR);
      if (r != NULL)
189
	{
190 191
	  *r = '\0';
	  if (strlen (path) >= 4 &&
192
	      g_ascii_strcasecmp (r - 4, G_DIR_SEPARATOR_S "bin") == 0)
193
	    {
194 195 196 197 198 199 200 201 202 203
	      r[-4] = '\0';
	      prefix = path;
	      if (slash == '/')
		{
		  /* Use forward slashes, less quoting trouble in Makefiles */
		  while ((p = strchr (prefix, '\\')) != NULL)
		    *p = '/';
		}
	      return prefix;
	    }
204 205 206
	}
    }

207 208 209
  g_printerr ("Cannot determine GIMP " GIMP_APP_VERSION " installation location\n");

  exit (EXIT_FAILURE);
210
#else
211 212
  /* On Unix assume the executable package is in the same prefix as the developer stuff */
  return pkg_config ("--variable=prefix gimp-2.0");
213 214 215
#endif
}

Michael Natterer's avatar
Michael Natterer committed
216
static const gchar *
217 218 219 220 221 222 223 224 225 226
get_exec_prefix (gchar slash)
{
#ifdef G_OS_WIN32
  if (exec_prefix != NULL)
    return exec_prefix;

  /* On Win32, exec_prefix is always same as prefix. Or is it? Maybe not,
   * but at least in tml's prebuilt stuff it is. If somebody else does
   * it another way, feel free to hack this.
   */
227
  return (exec_prefix = get_runtime_prefix (slash));
228
#else
229
  return EXEC_PREFIX;
230 231 232
#endif
}

233
static const gchar *
Michael Natterer's avatar
Michael Natterer committed
234
expand_and_munge (const gchar *value)
235
{
236 237
  const gchar *retval;

238
  if (starts_with_dir (value, "${prefix}"))
239
    retval = g_strconcat (PREFIX, value + strlen ("${prefix}"), NULL);
240
  else if (starts_with_dir (value, "${exec_prefix}"))
241 242 243 244 245 246
    retval = g_strconcat (EXEC_PREFIX, value + strlen ("${exec_prefix}"), NULL);
  else
    retval = g_strdup (value);

  if (starts_with_dir (retval, EXEC_PREFIX))
    retval = g_strconcat (get_exec_prefix ('/'), retval + strlen (EXEC_PREFIX), NULL);
247

248 249
  if (starts_with_dir (retval, PREFIX))
    retval = g_strconcat (get_runtime_prefix ('/'), retval + strlen (PREFIX), NULL);
250

251
  return retval;
252 253 254 255 256 257 258 259 260 261 262 263
}

static void
find_out_env_flags (void)
{
  gchar *p;

  if ((p = getenv ("CC")) != NULL && *p != '\0')
    env_cc = p;
  else if (msvc_syntax)
    env_cc = "cl -MD";
  else
264
    env_cc = CC;
265

266
  if (g_ascii_strncasecmp (env_cc, "cl", 2) == 0)
267 268 269 270 271
    msvc_syntax = TRUE;

  if ((p = getenv ("CFLAGS")) != NULL)
    env_cflags = p;
  else
272
    env_cflags = "";
273 274 275 276

  if ((p = getenv ("LDFLAGS")) != NULL)
    env_ldflags = p;
  else
277
    env_ldflags = "";
278 279 280 281 282 283 284 285 286 287

  if ((p = getenv ("LIBS")) != NULL && *p != '\0')
    env_libs = p;
  else
    env_libs = "";
}

static void
usage (int exit_status)
{
288
  g_print ("\
289
Usage: gimptool-2.0 [OPTION]...\n\
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
\n\
General options:\n\
  --help                  print this message\n\
  --quiet, --silent       don't echo build commands\n\
  --version               print the version of GIMP associated with this script\n\
  -n, --just-print, --dry-run, --recon\n\
                          don't actually run any commands; just print them\n\
Developer options:\n\
  --cflags                print the compiler flags that are necessary to\n\
                          compile a plug-in\n\
  --libs                  print the linker flags that are necessary to link a\n\
                          plug-in\n\
  --prefix=PREFIX         use PREFIX instead of the installation prefix that\n\
                          GIMP was built when computing the output for --cflags\n\
                          and --libs\n\
  --exec-prefix=PREFIX    use PREFIX instead of the installation exec prefix\n\
                          that GIMP was built when computing the output for\n\
                          --cflags and --libs\n\
  --msvc-syntax           print flags in MSVC syntax\n\
\n\
Installation directory options:\n\
  --prefix --exec-prefix --bindir --sbindir --libexecdir --datadir --sysconfdir\n\
  --sharedstatedir --localstatedir --libdir --infodir --mandir --includedir\n\
  --gimpplugindir --gimpdatadir\n\
\n\
The --cflags and --libs options can be appended with -noui to get appropriate\n\
settings for plug-ins which do not use GTK+.\n\
\n\
User options:\n\
  --build plug-in.c               build a plug-in from a source file\n\
  --install plug-in.c             same as --build, but installs the built\n\
                                  plug-in as well\n\
  --install-bin plug-in           install a compiled plug-in\n\
  --install-script script.scm     install a script-fu script\n\
\n\
  --uninstall-bin plug-in         remove a plug-in again\n\
  --uninstall-script plug-in      remove a script-fu script\n\
\n\
The --install and --uninstall options have \"admin\" counterparts (with\n\
prefix --install-admin instead of --install) that can be used instead to\n\
330
install/uninstall a plug-in or script in the machine directory instead of a\n\
331 332 333 334
user directory.\n\
\n\
For plug-ins which do not use GTK+, the --build and --install options can be\n\
appended with -noui for appropriate settings. For plug-ins that use GTK+ but\n\
335
not libgimpui, append -nogimpui.\n");
336 337
  exit (exit_status);
}
338

339
static gchar *
340
get_includedir (void)
341
{
342
  return pkg_config ("--variable=includedir gimp-2.0");
343 344
}

345 346
static void
do_includedir (void)
347
{
348
  g_print ("%s\n", get_includedir ());
349 350 351
}

static gchar *
352
get_cflags (void)
353
{
354
  return pkg_config ("--cflags gimpui-2.0");
355 356
}

357 358
static void
do_cflags (void)
359
{
360
  g_print ("%s\n", get_cflags ());
361 362 363
}

static gchar *
364
get_cflags_noui (void)
365
{
366
  return pkg_config ("--cflags gimp-2.0");
367 368 369
}

static void
370
do_cflags_noui (void)
371
{
372
  g_print ("%s\n", get_cflags_noui ());
373 374 375
}

static gchar *
376
get_cflags_nogimpui (void)
377
{
378
  return pkg_config ("--cflags gimp-2.0 gtk+-2.0");
379 380 381
}

static void
382
do_cflags_nogimpui (void)
383
{
384
  g_print ("%s\n", get_cflags_nogimpui ());
385 386 387 388 389
}

static gchar *
get_libs (void)
{
390
  return pkg_config ("--libs gimpui-2.0");
391 392 393 394 395
}

static void
do_libs (void)
{
396
  g_print ("%s\n", get_libs ());
397 398 399 400 401
}

static gchar *
get_libs_noui (void)
{
402
  return pkg_config ("--libs gimp-2.0");
403 404 405 406 407
}

static void
do_libs_noui (void)
{
408
  g_print ("%s\n", get_libs_noui ());
409 410
}

411 412 413 414 415 416 417 418 419
static gchar *
get_libs_nogimpui (void)
{
  return pkg_config ("--libs gimp-2.0 gtk+-2.0");
}

static void
do_libs_nogimpui (void)
{
420
  g_print ("%s\n", get_libs_nogimpui ());
421 422
}

423 424 425 426
static void
maybe_run (gchar *cmd)
{
  if (!silent)
427
    g_print ("%s\n", cmd);
428 429 430 431 432 433

  if (!dry_run)
    system (cmd);
}

static void
Michael Natterer's avatar
Michael Natterer committed
434 435 436 437
do_build_2 (const gchar *cflags,
	    const gchar *libs,
	    const gchar *install_dir,
	    const gchar *what)
438
{
Michael Natterer's avatar
Michael Natterer committed
439
  gchar       *cmd;
440
  const gchar *dest_dir;
Michael Natterer's avatar
Michael Natterer committed
441 442 443 444 445
  const gchar *output_flag;
  gchar       *dest_exe;
  const gchar *here_comes_linker_flags = "";
  const gchar *windows_subsystem_flag = "";
  gchar       *p, *q;
446 447 448 449 450 451 452 453 454

  if (install_dir != NULL)
    dest_dir = g_strconcat (install_dir, "/", NULL);
  else
    dest_dir = "";

  dest_exe = g_strdup (what);

  p = strrchr (dest_exe, '.');
455 456 457 458
  if (p == NULL ||
      !(strcmp (p, ".c")   == 0 ||
        strcmp (p, ".cc")  == 0 ||
        strcmp (p, ".cpp") == 0))
459
    {
460 461
      g_printerr ("plug-in source %s is not a C or C++ file?\n", what);
      exit (EXIT_FAILURE);
462 463 464 465 466
    }

  *p = '\0';
  q = strrchr (dest_exe, G_DIR_SEPARATOR);
#ifdef G_OS_WIN32
467 468 469 470 471
  {
    gchar *r = strrchr (dest_exe, '/');
    if (r != NULL && (q == NULL || r > q))
      q = r;
  }
472 473 474 475 476
#endif
  if (q == NULL)
    q = dest_exe;
  else
    q++;
477

478 479 480 481 482
  dest_exe = g_strconcat (q, EXEEXT, NULL);

  if (msvc_syntax)
    {
      output_flag = "-Fe";
483 484
      here_comes_linker_flags = " -link";
      windows_subsystem_flag = " -subsystem:windows";
485 486 487 488
    }
  else
    {
      output_flag = "-o ";
489 490 491
#ifdef G_OS_WIN32
      windows_subsystem_flag = " -mwindows";
#endif
492 493
    }

494
  cmd = g_strdup_printf ("%s %s %s %s%s%s %s%s %s%s %s %s",
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
			 env_cc,
			 env_cflags,
			 cflags,
			 output_flag,
			 dest_dir,
			 dest_exe,
			 what,
			 here_comes_linker_flags,
			 env_ldflags,
			 windows_subsystem_flag,
			 libs,
			 env_libs);
  maybe_run (cmd);
}

static void
511
do_build (const gchar *what)
512 513 514 515 516
{
  do_build_2 (get_cflags (), get_libs (), NULL, what);
}

static void
517
do_build_noui (const gchar *what)
518 519 520 521 522
{
  do_build_2 (get_cflags_noui (), get_libs_noui (), NULL, what);
}

static void
523
do_build_nogimpui (const gchar *what)
524 525 526 527 528
{
  do_build (what);
}

static gchar *
529
get_user_plugin_dir (void)
530
{
531 532 533 534
  return g_build_filename (g_get_home_dir (),
                           GIMPDIR,
                           "plug-ins",
                           NULL);
535 536 537
}

static void
538
do_install (const gchar *what)
539
{
540
  do_build_2 (get_cflags (), get_libs (), get_user_plugin_dir (), what);
541 542 543
}

static void
544
do_install_noui (const gchar *what)
545
{
546
  do_build_2 (get_cflags_noui (), get_libs_noui (), get_user_plugin_dir (), what);
547 548 549
}

static void
550
do_install_nogimpui (const gchar *what)
551 552 553 554 555 556 557
{
  do_install (what);
}

static gchar *
get_sys_plugin_dir (gboolean forward_slashes)
{
558
  const gchar *rprefix;
559

560 561 562 563 564 565 566 567
  rprefix = get_runtime_prefix (forward_slashes ? '/' : G_DIR_SEPARATOR);

  return g_build_path (forward_slashes ? "/" : G_DIR_SEPARATOR_S,
                       rprefix,
                       "lib", "gimp",
                       GIMP_PLUGIN_VERSION,
                       "plug-ins",
                       NULL);
568 569 570
}

static void
571
do_install_admin (const gchar *what)
572
{
573
  do_build_2 (get_cflags (), get_libs (), get_sys_plugin_dir (TRUE), what);
574 575 576
}

static void
577
do_install_admin_noui (const gchar *what)
578
{
579
  do_build_2 (get_cflags_noui (), get_libs_noui (), get_sys_plugin_dir (TRUE), what);
580 581 582
}

static void
583
do_install_admin_nogimpui (const gchar *what)
584
{
585
  do_build_2 (get_cflags (), get_libs (), get_sys_plugin_dir (TRUE), what);
586 587 588
}

static void
589 590
do_install_bin_2 (const gchar *dir,
		  const gchar *what)
591
{
592 593 594 595 596
  g_mkdir_with_parents (dir,
                        S_IRUSR | S_IXUSR | S_IWUSR |
                        S_IRGRP | S_IXGRP |
                        S_IROTH | S_IXOTH);

597 598 599 600
  maybe_run (g_strconcat (COPY, " ", what, " ", dir, NULL));
}

static void
601
do_install_bin (const gchar *what)
602
{
603
  do_install_bin_2 (get_user_plugin_dir (), what);
604 605 606
}

static void
607
do_install_admin_bin (const gchar *what)
608 609 610 611 612
{
  do_install_bin_2 (get_sys_plugin_dir (FALSE), what);
}

static void
613 614
do_uninstall (const gchar *dir,
	      const gchar *what)
615 616 617 618
{
  maybe_run (g_strconcat (REMOVE, " ", dir, G_DIR_SEPARATOR_S, what, NULL));
}

619 620
static const gchar *
maybe_append_exe (const gchar *what)
621 622 623 624
{
#ifdef G_OS_WIN32
  gchar *p = strrchr (what, '.');

625
  if (p == NULL || g_ascii_strcasecmp (p, ".exe") != 0)
626
    return g_strconcat (what, ".exe", NULL);
627 628 629 630 631 632
#endif

  return what;
}

static void
633
do_uninstall_bin (const gchar *what)
634
{
635
  do_uninstall (get_user_plugin_dir (), maybe_append_exe (what));
636 637 638
}

static void
639
do_uninstall_admin_bin (const gchar *what)
640 641 642 643 644
{
  do_uninstall (get_sys_plugin_dir (FALSE), maybe_append_exe (what));
}

static gchar *
645
get_user_script_dir (void)
646
{
647 648 649 650
  return g_build_filename (g_get_home_dir (),
                           GIMPDIR,
                           "scripts",
                           NULL);
651 652 653
}

static void
654
do_install_script (const gchar *what)
655
{
656
  do_install_bin_2 (get_user_script_dir (), what);
657 658 659
}

static gchar *
660
get_sys_script_dir (void)
661
{
662 663
  return g_build_filename (get_runtime_prefix (G_DIR_SEPARATOR),
                           "share", "gimp",
664
                           GIMP_PLUGIN_VERSION,
665 666
                           "scripts",
                           NULL);
667 668 669
}

static void
670
do_install_admin_script (const gchar *what)
671
{
672
  do_install_bin_2 (get_sys_script_dir (), what);
673 674 675
}

static void
676
do_uninstall_script (const gchar *what)
677
{
678
  do_uninstall (get_user_script_dir (), what);
679 680 681
}

static void
682
do_uninstall_admin_script (const gchar *what)
683
{
684
  do_uninstall (get_sys_script_dir (), what);
685 686 687 688 689 690 691 692 693 694
}

int
main (int    argc,
      char **argv)
{
  gint argi;
  gint i;

  if (argc == 1)
695
    usage (EXIT_SUCCESS);
696 697 698 699 700 701 702 703 704 705 706

  /* First scan for flags that affect our behaviour globally, but
   * are still allowed late on the command line.
   */
  argi = 0;
  while (++argi < argc)
    {
      if (strcmp (argv[argi], "-n") == 0 ||
	  strcmp (argv[argi], "--just-print") == 0 ||
	  strcmp (argv[argi], "--dry-run") == 0 ||
	  strcmp (argv[argi], "--recon") == 0)
707 708 709
        {
          dry_run = TRUE;
        }
710
      else if (strcmp (argv[argi], "--help") == 0)
711 712 713
        {
          usage (EXIT_SUCCESS);
        }
714
      else if (g_str_has_prefix (argv[argi], "--prefix="))
715 716 717
        {
          prefix = argv[argi] + strlen ("--prefix=");
        }
718
      else if (g_str_has_prefix (argv[argi], "--exec-prefix="))
719 720 721
        {
          exec_prefix = argv[argi] + strlen ("--exec_prefix=");
        }
722
      else if (strcmp (argv[argi], "--msvc-syntax") == 0)
723 724 725
        {
          msvc_syntax = TRUE;
        }
726 727
    }

728 729 730
#ifndef G_OS_WIN32
  if (msvc_syntax)
    {
731
      g_printerr ("Ignoring --msvc-syntax\n");
732 733 734 735
      msvc_syntax = FALSE;
    }
#endif

736 737 738 739 740 741 742
  find_out_env_flags ();

  /* Second pass, actually do something. */
  argi = 0;
  while (++argi < argc)
    {
      for (i = 0; i < G_N_ELEMENTS (dirs); i++)
743 744 745 746 747 748
        {
          if (strcmp (argv[argi],
                      g_strconcat ("--", dirs[i].option, NULL)) == 0)
            break;
        }

749
      if (i < G_N_ELEMENTS (dirs))
750 751 752
        {
          g_print ("%s\n", expand_and_munge (dirs[i].value));
        }
753
      else if (strcmp (argv[argi], "--quiet") == 0 ||
754 755 756 757
               strcmp (argv[argi], "--silent") == 0)
        {
          silent = TRUE;
        }
758 759
      else if (strcmp (argv[argi], "--version") == 0)
	{
760 761 762
	  g_print ("%d.%d.%d\n",
                   GIMP_MAJOR_VERSION, GIMP_MINOR_VERSION, GIMP_MICRO_VERSION);
	  exit (EXIT_SUCCESS);
763 764 765 766 767 768
	}
      else if (strcmp (argv[argi], "-n") == 0 ||
	       strcmp (argv[argi], "--just-print") == 0 ||
	       strcmp (argv[argi], "--dry-run") == 0 ||
	       strcmp (argv[argi], "--recon") == 0)
	;			/* Already handled */
769 770
      else if (strcmp (argv[argi], "--includedir") == 0)
	do_includedir ();
771 772 773 774 775
      else if (strcmp (argv[argi], "--cflags") == 0)
	do_cflags ();
      else if (strcmp (argv[argi], "--cflags-noui") == 0)
	do_cflags_noui ();
      else if (strcmp (argv[argi], "--cflags-nogimpui") == 0)
776
	do_cflags_nogimpui ();
777 778 779 780
      else if (strcmp (argv[argi], "--libs") == 0)
	do_libs ();
      else if (strcmp (argv[argi], "--libs-noui") == 0)
	do_libs_noui ();
781 782 783
      else if (strcmp (argv[argi], "--libs-nogimpui") == 0)
	do_libs_nogimpui ();
      else if (g_str_has_prefix (argv[argi], "--prefix="))
784
	;
785
      else if (g_str_has_prefix (argv[argi], "--exec-prefix="))
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
	;
      else if (strcmp (argv[argi], "--msvc-syntax") == 0)
	;
      else if (strcmp (argv[argi], "--build") == 0)
	do_build (argv[++argi]);
      else if (strcmp (argv[argi], "--build-noui") == 0)
	do_build_noui (argv[++argi]);
      else if (strcmp (argv[argi], "--build-nogimpui") == 0)
	do_build_nogimpui (argv[++argi]);
      else if (strcmp (argv[argi], "--install") == 0)
	do_install (argv[++argi]);
      else if (strcmp (argv[argi], "--install-noui") == 0)
	do_install_noui (argv[++argi]);
      else if (strcmp (argv[argi], "--install-nogimpui") == 0)
	do_install_nogimpui (argv[++argi]);
      else if (strcmp (argv[argi], "--install-admin") == 0)
	do_install_admin (argv[++argi]);
      else if (strcmp (argv[argi], "--install-admin-noui") == 0)
	do_install_admin_noui (argv[++argi]);
      else if (strcmp (argv[argi], "--install-admin-nogimpui") == 0)
	do_install_admin_nogimpui (argv[++argi]);
      else if (strcmp (argv[argi], "--install-bin") == 0)
	do_install_bin (argv[++argi]);
      else if (strcmp (argv[argi], "--install-admin-bin") == 0)
	do_install_admin_bin (argv[++argi]);
      else if (strcmp (argv[argi], "--uninstall-bin") == 0)
	do_uninstall_bin (argv[++argi]);
      else if (strcmp (argv[argi], "--uninstall-admin-bin") == 0)
	do_uninstall_admin_bin (argv[++argi]);
      else if (strcmp (argv[argi], "--install-script") == 0)
	do_install_script (argv[++argi]);
      else if (strcmp (argv[argi], "--install-admin-script") == 0)
	do_install_admin_script (argv[++argi]);
      else if (strcmp (argv[argi], "--uninstall-script") == 0)
	do_uninstall_script (argv[++argi]);
      else if (strcmp (argv[argi], "--uninstall-admin-script") == 0)
	do_uninstall_admin_script (argv[++argi]);
      else
	{
825 826
	  g_printerr ("Unrecognized switch %s\n", argv[argi]);
	  usage (EXIT_FAILURE);
827 828
	}
    }
829 830

  exit (EXIT_SUCCESS);
831 832 833 834 835 836
}
/*
 * Local Variables:
 * mode: c
 * End:
 */