Ignore:
Timestamp:
Sep 19, 2006, 1:16:21 AM (19 years ago)
Author:
bird
Message:

Made it build again on linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/kbuild.c

    r532 r534  
    3030
    3131#include "make.h"
     32#include "filedef.h"
    3233#include "variable.h"
    3334#include "dep.h"
     
    4041#ifndef va_copy
    4142# define va_copy(dst, src) do {(dst) = (src);} while (0)
    42 #endif 
     43#endif
    4344
    4445
    4546/**
    4647 * Gets a variable that must exist.
    47  * Will cause a fatal failure if the variable doesn't exist. 
    48  * 
     48 * Will cause a fatal failure if the variable doesn't exist.
     49 *
    4950 * @returns Pointer to the variable.
    5051 * @param   pszName     The variable name.
     
    5556#ifndef NDEBUG
    5657    unsigned i;
    57 #endif 
     58#endif
    5859    struct variable *pVar = lookup_variable(pszName, strlen(pszName));
    5960    if (!pVar)
     
    6667    {
    6768        printf("%d != %d %s\n", pVar->value_length, i, pVar->name);
     69# ifdef _MSC_VER
    6870        __asm int 3;
     71# endif
     72        assert(0);
    6973    }
    7074#endif
     
    7478/**
    7579 * Gets a variable that must exist and can be recursive.
    76  * Will cause a fatal failure if the variable doesn't exist. 
    77  * 
     80 * Will cause a fatal failure if the variable doesn't exist.
     81 *
    7882 * @returns Pointer to the variable.
    7983 * @param   pszName     The variable name.
     
    8488#ifndef NDEBUG
    8589    unsigned i;
    86 #endif 
     90#endif
    8791    struct variable *pVar = lookup_variable(pszName, strlen(pszName));
    8892    if (!pVar)
     
    9397    {
    9498        printf("%d != %d %s\n", pVar->value_length, i, pVar->name);
     99# ifdef _MSC_VER
    95100        __asm int 3;
     101# endif
     102        assert(0);
    96103    }
    97104#endif
     
    103110 * Looks up a variable.
    104111 * The value_length field is valid upon successful return.
    105  * 
     112 *
    106113 * @returns Pointer to the variable. NULL if not found.
    107114 * @param   pszName     The variable name.
     
    118125        {
    119126            printf("%d != %d %s\n", pVar->value_length, i, pVar->name);
     127# ifdef _MSC_VER
    120128            __asm int 3;
     129# endif
     130            assert(0);
    121131        }
    122132#endif
     
    219229*/
    220230static struct variable *
    221 kbuild_get_source_tool(struct variable *pTarget, struct variable *pSource, struct variable *pType, 
     231kbuild_get_source_tool(struct variable *pTarget, struct variable *pSource, struct variable *pType,
    222232                       struct variable *pBldTrg, struct variable *pBldTrgArch, const char *pszVarName)
    223233{
     
    261271            *pszEnd = '\0';
    262272            if (!strchr(pszEnd, '$'))
    263                 pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz, 
     273                pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz,
    264274                                          1 /* duplicate */, o_file, 0 /* !recursive */);
    265275            else
     
    276286                {
    277287                    *pszExpEnd = '\0';
    278                     pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp, 
     288                    pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp,
    279289                                              pszExpEnd - pszExp, 1 /* duplicate */,
    280290                                              o_file, 0 /* !recursive */);
     
    302312                                                   kbuild_get_variable("type"),
    303313                                                   kbuild_get_variable("bld_trg"),
    304                                                    kbuild_get_variable("bld_trg_arch"), 
     314                                                   kbuild_get_variable("bld_trg_arch"),
    305315                                                   argv[0]);
    306316    if (pVar)
    307317         o = variable_buffer_output(o, pVar->value, pVar->value_length);
    308318    return o;
    309                                                    
     319
    310320}
    311321
     
    347357    {
    348358        pszSrc = pSource->value + pPathRoot->value_length;
    349         if (    *pszSrc == '/' 
     359        if (    *pszSrc == '/'
    350360            &&  !strncmp(pszSrc, pPathSubCur->value, pPathSubCur->value_length))
    351361            pszSrc += 1 + pPathSubCur->value_length;
    352362    }
    353     else 
     363    else
    354364        pszSrc = pSource->value;
    355365
     
    358368    if (isalpha(pszSrc[0]) && pszSrc[1] == ':')
    359369        pszSrc += 2;
    360 #endif 
     370#endif
    361371    while (*pszSrc == '/'
    362372#ifdef HAVE_DOS_PATHS
    363373           || *pszSrc == '\\'
    364 #endif 
     374#endif
    365375           )
    366376        pszSrc++;
     
    374384            ||  *pszSrcEnd == '/'
    375385#ifdef HAVE_DOS_PATHS
    376             ||  *pszSrcEnd == '\\' 
     386            ||  *pszSrcEnd == '\\'
    377387            ||  *pszSrcEnd == ':'
    378388#endif
     
    405415    *psz = '\0';
    406416
    407     /* 
     417    /*
    408418     * Define the variable in the current set and return it.
    409419     */
    410     return define_variable_vl(pszVarName, strlen(pszVarName), pszResult, cch - 1, 
     420    return define_variable_vl(pszVarName, strlen(pszVarName), pszResult, cch - 1,
    411421                              0 /* use pszResult */, o_file, 0 /* !recursive */);
    412422}
     
    417427{
    418428    struct variable *pVar = kbuild_get_object_base(kbuild_lookup_variable("target"),
    419                                                    kbuild_lookup_variable("source"), 
     429                                                   kbuild_lookup_variable("source"),
    420430                                                   argv[0]);
    421431    if (pVar)
    422432         o = variable_buffer_output(o, pVar->value, pVar->value_length);
    423433    return o;
    424                                                    
     434
    425435}
    426436
     
    444454static struct variable *
    445455kbuild_get_object_suffix(struct variable *pTarget, struct variable *pSource,
    446                          struct variable *pBldTrg, struct variable *pBldTrgArch, 
     456                         struct variable *pBldTrg, struct variable *pBldTrgArch,
    447457                         const char *pszVarName)
    448458{
     
    475485            *pszEnd = '\0';
    476486            if (!strchr(pszEnd, '$'))
    477                 pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz, 
     487                pVar = define_variable_vl(pszVarName, strlen(pszVarName), psz, pszEnd - psz,
    478488                                          1 /* duplicate */, o_file, 0 /* !recursive */);
    479489            else
     
    490500                {
    491501                    *pszExpEnd = '\0';
    492                     pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp, 
    493                                               pszExpEnd - pszExp, 1 /* duplicate */, 
     502                    pVar = define_variable_vl(pszVarName, strlen(pszVarName), pszExp,
     503                                              pszExpEnd - pszExp, 1 /* duplicate */,
    494504                                              o_file, 0 /* !recursive */);
    495505                }
     
    515525                                                     kbuild_get_variable("source"),
    516526                                                     kbuild_get_variable("bld_trg"),
    517                                                      kbuild_get_variable("bld_trg_arch"), 
     527                                                     kbuild_get_variable("bld_trg_arch"),
    518528                                                     argv[0]);
    519529    if (pVar)
    520530         o = variable_buffer_output(o, pVar->value, pVar->value_length);
    521531    return o;
    522                                                    
     532
    523533}
    524534
     
    543553/* Fills in the SDK struct (remember to free it). */
    544554static void
    545 kbuild_get_sdks(struct kbuild_sdks *pSdks, struct variable *pTarget, struct variable *pSource, 
     555kbuild_get_sdks(struct kbuild_sdks *pSdks, struct variable *pTarget, struct variable *pSource,
    546556                struct variable *pBldType, struct variable *pBldTrg, struct variable *pBldTrgArch)
    547557{
     
    580590    pSdks->cTarget = 0;
    581591    sprintf(pszTmp, "$(%s_SDKS) $(%s_SDKS.%s) $(%s_SDKS.%s) $(%s_SDKS.%s.%s)",
    582             pTarget->value, pBldType->value, 
    583             pTarget->value, pBldTrg->value, 
    584             pTarget->value, pBldTrg->value, 
     592            pTarget->value, pBldType->value,
     593            pTarget->value, pBldTrg->value,
     594            pTarget->value, pBldTrg->value,
    585595            pTarget->value, pBldTrgArch->value);
    586596    pszIterator = pSdks->apsz[1] = allocated_variable_expand(pszTmp);
     
    593603    pSdks->cSource = 0;
    594604    sprintf(pszTmp, "$(%s_SDKS) $(%s_SDKS.%s) $(%s_SDKS.%s) $(%s_SDKS.%s.%s)",
    595             pSource->value, pBldType->value, 
    596             pSource->value, pBldTrg->value, 
    597             pSource->value, pBldTrg->value, 
     605            pSource->value, pBldType->value,
     606            pSource->value, pBldTrg->value,
     607            pSource->value, pBldTrg->value,
    598608            pSource->value, pBldTrgArch->value);
    599609    pszIterator = pSdks->apsz[2] = allocated_variable_expand(pszTmp);
     
    606616    pSdks->cTargetSource = 0;
    607617    sprintf(pszTmp, "$(%s_%s_SDKS) $(%s_%s_SDKS.%s) $(%s_%s_SDKS.%s) $(%s_%s_SDKS.%s.%s)",
    608             pTarget->value, pSource->value, pBldType->value, 
    609             pTarget->value, pSource->value, pBldTrg->value, 
    610             pTarget->value, pSource->value, pBldTrg->value, 
     618            pTarget->value, pSource->value, pBldType->value,
     619            pTarget->value, pSource->value, pBldTrg->value,
     620            pTarget->value, pSource->value, pBldTrg->value,
    611621            pTarget->value, pSource->value, pBldTrgArch->value);
    612622    pszIterator = pSdks->apsz[3] = allocated_variable_expand(pszTmp);
     
    619629        return;
    620630
    621     /* 
    622      * Allocate the variable array and create the variables. 
     631    /*
     632     * Allocate the variable array and create the variables.
    623633     */
    624634    pSdks->pa = (struct variable *)xmalloc(sizeof(pSdks->pa[0]) * i);
     
    770780*/
    771781static struct variable *
    772 kbuild_collect_source_prop(struct variable *pTarget, struct variable *pSource, 
     782kbuild_collect_source_prop(struct variable *pTarget, struct variable *pSource,
    773783                           struct variable *pTool, struct kbuild_sdks *pSdks,
    774784                           struct variable *pType, struct variable *pBldType,
     
    792802    Prop.value_length = strlen(pszProp);
    793803
    794     /* 
     804    /*
    795805     * Get the variables.
    796806     */
     
    943953    paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%.%.%",  pTarget, pSource, &Prop, pBldTrg, pBldTrgArch);
    944954    paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%.%",    pTarget, pSource, &Prop, pBldTrgCpu);
    945                                                                        
     955
    946956    paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%%",     pTarget, pSource, pType, &Prop);
    947957    paVars[iVar++].pVar = kbuild_lookup_variable_fmt("%_%_%%.%",   pTarget, pSource, pType, &Prop, pBldType);
     
    960970    for (iVar = iDirection > 0 ? 0 : cVars - 1; iVar != iVarEnd; iVar += iDirection)
    961971    {
    962         paVars[iVar].cchExp = 0; 
     972        paVars[iVar].cchExp = 0;
    963973        if (!paVars[iVar].pVar)
    964974            continue;
     
    10341044    kbuild_put_sdks(&Sdks);
    10351045    return o;
    1036                                                    
     1046
    10371047}
    10381048
     
    10441054*/
    10451055static struct variable *
    1046 kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(struct variable *pTarget, struct variable *pSource, 
    1047                                                                  struct variable *pOutBase, struct variable *pObjSuff, 
     1056kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(struct variable *pTarget, struct variable *pSource,
     1057                                                                 struct variable *pOutBase, struct variable *pObjSuff,
    10481058                                                                 const char *pszVarName, struct variable **ppDep,
    10491059                                                                 struct variable **ppDirDep)
     
    10641074    *ppDep = define_variable_vl("dep", 3, pszResult, cch - 1, 1 /*dup*/, o_file, 0 /* !recursive */);
    10651075
    1066     /* 
    1067      * obj 
     1076    /*
     1077     * obj
    10681078     */
    10691079    *psz = '\0';
    1070     pObj = define_variable_vl(pszVarName, strlen(pszVarName), pszResult, psz - pszResult, 
     1080    pObj = define_variable_vl(pszVarName, strlen(pszVarName), pszResult, psz - pszResult,
    10711081                              1/* dup */, o_file, 0 /* !recursive */);
    10721082
    1073     /* 
    1074      * PATH_$(target)_$(source) - this is global! 
     1083    /*
     1084     * PATH_$(target)_$(source) - this is global!
    10751085     */
    10761086    /* calc variable name. */
     
    10991109#ifdef HAVE_DOS_PATHS
    11001110            ||  *psz == '\\'
    1101 #endif 
     1111#endif
    11021112           )
    11031113        {
     
    11061116#ifdef HAVE_DOS_PATHS
    11071117                   ||   psz[-1] == '\\'
    1108 #endif 
     1118#endif
    11091119                  )
    11101120                psz--;
     
    12641274    memcpy(psz, pVar->value, pVar->value_length); psz += pVar->value_length;
    12651275    *psz++ = ' ';
    1266     memcpy(psz, pOutput->value, pOutput->value_length + 1); 
     1276    memcpy(psz, pOutput->value, pOutput->value_length + 1);
    12671277    do_variable_definition(NILF, "_OUT_FILES", pszVal, o_file, f_simple, 0 /* !target_var */);
    12681278    free(pszVal);
    12691279
    1270     /* 
     1280    /*
    12711281    $(target)_OBJS_ += $(obj)
    12721282    */
Note: See TracChangeset for help on using the changeset viewer.