/*-------------------------------------------------------------------------*/ /* Prolog to Wam Compiler INRIA Rocquencourt - ChLoE Project */ /* Application Manager Daniel Diaz - 1991 */ /* */ /* Build Make File */ /* */ /* bmf.c */ /*-------------------------------------------------------------------------*/ #include #include #include "bool.h" /*---------------------------------*/ /* Constants */ /*---------------------------------*/ #define MAX_MODULES 256 #define MAX_OTHERS 256 #define MAX_NAME_LG 65 #define MAX_FLAGS_LG 256 #define NB_NAME_PER_LINE 5 #define ERR_OPEN_FILE "Error - cannot open %s file\n" /*---------------------------------*/ /* Type Definitions */ /*---------------------------------*/ /*---------------------------------*/ /* Global Variables */ /*---------------------------------*/ char executable[MAX_NAME_LG]=""; char modules [MAX_MODULES][MAX_NAME_LG]; int nb_modules =0; char others [MAX_OTHERS][MAX_NAME_LG]; int nb_others =0; char pflags[MAX_FLAGS_LG] =""; char cflags[MAX_FLAGS_LG] ="-O2"; char lflags[MAX_FLAGS_LG] ="-s"; Bool verbose =FALSE; char *make_lines[]= { "OBJS = $(MODULES) $(OTHERS)" "", ".SUFFIXES:", ".SUFFIXES: .o .usr .c .pl $(SUFFIXES)", "", ".pl.c:", "\t$(COMPILER) $(PFLAGS) -c $*.pl", "", ".pl.usr:", "\tif [ -f $*.usr ]; then \\", "\ttouch $*.usr; \\", "\telse \\", "\t$(COMPILER) $(PFLAGS) -c $*.pl; \\", "\tfi", "", ".usr.o:", "\t$(WCC) $(CFLAGS) -c $*.c", "", ".c.o:", "\t$(WCC) $(CFLAGS) -c $*.c", "", "$(EXECUTABLE): $(OBJS)", "\t$(WCC) -o $(EXECUTABLE) $(CFLAGS) $(LFLAGS) $(OBJS) -l$(COMPILER)", "", "$(EXECUTABLE)_pp: $(OBJS)", "\t$(WCC) -o $(EXECUTABLE)_pp $(CFLAGS) $(LFLAGS) $(OBJS) -l$(COMPILER)_pp", "", "@" }; /*---------------------------------*/ /* Function Prototypes */ /*---------------------------------*/ void Read_Parameters (int argc,char *argv[]); void Generate_Make_File (void); void Display_Parameters (void); void Display_Help_And_Exit (char *bmf_name); /*-------------------------------------------------------------------------*/ /* MAIN */ /* */ /*-------------------------------------------------------------------------*/ main(int argc,char *argv[]) { char *p; Read_Parameters(argc,argv); if (verbose) printf("Build Make File\n\n"); if (nb_modules==0) { printf("No module specified (use -h to get some help)\n"); exit(1); } if (*executable=='\0') { strcpy(executable,modules[0]); if (p=strrchr(executable,'.')) *p='\0'; } if (verbose) Display_Parameters(); /* Generate_Make_File erases .d in modules[] */ Generate_Make_File(); exit(0); } /*-------------------------------------------------------------------------*/ /* READ_PARAMETERS */ /* */ /*-------------------------------------------------------------------------*/ void Read_Parameters(int argc,char *argv[]) { char c; char *p; int i,j; int x; if (argc==1) Display_Help_And_Exit(argv[0]); for(i=1;i