#
# http://pdaXrom.org 2004
# AtiCore hack
#

TARGETLIB = libaticore
TARGETSTATICLIB = libaticore.a
TARGETSHAREDLIB = libaticore.so.1

all:	$(TARGETSHAREDLIB) testcore atitest

ifndef $(CC)
CC = armv5tel-linux-gcc
endif
ifndef $(AS)
AS = armv5tel-linux-gcc
endif
ifndef $(AR)
AR = armv5tel-linux-ar
endif
ifndef $(RANLIB)
RANLIB = armv5tel-linux-ranlib
endif
ifndef $(LD)
LD = armv5tel-linux-ld
endif

ifndef $(ASFLAGS)
ASFLAGS=-mcpu=xscale -c
endif

OBJS  = aticore_0.o map.o
OBJS += aticore_1.o aticore_2.o aticore_3.o aticore_4.o aticore_5.o aticore_6.o aticore_7.o aticore_8.o aticore_9.o
# aticore_10.o
OBJS += aticore_11.o aticore_12.o aticore_13.o aticore_14.o aticore_15.o aticore_16.o aticore_17.o aticore_18.o aticore_19.o aticore_20.o
OBJS += aticore_21.o aticore_22.o aticore_23.o aticore_24.o aticore_25.o aticore_26.o

$(TARGETSTATICLIB): $(OBJS)
	$(AR) cru $@ $(OBJS)
	$(RANLIB) $@

$(TARGETSHAREDLIB): $(OBJS)
	$(CC) -shared -Wl,-soname,$(TARGETSHAREDLIB) -s -o $(TARGETSHAREDLIB).0.1 $(OBJS)
	ln -sf $(TARGETSHAREDLIB).0.1 $(TARGETSHAREDLIB)
	ln -sf $(TARGETSHAREDLIB).0.1 $(TARGETLIB).so

testcore: testcore.o
	$(CC) -s -o $@ $< -laticore -L.

atitest: atitest.o
	$(CC) -s -o $@ $< -laticore -L.

clean:
	rm -f $(OBJS) $(TARGETSTATICLIB) $(TARGETLIB).so* testcore.o testcore atitest.o atitest

install:
	mkdir -p $(DESTDIR)/usr/lib
	cp -a $(TARGETSHAREDLIB).0.1  $(DESTDIR)/usr/lib
	ln -sf $(TARGETSHAREDLIB).0.1 $(DESTDIR)/usr/lib/$(TARGETSHAREDLIB)
	ln -sf $(TARGETSHAREDLIB).0.1 $(DESTDIR)/usr/lib/$(TARGETLIB).so
