/* * Copyright (C) 2001, 2002 David Essex, Rildo Pragana. * Copyright (C) 1993, 1991 Rildo Pragana. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (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 * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA */ #include "htconfig.h" #include "htversion.h" #include "htcoboly.h" #include "htcoblib.h" #include "htglobals.h" int main(int argc, char *argv[]) { int rc = 1, idx, r; #if defined (__MINGW32__) char *pt; #endif prg_name = argv[0]; #if defined (__MINGW32__) strncpy(COBINSTDIR, argv[0], PATHMAX - 1); COBINSTDIR[PATHMAX - 1] = '\0'; pt = strrchr(COBINSTDIR, LT_DIRSEP_CHAR); if (pt != NULL) { *pt = '\0'; } else { strncpy(COBINSTDIR, COBDIR_DEFAULT, PATHMAX - 1); COBINSTDIR[PATHMAX - 1] = '\0'; } #endif /* fprintf (stderr, "htcobol debug 0: main: before initialize_setup COBINSTDIR=%s\n", COBINSTDIR); */ initialize_setup(); r = read_compiler_options(); process_verbose_options(argc, argv); /* fprintf (stderr, "htcobol debug 1: main: after process_verbose_options\n"); */ idx = process_command_line(argc, argv); /* fprintf (stderr, "htcobol debug 3: main: after process_command_line\n"); */ if (idx == argc) { fprintf (stderr, "No input file name provided\n"); exit (8); } /* fprintf (stderr, "htcobol debug 3: main: after file input check\n"); */ strcpy (file_path, argv[idx]); setup_filenames(); /* fprintf (stderr, "htcobol debug 4: main: after setup_filenames\n"); */ /* fprintf (stderr, "htcobol debug 5: main: HTG_compile_level_flag=%d\n", HTG_compile_level_flag); */ switch (HTG_compile_level_flag) { case HTG_COMPILE_LEVEL_P: rc = process_pp(); break; case HTG_COMPILE_LEVEL_PC: rc = process_pp(); if (rc == 0) { rc = process_compile(); } break; case HTG_COMPILE_LEVEL_PCA: case HTG_COMPILE_LEVEL_PCAL: case HTG_COMPILE_LEVEL_PCAM: case HTG_COMPILE_LEVEL_PCAS: rc = process_pp(); if (rc == 0) { rc = process_compile(); if (rc < 8) { rc = process_assemble(); } } break; default: break; } if (rc == 0) { if (HTG_compile_level_flag == HTG_COMPILE_LEVEL_PCAL) { if (r == 0) { setup_ld_paths(); } else { setup_ld_paths_defaults(); } rc = process_ld(); } if (HTG_compile_level_flag == HTG_COMPILE_LEVEL_PCAM) { rc = process_shlib_ld (); } if (HTG_compile_level_flag == HTG_COMPILE_LEVEL_PCAS) { rc = process_lib_ld (); } } else { HTG_RETURN_CODE = rc; } do_file_cleanup(); if (HTG_verbose_verbose == TRUE ) { printf("Compiler return code %d\n", HTG_RETURN_CODE); } return HTG_RETURN_CODE; }