* Makefile.in (sim-options_h): Define.
[deliverable/binutils-gdb.git] / sim / common / Make-common.in
CommitLineData
f2de7dfd
AC
1# Makefile fragment for common parts of all simulators.
2# Copyright (C) 1997 Free Software Foundation, Inc.
3# Contributed by Cygnus Support.
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19# This Makefile fragment consists of two separate parts.
20# They are merged into the final Makefile at points denoted by
21# "## COMMON_PRE_CONFIG_FRAG" and "## COMMON_POST_CONFIG_FRAG".
22#
23# The target Makefile should look like:
24#
25#># Copyright blah blah
26#>
27#>## COMMON_PRE_CONFIG_FRAG
28#>
29#># Any overrides necessary for the SIM_FOO config vars.
30#>SIM_FOO = ...
31#>
32#>## COMMON_POST_CONFIG_FRAG
33#>
34#># Rules to build target specific .o's.
35
36## COMMON_PRE_CONFIG_FRAG
37
38VPATH = @srcdir@
39srcdir = @srcdir@
40srcroot = $(srcdir)/../..
41
42prefix = @prefix@
43exec_prefix = @exec_prefix@
44
45host_alias = @host_alias@
46target_alias = @target_alias@
47program_transform_name = @program_transform_name@
48bindir = @bindir@
49
50libdir = @libdir@
51tooldir = $(libdir)/$(target_alias)
52
53datadir = @datadir@
54mandir = @mandir@
55man1dir = $(mandir)/man1
56infodir = @infodir@
57includedir = @includedir@
58
59SHELL = /bin/sh
60
6808fd61 61INSTALL = @INSTALL@
f2de7dfd
AC
62INSTALL_PROGRAM = @INSTALL_PROGRAM@
63INSTALL_DATA = @INSTALL_DATA@
f2de7dfd
AC
64
65CC = @CC@
66CC_FOR_BUILD = @CC_FOR_BUILD@
67CFLAGS = @CFLAGS@
68SIM_BSWAP = @sim_bswap@
69SIM_CFLAGS = @sim_cflags@
70SIM_DEBUG = @sim_debug@
f2de7dfd 71SIM_TRACE = @sim_trace@
717dbb29 72SIM_PROFILE = @sim_profile@
a77aa7ec 73
f2de7dfd
AC
74HDEFINES = @HDEFINES@
75TDEFINES =
76
77AR = @AR@
78AR_FLAGS = rc
79RANLIB = @RANLIB@
80MAKEINFO = makeinfo
81
82# Each simulator's Makefile.in defines one or more of these variables
0f2811d1
DE
83# to override our settings as necessary. There is no need to define these
84# in the simulator's Makefile.in if one is using the default value. In fact
85# it's preferable not to.
f2de7dfd
AC
86
87# List of object files, less common parts.
88SIM_OBJS =
6808fd61
ILT
89# List of extra dependencies.
90# Generally this consists of simulator specific files included by sim-main.h.
91SIM_EXTRA_DEPS =
f2de7dfd
AC
92# List of flags to always pass to $(CC).
93SIM_EXTRA_CFLAGS =
94# List of extra libraries to link with.
95SIM_EXTRA_LIBS =
96# List of extra program dependencies.
97SIM_EXTRA_LIBDEPS =
98# List of main object files for `run'.
99SIM_RUN_OBJS = run.o
100# Dependency of `all' to build any extra files.
101SIM_EXTRA_ALL =
102# Dependency of `install' to install any extra files.
103SIM_EXTRA_INSTALL =
104# Dependency of `clean' to clean any extra files.
105SIM_EXTRA_CLEAN =
106
107## End COMMON_PRE_CONFIG_FRAG
108
109## COMMON_POST_CONFIG_FRAG
110
717dbb29
DE
111CONFIG_CFLAGS = @DEFS@ $(SIM_CFLAGS) $(SIM_DEBUG) $(SIM_TRACE) $(SIM_PROFILE) \
112 $(SIM_BSWAP) $(SIM_EXTRA_CFLAGS) $(HDEFINES) $(TDEFINES)
f2de7dfd
AC
113CSEARCH = -I. -I$(srcdir) -I../common -I$(srcdir)/../common \
114 -I../../include -I$(srcroot)/include \
a77aa7ec 115 -I../../bfd -I$(srcroot)/bfd \
f2de7dfd
AC
116 -I../../opcodes -I$(srcroot)/opcodes
117ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS)
118BUILD_CFLAGS = -g -O $(CSEARCH)
119
120LIBIBERTY_LIB = ../../libiberty/libiberty.a
121BFD_LIB = ../../bfd/libbfd.a
122OPCODES_LIB = ../../opcodes/libopcodes.a
123CONFIG_LIBS = @LIBS@
124LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
125 $(SIM_EXTRA_LIBDEPS)
126EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBIBERTY_LIB) \
127 $(CONFIG_LIBS) $(SIM_EXTRA_LIBS)
128
129LIB_OBJS = callback.o targ-map.o $(SIM_OBJS)
130
131all: libsim.a run $(SIM_EXTRA_ALL)
132
133libsim.a: $(LIB_OBJS)
134 rm -f libsim.a
135 $(AR) $(ARFLAGS) libsim.a $(LIB_OBJS)
136 $(RANLIB) libsim.a
137
138run: $(SIM_RUN_OBJS) libsim.a $(LIBDEPS)
139 $(CC) $(ALL_CFLAGS) -o run \
140 $(SIM_RUN_OBJS) libsim.a $(EXTRA_LIBS)
141
142run.o: $(srcdir)/../common/run.c config.h tconfig.h \
143 $(srcroot)/include/callback.h
144 $(CC) -c $(srcdir)/../common/run.c $(ALL_CFLAGS)
145
146# FIXME: Ideally, callback.o and friends live in a library outside of
147# both the gdb and simulator source trees (e.g. devo/remote. Not
148# devo/libremote because this directory would contain more than just
149# a library).
150
151callback.o: $(srcdir)/../common/callback.c config.h tconfig.h \
152 $(srcroot)/include/callback.h targ-vals.h
153 $(CC) -c $(srcdir)/../common/callback.c $(ALL_CFLAGS)
154
155targ-map.o: targ-map.c targ-vals.h
156
157gentmap: Makefile $(srcdir)/../common/gentmap.c targ-vals.def
158 $(CC_FOR_BUILD) $(srcdir)/../common/gentmap.c -o gentmap $(BUILD_CFLAGS)
159
160targ-vals.h: gentmap
161 rm -f targ-vals.h
162 ./gentmap -h >targ-vals.h
163
164targ-map.c: gentmap
165 rm -f targ-map.c
166 ./gentmap -c >targ-map.c
167
a35e91c3
AC
168
169#
170# Rules for building sim-* components. Triggered by listing the corresponding
171# .o file in the list of simulator targets.
172#
173
6808fd61
ILT
174sim_main_headers = \
175 sim-main.h \
176 $(srcdir)/../common/sim-config.h \
177 $(srcdir)/../common/sim-base.h \
178 $(srcdir)/../common/sim-basics.h \
717dbb29 179 $(srcdir)/../common/sim-model.h \
c967f187 180 $(srcdir)/../common/sim-module.h \
0f2811d1 181 $(srcdir)/../common/sim-trace.h \
717dbb29 182 $(srcdir)/../common/sim-profile.h \
6808fd61
ILT
183 tconfig.h
184
a35e91c3
AC
185sim-assert_h = $(srcdir)/../common/sim-assert.h
186sim-endian_h = $(srcdir)/../common/sim-endian.h
187sim-n-endian_h = $(srcdir)/../common/sim-n-endian.h
188sim-bits_h = $(srcdir)/../common/sim-bits.h
189sim-config_h = $(srcdir)/../common/sim-config.h
190sim-n-bits_h = $(srcdir)/../common/sim-n-bits.h
191sim-core_h = $(srcdir)/../common/sim-core.h
192sim-n-core_h = $(srcdir)/../common/sim-n-core.h
193sim-events_h = $(srcdir)/../common/sim-events.h
194sim-io_h = $(srcdir)/../common/sim-io.h
c967f187 195sim-options_h = $(srcdir)/../common/sim-options.h
a35e91c3 196
6808fd61 197# FIXME: If this complicated way of building .o files from ../common is
c967f187 198# necessary, the reason should be documented here.
6808fd61
ILT
199
200BUILT_SRC_FROM_COMMON= \
201 sim-endian.c \
202 sim-inline.c \
203 sim-bits.c \
204 sim-events.c \
205 sim-core.c \
206 sim-config.c \
207 sim-io.c
208
209sim-bits.o: sim-bits.c $(sim-bits_h) $(sim-n-bits_h) $(sim-assert_h) \
210 $(SIM_EXTRA_DEPS)
a35e91c3
AC
211sim-bits.c: $(srcdir)/../common/sim-bits.c
212 rm -f $@ tmp-$@
213 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
214 cat $(srcdir)/../common/$@ >> tmp-$@
215 $(srcdir)/../../move-if-change tmp-$@ $@
216
6808fd61
ILT
217sim-config.o: sim-config.c $(sim-config_h) $(sim-nconfig_h) $(sim-assert_h) \
218 $(SIM_EXTRA_DEPS)
a35e91c3
AC
219sim-config.c: $(srcdir)/../common/sim-config.c
220 rm -f $@ tmp-$@
221 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
222 cat $(srcdir)/../common/$@ >> tmp-$@
223 $(srcdir)/../../move-if-change tmp-$@ $@
224
6808fd61
ILT
225sim-core.o: sim-core.c $(sim-core_h) $(sim-n-core_h) \
226 $(SIM_EXTRA_DEPS)
a35e91c3
AC
227sim-core.c: $(srcdir)/../common/sim-core.c
228 rm -f $@ tmp-$@
229 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
230 cat $(srcdir)/../common/$@ >> tmp-$@
231 $(srcdir)/../../move-if-change tmp-$@ $@
232
6808fd61
ILT
233sim-endian.o: sim-endian.c $(sim-endian_h) $(sim-n-endian_h) $(sim-assert_h) \
234 $(SIM_EXTRA_DEPS)
a35e91c3
AC
235sim-endian.c: $(srcdir)/../common/sim-endian.c
236 rm -f $@ tmp-$@
237 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
238 cat $(srcdir)/../common/$@ >> tmp-$@
239 $(srcdir)/../../move-if-change tmp-$@ $@
240
6808fd61
ILT
241sim-events.o: sim-events.c $(sim-events_h) $(sim-assert_h) \
242 $(SIM_EXTRA_DEPS)
a35e91c3
AC
243sim-events.c: $(srcdir)/../common/sim-events.c
244 rm -f $@ tmp-$@
245 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
246 cat $(srcdir)/../common/$@ >> tmp-$@
247 $(srcdir)/../../move-if-change tmp-$@ $@
248
249sim-inline.c: $(srcdir)/../common/sim-inline.c
250 rm -f $@ tmp-$@
251 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
252 cat $(srcdir)/../common/$@ >> tmp-$@
253 $(srcdir)/../../move-if-change tmp-$@ $@
254
6808fd61
ILT
255sim-io.o: sim-io.c $(sim_main_headers) $(sim-io_h) $(sim-assert_h) \
256 $(SIM_EXTRA_DEPS)
a35e91c3
AC
257sim-io.c: $(srcdir)/../common/sim-io.c
258 rm -f $@ tmp-$@
259 echo "# 1 \"$(srcdir)/../common/$@\"" > tmp-$@
260 cat $(srcdir)/../common/$@ >> tmp-$@
261 $(srcdir)/../../move-if-change tmp-$@ $@
262
717dbb29 263sim-module.o: $(srcdir)/../common/sim-module.c $(sim_main_headers) \
c967f187 264 $(sim-io_h) $(SIM_EXTRA_DEPS)
717dbb29
DE
265 $(CC) -c $(srcdir)/../common/sim-module.c $(ALL_CFLAGS)
266
e9b2f579 267sim-options.o: $(srcdir)/../common/sim-options.c $(sim_main_headers) \
c967f187 268 $(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
0f2811d1
DE
269 $(CC) -c $(srcdir)/../common/sim-options.c $(ALL_CFLAGS)
270
e9b2f579 271sim-trace.o: $(srcdir)/../common/sim-trace.c $(sim_main_headers) \
c967f187 272 $(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
e9b2f579
DE
273 $(CC) -c $(srcdir)/../common/sim-trace.c $(ALL_CFLAGS)
274
717dbb29 275sim-profile.o: $(srcdir)/../common/sim-profile.c $(sim_main_headers) \
c967f187 276 $(sim-options_h) $(sim-io_h) $(SIM_EXTRA_DEPS)
717dbb29
DE
277 $(CC) -c $(srcdir)/../common/sim-profile.c $(ALL_CFLAGS)
278
c967f187
DE
279sim-model.o: $(srcdir)/../common/sim-model.c $(sim_main_headers) \
280 $(sim-io_h) $(SIM_EXTRA_DEPS)
281 $(CC) -c $(srcdir)/../common/sim-model.c $(ALL_CFLAGS)
282
6808fd61 283sim-utils.o: $(srcdir)/../common/sim-utils.c $(sim_main_headers) \
c967f187 284 $(SIM_EXTRA_DEPS)
6808fd61 285 $(CC) -c $(srcdir)/../common/sim-utils.c $(ALL_CFLAGS)
a35e91c3 286
0f2811d1
DE
287sim-load.o: $(srcdir)/../common/sim-load.c
288 $(CC) -c $(srcdir)/../common/sim-load.c $(ALL_CFLAGS)
289
c95d08a8
DE
290nrun.o: $(srcdir)/../common/nrun.c config.h tconfig.h \
291 $(srcroot)/include/callback.h $(sim_main_headers)
292 $(CC) -c $(srcdir)/../common/nrun.c $(ALL_CFLAGS)
a35e91c3 293
c967f187
DE
294# CGEN support.
295
296cgen-scache.o: $(srcdir)/../common/cgen-scache.c $(sim_main_headers) \
297 $(SIM_EXTRA_DEPS) $(srcdir)/../common/cgen-scache.h
298 $(CC) -c $(srcdir)/../common/cgen-scache.c $(ALL_CFLAGS)
299
300cgen-trace.o: $(srcdir)/../common/cgen-trace.c $(sim_main_headers) \
301 $(SIM_EXTRA_DEPS) $(srcdir)/../common/cgen-trace.h
302 $(CC) -c $(srcdir)/../common/cgen-trace.c $(ALL_CFLAGS)
303
304cgen-utils.o: $(srcdir)/../common/cgen-utils.c $(sim_main_headers) \
305 $(SIM_EXTRA_DEPS) $(srcdir)/../common/cgen-mem.h \
306 $(srcdir)/../common/cgen-sem.h
307 $(CC) -c $(srcdir)/../common/cgen-utils.c $(ALL_CFLAGS)
308
309# Support targets.
310
f2de7dfd
AC
311install: install-common $(SIM_EXTRA_INSTALL)
312
6808fd61
ILT
313install-common: installdirs
314 n=`echo run | sed '$(program_transform_name)'`; \
315 $(INSTALL_PROGRAM) run $(bindir)/$$n
316
317installdirs:
318 $(SHELL) $(srcdir)/../../mkinstalldirs $(bindir)
f2de7dfd
AC
319
320check:
321
322info:
323clean-info:
324install-info:
325
326.NOEXPORT:
327MAKEOVERRIDES=
328
329tags etags: TAGS
330
331TAGS: force
332 etags *.c *.h
333
717dbb29 334clean: $(SIM_EXTRA_CLEAN)
f2de7dfd
AC
335 rm -f *.[oa] *~ core
336 rm -f run libsim.a
337 rm -f gentmap targ-map.c targ-vals.h
6808fd61 338 rm -f $(BUILT_SRC_FROM_COMMON)
f2de7dfd 339
717dbb29 340distclean mostlyclean maintainer-clean realclean: clean
f2de7dfd
AC
341 rm -f TAGS
342 rm -f Makefile config.cache config.log config.status
343 rm -f tconfig.h config.h stamp-h
0f399b0c 344 rm -f targ-vals.def
f2de7dfd
AC
345
346.c.o:
347 $(CC) -c $(ALL_CFLAGS) $<
348
349# Dummy target to force execution of dependent targets.
350force:
351
352Makefile: Makefile.in $(srcdir)/../common/Make-common.in config.status
353 CONFIG_HEADERS= $(SHELL) ./config.status
354
355config.status: configure
356 $(SHELL) ./config.status --recheck
357
358config.h: stamp-h ; @true
359stamp-h: config.in config.status
360 CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
361
362## End COMMON_POST_CONFIG_FRAG
This page took 0.042094 seconds and 4 git commands to generate.