* configure: Regenerated to track ../common/aclocal.m4 changes.
[deliverable/binutils-gdb.git] / sim / README-HACKING
CommitLineData
b69cc8ab 1This is a loose collection of notes for people hacking on simulators.
51037f28 2If this document gets big enough it can be prettied up then.
b69cc8ab
AC
3
4Contents
5
6- The "common" directory
7- Common Makefile Support
51037f28 8- TAGS support
b69cc8ab 9- Generating "configure" files
51037f28 10- tconfig.in
c2816431
TT
11- C Language Assumptions
12- "dump" commands under gdb
b69cc8ab
AC
13\f
14The "common" directory
15======================
16
17The common directory contains:
18
19- common documentation files (e.g. run.1, and maybe in time .texi files)
20- common source files (e.g. run.c)
21- common Makefile fragment and configury (e.g. Make-common.in, aclocal.m4).
22
23In addition "common" contains portions of the system call support
24(e.g. callback.c, nltvals.def).
25
26Even though no files are built in this directory, it is still configured
27so support for regenerating nltvals.def is present.
28\f
29Common Makefile Support
30=======================
31
32A common configuration framework is available for simulators that want
33to use it. The common framework exists to remove a lot of duplication
34in configure.in and Makefile.in, and it also provides a foundation for
35enhancing the simulators uniformly (e.g. the more they share in common
36the easier a feature added to one is added to all).
37
38The configure.in of a simulator using the common framework should look like:
39
40--- snip ---
41dnl Process this file with autoconf to produce a configure script.
b69cc8ab
AC
42AC_PREREQ(2.5)dnl
43AC_INIT(Makefile.in)
44
45SIM_AC_COMMON
46
47... target specific additions ...
48
49SIM_AC_OUTPUT
50--- snip ---
51
52SIM_AC_COMMON:
53
54- invokes the autoconf macros most often used by the simulators
55- defines --enable/--with options usable by all simulators
56- initializes sim_link_files/sim_link_links as the set of symbolic links
57 to set up
58
59SIM_AC_OUTPUT:
60
61- creates the symbolic links defined in sim_link_{files,links}
62- creates config.h
63- creates the Makefile
64
65The Makefile.in of a simulator using the common framework should look like:
66
67--- snip ---
68# Makefile for blah ...
69# Copyright blah ...
70
71## COMMON_PRE_CONFIG_FRAG
72
73# These variables are given default values in COMMON_PRE_CONFIG_FRAG.
74# We override the ones we need to here.
75# Not all of these need to be mentioned, only the necessary ones.
51037f28 76# In fact it is better to *not* mention ones if the value is the default.
b69cc8ab
AC
77
78# List of object files, less common parts.
79SIM_OBJS =
51037f28
DE
80# List of extra dependencies.
81# Generally this consists of simulator specific files included by sim-main.h.
82SIM_EXTRA_DEPS =
b69cc8ab
AC
83# List of flags to always pass to $(CC).
84SIM_EXTRA_CFLAGS =
85# List of extra libraries to link with.
86SIM_EXTRA_LIBS =
87# List of extra program dependencies.
88SIM_EXTRA_LIBDEPS =
89# List of main object files for `run'.
90SIM_RUN_OBJS = run.o
91# Dependency of `all' to build any extra files.
92SIM_EXTRA_ALL =
93# Dependency of `install' to install any extra files.
94SIM_EXTRA_INSTALL =
95# Dependency of `clean' to clean any extra files.
96SIM_EXTRA_CLEAN =
97
98## COMMON_POST_CONFIG_FRAG
99
100# Rules need to build $(SIM_OBJS), plus whatever else the target wants.
101
102... target specific rules ...
103--- snip ---
104
105COMMON_{PRE,POST}_CONFIG_FRAG are markers for SIM_AC_OUTPUT to tell it
106where to insert the two pieces of common/Make-common.in.
107The resulting Makefile is created by doing autoconf substitions on
108both the target's Makefile.in and Make-common.in, and inserting
109the two pieces of Make-common.in into the target's Makefile.in at
110COMMON_{PRE,POST}_CONFIG_FRAG.
51037f28
DE
111
112Note that SIM_EXTRA_{INSTALL,CLEAN} could be removed and "::" targets
113could be used instead. However, it's not clear yet whether "::" targets
114are portable enough.
115\f
116TAGS support
117============
118
119Many files generate program symbols at compile time.
120Such symbols can't be found with grep nor do they normally appear in
121the TAGS file. To get around this, source files can add the comment
122
123/* TAGS: foo1 foo2 */
124
125where foo1, foo2 are program symbols. Symbols found in such comments
126are greppable and appear in the TAGS file.
b69cc8ab
AC
127\f
128Generating "configure" files
129============================
130
131For target's using the common framework, "configure" can be generated
c2816431
TT
132by running `autoconf -l ../common'. This will ensure that the
133qaclocal.m4 from the `common' directory is found.
b69cc8ab
AC
134
135To regenerate the configure files for all targets using the common framework:
136
137 $ cd devo/sim
c2816431 138 $ make -f Makefile.in SHELL=/bin/sh autoconf-common
b69cc8ab
AC
139
140To add a change-log entry to the ChangeLog file for each updated
141directory (WARNING - check the modified new-ChangeLog files before
142renaming):
143
c2816431 144 $ make -f Makefile.in SHELL=/bin/sh autoconf-changelog
b69cc8ab 145 $ more */new-ChangeLog
c2816431 146 $ make -f Makefile.in SHELL=/bin/sh autoconf-install
b69cc8ab 147
96527c4e
AC
148In a similar vein, both the configure and config.in files can be
149updated using the sequence:
150
151 $ cd devo/sim
c2816431
TT
152 $ make -f Makefile.in SHELL=/bin/sh autoheader-common
153 $ make -f Makefile.in SHELL=/bin/sh autoheader-changelog
96527c4e 154 $ more */new-ChangeLog
c2816431 155 $ make -f Makefile.in SHELL=/bin/sh autoheader-install
51037f28
DE
156\f
157tconfig.in
158==========
159
160File tconfig.in defines one or more target configuration macros
161(e.g. a tm.h file). There are very few that need defining.
162For a list of all of them, see common/tconfig.in.
163It contains them all, commented out.
164The intent is that a new port can just copy this file and
165define the ones it needs.
b83adf4e
AC
166\f
167C Language Assumptions
168======================
169
170The programmer may assume that the simulator is being built using an
171ANSI C compiler that supports a 64 bit data type. Consequently:
172
173 o prototypes can be used (although using
174 PARAMS() and K&R declarations wouldn't
175 go astray).
176
177 o If sim-types.h is included, the two
178 types signed64 and unsigned64 are
179 available.
180
181 o The type `unsigned' is valid.
182
c2816431 183However, the user should be aware of the following:
b83adf4e 184
c2816431
TT
185 o GCC's `<number>LL' is NOT acceptable.
186 Microsoft-C doesn't reconize it.
b83adf4e 187
c2816431
TT
188 o MSC's `<number>i64' is NOT acceptable.
189 GCC doesn't reconize it.
190
191 o GCC's `long long' MSC's `_int64' can
192 NOT be used to define 64 bit integer data
193 types.
194
195 o An empty array (eg int a[0]) is not valid.
196
197When building with GCC it is effectivly a requirement that
198--enable-sim-warnings be specified during configuration.
199\f
200"dump" commands under gdb
201=========================
202
203gdbinit.in contains the following
204
205define dump
206set sim_debug_dump ()
207end
208
209Simulators that define the sim_debug_dump function can then have their
210internal state pretty printed from gdb.
211
212FIXME: This can obviously be made more elaborate. As needed it will be.
213\f
214"dump" commands under gdb
215=========================
216
217gdbinit.in contains the following
218
219define dump
220set sim_debug_dump ()
221end
222
223Simulators that define the sim_debug_dump function can then have their
224internal state pretty printed from gdb.
225
226FIXME: This can obviously be made more elaborate. As needed it will be.
This page took 0.061649 seconds and 4 git commands to generate.