OLDCC = armcc -w
# Don't build enquire
ENQUIRE=
CROSS_LIBGCC1 = libgcc1-aof.a
LIBGCC2 = libgcc2-aof.a
LIBGCC = libgcc-aof.a
LIBGCC2_CFLAGS = -O2 -fomit-frame-pointer
LIBGCC1_TEST = #libgcc1-atest
EXTRA_PARTS = crtbegin.o crtend.o
STMP_FIXPROTO =

# Rule to build libgcc1.a and libgcc2.a and libgcc.a, since the librarian 
# for the ARM tools is somewhat quirky, and needs a special rule to use it.
libgcc1-aof.a: libgcc1.c $(CONFIG_H) config.status
	-rm -rf tmplib libgcc1.a libgcc1-aof.a tmplibgcc1.a
	mkdir tmplib
	for name in $(LIB1FUNCS); \
	do \
	  echo $${name}; \
	  rm -f $${name}$(objext); \
	  $(OLDCC) $(CCLIBFLAGS) $(INCLUDES) -c -DL$${name} $(srcdir)/libgcc1.c; \
	  if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
	  mv libgcc1$(objext) tmplib/$${name}$(objext); \
	done
	(cd tmplib; \
	 armlib -c tmplibgcc1.a *; \
	 mv tmplibgcc1.a ..)
	mv tmplibgcc1.a libgcc1-aof.a
	rm -rf tmplib

libgcc2-aof.a: libgcc2.c libgcc2.ready $(CONFIG_H) $(LIB2FUNCS_EXTRA) \
   machmode.h longlong.h gbl-ctors.h config.status
	-rm -f tmplibgcc2.a
	-rm -rf tmplib
	mkdir tmplib
	for name in $(LIB2FUNCS); \
	do \
	  echo $${name}; \
	  $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) -c -DL$${name} \
	      $(srcdir)/libgcc2.c -o tmplib/$${name}$(objext); \
	  if [ $$? -eq 0 ] ; then true; else exit 1; fi; \
	done
	(cd tmplib; \
	 armlib -c tmplibgcc2.a *; \
	 mv tmplibgcc2.a ..)
	mv tmplibgcc2.a libgcc2-aof.a
	rm -rf tmplib

# Combine the various libraries into a single library, libgcc.a.
libgcc-aof.a: $(CROSS_LIBGCC1) $(LIBGCC2)
	-rm -rf tmplibgcc.a libgcc.a tmpcopy libgcc-aof.a
	mkdir tmpcopy
	(cd tmpcopy; armlib -e ../$(LIBGCC1) \*)
	-(cd tmpcopy; chmod +w * > /dev/null 2>&1)
	(cd tmpcopy; armlib -e ../$(LIBGCC2) \*)
	(cd tmpcopy; armlib -co ../tmplibgcc.a *$(objext))
	rm -rf tmpcopy
	mv tmplibgcc.a libgcc.a
	ln libgcc.a libgcc-aof.a

libgcc1-atest: libgcc1-test.o native $(GCC_PARTS) $(EXTRA_PARTS)
	@echo "Testing libgcc1.  Ignore linker warning messages."
	$(GCC_FOR_TARGET) $(GCC_CFLAGS) libgcc1-test.o -o libgcc1-test \
	-v
