CFLAGS=-O3 -omit-frame-pointer -D__KERNEL__ -I../include $(EXTRA_CFLAGS)

PERL=perl

AES_CORE_OBJ:=aes_crypt.o

ASM-$(ARCH_ASM):=1
ASM_X86:=$(ASM-i586)$(ASM-i686)
ifneq ($(strip $(ASM_X86)),)
AES_CORE_OBJ=asm/aesx86-elf.o
endif

BASELIBOBJ=aes_tables.o aes_setkey.o aes_cbc.o
LIBOBJ=$(AES_CORE_OBJ) $(BASELIBOBJ)
LIBOBJSET=$(AES_CORE_OBJ) $(BASELIBOBJ)
BLIB=libaes.a

$(BLIB): $(LIBOBJ)
	/bin/rm -f $(BLIB)
	ar cr $(BLIB) $(LIBOBJ)
	-if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \
	else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
	else exit 0; fi; fi

clean:
			rm -f *.[oa] core asm/*.o asm/*.cpp

$(LIBOBJSET):		aes.h aes_options.h

# elf
asm/aesx86-elf.o:	asm/aesx86unix.cpp
			$(CPP) -DELF -x c $< | as -o $@

# solaris
asm/aesx86-sol.s:	asm/aesx86unix.cpp
			$(CC) -DSOL -x c $^ | sed 's/^#.*//' > $@

# a.out
asm/aesx86-aout.o:	asm/aesx86unix.cpp
			$(CPP) -DOUT -x c $^ | as -o $@

# bsdi
asm/aesx86-bsdi.o:	asm/aesx86unix.cpp
			$(CPP) -DBSDI -x c $^ | as -o $@

asm/aesx86unix.cpp:	asm/aes-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
	(cd asm; $(PERL) aes-586.pl cpp $(PROCESSOR) >aesx86unix.cpp)
