1#  Copyright (c) 2012 ARM Ltd.  All rights reserved.
2#
3#  Redistribution and use in source and binary forms, with or without
4#  modification, are permitted provided that the following conditions
5#  are met:
6#  1. Redistributions of source code must retain the above copyright
7#     notice, this list of conditions and the following disclaimer.
8#  2. Redistributions in binary form must reproduce the above copyright
9#     notice, this list of conditions and the following disclaimer in the
10#     documentation and/or other materials provided with the distribution.
11#  3. The name of the company may not be used to endorse or promote
12#     products derived from this software without specific prior written
13#     permission.
14#
15#  THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
16#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18#  IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20#  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26DESTDIR =
27VPATH = @srcdir@ @srcdir@/..
28srcdir = @srcdir@
29objdir = .
30srcroot = $(srcdir)/../..
31objroot = $(objdir)/../..
32
33prefix = @prefix@
34exec_prefix = @exec_prefix@
35
36host_alias = @host_alias@
37target_alias = @target_alias@
38
39bindir = @bindir@
40libdir = @libdir@
41tooldir = $(exec_prefix)/$(target_alias)
42
43objtype = @objtype@
44
45INSTALL = @INSTALL@
46INSTALL_PROGRAM = @INSTALL_PROGRAM@
47INSTALL_DATA = @INSTALL_DATA@
48
49# Multilib support variables.
50# TOP is used instead of MULTI{BUILD,SRC}TOP.
51MULTISRCTOP =
52MULTIBUILDTOP =
53MULTIDIRS =
54MULTISUBDIR =
55MULTIDO = true
56MULTICLEAN = true
57
58SHELL =	/bin/sh
59
60CC = @CC@
61
62AS = @AS@
63AR = @AR@
64LD = @LD@
65RANLIB = @RANLIB@
66
67SUBDIRS = @subdirs@
68
69OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
70	then echo ${objroot}/../binutils/objdump ; \
71	else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
72OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
73	then echo ${objroot}/../binutils/objcopy ; \
74	else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
75
76OBJS = ftruncate.o libcfunc.o syscalls.o truncate.o _exit.o _kill.o
77CRT0		= crt0.o
78CRT0_INSTALL	= install-crt0
79
80CRT0_INSTALL	= install-crt0
81RDIMON_CRT0	= rdimon-crt0.o
82RDIMON_BSP	= librdimon.a
83RDIMON_OBJS	= $(patsubst %,rdimon-%,$(OBJS))
84RDIMON_SCRIPTS	= rdimon.specs aem-ve.specs aem-validation.specs
85RDIMON_INSTALL	= install-rdimon
86
87CFLAGS		= -g
88
89# Host specific makefile fragment comes in here.
90@host_makefile_frag@
91
92#
93# build a test program for each target board. Just trying to get
94# it to link is a good test, so we ignore all the errors for now.
95#
96all: ${CRT0} ${RDIMON_CRT0} ${RDIMON_BSP} ${RDIMON_SCRIPTS}
97	@rootpre=`pwd`/; export rootpre; \
98	srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
99	for dir in .. ${SUBDIRS}; do \
100	  if [ x$$dir != x.. ]; then \
101	    if [ -d $$dir ]; then \
102	      (cd $$dir; $(MAKE) $(FLAGS_TO_PASS)); \
103	    else true; fi; \
104	  else true; fi; \
105	done
106
107#
108# here's where we build the test programs for each target
109#
110.PHONY: test
111test:
112
113#
114crt0.o: crt0.S
115
116rdimon-crt0.o: crt0.S
117	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
118
119#rdimon-trap.o: trap.S
120#	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
121
122rdimon-_exit.o: _exit.c
123	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
124
125rdimon-ftruncate.o: ftruncate.c
126	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
127
128rdimon-_kill.o: _kill.c
129	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
130
131rdimon-libcfunc.o: libcfunc.c
132	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
133
134rdimon-syscalls.o: syscalls.c
135	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
136
137rdimon-truncate.o: truncate.c
138	$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) $(INCLUDES) -DARM_RDI_MONITOR -o $@ -c $<
139
140$(RDIMON_BSP): $(RDIMON_OBJS)
141	${AR} ${ARFLAGS} $@ $^
142	${RANLIB} $@
143
144clean mostlyclean:
145	rm -f a.out core *.i *.o *-test *.srec *.dis *.x $(SIM_BSP) ${RDIMON_SCRIPTS}
146	@rootpre=`pwd`/; export rootpre; \
147	srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
148	for dir in .. ${SUBDIRS}; do \
149	  if [ x$$dir != x.. ]; then \
150	    if [ -d $$dir ]; then \
151	      (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) clean); \
152	    else true; fi; \
153	  else true; fi; \
154	done
155
156distclean maintainer-clean realclean: clean
157	rm -f Makefile config.status *~
158
159.PHONY: install info install-info clean-info
160install: ${CRT0_INSTALL} ${RDIMON_INSTALL}
161	@rootpre=`pwd`/; export rootpre; \
162	srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
163	for dir in .. ${SUBDIRS}; do \
164	  if [ x$$dir != x.. ]; then \
165	    if [ -d $$dir ]; then \
166	      (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) install); \
167	    else true; fi; \
168	  else true; fi; \
169	done
170
171install-crt0:
172	${INSTALL_DATA} ${CRT0} $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x
173
174install-rdimon:
175	set -e; for x in ${RDIMON_CRT0} ${RDIMON_BSP}; do ${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
176	set -e; for x in ${RDIMON_SCRIPTS}; do ${INSTALL_DATA} ${srcdir}/${objtype}$$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; done
177
178# Make copies of the scripts to facilitate in-tree bootstrapping.
179${RDIMON_SCRIPTS}: %: ${objtype}%
180	cp $< $@
181
182doc:
183info:
184install-info:
185clean-info:
186
187Makefile: Makefile.in config.status @host_makefile_frag_path@
188	$(SHELL) config.status
189
190config.status: configure
191	$(SHELL) config.status --recheck
192