Changeset 30 for trunk/src/kmk


Ignore:
Timestamp:
Nov 30, 2002, 7:53:42 AM (23 years ago)
Author:
bird
Message:

Basic nmake emulation.

Location:
trunk/src/kmk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/job.c

    r27 r30  
    4545#endif
    4646#endif /* not lint */
     47
     48#ifdef NMAKE
     49#define OLD_JOKE 1
     50#endif
    4751
    4852#ifndef OLD_JOKE
     
    11431147                if (strcmp(gn->name,"love") == 0)
    11441148                    (*abortProc)("Not war.");
    1145                 else
     1149#ifdef NMAKE
     1150        else if (strcmp(gn->name,"fire") == 0)
     1151                    (*abortProc)("No match.");
     1152#endif
     1153        else
    11461154#endif
    11471155                    (*abortProc)("%s %s. Stop", msg, gn->name);
  • trunk/src/kmk/main.c

    r27 r30  
    168168Lst                     envFirstVars;   /* (-E) vars to override from env */
    169169static Boolean          jobsRunning;    /* TRUE if the jobs might be running */
    170 
     170#ifdef NMAKE
     171static Boolean          go_to_objdir;   /* ! -o flag */
     172#endif
    171173static void             MainParseArgs __P((int, char **));
    172174char *                  chdir_verify_path __P((char *, char *));
     
    203205        optind = 1;     /* since we're called more than once */
    204206#ifdef REMOTE
    205 # define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv"
     207# ifdef NMAKE
     208#  define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstvo"
     209# else
     210#  define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv"
     211# endif
    206212#else
    207 # define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv"
     213# ifdef NMAKE
     214#  define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstvo"
     215# else
     216#  define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv"
     217# endif
    208218#endif
    209219rearg:  while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
     
    361371                        Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
    362372                        break;
     373#ifdef NMAKE
     374                case 'o':
     375                        go_to_objdir = TRUE;
     376                        Var_Append(MAKEFLAGS, "-o", VAR_GLOBAL);
     377                        break;
     378#endif
    363379                case 'q':
    364380                        queryFlag = TRUE;
     
    450466        char *obpath;
    451467{
    452         struct stat sb;
     468        struct stat sb;
     469#ifdef NMAKE
     470        if (!go_to_objdir)
     471            return NULL;
     472#endif
    453473
    454474        if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
     
    679699        debug = 0;                      /* No debug verbosity, please. */
    680700        jobsRunning = FALSE;
     701#ifdef NMAKE
     702        go_to_objdir = FALSE;
     703#endif
    681704
    682705        maxLocal = DEFMAXLOCAL;         /* Set default local max concurrency */
     
    13911414usage()
    13921415{
    1393         (void)fprintf(stderr, "%s\n%s\n%s\n",
    1394 "usage: make [-Beiknqrstv] [-D variable] [-d flags] [-E variable] [-f makefile]",
    1395 "            [-I directory] [-j max_jobs] [-m directory] [-V variable]",
    1396 "            [variable=value] [target ...]");
     1416        (void)fprintf(stderr, "%s\n%s\n%s\n"
     1417#ifdef NMAKE
     1418"%s\n"
     1419#endif
     1420    ,
     1421"usage: kmk [-Beiknqrstv] [-D variable] [-d flags] [-E variable] [-f makefile]",
     1422"           [-I directory] [-j max_jobs] [-m directory] [-V variable]",
     1423"           [variable=value] [target ...]"
     1424#ifdef NMAKE
     1425,"NMAKE compatible mode enabled."
     1426
     1427#endif
     1428);
    13971429        exit(2);
    13981430}
  • trunk/src/kmk/parse.c

    r27 r30  
    21722172                lineno++;
    21732173                lastc = ' ';
     2174#ifdef NMAKE
     2175                do {
     2176                        while ((c = ParseReadc ()) == ' ' || c == '\t') {
     2177                            continue;
     2178                        }
     2179                        if (c != '#')
     2180                            break;
     2181                        /* comment - skip line */
     2182                        while ((c = ParseReadc ()) != '\n' && c != EOF) {
     2183                            continue;
     2184                        }
     2185                        if (c == EOF)
     2186                            break;
     2187                } while (1);
     2188#else
    21742189                while ((c = ParseReadc ()) == ' ' || c == '\t') {
    21752190                    continue;
    21762191                }
     2192#endif
    21772193                if (c == EOF || c == '\n') {
    21782194                    goto line_read;
     
    22972313        *ep = 0;
    22982314
     2315#ifdef NMAKE
     2316        if (line[0] == '.' || line[0] == '!') {
     2317#else
    22992318        if (line[0] == '.') {
     2319#endif
    23002320            /*
    23012321             * The line might be a conditional. Ask the conditional module
     
    24092429    do {
    24102430        while ((line = ParseReadLine ()) != NULL) {
     2431//debugkso: fprintf(stderr, "%s(%d): inLine=%d line=%s\n", fname, lineno, inLine, line);
    24112432            if (*line == '.') {
    24122433                /*
     
    24502471                 * a creation command.
    24512472                 */
    2452 #ifndef POSIX
     2473#if !defined(POSIX) || defined(NMAKE)
    24532474            shellCommand:
    24542475#endif
     
    24962517                 * and add it to the current list of targets.
    24972518                 */
    2498 #ifndef POSIX
     2519#if !defined(POSIX) || defined(NMAKE)
    24992520                Boolean nonSpace = FALSE;
    25002521#endif
     
    25082529                        goto nextLine;
    25092530                    }
    2510 #ifndef POSIX
     2531#if !defined(POSIX) || defined(NMAKE)
    25112532                    while ((*cp != ':') && (*cp != '!') && (*cp != '\0')) {
    25122533                        nonSpace = TRUE;
     
    25162537                }
    25172538
    2518 #ifndef POSIX
     2539#if !defined(POSIX) || defined(NMAKE)
    25192540                if (*cp == '\0') {
    25202541                    if (inLine) {
     2542#ifndef NMAKE
    25212543                        Parse_Error (PARSE_WARNING,
    25222544                                     "Shell command needs a leading tab");
     2545#endif
    25232546                        goto shellCommand;
    25242547                    } else if (nonSpace) {
     
    25432566
    25442567                    ParseDoDependency (line);
    2545 #ifndef POSIX
     2568#if !defined(POSIX) || defined(NMAKE)
    25462569                }
    25472570#endif
  • trunk/src/kmk/var.c

    r27 r30  
    183183static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
    184184static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData));
     185#ifdef NMAKE
     186static Boolean VarBase __P((char *, Boolean, Buffer, ClientData));
     187#endif
    185188static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData));
    186189#ifdef SYSVVARSUB
     
    795798    return (dummy ? TRUE : TRUE);
    796799}
     800
     801#ifdef NMAKE
     802/*-
     803 *-----------------------------------------------------------------------
     804 * VarBase --
     805 *      Remove the head and suffix of the given word and place the result
     806 *      in the given buffer.
     807 *
     808 * Results:
     809 *      TRUE if characters were added to the buffer (a space needs to be
     810 *      added to the buffer before the next word).
     811 *
     812 * Side Effects:
     813 *      The trimmed word is added to the buffer.
     814 *
     815 *-----------------------------------------------------------------------
     816 */
     817static Boolean
     818VarBase (word, addSpace, buf, dummy)
     819    char          *word;        /* Word to trim */
     820    Boolean       addSpace;     /* TRUE if need to stick a space in the
     821                                 * buffer before adding the tail */
     822    Buffer        buf;          /* Buffer in which to store it */
     823    ClientData    dummy;
     824{
     825    register char *slash;
     826
     827    if (addSpace) {
     828        Buf_AddByte (buf, (Byte)' ');
     829    }
     830
     831    slash = strrchr (word, '/');
     832    if (slash != (char *)NULL) {
     833        register char *dot;
     834        *slash++ = '\0';
     835        dot = strrchr (slash, '.');
     836        if (dot)
     837        {
     838            *dot = '\0';
     839            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     840            *dot = '.';
     841        }
     842        else
     843            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     844        slash[-1] = '/';
     845    } else {
     846        register char *dot;
     847        dot = strrchr (slash, '.');
     848        if (dot)
     849        {
     850            *dot = '\0';
     851            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     852            *dot = '.';
     853        }
     854        else
     855            Buf_AddBytes (buf, strlen(slash), (Byte *)slash);
     856    }
     857    return (dummy ? TRUE : TRUE);
     858}
     859
     860#endif
    797861
    798862/*-
     
    14961560    dynamic = FALSE;
    14971561    start = str;
     1562//debugkso: fprintf(stderr, "var: str=%s\n", str);
    14981563
    14991564    if (str[1] != '(' && str[1] != '{') {
     
    15901655        v = VarFind (str, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
    15911656        if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) &&
     1657#ifdef NMAKE
     1658            (vlen == 2) && (str[1] == 'F' || str[1] == 'D' || str[1] == 'B' || str[1] == 'R'))
     1659#else
    15921660            (vlen == 2) && (str[1] == 'F' || str[1] == 'D'))
     1661#endif
    15931662        {
    15941663            /*
     
    16221691                        val = (char *)Buf_GetAll(v->val, (int *)NULL);
    16231692
     1693#ifdef NMAKE
     1694                        switch (str[1])
     1695                        {
     1696                        case 'D': val = VarModify(val, VarHead, (ClientData)0); break;
     1697                        case 'B': val = VarModify(val, VarBase, (ClientData)0); break;
     1698                        case 'R': val = VarModify(val, VarRoot, (ClientData)0); break;
     1699                        default:  val = VarModify(val, VarTail, (ClientData)0); break;
     1700                        }
     1701#else
    16241702                        if (str[1] == 'D') {
    16251703                            val = VarModify(val, VarHead, (ClientData)0);
     
    16271705                            val = VarModify(val, VarTail, (ClientData)0);
    16281706                        }
     1707#endif
    16291708                        /*
    16301709                         * Resulting string is dynamically allocated, so
     
    16431722
    16441723        if (v == (Var *)NIL) {
     1724//debugkso: fprintf(stderr, "\tv == (Var *)NIL vlen=%d str=%s\n", vlen, str);
     1725
    16451726            if (((vlen == 1) ||
    16461727                 (((vlen == 2) && (str[1] == 'F' ||
     1728#ifdef NMAKE
     1729                                         str[1] == 'D' || str[1] == 'B' || str[1] == 'R')))) &&
     1730#else
    16471731                                         str[1] == 'D')))) &&
     1732#endif
    16481733                ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)))
    16491734            {
Note: See TracChangeset for help on using the changeset viewer.