[48] | 1 | /* $Id: mainmain.c 48 2003-04-05 03:22:01Z bird $
|
---|
| 2 | *
|
---|
| 3 | * The real mail entry point for kMk.
|
---|
| 4 | *
|
---|
| 5 | * Copyright (c) 2003 knut st. osmundsen <bird@anduin.net>
|
---|
| 6 | *
|
---|
| 7 | *
|
---|
| 8 | * This file is part of kBuild.
|
---|
| 9 | *
|
---|
| 10 | * kBuild is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * kBuild is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with kBuild; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 23 | *
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | /*******************************************************************************
|
---|
| 28 | * Header Files *
|
---|
| 29 | *******************************************************************************/
|
---|
| 30 | #include <kLib/kString.h>
|
---|
| 31 | #include <kLib/kPath.h>
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | /*******************************************************************************
|
---|
| 35 | * External Functions *
|
---|
| 36 | *******************************************************************************/
|
---|
| 37 | extern main_kMk(int argc, char **argv);
|
---|
| 38 | extern main_kShell(int argc, char **argv);
|
---|
| 39 | extern main_kDepend(int argc, char **argv);
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | * The real main of the merged tool suite (all in one).
|
---|
| 44 | *
|
---|
| 45 | * There is two ways the tool can be made work different, either thru
|
---|
| 46 | * it's name or thru the first argument.
|
---|
| 47 | */
|
---|
| 48 | int main(int argc, char **argv)
|
---|
| 49 | {
|
---|
| 50 | int rc = 16;
|
---|
| 51 | char * psz;
|
---|
| 52 |
|
---|
| 53 | /* @todo Debug build must register exception handler here. */
|
---|
| 54 |
|
---|
| 55 | /*
|
---|
| 56 | * Which tool is this?
|
---|
| 57 | * Give argument preference and check the first.
|
---|
| 58 | */
|
---|
| 59 | if (argc > 1 && !kStrCmp(argv[1], "--kShell"))
|
---|
| 60 | rc = main_kShell(argc, argv);
|
---|
| 61 | #if 0
|
---|
| 62 | else if (argc > 1 && !kStrCmp(argv[1], "--kDepend"))
|
---|
| 63 | rc = main_kDepend(argc, argv);
|
---|
| 64 | #endif
|
---|
| 65 | else if (argc > 1 && !kStrCmp(argv[1], "--kMk"))
|
---|
| 66 | rc = main_kDepend(argc, argv);
|
---|
| 67 | else
|
---|
| 68 | {
|
---|
| 69 | /* check name */
|
---|
| 70 | psz = kPathName(argv[0], NULL, 0);
|
---|
| 71 | if (!kStrNICmp(psz, "kShell", 6) && (!psz[6] || psz[6] == '.'))
|
---|
| 72 | rc = main_kShell(argc, argv);
|
---|
| 73 | #if 0
|
---|
| 74 | else if (!kStrNICmp(psz, "kDepend", 7) && (!psz[7] || psz[7] == '.'))
|
---|
| 75 | rc = main_kDepend(argc, argv);
|
---|
| 76 | #endif
|
---|
| 77 | else /* kMk is default */
|
---|
| 78 | rc = main_kMk(argc, argv);
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | /* @todo Debug build must unregister exception handler here. */
|
---|
| 82 |
|
---|
| 83 | return rc;
|
---|
| 84 | }
|
---|