# gcc-support/Makefile
#
# ABLE GCC Support Library
#
# Support library for building ABLE userland applications using a
# cross-gcc on linux or a similar environment.
#
# Copyright 2006 Simtec Electronics
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA

all: libgcc-able.a

LIBGCCFUNCS := cmpdi2 adddf3 ashrdi3 ashldi3 lshrdi3 fixdfdi fixunsdfdi fixunsdfsi floatdidf floatundidf clz

FOBJ=$(addsuffix .o,$(LIBGCCFUNCS))

OBJ := dp-bit.o fp-bit.o $(FOBJ)

CROSS ?= /opt/simtec/tools/arm-bin217-gcc424/bin/arm-unknown-linux-gnueabi-
AR := $(CROSS)ar
RANLIB := $(CROSS)ranlib
CC := $(CROSS)gcc
RM := rm -f
ABLE_LIB := /opt/simtec/able
ABI_FLAGS=-mabi=apcs-gnu -mno-thumb-interwork -mfloat-abi=soft -mfpu=fpa
Q=@

libgcc-able.a: $(OBJ)
	@echo "       AR libgcc-able.a"
	$(Q)$(RM) $@
	$(Q)$(AR) cru $@ $^
	$(Q)$(RANLIB) $@

%.o: %.c
	@echo "       CC $@"
	$(Q)$(CC) $(ABI_FLAGS) -mcpu=arm7 -o $@ -c $<

$(FOBJ): libgcc2.c 
	@echo "  FUNC CC $@"
	$(Q)$(CC) $(ABI_FLAGS) -DL_$* -mcpu=arm7 -o $@ -c libgcc2.c

clean:
	@echo "    CLEAN ABLE gcc support library"
	$(Q)$(RM) $(OBJ) libgcc-able.a

dev-install: libgcc-able.a
	sudo cp libgcc-able.a $(ABLE_LIB)/lib/
