18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#
38c2ecf20Sopenharmony_ci# This is a simple Makefile to test some of the RAID-6 code
48c2ecf20Sopenharmony_ci# from userspace.
58c2ecf20Sopenharmony_ci#
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cipound := \#
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciCC	 = gcc
108c2ecf20Sopenharmony_ciOPTFLAGS = -O2			# Adjust as desired
118c2ecf20Sopenharmony_ciCFLAGS	 = -I.. -I ../../../include -g $(OPTFLAGS)
128c2ecf20Sopenharmony_ciLD	 = ld
138c2ecf20Sopenharmony_ciAWK	 = awk -f
148c2ecf20Sopenharmony_ciAR	 = ar
158c2ecf20Sopenharmony_ciRANLIB	 = ranlib
168c2ecf20Sopenharmony_ciOBJS	 = int1.o int2.o int4.o int8.o int16.o int32.o recov.o algos.o tables.o
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciARCH := $(shell uname -m 2>/dev/null | sed -e /s/i.86/i386/)
198c2ecf20Sopenharmony_ciifeq ($(ARCH),i386)
208c2ecf20Sopenharmony_ci        CFLAGS += -DCONFIG_X86_32
218c2ecf20Sopenharmony_ci        IS_X86 = yes
228c2ecf20Sopenharmony_ciendif
238c2ecf20Sopenharmony_ciifeq ($(ARCH),x86_64)
248c2ecf20Sopenharmony_ci        CFLAGS += -DCONFIG_X86_64
258c2ecf20Sopenharmony_ci        IS_X86 = yes
268c2ecf20Sopenharmony_ciendif
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciifeq ($(ARCH),arm)
298c2ecf20Sopenharmony_ci        CFLAGS += -I../../../arch/arm/include -mfpu=neon
308c2ecf20Sopenharmony_ci        HAS_NEON = yes
318c2ecf20Sopenharmony_ciendif
328c2ecf20Sopenharmony_ciifeq ($(ARCH),aarch64)
338c2ecf20Sopenharmony_ci        CFLAGS += -I../../../arch/arm64/include
348c2ecf20Sopenharmony_ci        HAS_NEON = yes
358c2ecf20Sopenharmony_ciendif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciifeq ($(findstring ppc,$(ARCH)),ppc)
388c2ecf20Sopenharmony_ci        CFLAGS += -I../../../arch/powerpc/include
398c2ecf20Sopenharmony_ci        HAS_ALTIVEC := $(shell printf '$(pound)include <altivec.h>\nvector int a;\n' |\
408c2ecf20Sopenharmony_ci                         gcc -c -x c - >/dev/null && rm ./-.o && echo yes)
418c2ecf20Sopenharmony_ciendif
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciifeq ($(ARCH),loongarch64)
448c2ecf20Sopenharmony_ci        CFLAGS += -I../../../arch/loongarch/include -DCONFIG_LOONGARCH=1
458c2ecf20Sopenharmony_ci        CFLAGS += $(shell echo 'vld $$vr0, $$zero, 0' |         \
468c2ecf20Sopenharmony_ci                    gcc -c -x assembler - >/dev/null 2>&1 &&    \
478c2ecf20Sopenharmony_ci                    rm ./-.o && echo -DCONFIG_CPU_HAS_LSX=1)
488c2ecf20Sopenharmony_ci        CFLAGS += $(shell echo 'xvld $$xr0, $$zero, 0' |        \
498c2ecf20Sopenharmony_ci                    gcc -c -x assembler - >/dev/null 2>&1 &&    \
508c2ecf20Sopenharmony_ci                    rm ./-.o && echo -DCONFIG_CPU_HAS_LASX=1)
518c2ecf20Sopenharmony_ciendif
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ciifeq ($(IS_X86),yes)
548c2ecf20Sopenharmony_ci        OBJS   += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o
558c2ecf20Sopenharmony_ci        CFLAGS += -DCONFIG_X86
568c2ecf20Sopenharmony_ci	CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" |          \
578c2ecf20Sopenharmony_ci		    gcc -c -x assembler - >/dev/null 2>&1 &&	\
588c2ecf20Sopenharmony_ci		    rm ./-.o && echo -DCONFIG_AS_AVX512=1)
598c2ecf20Sopenharmony_cielse ifeq ($(HAS_NEON),yes)
608c2ecf20Sopenharmony_ci        OBJS   += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
618c2ecf20Sopenharmony_ci        CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1
628c2ecf20Sopenharmony_cielse ifeq ($(HAS_ALTIVEC),yes)
638c2ecf20Sopenharmony_ci        CFLAGS += -DCONFIG_ALTIVEC
648c2ecf20Sopenharmony_ci        OBJS += altivec1.o altivec2.o altivec4.o altivec8.o \
658c2ecf20Sopenharmony_ci                vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o
668c2ecf20Sopenharmony_cielse ifeq ($(ARCH),loongarch64)
678c2ecf20Sopenharmony_ci        OBJS += loongarch_simd.o recov_loongarch_simd.o
688c2ecf20Sopenharmony_ciendif
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci.c.o:
718c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) -c -o $@ $<
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci%.c: ../%.c
748c2ecf20Sopenharmony_ci	cp -f $< $@
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci%.uc: ../%.uc
778c2ecf20Sopenharmony_ci	cp -f $< $@
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciall:	raid6.a raid6test
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciraid6.a: $(OBJS)
828c2ecf20Sopenharmony_ci	 rm -f $@
838c2ecf20Sopenharmony_ci	 $(AR) cq $@ $^
848c2ecf20Sopenharmony_ci	 $(RANLIB) $@
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciraid6test: test.c raid6.a
878c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) -o raid6test $^
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cineon1.c: neon.uc ../unroll.awk
908c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=1 < neon.uc > $@
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cineon2.c: neon.uc ../unroll.awk
938c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=2 < neon.uc > $@
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cineon4.c: neon.uc ../unroll.awk
968c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=4 < neon.uc > $@
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cineon8.c: neon.uc ../unroll.awk
998c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=8 < neon.uc > $@
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cialtivec1.c: altivec.uc ../unroll.awk
1028c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=1 < altivec.uc > $@
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cialtivec2.c: altivec.uc ../unroll.awk
1058c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=2 < altivec.uc > $@
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cialtivec4.c: altivec.uc ../unroll.awk
1088c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=4 < altivec.uc > $@
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cialtivec8.c: altivec.uc ../unroll.awk
1118c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=8 < altivec.uc > $@
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_civpermxor1.c: vpermxor.uc ../unroll.awk
1148c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=1 < vpermxor.uc > $@
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_civpermxor2.c: vpermxor.uc ../unroll.awk
1178c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=2 < vpermxor.uc > $@
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_civpermxor4.c: vpermxor.uc ../unroll.awk
1208c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=4 < vpermxor.uc > $@
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_civpermxor8.c: vpermxor.uc ../unroll.awk
1238c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=8 < vpermxor.uc > $@
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ciint1.c: int.uc ../unroll.awk
1268c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=1 < int.uc > $@
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ciint2.c: int.uc ../unroll.awk
1298c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=2 < int.uc > $@
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ciint4.c: int.uc ../unroll.awk
1328c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=4 < int.uc > $@
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciint8.c: int.uc ../unroll.awk
1358c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=8 < int.uc > $@
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ciint16.c: int.uc ../unroll.awk
1388c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=16 < int.uc > $@
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciint32.c: int.uc ../unroll.awk
1418c2ecf20Sopenharmony_ci	$(AWK) ../unroll.awk -vN=32 < int.uc > $@
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_citables.c: mktables
1448c2ecf20Sopenharmony_ci	./mktables > tables.c
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ciclean:
1478c2ecf20Sopenharmony_ci	rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c vpermxor*.c neon*.c tables.c raid6test
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_cispotless: clean
1508c2ecf20Sopenharmony_ci	rm -f *~
151