2001-10-21 01:02:39 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, 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 program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
#if !defined(WINNT)
|
2002-05-28 02:50:39 +02:00
|
|
|
#ident "$Id: load_module.cc,v 1.6 2002/05/28 00:50:39 steve Exp $"
|
2001-10-21 01:02:39 +02:00
|
|
|
#endif
|
|
|
|
|
|
2001-10-22 04:05:20 +02:00
|
|
|
# include "config.h"
|
2001-10-21 01:02:39 +02:00
|
|
|
# include "util.h"
|
|
|
|
|
# include "parse_api.h"
|
|
|
|
|
# include "compiler.h"
|
|
|
|
|
# include <iostream.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char dir_character = '/';
|
2002-04-04 07:26:13 +02:00
|
|
|
extern FILE *depend_file;
|
2001-10-21 01:02:39 +02:00
|
|
|
|
|
|
|
|
bool load_module(const char*type)
|
|
|
|
|
{
|
|
|
|
|
char path[4096];
|
|
|
|
|
|
|
|
|
|
for (list<const char*>::iterator cur = library_dirs.begin()
|
|
|
|
|
; cur != library_dirs.end()
|
|
|
|
|
; cur ++ ) {
|
2001-11-16 06:07:19 +01:00
|
|
|
for (list<const char*>::iterator suf = library_suff.begin()
|
|
|
|
|
; suf != library_suff.end()
|
|
|
|
|
; suf ++ ) {
|
2001-10-21 01:02:39 +02:00
|
|
|
|
2001-11-16 06:07:19 +01:00
|
|
|
sprintf(path, "%s%c%s%s", *cur, dir_character, type, *suf);
|
2001-10-21 01:02:39 +02:00
|
|
|
|
2001-11-16 06:07:19 +01:00
|
|
|
FILE*file = fopen(path, "r");
|
|
|
|
|
if (file == 0)
|
|
|
|
|
continue;
|
2002-04-04 07:26:13 +02:00
|
|
|
if(depend_file) {
|
|
|
|
|
fprintf(depend_file, "%s\n", path);
|
|
|
|
|
}
|
2001-10-21 01:02:39 +02:00
|
|
|
|
2002-05-28 02:50:39 +02:00
|
|
|
if (ivlpp_string) {
|
|
|
|
|
fclose(file);
|
|
|
|
|
char*cmdline = (char*)malloc(strlen(ivlpp_string) +
|
|
|
|
|
strlen(path) + 2);
|
|
|
|
|
strcpy(cmdline, ivlpp_string);
|
|
|
|
|
strcat(cmdline, " ");
|
|
|
|
|
strcat(cmdline, path);
|
|
|
|
|
file = popen(cmdline, "r");
|
|
|
|
|
|
|
|
|
|
if (verbose_flag)
|
|
|
|
|
cerr << "Executing: " << cmdline << endl;
|
|
|
|
|
|
|
|
|
|
pform_parse(path, file);
|
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (verbose_flag)
|
|
|
|
|
cerr << "Loading library file "
|
|
|
|
|
<< path << "." << endl;
|
|
|
|
|
|
|
|
|
|
pform_parse(path, file);
|
|
|
|
|
|
|
|
|
|
fclose(file);
|
|
|
|
|
}
|
2001-11-21 00:36:34 +01:00
|
|
|
|
2001-11-16 06:07:19 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2001-10-21 01:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: load_module.cc,v $
|
2002-05-28 02:50:39 +02:00
|
|
|
* Revision 1.6 2002/05/28 00:50:39 steve
|
|
|
|
|
* Add the ivl -C flag for bulk configuration
|
|
|
|
|
* from the driver, and use that to run library
|
|
|
|
|
* modules through the preprocessor.
|
|
|
|
|
*
|
2002-04-04 07:26:13 +02:00
|
|
|
* Revision 1.5 2002/04/04 05:26:13 steve
|
|
|
|
|
* Add dependency generation.
|
|
|
|
|
*
|
2001-11-21 00:36:34 +01:00
|
|
|
* Revision 1.4 2001/11/20 23:36:34 steve
|
|
|
|
|
* Close library files after parsing.
|
|
|
|
|
*
|
2001-11-16 06:07:19 +01:00
|
|
|
* Revision 1.3 2001/11/16 05:07:19 steve
|
|
|
|
|
* Add support for +libext+ in command files.
|
|
|
|
|
*
|
2001-10-22 04:05:20 +02:00
|
|
|
* Revision 1.2 2001/10/22 02:05:21 steve
|
|
|
|
|
* Handle activating tasks in another root.
|
|
|
|
|
*
|
2001-10-21 01:02:39 +02:00
|
|
|
* Revision 1.1 2001/10/20 23:02:40 steve
|
|
|
|
|
* Add automatic module libraries.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|