1 /* gEDA - GPL Electronic Design Automation
2 * gnetlist - gEDA Netlist
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
35 #include <libgeda/libgeda.h>
37 #include "../include/globals.h"
38 #include "../include/prototype.h"
40 #ifdef HAVE_LIBDMALLOC
44 #define OPTIONS "o:qieIhvsg:c:l:m:O:n"
46 #ifndef OPTARG_IN_UNISTD
52 /* Added by SDB 3.3.2006. */
53 #ifdef HAVE_GETOPT_LONG
54 struct option long_options
[] =
57 {"nomunge", 0, 0, 'n'},
58 {"verbose", 0, 0, 'v'},
60 {"embedd", 0, 0, 'e'},
61 {"include", 0, 0, 'I'},
70 printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd
);
71 printf(" -e --embedd Force embedding contents of .include file (spice-sdb)\n");
72 printf(" -h --help Print this help string\n");
73 printf(" -i Interactive scheme mode\n");
74 printf(" -I --include Put .INCLUDE <filename> in output file instead\n");
75 printf(" of model file's contents (spice-sdb)\n");
76 printf(" -q Quiet mode\n");
77 printf(" -l filename Load scheme file before loading backend\n");
78 printf(" -m filename Load scheme file after loading backend,\n");
79 printf(" but still before executing procedure\n");
80 printf(" -n --nomunge Don't autocorrect refdeses (spice-sdb)\n");
81 printf(" -g proc Scheme procedure (netlister backend) to execute.\n");
82 printf(" Use '-g help' to list available backends.\n");
83 printf(" -o filename Output netlist filename\n");
84 printf(" -c string Execute string as a scheme script\n");
85 printf(" -O option Pass the given option to the backend\n");
86 printf(" -v --verbose Verbose mode on\n");
87 printf(" -s --sort Sort output netlist (spice-sdb)\n");
92 /* --------------------------------------------------------------- *
93 * create_command_line takes argc and argv, and returns a single
94 * string which is the command line used to invoke the program.
95 * It is used to pass the command invocation to the SPICE netlist
96 * for inclusion on the first SPICE line.
98 * --------------------------------------------------------------- */
99 char *create_command_line(int argc
, char *argv
[])
102 char *local_command_line
= NULL
;
104 local_command_line
= g_strdup (argv
[0]); /* Initialize command line string */
105 for (i
= 1; i
< argc
; i
++) {
106 local_command_line
= g_strconcat (local_command_line
, " ", argv
[i
], NULL
);
108 return local_command_line
;
113 /* from guile (libguile/gh_init.c) */
115 catch_handler (void *data
, SCM tag
, SCM throw_args
)
117 fprintf (stderr
, "\nJust got an error; tag is\n ");
118 scm_display (tag
, scm_current_output_port ());
119 scm_newline (scm_current_output_port ());
120 scm_newline (scm_current_output_port ());
125 int parse_commandline(int argc
, char *argv
[])
129 /* Converted to getopt_long by SDB 3.3.2006 */
130 #ifdef HAVE_GETOPT_LONG
131 /* int option_index = 0; */
133 while ((ch
= getopt_long(argc
, argv
, OPTIONS
, long_options
, NULL
/* &option_index */)) != -1) {
135 while ((ch
= getopt(argc
, argv
, OPTIONS
)) != -1) {
140 backend_params
= g_slist_append(backend_params
, "verbose_mode");
145 backend_params
= g_slist_append(backend_params
, "interactive_mode");
146 interactive_mode
= TRUE
;
150 backend_params
= g_slist_append(backend_params
, "include_mode");
155 backend_params
= g_slist_append(backend_params
, "embedd_mode");
160 backend_params
= g_slist_append(backend_params
, "quiet_mode");
165 guile_proc
= g_strdup(optarg
);
170 pre_backend_list
= g_slist_append(pre_backend_list
, optarg
);
174 post_backend_list
= g_slist_append(post_backend_list
, optarg
);
178 backend_params
= g_slist_append(backend_params
, "nomunge_mode");
183 g_free(output_filename
);
184 output_filename
= g_strdup(optarg
);
188 backend_params
= g_slist_append(backend_params
, optarg
);
192 scm_internal_stack_catch (SCM_BOOL_T
,
193 (scm_t_catch_body
) scm_c_eval_string
,
195 (scm_t_catch_handler
) catch_handler
,
200 backend_params
= g_slist_append(backend_params
, "sort_mode");
217 verbose_mode
= FALSE
;