#
# Makefile for gcc crt0_xxx.o startup modules and libg.
#
# Compiler: c4x gcc (>=1.9.62, 1.10.x)
#
# Volker Kuhlmann
#   February, March 1998
#


# Enter the directory used when compiling gcc (--prefix=DIR) here:
INSTPREFIX	= /usr/local
#INSTPREFIX	= /tmp/c4x

# Enter location and version of gcc here:
GCCDIR		= lib/gcc-lib/c4x/2.8.1


INSTDIR		= $(INSTPREFIX)/$(GCCDIR)

# Name of assembler file used for all crt0_xxx.o
# (crt0_xxx.s files, or crt0_xxx.c files, are currently not supported by
# this Makefile. One could use the C preprocessor on .S assembly files.)
ASRC		= crt0.s



CC		= c4x-gcc
CFLAGS		= -bc4x

AS_CPP		= $(CC) -x assembler-with-cpp
AS_CPPFLAGS	= -bc4x
# -mregparm/-mmemparm | -msmall / -mbig
# -m30 | -m31 | -m32 | -m40 | -m44 = target DSP

AS		= c4x-as
ASFLAGS		=
# -r | -p = register / stack arg passing, -s | -b small / big mem model
# -m30 | -m31 | -m32 | -m40 | -m44 = target DSP

AR		= c4x-ar
ARFLAGS		= -rvs


#crt0_[34][sb][rm].o
OBJS = crt0_3sr.o crt0_3sm.o crt0_3br.o crt0_3bm.o \
	crt0_4sr.o crt0_4sm.o crt0_4br.o crt0_4bm.o

# objects which go into libg.a (may be empty)
LIBGOBJS =

# objects which go into libc.a (may be empty)
LIBCOBJS =

INSTALL = $(OBJS) libg.a libc.a


all: $(INSTALL)

crt0_3sr.o:
	$(AS) $(ASFLAGS) -m30 -s -r $(XASFLAGS) -o $*.o $(ASRC)
crt0_3sm.o:
	$(AS) $(ASFLAGS) -m30 -s -p $(XASFLAGS) -o $*.o $(ASRC)
crt0_3br.o:
	$(AS) $(ASFLAGS) -m30 -b -r $(XASFLAGS) -o $*.o $(ASRC)
crt0_3bm.o:
	$(AS) $(ASFLAGS) -m30 -b -p $(XASFLAGS) -o $*.o $(ASRC)
crt0_4sr.o:
	$(AS) $(ASFLAGS) -m40 -s -r $(XASFLAGS) -o $*.o $(ASRC)
crt0_4sm.o:
	$(AS) $(ASFLAGS) -m40 -s -p $(XASFLAGS) -o $*.o $(ASRC)
crt0_4br.o:
	$(AS) $(ASFLAGS) -m40 -b -r $(XASFLAGS) -o $*.o $(ASRC)
crt0_4bm.o:
	$(AS) $(ASFLAGS) -m40 -b -p $(XASFLAGS) -o $*.o $(ASRC)

libg.a:
	$(AR) $(ARFLAGS) $*.a $(LIBGOBJS)
libc.a:
	$(AR) $(ARFLAGS) $*.a $(LIBCOBJS)

install: all
	cp -p $(INSTALL) $(INSTDIR)
	cd $(INSTDIR); chmod 644 $(INSTALL)
	-cd $(INSTDIR); chown 0:0 $(INSTALL)

uninstall:
	cd $(INSTDIR); rm -f $(INSTALL)

clean:
	rm -f *.o *.a *% *~
