[MPlayer-dev-eng] [PATCH] possibly cleaner way to generate ARCH_, ENABLE_ etc. defines
Reimar Doeffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Jun 16 18:56:33 CEST 2007
Hello,
please comment on attached patch.
Can probably be further simplified, but I'm not motivated to take it
that far...
Greetings,
Reimar Doeffinger
-------------- next part --------------
Index: configure
===================================================================
--- configure (revision 23566)
+++ configure (working copy)
@@ -1587,9 +1587,8 @@
case "$host_arch" in
i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
- _def_arch_x86="#define ARCH_X86 1"
+ _arch='X86 X86_32'
_target_arch_x86="ARCH_X86 = yes"
- _def_arch="#define ARCH_X86_32 1"
_target_arch="ARCH_X86_32 = yes"
iproc=486
proc=i486
@@ -1822,7 +1821,7 @@
;;
ia64)
- _def_arch='#define ARCH_IA64 1'
+ _arch='IA64'
_target_arch='ARCH_IA64 = yes'
iproc='ia64'
proc=''
@@ -1832,9 +1831,8 @@
;;
x86_64|amd64)
- _def_arch='#define ARCH_X86_64 1'
+ _arch='X86 X86_64'
_target_arch='ARCH_X86_64 = yes'
- _def_arch_x86="#define ARCH_X86 1"
_target_arch_x86="ARCH_X86 = yes"
iproc='x86_64'
@@ -1911,7 +1909,7 @@
;;
sparc)
- _def_arch='#define ARCH_SPARC 1'
+ _arch='SPARC'
_target_arch='ARCH_SPARC = yes'
iproc='sparc'
if sunos ; then
@@ -1936,7 +1934,7 @@
;;
sparc64)
- _def_arch='#define ARCH_SPARC 1'
+ _arch='SPARC'
_target_arch='ARCH_SPARC = yes'
_vis='yes'
_def_vis='#define HAVE_VIS = yes'
@@ -1948,7 +1946,7 @@
;;
arm|armv4l|armv5tel)
- _def_arch='#define ARCH_ARMV4L 1'
+ _arch='ARM ARMV4L'
_target_arch='ARCH_ARMV4L = yes'
iproc='arm'
proc=''
@@ -1958,7 +1956,7 @@
;;
ppc|powerpc)
- _def_arch='#define ARCH_POWERPC 1'
+ _arch='POWERPC PPC'
_def_dcbzl='#define NO_DCBZL 1'
_target_arch='ARCH_POWERPC = yes'
iproc='ppc'
@@ -2070,7 +2068,7 @@
;;
alpha)
- _def_arch='#define ARCH_ALPHA 1'
+ _arch='ALPHA'
_target_arch='ARCH_ALPHA = yes'
iproc='alpha'
_march=''
@@ -2121,7 +2119,7 @@
;;
mips)
- _def_arch='#define ARCH_SGI_MIPS 1'
+ _arch='SGI_MIPS'
_target_arch='ARCH_SGI_MIPS = yes'
iproc='sgi-mips'
proc=''
@@ -2150,7 +2148,7 @@
;;
hppa)
- _def_arch='#define ARCH_PA_RISC 1'
+ _arch='PA_RISC'
_target_arch='ARCH_PA_RISC = yes'
iproc='PA-RISC'
proc=''
@@ -2160,7 +2158,7 @@
;;
s390)
- _def_arch='#define ARCH_S390 1'
+ _arch='S390'
_target_arch='ARCH_S390 = yes'
iproc='390'
proc=''
@@ -2170,7 +2168,7 @@
;;
s390x)
- _def_arch='#define ARCH_S390X 1'
+ _arch='S390X'
_target_arch='ARCH_S390X = yes'
iproc='390x'
proc=''
@@ -2180,7 +2178,7 @@
;;
vax)
- _def_arch='#define ARCH_VAX 1'
+ _arch='VAX'
_target_arch='ARCH_VAX = yes'
iproc='vax'
proc=''
@@ -2190,7 +2188,7 @@
;;
generic)
- _def_arch='#define ARCH_GENERIC 1'
+ _arch='GENERIC'
_target_arch='ARCH_GENERIC = yes'
iproc=''
proc=''
@@ -2470,30 +2468,20 @@
echores "$_iwmmxt"
fi
-_def_mmx='#undef HAVE_MMX'
-test "$_mmx" = yes && _def_mmx='#define HAVE_MMX 1'
-_def_mmxext='#undef HAVE_MMX2'
-test "$_mmxext" = yes && _def_mmxext='#define HAVE_MMX2 1'
-_def_3dnow='#undef HAVE_3DNOW'
-test "$_3dnow" = yes && _def_3dnow='#define HAVE_3DNOW 1'
-_def_3dnowext='#undef HAVE_3DNOWEX'
-test "$_3dnowext" = yes && _def_3dnowext='#define HAVE_3DNOWEX 1'
-_def_sse='#undef HAVE_SSE'
-test "$_sse" = yes && _def_sse='#define HAVE_SSE 1'
-_def_sse2='#undef HAVE_SSE2'
-test "$_sse2" = yes && _def_sse2='#define HAVE_SSE2 1'
-_def_ssse3='#undef HAVE_SSSE3'
-test "$_ssse3" = yes && _def_ssse3='#define HAVE_SSSE3 1'
-_def_cmov='#undef HAVE_CMOV'
-test "$_cmov" = yes && _def_cmov='#define HAVE_CMOV 1'
-_def_fast_cmov='#undef HAVE_FAST_CMOV'
-test "$_fast_cmov" = yes && _def_fast_cmov='#define HAVE_FAST_CMOV 1'
-_def_armv5te='#undef HAVE_ARMV5TE'
-test "$_armv5te" = yes && _def_armv5te='#define HAVE_ARMV5TE 1'
-_def_armv6='#undef HAVE_ARMV6'
-test "$_armv6" = yes && _def_armv6='#define HAVE_ARMV6 1'
-_def_iwmmxt='#undef HAVE_IWMMXT'
-test "$_iwmmxt" = yes && _def_iwmmxt='#define HAVE_IWMMXT 1'
+_arch_all="X86 X86_32 X86_64 IA64 SPARC ARM ARMV4L POWERPC PPC ALPHA SGI_MIPS PA_RISC S390 S390X VAX GENERIC"
+_cpuexts_all="MMX MMX2 3DNOW 3DNOWEX SSE SSE2 SSSE3 FAST_CMOV CMOV ARMV5TE ARMV6 IWMMXT MLIB MMI SH4 BFIN"
+test "$_mmx" = yes && _cpuexts="MMX $_cpuexts"
+test "$_mmxext" = yes && _cpuexts="MMX2 $_cpuexts"
+test "$_3dnow" = yes && _cpuexts="3DNOW $_cpuexts"
+test "$_3dnowext" = yes && _cpuexts="3DNOWEX $_cpuexts"
+test "$_sse" = yes && _cpuexts="SSE $_cpuexts"
+test "$_sse2" = yes && _cpuexts="SSE2 $_cpuexts"
+test "$_ssse3" = yes && _cpuexts="SSSE3 $_cpuexts"
+test "$_cmov" = yes && _cpuexts="CMOV $_cpuexts"
+test "$_fast_cmov" = yes && _cpuexts="FAST_CMOV $_cpuexts"
+test "$_armv5te" = yes && _cpuexts="ARMV5TE $_cpuexts"
+test "$_armv6" = yes && _cpuexts="ARMV6 $_cpuexts"
+test "$_iwmmxt" = yes && _cpuexts="IWMMXT $_cpuexts"
# Checking kernel version...
if x86_32 && linux ; then
@@ -5143,11 +5131,7 @@
EOF
cc_check -lmlib && _mlib=yes
fi
-if test "$_mlib" = yes ; then
- _def_mlib='#define HAVE_MLIB 1'
-else
- _def_mlib='#undef HAVE_MLIB'
-fi
+test "$_mlib" = yes && _cpuexts="MLIB $_cpuexts"
echores "$_mlib"
fi #if sunos
@@ -7704,9 +7688,11 @@
#############################################################################
ff_config_enable () {
+_nprefix=$3;
+test -z "$_nprefix" && _nprefix='CONFIG'
for part in $1; do
if ` echo $2 | grep $part > /dev/null `; then
- echo "#define CONFIG_$part 1"
+ echo "#define ${_nprefix}_$part 1"
echo "#define ENABLE_$part 1"
else
echo "#define ENABLE_$part 0"
@@ -8164,25 +8150,12 @@
byte first (like Motorola and SPARC, unlike Intel and VAX). */
$_def_words_endian
-$_def_arch
-$_def_arch_x86
+`ff_config_enable "$_arch_all" "$_arch" "ARCH"`
/* For the PPC. G5 has the dcbzl when in 64bit mode but G4s and earlier do not
have the instruction. */
$_def_dcbzl
-/* libmpeg2 wants ARCH_PPC and the rest of mplayer use ARCH_POWERPC,
- * define ARCH_PPC if ARCH_POWERPC is set to cope with that.
- */
-#ifdef ARCH_POWERPC
-#define ARCH_PPC 1
-#endif
-
-/* the same issue as with ARCH_POWERPC but with ffmpeg/libavcodec */
-#ifdef ARCH_ARMV4L
-#define ARCH_ARM 1
-#endif
-
/* only gcc3 can compile mvi instructions */
$_def_gcc_mvi_support
@@ -8384,60 +8357,13 @@
$_def_gethostbyname2
/* Extension defines */
-$_def_3dnow // only define if you have 3DNOW (AMD k6-2, AMD Athlon, iDT WinChip, etc.)
-$_def_3dnowext // only define if you have 3DNOWEXT (AMD Athlon, etc.)
-$_def_mmx // only define if you have MMX (newer x86 chips, not P54C/PPro)
-$_def_mmxext // only define if you have MMX2 (Athlon/PIII/4/CelII)
-$_def_sse // only define if you have SSE (Intel Pentium III/4 or Celeron II)
-$_def_sse2 // only define if you have SSE2 (Intel Pentium 4)
-$_def_ssse3 // only define if you have SSSE3 (Intel Core 2)
-$_def_cmov // only define if you have CMOV (i686+, without VIA C3)
-$_def_fast_cmov // only define if CMOV is fast
-$_def_altivec // only define if you have Altivec (G4)
-$_def_armv5te // only define if you have Enhanced DSP Extensions (ARM)
-$_def_armv6 // only define if you have ARMv6
-$_def_iwmmxt // only define if you have XScale IWMMX (ARM)
+`ff_config_enable "$_cpuexts_all" "$_cpuexts" "HAVE"`
$_def_altivec_h // enables usage of altivec.h
$_def_mlib // Sun mediaLib, available only on solaris
$_def_vis // only define if you have VIS ( ultrasparc )
-/* lavc extensions */
-#ifdef HAVE_MMX
-#define ENABLE_MMX 1
-#else
-#define ENABLE_MMX 0
-#endif
-#ifdef ARCH_ARMV4L
-#define ENABLE_ARMV4L 1
-#else
-#define ENABLE_ARMV4L 0
-#endif
-#ifdef HAVE_MLIB
-#define ENABLE_MLIB 1
-#else
-#define ENABLE_MLIB 0
-#endif
-#ifdef ARCH_SPARC
-#define ENABLE_SPARC 1
-#else
-#define ENABLE_SPARC 0
-#endif
-#ifdef ARCH_ALPHA
-#define ENABLE_ALPHA 1
-#else
-#define ENABLE_ALPHA 0
-#endif
-#ifdef ARCH_POWERPC
-#define ENABLE_POWERPC 1
-#else
-#define ENABLE_POWERPC 0
-#endif
-#define ENABLE_MMI 0
-#define ENABLE_SH4 0
-#define ENABLE_BFIN 0
-
/* libmpeg2 uses a different feature test macro for mediaLib */
#ifdef HAVE_MLIB
#define LIBMPEG2_MLIB 1
More information about the MPlayer-dev-eng
mailing list