File: c2init.in

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (180 lines) | stat: -rwxr-xr-x 4,740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#! /bin/sh
# @configure_input@
#---------------------------------------------------------------------------#
# Copyright (C) 1995-1999 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#

# C2INIT - Convert *.c to *_init.c
#
# This script outputs an appropriate init.c, given the .c files.
# Type `c2init --help' for usage message.
#

# If you change these, you will also need to change Mmake.common.in,
# scripts/ml.in, tools/bootcheck, tools/binary, tools/binary_step and
# tools/linear.
RT_LIB_NAME=mer_rt
STD_LIB_NAME=mer_std
TRACE_LIB_NAME=mer_trace
BROWSER_LIB_NAME=mer_browser

MERCURY_MOD_LIB_DIR=${MERCURY_MOD_LIB_DIR=@LIBDIR@/modules}
MKINIT=${MERCURY_MKINIT=mkinit}

# maximum number of calls to put in a single function
maxcalls=40
defentry=mercury__main_2_0
init_opt=""
trace_opt=""
library_opt=""
extra_inits_opt=""
aditi_opt=""
extra_init_dirs=""

# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@

# IMPORTANT: the manpage is produced automatically from this help
# message, so if you change the help message, don't forget to check
# that the manpage still looks OK.
Help="\
Name:	c2init - Create Mercury initialization file.
Usage:	c2init [options] *.c *.init ...
Options: 
	-a, --aditi
		Generate a function to upload Aditi-RL data to a database.
	-c <n>, --max-calls <n>
		Break up the initialization into groups of at most <n> function
		calls.  (Default value of <n> is 40.)
	-i, --include-initialization-code
		Always include code that calls the initialization functions
		of the various modules. With this option, the debugger can use
		information from any modules that were compiled with execution
		tracing to print (partial) stack traces, and to print the
		values of variables in ancestors of the current call, even
		in grades in which this not normally possible.
	-t, --trace
		Enable execution tracing in the generated executable.
		Implies -i.
	-l, --library
		Don't generate a \`main()' function.
		Instead, generate a function
			mercury_main(int argc, char **argv);
		(declared in \"init.h\") that can be called from C code.
		(A more fine-grained interface is also available;
		see \"init.h\" for details.)
	-I <directory>, --init-file-directory <directory>
		Include <directory> in the list of directories searched to
		locate \`.init' files.
	-w <label>, --entry-point <label>
		Set entry point to <label>.
		(Default value is \`mercury__main_2_0'.)
	-x, --extra-inits
		Search \`.c' files for extra initialization functions.
		(This may be necessary if the C files contain
		hand-coded C code with \`INIT' comments, rather than
		containing only C code that was automatically generated
		by the Mercury compiler.)

$grade_usage

Environment variables:
	MERCURY_MOD_LIB_DIR, MERCURY_MOD_LIB_MODS, MERCURY_MKINIT.
"

while true; do
	case "$1" in
	-a|--aditi)
		aditi_opt="-a"; shift;;	
	-a-|--no-aditi)
		aditi_opt=""; shift;;	
	-c|--max-calls)
		maxcalls="$2"; shift;;

	-i|--include-initialization-code)
		init_opt="-i";;

	-t|--trace)
		trace_opt="-t";;

	-l|--library)
		library_opt="-l";;

	-l-|--no-library)
		library_opt="";;

	-I|--init-file-directory)
		extra_init_dirs="$extra_init_dirs -I $2"; shift;;

	-w|--entry-point)
		defentry="$2"; shift;;

	-x|--extra-inits)
		extra_inits_opt="-x";;

	-x-|--no-extra-inits)
		extra_inits_opt="";;

	-h|--help|"-?")
		echo "$Help"
		exit 0;;

	# include the file `parse_grade_options.sh-subr'
	@PARSE_GRADE_OPTIONS@

	--)
		break;;

	-*)
		echo "`basename $0`: invalid option \`$1'" 1>&2;
		echo "Try \`$0 --help' for help." 1>&2;
		exit 1;;

	*)
		break;;
	esac
	shift
done

# include the file `final_grade_options.sh-subr'
@FINAL_GRADE_OPTIONS@

case $require_tracing in
	true)
		trace_opt="-t" ;;
esac

case $stack_trace in
	true)
		init_opt="-i" ;;
esac

case "$trace_opt" in
	-t)
		init_opt="-i"
		MERCURY_MOD_LIB_MODS=${MERCURY_MOD_LIB_MODS="\
				$MERCURY_MOD_LIB_DIR/$RT_LIB_NAME.init \
				$MERCURY_MOD_LIB_DIR/$STD_LIB_NAME.init \
				$MERCURY_MOD_LIB_DIR/$BROWSER_LIB_NAME.init \
			"}
		;;
	*)
		MERCURY_MOD_LIB_MODS=${MERCURY_MOD_LIB_MODS="\
				$MERCURY_MOD_LIB_DIR/$RT_LIB_NAME.init \
				$MERCURY_MOD_LIB_DIR/$STD_LIB_NAME.init \
			"}
		;;
esac

case $# in
	0) exec $MKINIT $aditi_opt -c"$maxcalls" $init_opt $trace_opt \
		$library_opt -w"$defentry" $extra_inits_opt \
		$extra_init_dirs $EXTRA_INIT_FILES $MERCURY_MOD_LIB_MODS
	   ;;
	*) exec $MKINIT $aditi_opt -c"$maxcalls" $init_opt $trace_opt \
		$library_opt -w"$defentry" $extra_inits_opt \
		$extra_init_dirs "$@" $EXTRA_INIT_FILES $MERCURY_MOD_LIB_MODS
	   ;;
esac