1# Copyright (c) 1995, 1996, 2001 Cygnus Support
2#
3# The authors hereby grant permission to use, copy, modify, distribute,
4# and license this software and its documentation for any purpose, provided
5# that existing copyright notices are retained in all copies and that this
6# notice is included verbatim in any distributions. No written agreement,
7# license, or royalty fee is required for any of the authorized uses.
8# Modifications to this software may be copyrighted by their authors
9# and need not follow the licensing terms described here, provided that
10# the new terms are clearly indicated on the first page of each file where
11# they apply.
12#
13# This currently works with Motorola's MVME135 and IDP m68k based
14# target boards.
15#
16
17VPATH = @srcdir@
18srcdir = @srcdir@
19objdir = .
20srcroot = $(srcdir)/../..
21objroot = $(objdir)/../..
22
23prefix = @prefix@
24exec_prefix = @exec_prefix@
25
26host_alias = @host_alias@
27target_alias = @target_alias@
28program_transform_name = @program_transform_name@
29
30bindir = @bindir@
31libdir = @libdir@
32tooldir = $(exec_prefix)/$(target_alias)
33
34# Multilib support variables.
35# TOP is used instead of MULTI{BUILD,SRC}TOP.
36MULTIDIRS =
37MULTISUBDIR =
38MULTIDO = true
39MULTICLEAN = true
40
41INSTALL = @INSTALL@
42INSTALL_PROGRAM = @INSTALL_PROGRAM@
43INSTALL_DATA = @INSTALL_DATA@
44
45SHELL =	/bin/sh
46
47CC = @CC@
48
49AS = @AS@
50AR = @AR@
51LD = @LD@
52RANLIB = @RANLIB@
53AR_FLAGS = qv
54
55OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
56	then echo ${objroot}/../binutils/objdump ; \
57	else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
58OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
59	then echo ${objroot}/../binutils/objcopy ; \
60	else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
61
62SCRIPTS = mvme162 mvme135 idp bcc
63
64OBJS =  close.o fstat.o getpid.o isatty.o kill.o \
65	lseek.o open.o print.o putnum.o read.o sbrk.o stat.o \
66	unlink.o write.o
67
68CFLAGS = -g
69# ARFLAGS = rv
70
71
72# Here is all of the simulator stuff
73SIM_SCRIPTS	= sim.ld
74SIM_LDFLAGS	= -Tsim.ld
75SIM_BSP		= libsim.a
76SIM_CRT0	= sim-crt0.o
77SIM_OBJS	= sim-print.o sim-inbyte.o sim-sbrk.o sim-abort.o sim-errno.o simulator.o sim-funcs.o unlink.o
78SIM_TEST	=
79SIM_INSTALL	= install-sim
80
81
82CRT0 = crt0.o
83#
84# here's all the MVME135 target stuff
85#
86MVME_LDFLAGS=	-L${srcdir} -Tmvme135.ld
87MVME135_BSP=	libmvme135.a
88MVME162_BSP=	libmvme162.a
89#MVME135_OBJS=	mvme.o
90#MVME162_OBJS=	mvme.o
91# Uncomment the last two objects if you want to use the GDB stub.
92# The stub is included "as is", and will likely take some hacking
93# to work on your system.
94MVME135_OBJS=	cpu32bug.o # mvme-stub.o mvme135-asm.o
95MVME162_OBJS=	cpu32bug.o # mvme-stub.o mvme162lx-asm.o
96
97
98#
99# here's all the BCC target stuff
100#
101BCC_LDFLAGS=	-L${srcdir} -Tbcc.ld
102BCC_BSP=	libbcc.a
103BCC_OBJS=	cpu32bug.o
104
105#
106# here's all the IDP target stuff
107#
108IDP_LDFLAGS=	-L${srcdir} -Tidp.ld
109IDP_BSP=	libidp.a
110IDP_OBJS=	leds.o idp-inbyte.o idp-outbyte.o mc68ec.o
111
112#
113# here's all the IDP GDB target stuff
114#
115IDPGDB_LDFLAGS=	-L${srcdir} -Tidpgdb.ld
116IDPGDB_BSP=	libidpgdb.a
117IDPGDB_OBJS=	leds.o idp-inbyte.o idp-gdb-outbyte.o mc68ec.o
118
119#
120# here's all the DBUG target stuff
121#
122DBUG_BSP=	libdbug.a
123DBUG_OBJS=	dbug-exit.o dbug-inbyte.o dbug-outbyte.o
124
125# Host specific makefile fragment comes in here.
126@host_makefile_frag@
127
128#
129# build a test program for each target board. Just trying to get
130# it to link is a good test, so we ignore all the errors for now.
131#
132all: ${SIM_CRT0} ${SIM_BSP} ${CRT0} ${BCC_BSP} ${IDP_BSP} ${IDPGDB_BSP} ${MVME135_BSP} ${MVME162_BSP} ${DBUG_BSP}
133
134#
135# here's where we build the board support packages for each target
136#
137${SIM_BSP}: ${SIM_OBJS}
138	${AR} ${ARFLAGS} $@ ${SIM_OBJS}
139	${RANLIB} $@
140
141${BCC_BSP}: $(OBJS) ${BCC_OBJS}
142	${AR} ${ARFLAGS} $@ $(OBJS) ${BCC_OBJS}
143	${RANLIB} $@
144
145${IDP_BSP}: $(OBJS) ${IDP_OBJS}
146	${AR} ${ARFLAGS} $@ $(OBJS) ${IDP_OBJS}
147	${RANLIB} $@
148
149${IDPGDB_BSP}: $(OBJS) ${IDPGDB_OBJS}
150	${AR} ${ARFLAGS} $@ $(OBJS) ${IDPGDB_OBJS}
151	${RANLIB} $@
152
153${DBUG_BSP}: $(OBJS) ${DBUG_OBJS}
154	${AR} ${ARFLAGS} $@ $(OBJS) ${DBUG_OBJS}
155	${RANLIB} $@
156
157${MVME135_BSP}: $(OBJS) ${MVME135_OBJS}
158	${AR} ${ARFLAGS} $@ $(OBJS) ${MVME135_OBJS}
159	${RANLIB} $@
160
161${MVME162_BSP}: $(OBJS) ${MVME162_OBJS}
162	${AR} ${ARFLAGS} $@ $(OBJS) ${MVME162_OBJS}
163	${RANLIB} $@
164
165leds.o: ${srcdir}/leds.c
166	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
167
168idp-inbyte.o: ${srcdir}/idp-inbyte.c
169	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
170
171idp-outbyte.o: ${srcdir}/idp-outbyte.c
172	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
173
174idp-gdb-outbyte.o: ${srcdir}/idp-outbyte.c
175	$(CC) $(CFLAGS_FOR_TARGET) -DGDB_MONITOR_OUTPUT $(INCLUDES) -c $< -o $@
176
177mc68ec.o: ${srcdir}/mc68ec.c
178	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $<
179
180test.o: ${srcdir}/test.c
181
182#
183# Make a simple test case to test the linker script, startup code, and
184# I/O code
185#
186test: $(OBJS) idp-test.srec mvme135-test.srec bcc-test.srec \
187	idp-test.dis mvme135-test.dis bcc-test.dis
188	@echo Done...
189
190# compile a fully linked binary. The -N option is for a.out, so the
191# base address will be zero, rather than the default of 0x2020. The
192# -Wl,-T*.ld is for the linker script. By using -Wl, the linker script
193# is put on the proper place in the comand line for ld, and all the
194# symbols will get fully resolved.
195
196idp-test.x: test.o ${CRT0} Makefile ${IDP_BSP}
197	${CC} $(CFLAGS_FOR_TARGET) -L${srcdir} -L${objdir} \
198	test.o -o $@ $(LDFLAGS_FOR_TARGET) -N -Wl,-Tidp.ld
199idp-test.srec: idp-test.x
200	$(OBJCOPY) -O srec idp-test.x $@
201idp-test.dis: idp-test.x
202	@rm -fr idp-test.dis
203	$(OBJDUMP) -d idp-test.x > $@
204idp-test: idp-test.srec idp-test.dis
205
206idpgdb-test.x: test.o ${CRT0} Makefile ${IDPGDB_BSP}
207	${CC} $(CFLAGS_FOR_TARGET) -L${srcdir} -L${objdir} \
208	test.o -o $@ $(LDFLAGS_FOR_TARGET) -N -Wl,-Tidpgdb.ld
209idpgdb-test.srec: idpgdb-test.x
210	$(OBJCOPY) -O srec idpgdb-test.x $@
211idpgdb-test.dis: idpgdb-test.x
212	@rm -fr idpgdb-test.dis
213	$(OBJDUMP) -d idpgdb-test.x > $@
214idpgdb-test: idpgdb-test.srec idpgdb-test.dis
215
216mvme135-test.x: test.o ${CRT0} ${srcdir}/mvme135.ld Makefile  ${MVME135_BSP}
217	${CC} -L${srcdir} -L${objdir} test.o -o $@ $(LDFLAGS_FOR_TARGET) \
218	-N -Wl,-Tmvme135.ld -nostdlib
219mvme135-test.srec: mvme135-test.x
220	$(OBJCOPY) -O srec mvme135-test.x $@
221mvme135-test.dis: mvme135-test.x
222	@rm -fr mvme135-test.dis
223	$(OBJDUMP) -d mvme135-test.x > $@
224mvme135-test: mvme135-test.srec mvme135-test.dis
225
226mvme162-test.x: test.o ${CRT0} ${srcdir}/mvme162.ld Makefile  ${MVME162_BSP}
227	${CC} -L${srcdir} -L${objdir} test.o -o $@ $(LDFLAGS_FOR_TARGET) \
228	-N -Wl,-Tmvme162.ld -nostdlib
229mvme162-test.srec: mvme162-test.x
230	$(OBJCOPY) -O srec mvme162-test.x $@
231mvme162-test.dis: mvme162-test.x
232	@rm -fr mvme162-test.dis
233	$(OBJDUMP) -d mvme162-test.x > $@
234mvme162-test: mvme162-test.srec mvme162-test.dis
235
236bcc-test.x: test.o ${CRT0} ${srcdir}/bcc.ld Makefile  ${BCC_BSP}
237	${CC} -L${srcdir} -L${objdir} test.o -o $@ $(LDFLAGS_FOR_TARGET) \
238	-N -Wl,-Tbcc.ld -nostdlib
239bcc-test.srec: bcc-test.x
240	$(OBJCOPY) -O srec bcc-test.x $@
241bcc-test.dis: bcc-test.x
242	@rm -fr bcc-test.dis
243	$(OBJDUMP) -d bcc-test.x > $@
244bcc-test: bcc-test.srec bcc-test.dis
245
246# a C++ test case
247dtor.o:  $(srcdir)/dtor.C
248	$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -o $@ -c $<
249dtor.dis: dtor.x
250	@rm -fr dtor.dis
251	$(OBJDUMP) -d dtor.x > $@
252dtor.x: dtor.o ${CRT0} ${srcdir}/mvme135.ld Makefile  ${MVME135_BSP}
253	${CC} -L${srcdir} -L${objdir} dtor.o -o $@ $(LIBS_FOR_TARGET) \
254	-N -Wl,-Tmvme135.ld -nostdlib
255
256unlink.o: $(srcdir)/../unlink.c
257
258.PHONY: install info dvi doc install-info clean-info
259install:
260	# install SIM stuff
261	$(INSTALL_PROGRAM) $(SIM_CRT0) $(tooldir)/lib${MULTISUBDIR}/$(SIM_CRT0)
262	$(INSTALL_PROGRAM) $(SIM_BSP) $(tooldir)/lib${MULTISUBDIR}/$(SIM_BSP)
263	$(INSTALL_DATA) ${srcdir}/sim.ld $(tooldir)/lib${MULTISUBDIR}/sim.ld
264	#
265	$(INSTALL_PROGRAM) $(CRT0) $(tooldir)/lib${MULTISUBDIR}/$(CRT0)
266	# install BCC stuff
267	$(INSTALL_PROGRAM) $(BCC_BSP) $(tooldir)/lib${MULTISUBDIR}/$(BCC_BSP)
268	$(INSTALL_DATA) ${srcdir}/bcc.ld $(tooldir)/lib${MULTISUBDIR}/bcc.ld
269	# install IDP stuff
270	$(INSTALL_PROGRAM) $(IDP_BSP) $(tooldir)/lib${MULTISUBDIR}/$(IDP_BSP)
271	$(INSTALL_DATA) ${srcdir}/idp.ld $(tooldir)/lib${MULTISUBDIR}/idp.ld
272	# install IDPGDB stuff
273	$(INSTALL_PROGRAM) $(IDPGDB_BSP) $(tooldir)/lib${MULTISUBDIR}/$(IDPGDB_BSP)
274	$(INSTALL_DATA) ${srcdir}/idpgdb.ld $(tooldir)/lib${MULTISUBDIR}/idpgdb.ld
275	# install MVME135 stuff
276	$(INSTALL_PROGRAM) $(MVME135_BSP) $(tooldir)/lib${MULTISUBDIR}/$(MVME135_BSP)
277	$(INSTALL_DATA) ${srcdir}/mvme135.ld $(tooldir)/lib${MULTISUBDIR}/mvme135.ld
278	# install MVME162lx stuff
279	$(INSTALL_PROGRAM) $(MVME162_BSP) $(tooldir)/lib${MULTISUBDIR}/$(MVME162_BSP)
280	$(INSTALL_DATA) ${srcdir}/mvme162.ld $(tooldir)/lib${MULTISUBDIR}/mvme162.ld
281	# install DBUG stuff
282	$(INSTALL_PROGRAM) $(DBUG_BSP) $(tooldir)/lib${MULTISUBDIR}/$(DBUG_BSP)
283	$(INSTALL_DATA) ${srcdir}/sbc5204.ld $(tooldir)/lib${MULTISUBDIR}/sbc5204.ld
284	$(INSTALL_DATA) ${srcdir}/sbc5206.ld $(tooldir)/lib${MULTISUBDIR}/sbc5206.ld
285
286# target specific makefile fragment comes in here.
287@target_makefile_frag@
288
289clean mostlyclean:
290	rm -f a.out core *.i *~ *.a *.o *-test *.srec *.dis *.x *.map
291
292distclean maintainer-clean realclean: clean
293	rm -f Makefile config.cache config.log config.status
294
295info dvi doc:
296install-info:
297clean-info:
298
299Makefile: Makefile.in config.status @host_makefile_frag_path@ @target_makefile_frag_path@
300	$(SHELL) config.status
301
302config.status: configure
303	$(SHELL) config.status --recheck
304