Print this page
make: remove maketool support


1297  *              dmake_add_mode_specified        Set for make -x
1298  *              dmake_compat_mode_specified     Set for make -x SUN_MAKE_COMPAT_MODE=
1299  *              dmake_output_mode_specified     Set for make -x DMAKE_OUTPUT_MODE=
1300  *              dmake_odir_specified    Set for make -o
1301  *              dmake_rcfile_specified  Set for make -c
1302  *              env_wins                Set for make -e
1303  *              ignore_default_mk       Set for make -r
1304  *              trace_status            Set for make -p
1305  *
1306  *      Global variables used:
1307  *              .make.state path & name set for make -K
1308  *              continue_after_error    Set for make -k
1309  *              debug_level             Set for make -d
1310  *              do_not_exec_rule        Set for make -n
1311  *              filter_stderr           Set for make -X
1312  *              ignore_errors_all       Set for make -i
1313  *              no_parallel             Set for make -R
1314  *              quest                   Set for make -q
1315  *              read_trace_level        Set for make -D
1316  *              report_dependencies     Set for make -P
1317  *              send_mtool_msgs         Set for make -K
1318  *              silent_all              Set for make -s
1319  *              touch                   Set for make -t
1320  */
1321 static int
1322 parse_command_option(register char ch)
1323 {
1324         static int              invert_next = 0;
1325         int                     invert_this = invert_next;
1326 
1327         invert_next = 0;
1328         switch (ch) {
1329         case '-':                        /* Ignore "--" */
1330                 return 0;
1331         case '~':                        /* Invert next option */
1332                 invert_next = 1;
1333                 return 0;
1334         case 'B':                        /* Obsolete */
1335                 return 0;
1336         case 'b':                        /* Obsolete */
1337                 return 0;


1418                 if (invert_this) {
1419                         dmake_add_mode_specified = false;
1420                 } else {
1421                         dmake_add_mode_specified = true;
1422                 }
1423                 return 1024;
1424         case 'N':                        /* Reverse -n */
1425                 if (invert_this) {
1426                         do_not_exec_rule = true;
1427                 } else {
1428                         do_not_exec_rule = false;
1429                 }
1430                 return 0;
1431         case 'n':                        /* Print, not exec commands */
1432                 if (invert_this) {
1433                         do_not_exec_rule = false;
1434                 } else {
1435                         do_not_exec_rule = true;
1436                 }
1437                 return 0;
1438         case 'O':                        /* Send job start & result msgs */
1439                 if (invert_this) {
1440                         send_mtool_msgs = false;
1441                 } else {
1442                 }
1443                 return 128;
1444         case 'o':                        /* Use alternative dmake output dir */
1445                 if (invert_this) {
1446                         dmake_odir_specified = false;
1447                 } else {
1448                         dmake_odir_specified = true;
1449                 }
1450                 return 512;
1451         case 'P':                        /* Print for selected targets */
1452                 if (invert_this) {
1453                         report_dependencies_level--;
1454                 } else {
1455                         report_dependencies_level++;
1456                 }
1457                 return 0;
1458         case 'p':                        /* Print description */
1459                 if (invert_this) {
1460                         trace_status = false;
1461                         do_not_exec_rule = false;
1462                 } else {
1463                         trace_status = true;


2481                                 if (argv[i+1] == NULL) {
2482                                         fatal(catgets(catd, 1, 196, "No dmake max jobs argument after -j flag"));
2483                                 }
2484                                 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
2485                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2486                                 break;
2487                         case 16: /* -M seen */
2488                                 if (argv[i+1] == NULL) {
2489                                         fatal(catgets(catd, 1, 323, "No pmake machinesfile argument after -M flag"));
2490                                 }
2491                                 MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE"));
2492                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2493                                 break;
2494                         case 32: /* -m seen */
2495                                 if (argv[i+1] == NULL) {
2496                                         fatal(catgets(catd, 1, 197, "No dmake mode argument after -m flag"));
2497                                 }
2498                                 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
2499                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2500                                 break;
2501                         case 128: /* -O seen */
2502                                 if (argv[i+1] == NULL) {
2503                                         fatal(catgets(catd, 1, 287, "No file descriptor argument after -O flag"));
2504                                 }
2505                                 mtool_msgs_fd = atoi(argv[i+1]);
2506                                 /* find out if mtool_msgs_fd is a valid file descriptor */
2507                                 if (fstat(mtool_msgs_fd, &statbuf) < 0) {
2508                                         fatal(catgets(catd, 1, 355, "Invalid file descriptor %d after -O flag"), mtool_msgs_fd);
2509                                 }
2510                                 argv[i] = NULL;
2511                                 argv[i+1] = NULL;
2512                                 continue;
2513                         case 256: /* -K seen */
2514                                 if (argv[i+1] == NULL) {
2515                                         fatal(catgets(catd, 1, 288, "No makestate filename argument after -K flag"));
2516                                 }
2517                                 MBSTOWCS(wcs_buffer, argv[i+1]);
2518                                 make_state = GETNAME(wcs_buffer, FIND_LENGTH);
2519                                 keep_state = true;
2520                                 argv[i] = NULL;
2521                                 argv[i+1] = NULL;
2522                                 continue;
2523                         case 512:       /* -o seen */
2524                                 if (argv[i+1] == NULL) {
2525                                         fatal(catgets(catd, 1, 312, "No dmake output dir argument after -o flag"));
2526                                 }
2527                                 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_ODIR"));
2528                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2529                                 break;
2530                         case 1024: /* -x seen */
2531                                 if (argv[i+1] == NULL) {
2532                                         fatal(catgets(catd, 1, 351, "No argument after -x flag"));


3188                 retmem((wchar_t *) cp1);
3189         }
3190 
3191 APPEND_MACRO:
3192         len_array = strlen(Ar->start);
3193         esc_value = (char*)malloc(strlen(value)*2 + 1);
3194         quote_str(value, esc_value);
3195         esc_len = strlen(esc_value) - strlen(value);
3196         if (len_array + len_macro + esc_len + 5 >= Ar->size) goto  ALLOC_ARRAY;
3197         strcat(Ar->start, " ");
3198         strncat(Ar->start, name, cp0-name);
3199         strcat(Ar->start, "=");
3200         strncat(Ar->start, esc_value, strlen(esc_value));
3201         free(esc_value);
3202         return;
3203 ERROR_MACRO:    
3204         /* Macro without '=' or with invalid left/right part */
3205         return;
3206 }
3207 
3208 #ifdef TEAMWARE_MAKE_CMN
3209 /*
3210  * This function, if registered w/ avo_cli_get_license(), will be called
3211  * if the application is about to exit because:
3212  *   1) there has been certain unrecoverable error(s) that cause the
3213  *      application to exit immediately.
3214  *   2) the user has lost a license while the application is running.
3215  */
3216 extern "C" void
3217 dmake_exit_callback(void)
3218 {
3219         fatal(catgets(catd, 1, 306, "can not get a license, exiting..."));
3220         exit(1);
3221 }
3222 
3223 /*
3224  * This function, if registered w/ avo_cli_get_license(), will be called
3225  * if the application can not get a license.
3226  */
3227 extern "C" void
3228 dmake_message_callback(char *err_msg)
3229 {
3230         static Boolean  first = true;
3231 
3232         if (!first) {
3233                 return;
3234         }
3235         first = false;
3236         if ((!list_all_targets) &&
3237             (report_dependencies_level == 0) &&
3238             (dmake_mode_type != serial_mode)) {
3239                 warning(catgets(catd, 1, 313, "can not get a TeamWare license, defaulting to serial mode..."));
3240         }
3241 }
3242 #endif
3243 
3244 
3245 static void
3246 report_dir_enter_leave(Boolean entering)
3247 {
3248         char    rcwd[MAXPATHLEN];
3249 static  char *  mlev = NULL;
3250         char *  make_level_str = NULL;
3251         int     make_level_val = 0;
3252 
3253         make_level_str = getenv(NOCATGETS("MAKELEVEL"));
3254         if(make_level_str) {
3255                 make_level_val = atoi(make_level_str);
3256         }
3257         if(mlev == NULL) {
3258                 mlev = (char*) malloc(MAXPATHLEN);
3259         }
3260         if(entering) {
3261                 sprintf(mlev, NOCATGETS("MAKELEVEL=%d"), make_level_val + 1);
3262         } else {
3263                 make_level_val--;
3264                 sprintf(mlev, NOCATGETS("MAKELEVEL=%d"), make_level_val);




1297  *              dmake_add_mode_specified        Set for make -x
1298  *              dmake_compat_mode_specified     Set for make -x SUN_MAKE_COMPAT_MODE=
1299  *              dmake_output_mode_specified     Set for make -x DMAKE_OUTPUT_MODE=
1300  *              dmake_odir_specified    Set for make -o
1301  *              dmake_rcfile_specified  Set for make -c
1302  *              env_wins                Set for make -e
1303  *              ignore_default_mk       Set for make -r
1304  *              trace_status            Set for make -p
1305  *
1306  *      Global variables used:
1307  *              .make.state path & name set for make -K
1308  *              continue_after_error    Set for make -k
1309  *              debug_level             Set for make -d
1310  *              do_not_exec_rule        Set for make -n
1311  *              filter_stderr           Set for make -X
1312  *              ignore_errors_all       Set for make -i
1313  *              no_parallel             Set for make -R
1314  *              quest                   Set for make -q
1315  *              read_trace_level        Set for make -D
1316  *              report_dependencies     Set for make -P

1317  *              silent_all              Set for make -s
1318  *              touch                   Set for make -t
1319  */
1320 static int
1321 parse_command_option(register char ch)
1322 {
1323         static int              invert_next = 0;
1324         int                     invert_this = invert_next;
1325 
1326         invert_next = 0;
1327         switch (ch) {
1328         case '-':                        /* Ignore "--" */
1329                 return 0;
1330         case '~':                        /* Invert next option */
1331                 invert_next = 1;
1332                 return 0;
1333         case 'B':                        /* Obsolete */
1334                 return 0;
1335         case 'b':                        /* Obsolete */
1336                 return 0;


1417                 if (invert_this) {
1418                         dmake_add_mode_specified = false;
1419                 } else {
1420                         dmake_add_mode_specified = true;
1421                 }
1422                 return 1024;
1423         case 'N':                        /* Reverse -n */
1424                 if (invert_this) {
1425                         do_not_exec_rule = true;
1426                 } else {
1427                         do_not_exec_rule = false;
1428                 }
1429                 return 0;
1430         case 'n':                        /* Print, not exec commands */
1431                 if (invert_this) {
1432                         do_not_exec_rule = false;
1433                 } else {
1434                         do_not_exec_rule = true;
1435                 }
1436                 return 0;
1437         case 'O':                        /* Integrate with maketool, obsolete */
1438                 return 0;




1439         case 'o':                        /* Use alternative dmake output dir */
1440                 if (invert_this) {
1441                         dmake_odir_specified = false;
1442                 } else {
1443                         dmake_odir_specified = true;
1444                 }
1445                 return 512;
1446         case 'P':                        /* Print for selected targets */
1447                 if (invert_this) {
1448                         report_dependencies_level--;
1449                 } else {
1450                         report_dependencies_level++;
1451                 }
1452                 return 0;
1453         case 'p':                        /* Print description */
1454                 if (invert_this) {
1455                         trace_status = false;
1456                         do_not_exec_rule = false;
1457                 } else {
1458                         trace_status = true;


2476                                 if (argv[i+1] == NULL) {
2477                                         fatal(catgets(catd, 1, 196, "No dmake max jobs argument after -j flag"));
2478                                 }
2479                                 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
2480                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2481                                 break;
2482                         case 16: /* -M seen */
2483                                 if (argv[i+1] == NULL) {
2484                                         fatal(catgets(catd, 1, 323, "No pmake machinesfile argument after -M flag"));
2485                                 }
2486                                 MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE"));
2487                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2488                                 break;
2489                         case 32: /* -m seen */
2490                                 if (argv[i+1] == NULL) {
2491                                         fatal(catgets(catd, 1, 197, "No dmake mode argument after -m flag"));
2492                                 }
2493                                 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
2494                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2495                                 break;












2496                         case 256: /* -K seen */
2497                                 if (argv[i+1] == NULL) {
2498                                         fatal(catgets(catd, 1, 288, "No makestate filename argument after -K flag"));
2499                                 }
2500                                 MBSTOWCS(wcs_buffer, argv[i+1]);
2501                                 make_state = GETNAME(wcs_buffer, FIND_LENGTH);
2502                                 keep_state = true;
2503                                 argv[i] = NULL;
2504                                 argv[i+1] = NULL;
2505                                 continue;
2506                         case 512:       /* -o seen */
2507                                 if (argv[i+1] == NULL) {
2508                                         fatal(catgets(catd, 1, 312, "No dmake output dir argument after -o flag"));
2509                                 }
2510                                 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_ODIR"));
2511                                 name = GETNAME(wcs_buffer, FIND_LENGTH);
2512                                 break;
2513                         case 1024: /* -x seen */
2514                                 if (argv[i+1] == NULL) {
2515                                         fatal(catgets(catd, 1, 351, "No argument after -x flag"));


3171                 retmem((wchar_t *) cp1);
3172         }
3173 
3174 APPEND_MACRO:
3175         len_array = strlen(Ar->start);
3176         esc_value = (char*)malloc(strlen(value)*2 + 1);
3177         quote_str(value, esc_value);
3178         esc_len = strlen(esc_value) - strlen(value);
3179         if (len_array + len_macro + esc_len + 5 >= Ar->size) goto  ALLOC_ARRAY;
3180         strcat(Ar->start, " ");
3181         strncat(Ar->start, name, cp0-name);
3182         strcat(Ar->start, "=");
3183         strncat(Ar->start, esc_value, strlen(esc_value));
3184         free(esc_value);
3185         return;
3186 ERROR_MACRO:    
3187         /* Macro without '=' or with invalid left/right part */
3188         return;
3189 }
3190 





































3191 static void
3192 report_dir_enter_leave(Boolean entering)
3193 {
3194         char    rcwd[MAXPATHLEN];
3195 static  char *  mlev = NULL;
3196         char *  make_level_str = NULL;
3197         int     make_level_val = 0;
3198 
3199         make_level_str = getenv(NOCATGETS("MAKELEVEL"));
3200         if(make_level_str) {
3201                 make_level_val = atoi(make_level_str);
3202         }
3203         if(mlev == NULL) {
3204                 mlev = (char*) malloc(MAXPATHLEN);
3205         }
3206         if(entering) {
3207                 sprintf(mlev, NOCATGETS("MAKELEVEL=%d"), make_level_val + 1);
3208         } else {
3209                 make_level_val--;
3210                 sprintf(mlev, NOCATGETS("MAKELEVEL=%d"), make_level_val);