xref: /openbmc/linux/lib/raid6/test/Makefile (revision b6bec26c)
1#
2# This is a simple Makefile to test some of the RAID-6 code
3# from userspace.
4#
5
6CC	 = gcc
7OPTFLAGS = -O2			# Adjust as desired
8CFLAGS	 = -I.. -I ../../../include -g $(OPTFLAGS)
9LD	 = ld
10AWK	 = awk -f
11AR	 = ar
12RANLIB	 = ranlib
13OBJS	 = int1.o int2.o int4.o int8.o int16.o int32.o recov.o algos.o tables.o
14
15ARCH := $(shell uname -m 2>/dev/null | sed -e /s/i.86/i386/)
16ifeq ($(ARCH),i386)
17        CFLAGS += -DCONFIG_X86_32
18        IS_X86 = yes
19endif
20ifeq ($(ARCH),x86_64)
21        CFLAGS += -DCONFIG_X86_64
22        IS_X86 = yes
23endif
24
25ifeq ($(IS_X86),yes)
26        OBJS   += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o
27        CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1" |	\
28                    gcc -c -x assembler - >&/dev/null &&	\
29                    rm ./-.o && echo -DCONFIG_AS_AVX2=1)
30else
31        HAS_ALTIVEC := $(shell echo -e '\#include <altivec.h>\nvector int a;' |\
32                         gcc -c -x c - >&/dev/null && \
33                         rm ./-.o && echo yes)
34        ifeq ($(HAS_ALTIVEC),yes)
35                OBJS += altivec1.o altivec2.o altivec4.o altivec8.o
36        endif
37endif
38
39.c.o:
40	$(CC) $(CFLAGS) -c -o $@ $<
41
42%.c: ../%.c
43	cp -f $< $@
44
45%.uc: ../%.uc
46	cp -f $< $@
47
48all:	raid6.a raid6test
49
50raid6.a: $(OBJS)
51	 rm -f $@
52	 $(AR) cq $@ $^
53	 $(RANLIB) $@
54
55raid6test: test.c raid6.a
56	$(CC) $(CFLAGS) -o raid6test $^
57
58altivec1.c: altivec.uc ../unroll.awk
59	$(AWK) ../unroll.awk -vN=1 < altivec.uc > $@
60
61altivec2.c: altivec.uc ../unroll.awk
62	$(AWK) ../unroll.awk -vN=2 < altivec.uc > $@
63
64altivec4.c: altivec.uc ../unroll.awk
65	$(AWK) ../unroll.awk -vN=4 < altivec.uc > $@
66
67altivec8.c: altivec.uc ../unroll.awk
68	$(AWK) ../unroll.awk -vN=8 < altivec.uc > $@
69
70int1.c: int.uc ../unroll.awk
71	$(AWK) ../unroll.awk -vN=1 < int.uc > $@
72
73int2.c: int.uc ../unroll.awk
74	$(AWK) ../unroll.awk -vN=2 < int.uc > $@
75
76int4.c: int.uc ../unroll.awk
77	$(AWK) ../unroll.awk -vN=4 < int.uc > $@
78
79int8.c: int.uc ../unroll.awk
80	$(AWK) ../unroll.awk -vN=8 < int.uc > $@
81
82int16.c: int.uc ../unroll.awk
83	$(AWK) ../unroll.awk -vN=16 < int.uc > $@
84
85int32.c: int.uc ../unroll.awk
86	$(AWK) ../unroll.awk -vN=32 < int.uc > $@
87
88tables.c: mktables
89	./mktables > tables.c
90
91clean:
92	rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c tables.c raid6test
93
94spotless: clean
95	rm -f *~
96