prepare the xspice cmpp processor for build in a separate directory
This commit is contained in:
parent
d0392a026b
commit
3fec598934
11
ChangeLog
11
ChangeLog
|
|
@ -1,3 +1,14 @@
|
||||||
|
2011-01-25 Robert Larice
|
||||||
|
* src/xspice/cmpp/cmpp.h ,
|
||||||
|
* src/xspice/cmpp/pp_lst.c ,
|
||||||
|
* src/xspice/cmpp/pp_mod.c ,
|
||||||
|
* src/xspice/cmpp/read_ifs.c ,
|
||||||
|
* src/xspice/cmpp/util.c ,
|
||||||
|
* src/xspice/cmpp/writ_ifs.c :
|
||||||
|
prepare the xspice cmpp processor for build in a separate directory
|
||||||
|
Two environment variables are introduced to augment the the hardwired
|
||||||
|
filenames with directory names
|
||||||
|
|
||||||
2011-01-25 Robert Larice
|
2011-01-25 Robert Larice
|
||||||
* src/frontend/Makefile.am ,
|
* src/frontend/Makefile.am ,
|
||||||
* src/spicelib/devices/adms/admst/ngspiceMakefile.am.xml
|
* src/spicelib/devices/adms/admst/ngspiceMakefile.am.xml
|
||||||
|
|
|
||||||
|
|
@ -285,3 +285,4 @@ Status_t read_ifs_file(char *filename, int mode, Ifs_Table_t *ifs_table);
|
||||||
Status_t write_ifs_c_file(char *filename, Ifs_Table_t *ifs_table);
|
Status_t write_ifs_c_file(char *filename, Ifs_Table_t *ifs_table);
|
||||||
|
|
||||||
|
|
||||||
|
FILE *fopen_with_path(const char *path, const char *mode);
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ static Status_t read_modpath(
|
||||||
*num_models = 0;
|
*num_models = 0;
|
||||||
|
|
||||||
/* Open the model pathname file */
|
/* Open the model pathname file */
|
||||||
fp = fopen(filename, "r");
|
fp = fopen_with_path(filename, "r");
|
||||||
|
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
sprintf(msg, "ERROR - File not found: %s", filename);
|
sprintf(msg, "ERROR - File not found: %s", filename);
|
||||||
|
|
@ -358,7 +358,7 @@ static Status_t read_udnpath(
|
||||||
*num_nodes = 0;
|
*num_nodes = 0;
|
||||||
|
|
||||||
/* Open the node pathname file */
|
/* Open the node pathname file */
|
||||||
fp = fopen(filename, "r");
|
fp = fopen_with_path(filename, "r");
|
||||||
|
|
||||||
/* For backward compatibility, return with WARNING only if file not found */
|
/* For backward compatibility, return with WARNING only if file not found */
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
|
|
@ -787,7 +787,7 @@ static Status_t write_CMextrn(
|
||||||
|
|
||||||
|
|
||||||
/* Open the file to be written */
|
/* Open the file to be written */
|
||||||
fp = fopen("cmextrn.h", "w");
|
fp = fopen_with_path("cmextrn.h", "w");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
print_error("ERROR - Problems opening CMextrn.h for write");
|
print_error("ERROR - Problems opening CMextrn.h for write");
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
@ -827,7 +827,7 @@ static Status_t write_CMinfo(
|
||||||
|
|
||||||
|
|
||||||
/* Open the file to be written */
|
/* Open the file to be written */
|
||||||
fp = fopen("cminfo.h", "w");
|
fp = fopen_with_path("cminfo.h", "w");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
print_error("ERROR - Problems opening CMinfo.h for write");
|
print_error("ERROR - Problems opening CMinfo.h for write");
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
@ -871,7 +871,7 @@ static Status_t write_UDNextrn(
|
||||||
|
|
||||||
|
|
||||||
/* Open the file to be written */
|
/* Open the file to be written */
|
||||||
fp = fopen("udnextrn.h", "w");
|
fp = fopen_with_path("udnextrn.h", "w");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
print_error("ERROR - Problems opening UDNextrn.h for write");
|
print_error("ERROR - Problems opening UDNextrn.h for write");
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
@ -913,7 +913,7 @@ static Status_t write_UDNinfo(
|
||||||
|
|
||||||
|
|
||||||
/* Open the file to be written */
|
/* Open the file to be written */
|
||||||
fp = fopen("udninfo.h", "w");
|
fp = fopen_with_path("udninfo.h", "w");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
print_error("ERROR - Problems opening UDNinfo.h for write");
|
print_error("ERROR - Problems opening UDNinfo.h for write");
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
@ -952,7 +952,7 @@ static Status_t write_objects_inc(
|
||||||
|
|
||||||
|
|
||||||
/* Open the file to be written */
|
/* Open the file to be written */
|
||||||
fp = fopen("objects.inc", "w");
|
fp = fopen_with_path("objects.inc", "w");
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
print_error("ERROR - Problems opening objects.inc file for write");
|
print_error("ERROR - Problems opening objects.inc file for write");
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
@ -1005,7 +1005,7 @@ static Status_t read_udn_type_name(
|
||||||
static char *struct_type = "Evt_Udn_Info_t";
|
static char *struct_type = "Evt_Udn_Info_t";
|
||||||
|
|
||||||
/* Open the file from which the node type name will be read */
|
/* Open the file from which the node type name will be read */
|
||||||
fp = fopen(path, "r");
|
fp = fopen_with_path(path, "r");
|
||||||
if(fp == NULL)
|
if(fp == NULL)
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ void preprocess_mod_file (
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mod_yyin = fopen (filename, "r");
|
mod_yyin = fopen_with_path (filename, "r");
|
||||||
if (mod_yyin == NULL) {
|
if (mod_yyin == NULL) {
|
||||||
sprintf(error_str, "ERROR - Could not open input .mod file: %s",
|
sprintf(error_str, "ERROR - Could not open input .mod file: %s",
|
||||||
filename);
|
filename);
|
||||||
|
|
@ -139,7 +139,7 @@ void preprocess_mod_file (
|
||||||
current_filename = filename;
|
current_filename = filename;
|
||||||
|
|
||||||
change_extension (filename, "c", output_filename);
|
change_extension (filename, "c", output_filename);
|
||||||
mod_yyout = fopen (output_filename, "w");
|
mod_yyout = fopen_with_path (output_filename, "w");
|
||||||
|
|
||||||
if (mod_yyout == NULL) {
|
if (mod_yyout == NULL) {
|
||||||
sprintf(error_str, "ERROR - Could not open output .c: %s",
|
sprintf(error_str, "ERROR - Could not open output .c: %s",
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ Status_t read_ifs_file(
|
||||||
|
|
||||||
/* Open the ifs file for read access */
|
/* Open the ifs file for read access */
|
||||||
|
|
||||||
fp = fopen(filename, "r");
|
fp = fopen_with_path(filename, "r");
|
||||||
|
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
perror (prog_name);
|
perror (prog_name);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ NON-STANDARD FEATURES
|
||||||
#include "cmpp.h"
|
#include "cmpp.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -83,3 +84,23 @@ void str_to_lower(char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FILE *fopen_with_path(const char *path, const char *mode)
|
||||||
|
{
|
||||||
|
char buf[MAX_PATH_LEN+1];
|
||||||
|
|
||||||
|
if(path[0] != '/') {
|
||||||
|
const char *e = getenv((*mode == 'w') ? "CMPP_ODIR" : "CMPP_IDIR");
|
||||||
|
if(e) {
|
||||||
|
if(strlen(e) + 1 + strlen(path) < sizeof(buf)) {
|
||||||
|
strcpy(buf, e);
|
||||||
|
strcat(buf, "/");
|
||||||
|
strcat(buf, path);
|
||||||
|
path = buf;
|
||||||
|
} else {
|
||||||
|
path = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fopen(path, mode);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ Status_t write_ifs_c_file(
|
||||||
|
|
||||||
/* Open the ifspec.c file for write access */
|
/* Open the ifspec.c file for write access */
|
||||||
|
|
||||||
fp = fopen(filename, "w");
|
fp = fopen_with_path(filename, "w");
|
||||||
|
|
||||||
if(fp == NULL) {
|
if(fp == NULL) {
|
||||||
sprintf(msg, "ERROR - Can't create file: %s", filename);
|
sprintf(msg, "ERROR - Can't create file: %s", filename);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue