diff --git a/ChangeLog b/ChangeLog index f17c00f95f..c1eb18631e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2005-07-31 Manish Singh + + * acinclude.m4 + * m4macros/Makefile.am + * m4macros/detectcflags.m4: new macro: GIMP_DETECT_CFLAGS; used + to detect which of a set of compiler options a compiler supports. + + * configure.in: use the above for the altivec and -fno-strict-aliasing + flags. Also, use it to detect the presence of -mmmx and -msse, since + those are needed to compile even MMX/SSE assembly with gcc 4.0. Define + MMX/SSE_EXTRA_CFLAGS. + + * app/composite/Makefile.am: compile each of the composite flavors + into their own library, so we can use automake's per-target CFLAGS. + Use MMX/SSE/ALTIVEC_EXTRA_CFLAGS in the appropriate places. Build + libappcomposite.a out of the resulting objects. + + * app/composite/gimp-composite-3dnow.c + * app/composite/gimp-composite-altivec.c + * app/composite/gimp-composite-mmx.c + * app/composite/gimp-composite-sse.c + * app/composite/gimp-composite-sse2.c + * app/composite/gimp-composite-vis.c + * app/composite/make-installer.py: move the _init functions into + the installers, so only actually mmx/sse/etc. code gets compiled + under the appropriate CFLAGS. + + * app/composite/gimp-composite-3dnow-installer.c + * app/composite/gimp-composite-altivec-installer.c + * app/composite/gimp-composite-mmx-installer.c + * app/composite/gimp-composite-sse-installer.c + * app/composite/gimp-composite-sse2-installer.c + * app/composite/gimp-composite-vis-installer.c: regenerated. + + * app/composite/gimp-composite.c: remove useless cpu-accel.h include. + 2005-07-31 DindinX * app/dialogs/preferences-dialog.c: when the notebook page is changed diff --git a/acinclude.m4 b/acinclude.m4 index e1e6f5e118..2a1242f5b4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,3 +1,4 @@ +m4_include([m4macros/detectcflags.m4]) m4_include([m4macros/pythondev.m4]) m4_include([m4macros/gimpprint.m4]) m4_include([m4macros/alsa.m4]) diff --git a/app/composite/Makefile.am b/app/composite/Makefile.am index 34534030fb..48d4d2538f 100644 --- a/app/composite/Makefile.am +++ b/app/composite/Makefile.am @@ -4,15 +4,8 @@ libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Gimp-Composite\" \ - $(ALTIVEC_EXTRA_CFLAGS) \ @GTHREAD_CFLAGS@ -AM_CCASFLAGS = \ - -I$(top_builddir) \ - -I$(top_srcdir) \ - -I$(top_builddir)/app \ - -I$(top_srcdir)/app - INCLUDES = \ -I$(top_builddir) \ -I$(top_srcdir) \ @@ -21,29 +14,57 @@ INCLUDES = \ $(GLIB_CFLAGS) \ -I$(includedir) -noinst_LIBRARIES = libappcomposite.a +composite_libraries = \ + libcomposite3dnow.a \ + libcompositealtivec.a \ + libcompositemmx.a \ + libcompositesse.a \ + libcompositesse2.a \ + libcompositevis.a -libappcomposite_a_sources = \ +noinst_LIBRARIES = $(composite_libraries) libcomposite.a + +libcomposite3dnow_a_SOURCES = \ gimp-composite-3dnow.c \ - gimp-composite-3dnow.h \ + gimp-composite-3dnow.h + +libcompositealtivec_a_CFLAGS = $(ALTIVEC_EXTRA_CFLAGS) + +libcompositealtivec_a_SOURCES = \ gimp-composite-altivec.c \ - gimp-composite-altivec.h \ + gimp-composite-altivec.h + +libcompositemmx_a_CFLAGS = $(MMX_EXTRA_CFLAGS) + +libcompositemmx_a_SOURCES = \ + gimp-composite-mmx.c \ + gimp-composite-mmx.h + +libcompositesse_a_CFLAGS = $(SSE_EXTRA_CFLAGS) + +libcompositesse_a_SOURCES = \ + gimp-composite-sse.c \ + gimp-composite-sse.h + +libcompositesse2_a_CFLAGS = $(SSE_EXTRA_CFLAGS) + +libcompositesse2_a_SOURCES = \ + gimp-composite-sse2.c \ + gimp-composite-sse2.h + +libcompositevis_a_SOURCES = \ + gimp-composite-vis.c \ + gimp-composite-vis.h + +libcomposite_a_sources = \ gimp-composite-generic.c \ gimp-composite-generic.h \ - gimp-composite-mmx.c \ - gimp-composite-mmx.h \ - gimp-composite-sse.c \ - gimp-composite-sse.h \ - gimp-composite-sse2.c \ - gimp-composite-sse2.h \ gimp-composite-util.h \ - gimp-composite-vis.c \ - gimp-composite-vis.h \ gimp-composite-x86.h \ gimp-composite.c \ gimp-composite.h -libappcomposite_a_built_sources = \ +libcomposite_a_built_sources = \ gimp-composite-3dnow-installer.c \ gimp-composite-altivec-installer.c \ gimp-composite-generic-installer.c \ @@ -52,18 +73,34 @@ libappcomposite_a_built_sources = \ gimp-composite-sse2-installer.c \ gimp-composite-vis-installer.c -libappcomposite_a_SOURCES = \ - $(libappcomposite_a_built_sources) \ - $(libappcomposite_a_sources) +libcomposite_a_SOURCES = \ + $(libcomposite_a_built_sources) \ + $(libcomposite_a_sources) + +## This is a huge hack +libappcomposite.a: $(noinst_LIBRARIES) + -rm -f libappcomposite.a + $(AR) $(ARFLAGS) libappcomposite.a $(libcomposite_a_OBJECTS) \ + $(libcomposite3dnow_a_OBJECTS) \ + $(libcompositealtivec_a_OBJECTS) \ + $(libcompositemmx_a_OBJECTS) \ + $(libcompositesse_a_OBJECTS) \ + $(libcompositesse2_a_OBJECTS) \ + $(libcompositevis_a_OBJECTS) + $(RANLIB) libappcomposite.a + +all-local: libappcomposite.a + +clean_libs = libappcomposite.a regenerate: gimp-composite-generic.o gimp-composite-mmx.o gimp-composite-sse.o gimp-composite-sse2.o gimp-composite-3dnow.o gimp-composite-altivec.o gimp-composite-vis.o - $(srcdir)/make-installer.py -f gimp-composite-generic.o - $(srcdir)/make-installer.py -t -r 'defined(COMPILE_MMX_IS_OKAY)' -f gimp-composite-mmx.o - $(srcdir)/make-installer.py -t -r 'defined(COMPILE_SSE_IS_OKAY)' -f gimp-composite-sse.o - $(srcdir)/make-installer.py -t -r 'defined(COMPILE_SSE2_IS_OKAY)' -f gimp-composite-sse2.o - $(srcdir)/make-installer.py -t -r 'defined(COMPILE_3DNOW_IS_OKAY)' -f gimp-composite-3dnow.o - $(srcdir)/make-installer.py -t -r 'defined(COMPILE_ALTIVEC_IS_OKAY)' -f gimp-composite-altivec.o - $(srcdir)/make-installer.py -t -r 'defined(COMPILE_VIS_IS_OKAY)' -f gimp-composite-vis.o + $(srcdir)/make-installer.py -f gimp-composite-generic.o + $(srcdir)/make-installer.py -f gimp-composite-mmx.o -t -r 'defined(COMPILE_MMX_IS_OKAY)' -c 'X86_MMX' + $(srcdir)/make-installer.py -f gimp-composite-sse.o -t -r 'defined(COMPILE_SSE_IS_OKAY)' -c 'X86_SSE' -c 'X86_MMXEXT' + $(srcdir)/make-installer.py -f gimp-composite-sse2.o -t -r 'defined(COMPILE_SSE2_IS_OKAY)' -c 'X86_SSE2' + $(srcdir)/make-installer.py -f gimp-composite-3dnow.o -t -r 'defined(COMPILE_3DNOW_IS_OKAY)' -c 'X86_3DNOW' + $(srcdir)/make-installer.py -f gimp-composite-altivec.o -t -r 'defined(COMPILE_ALTIVEC_IS_OKAY)' -c 'PPC_ALTIVEC' + $(srcdir)/make-installer.py -f gimp-composite-vis.o -t -r 'defined(COMPILE_VIS_IS_OKAY)' EXTRA_DIST = \ make-installer.py \ @@ -85,7 +122,7 @@ TESTS = \ EXTRA_PROGRAMS = gimp-composite-test $(TESTS) -CLEANFILES = $(EXTRA_PROGRAMS) +CLEANFILES = $(EXTRA_PROGRAMS) $(clean_libs) gimp_composite_test_SOURCES = \ gimp-composite-regression.c \ diff --git a/app/composite/gimp-composite-3dnow-installer.c b/app/composite/gimp-composite-3dnow-installer.c index 35611e79ed..43b4cec515 100644 --- a/app/composite/gimp-composite-3dnow-installer.c +++ b/app/composite/gimp-composite-3dnow-installer.c @@ -5,6 +5,7 @@ #include #include #include "base/base-types.h" +#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-3dnow.h" @@ -17,3 +18,16 @@ gimp_composite_3dnow_install (void) return (FALSE); } + +gboolean +gimp_composite_3dnow_init (void) +{ +#if defined(COMPILE_3DNOW_IS_OKAY) + if (cpu_accel () & CPU_ACCEL_X86_3DNOW) + { + return (TRUE); + } +#endif + + return (FALSE); +} diff --git a/app/composite/gimp-composite-3dnow.c b/app/composite/gimp-composite-3dnow.c index 5dafd351a6..4d4cae2ad9 100644 --- a/app/composite/gimp-composite-3dnow.c +++ b/app/composite/gimp-composite-3dnow.c @@ -28,7 +28,6 @@ #include #include "base/base-types.h" -#include "base/cpu-accel.h" #include "gimp-composite.h" @@ -37,15 +36,3 @@ #ifdef COMPILE_3DNOW_IS_OKAY #endif - -gboolean -gimp_composite_3dnow_init (void) -{ -#ifdef COMPILE_3DNOW_IS_OKAY - if (cpu_accel () & CPU_ACCEL_X86_3DNOW) - { - return (TRUE); - } -#endif - return (FALSE); -} diff --git a/app/composite/gimp-composite-altivec-installer.c b/app/composite/gimp-composite-altivec-installer.c index 9977451dfe..b781fe6e10 100644 --- a/app/composite/gimp-composite-altivec-installer.c +++ b/app/composite/gimp-composite-altivec-installer.c @@ -50,3 +50,16 @@ gimp_composite_altivec_install (void) return (FALSE); } + +gboolean +gimp_composite_altivec_init (void) +{ +#if defined(COMPILE_ALTIVEC_IS_OKAY) + if (cpu_accel () & CPU_ACCEL_PPC_ALTIVEC) + { + return (TRUE); + } +#endif + + return (FALSE); +} diff --git a/app/composite/gimp-composite-altivec.c b/app/composite/gimp-composite-altivec.c index 5bb0acc8aa..e073796f66 100644 --- a/app/composite/gimp-composite-altivec.c +++ b/app/composite/gimp-composite-altivec.c @@ -26,7 +26,6 @@ #include #include "base/base-types.h" -#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-altivec.h" @@ -962,16 +961,3 @@ gimp_composite_dodge_rgba8_rgba8_rgba8_altivec (GimpCompositeContext *ctx) } #endif /* COMPILE_IS_OKAY */ - -gboolean -gimp_composite_altivec_init (void) -{ -#ifdef COMPILE_ALTIVEC_IS_OKAY - if (cpu_accel () & CPU_ACCEL_PPC_ALTIVEC) - { - return (TRUE); - } -#endif - - return (FALSE); -} diff --git a/app/composite/gimp-composite-mmx-installer.c b/app/composite/gimp-composite-mmx-installer.c index b366c244d2..870289ccbf 100644 --- a/app/composite/gimp-composite-mmx-installer.c +++ b/app/composite/gimp-composite-mmx-installer.c @@ -5,6 +5,7 @@ #include #include #include "base/base-types.h" +#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-mmx.h" @@ -50,3 +51,16 @@ gimp_composite_mmx_install (void) return (FALSE); } + +gboolean +gimp_composite_mmx_init (void) +{ +#if defined(COMPILE_MMX_IS_OKAY) + if (cpu_accel () & CPU_ACCEL_X86_MMX) + { + return (TRUE); + } +#endif + + return (FALSE); +} diff --git a/app/composite/gimp-composite-mmx.c b/app/composite/gimp-composite-mmx.c index 0409b6484d..19b1490dc8 100644 --- a/app/composite/gimp-composite-mmx.c +++ b/app/composite/gimp-composite-mmx.c @@ -36,7 +36,6 @@ #include #include "base/base-types.h" -#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-mmx.h" @@ -2438,15 +2437,3 @@ xxxgimp_composite_valueonly_va8_va8_va8_mmx (GimpCompositeContext *_op) #endif #endif /* COMPILE_IS_OKAY */ - -gboolean -gimp_composite_mmx_init (void) -{ -#ifdef COMPILE_MMX_IS_OKAY - if (cpu_accel () & CPU_ACCEL_X86_MMX) - { - return (TRUE); - } -#endif - return (FALSE); -} diff --git a/app/composite/gimp-composite-sse-installer.c b/app/composite/gimp-composite-sse-installer.c index e4092ca998..d5fc69fc35 100644 --- a/app/composite/gimp-composite-sse-installer.c +++ b/app/composite/gimp-composite-sse-installer.c @@ -5,6 +5,7 @@ #include #include #include "base/base-types.h" +#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-sse.h" @@ -48,3 +49,18 @@ gimp_composite_sse_install (void) return (FALSE); } + +gboolean +gimp_composite_sse_init (void) +{ +#if defined(COMPILE_SSE_IS_OKAY) + guint32 cpu = cpu_accel (); + + if (cpu & CPU_ACCEL_X86_SSE || cpu & CPU_ACCEL_X86_MMXEXT) + { + return (TRUE); + } +#endif + + return (FALSE); +} diff --git a/app/composite/gimp-composite-sse.c b/app/composite/gimp-composite-sse.c index fda4ea1961..febe052d62 100644 --- a/app/composite/gimp-composite-sse.c +++ b/app/composite/gimp-composite-sse.c @@ -36,7 +36,6 @@ #include #include "base/base-types.h" -#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-sse.h" @@ -2034,18 +2033,3 @@ xxxgimp_composite_valueonly_va8_va8_va8_sse (GimpCompositeContext *_op) #endif #endif /* COMPILE_SSE_IS_OKAY */ - -gboolean -gimp_composite_sse_init (void) -{ -#ifdef COMPILE_SSE_IS_OKAY - guint32 cpu = cpu_accel (); - - if (cpu & CPU_ACCEL_X86_SSE || cpu & CPU_ACCEL_X86_MMXEXT) - { - return (TRUE); - } -#endif - - return (FALSE); -} diff --git a/app/composite/gimp-composite-sse2-installer.c b/app/composite/gimp-composite-sse2-installer.c index 8f56d3c920..1addf242b7 100644 --- a/app/composite/gimp-composite-sse2-installer.c +++ b/app/composite/gimp-composite-sse2-installer.c @@ -5,6 +5,7 @@ #include #include #include "base/base-types.h" +#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-sse2.h" @@ -44,3 +45,16 @@ gimp_composite_sse2_install (void) return (FALSE); } + +gboolean +gimp_composite_sse2_init (void) +{ +#if defined(COMPILE_SSE2_IS_OKAY) + if (cpu_accel () & CPU_ACCEL_X86_SSE2) + { + return (TRUE); + } +#endif + + return (FALSE); +} diff --git a/app/composite/gimp-composite-sse2.c b/app/composite/gimp-composite-sse2.c index 72cf26c466..1c0a341647 100644 --- a/app/composite/gimp-composite-sse2.c +++ b/app/composite/gimp-composite-sse2.c @@ -30,7 +30,6 @@ #include #include "base/base-types.h" -#include "base/cpu-accel.h" #include "gimp-composite.h" #include "gimp-composite-sse2.h" @@ -672,17 +671,3 @@ gimp_composite_swap_rgba8_rgba8_rgba8_sse2 (GimpCompositeContext *_op) } #endif /* COMPILE_SSE2_IS_OKAY */ - -gboolean -gimp_composite_sse2_init (void) -{ -#ifdef COMPILE_SSE2_IS_OKAY - guint32 cpu = cpu_accel (); - - if (cpu & CPU_ACCEL_X86_SSE2) - { - return (TRUE); - } -#endif - return (FALSE); -} diff --git a/app/composite/gimp-composite-vis-installer.c b/app/composite/gimp-composite-vis-installer.c index 3af0fa0dc3..9afa2d3048 100644 --- a/app/composite/gimp-composite-vis-installer.c +++ b/app/composite/gimp-composite-vis-installer.c @@ -17,3 +17,13 @@ gimp_composite_vis_install (void) return (FALSE); } + +gboolean +gimp_composite_vis_init (void) +{ +#if defined(COMPILE_VIS_IS_OKAY) + return (TRUE); +#else + return (FALSE); +#endif +} diff --git a/app/composite/gimp-composite-vis.c b/app/composite/gimp-composite-vis.c index 8c75da2c56..092a956901 100644 --- a/app/composite/gimp-composite-vis.c +++ b/app/composite/gimp-composite-vis.c @@ -35,13 +35,3 @@ #ifdef COMPILE_VIS_IS_OKAY #endif - -gboolean -gimp_composite_vis_init (void) -{ -#ifdef COMPILE_VIS_IS_OKAY - return (TRUE); -#else - return (FALSE); -#endif -} diff --git a/app/composite/gimp-composite.c b/app/composite/gimp-composite.c index de473430c0..871d3ff862 100644 --- a/app/composite/gimp-composite.c +++ b/app/composite/gimp-composite.c @@ -29,7 +29,6 @@ #include #include "base/base-types.h" -#include "base/cpu-accel.h" #include "gimp-composite.h" diff --git a/app/composite/make-installer.py b/app/composite/make-installer.py index 88bd773bdb..3c4f15144d 100755 --- a/app/composite/make-installer.py +++ b/app/composite/make-installer.py @@ -435,6 +435,58 @@ def gimp_composite_installer_install2(fpout, name, function_table, requirements= print >>fpout, '}' pass +def gimp_composite_installer_install3(fpout, name, requirements=[], cpu_feature=[]): + if not requirements and not cpu_feature: + return + + print >>fpout, '' + print >>fpout, 'gboolean' + print >>fpout, '%s_init (void)' % (functionnameify(name)) + print >>fpout, '{' + + need_endif = False + + for r in requirements: + print >>fpout, '#if %s' % (r) + pass + + if cpu_feature: + if len(cpu_feature) >= 2: + features = [] + for f in cpu_feature: + features.append('cpu & CPU_ACCEL_%s' % f) + feature_test = ' || '.join(features) + + print >>fpout, ' guint32 cpu = cpu_accel ();' + print >>fpout, '' + else: + feature_test = 'cpu_accel () & CPU_ACCEL_%s' % cpu_feature[0] + + print >>fpout, ' if (%s)' % feature_test + print >>fpout, ' {' + print >>fpout, ' return (TRUE);' + print >>fpout, ' }' + + if requirements: + print >>fpout, '#endif' + print >>fpout, '' + else: + print >>fpout, ' return (TRUE);' + + if requirements: + print >>fpout, '#else' + need_endif = True + + if requirements or cpu_feature: + print >>fpout, ' return (FALSE);' + + if need_endif: + print >>fpout, '#endif' + + print >>fpout, '}' + pass + + def gimp_composite_hfile(fpout, name, function_table): print >>fpout, '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */' print >>fpout, '/* REGENERATE BY USING make-installer.py */' @@ -445,7 +497,7 @@ def gimp_composite_hfile(fpout, name, function_table): return -def gimp_composite_cfile(fpout, name, function_table, requirements=[]): +def gimp_composite_cfile(fpout, name, function_table, requirements=[], cpu_feature=[]): print >>fpout, '/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT */' print >>fpout, '/* REGENERATE BY USING make-installer.py */' print >>fpout, '#include "config.h"' @@ -453,6 +505,8 @@ def gimp_composite_cfile(fpout, name, function_table, requirements=[]): print >>fpout, '#include ' print >>fpout, '#include ' print >>fpout, '#include "base/base-types.h"' + if cpu_feature: + print >>fpout, '#include "base/cpu-accel.h"' print >>fpout, '#include "gimp-composite.h"' print >>fpout, '' print >>fpout, '#include "%s.h"' % (filenameify(name)) @@ -462,26 +516,31 @@ def gimp_composite_cfile(fpout, name, function_table, requirements=[]): gimp_composite_installer_install2(fpout, name, function_table, requirements) + gimp_composite_installer_install3(fpout, name, requirements, cpu_feature) + return ########################################### op = optparse.OptionParser(version="$Revision$") -op.add_option('-f', '--file', action='store', type='string', dest='file', default=None, +op.add_option('-f', '--file', action='store', type='string', dest='file', default=None, help='the input object file') -op.add_option('-t', '--test', action='store_true', dest='test', default=False, +op.add_option('-t', '--test', action='store_true', dest='test', default=False, help='generate regression testing code') -op.add_option('-i', '--iterations', action='store', type='int', dest='iterations', default=10, +op.add_option('-i', '--iterations', action='store', type='int', dest='iterations', default=10, help='number of iterations in regression tests') -op.add_option('-n', '--n-pixels', action='store', type="int", dest='n_pixels', default=1024*8192+16+1, +op.add_option('-n', '--n-pixels', action='store', type="int", dest='n_pixels', default=1024*8192+16+1, help='number of pixels in each regression test iteration') -op.add_option('-r', '--requires', action='append', type='string', dest='requires', default=[], +op.add_option('-r', '--requires', action='append', type='string', dest='requires', default=[], help='cpp #if conditionals') +op.add_option('-c', '--cpu-feature', action='append', type='string', dest='cpu_feature', default=[], + help='cpu_accel feature tests') + options, args = op.parse_args() table = load_function_table(options.file) -gimp_composite_cfile(open(filenameify(options.file) + "-installer.c", "w"), options.file, table, options.requires) +gimp_composite_cfile(open(filenameify(options.file) + "-installer.c", "w"), options.file, table, options.requires, options.cpu_feature) if options.test == True: gimp_composite_regression(open(filenameify(options.file) + "-test.c", "w"), table, options) diff --git a/configure.in b/configure.in index 01205f3816..424558d192 100644 --- a/configure.in +++ b/configure.in @@ -564,18 +564,27 @@ AC_ARG_ENABLE(sse, enable_sse=$enable_mmx) if test "x$enable_mmx" = xyes; then + GIMP_DETECT_CFLAGS(MMX_EXTRA_CFLAGS, '-mmmx') + SSE_EXTRA_CFLAGS= AC_MSG_CHECKING(whether we can compile MMX code) + mmx_save_CFLAGS="$CFLAGS" + CFLAGS="$mmx_save_CFLAGS $MMX_EXTRA_CFLAGS" + AC_COMPILE_IFELSE([asm ("movq 0, %mm0");], AC_DEFINE(USE_MMX, 1, [Define to 1 if MMX assembly is available.]) AC_MSG_RESULT(yes) if test "x$enable_sse" = xyes; then + GIMP_DETECT_CFLAGS(sse_flag, '-msse') + SSE_EXTRA_CFLAGS="$MMX_EXTRA_CFLAGS $sse_flag" AC_MSG_CHECKING(whether we can compile SSE code) + CFLAGS="$CFLAGS $sse_flag" + AC_COMPILE_IFELSE([asm ("movntps %xmm0, 0");], AC_DEFINE(USE_SSE, 1, [Define to 1 if SSE assembly is available.]) AC_MSG_RESULT(yes) @@ -592,6 +601,10 @@ if test "x$enable_mmx" = xyes; then AC_MSG_WARN([The assembler does not support the MMX command set.]) ) + CFLAGS="$mmx_save_CFLAGS" + + AC_SUBST(MMX_EXTRA_CFLAGS) + AC_SUBST(SSE_EXTRA_CFLAGS) fi @@ -605,20 +618,7 @@ AC_ARG_ENABLE(altivec, if test "x$enable_altivec" = xyes; then - altivec_flag= - for flag in '-faltivec' '-maltivec -mabi=altivec'; do - if test -z "$altivec_flag"; then - altivec_save_CFLAGS="$CFLAGS" - CFLAGS="$altivec_save_CFLAGS $flag" - AC_MSG_CHECKING([whether [$]CC understands [$]flag]) - AC_TRY_COMPILE([], [], [altivec_flag_works=yes], [altivec_flag_works=no]) - AC_MSG_RESULT($altivec_flag_works) - CFLAGS="$altivec_save_CFLAGS" - if test "x$altivec_flag_works" = "xyes"; then - altivec_flag="$flag" - fi - fi - done + GIMP_DETECT_CFLAGS(altivec_flag, '-faltivec' '-maltivec -mabi=altivec') ALTIVEC_EXTRA_CFLAGS= case "$altivec_flag" in @@ -1417,23 +1417,7 @@ if test "x$enable_python" != xno; then AC_SUBST(PYGTK_DEFSDIR) AC_MSG_RESULT($PYGTK_DEFSDIR) - dnl enable -fno-strict-aliasing if compiler supports it - PYGIMP_EXTRA_CFLAGS= - case " $CFLAGS " in - *@<:@\ \ @:>@-fno-strict-aliasing@<:@\ \ @:>@*) - ;; - *) - pygimp_save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fno-strict-aliasing" - AC_MSG_CHECKING([whether [$]CC understands -fno-strict-aliasing]) - AC_TRY_COMPILE([], [], [pygimp_has_option=yes], [pygimp_has_option=no]) - AC_MSG_RESULT($pygimp_has_option) - CFLAGS="$pygimp_save_CFLAGS" - if test "x$pygimp_has_option" = "xyes"; then - PYGIMP_EXTRA_CFLAGS="-fno-strict-aliasing" - fi - ;; - esac + GIMP_DETECT_CFLAGS(PYGIMP_EXTRA_CFLAGS, '-fno-strict-aliasing') AC_SUBST(PYGIMP_EXTRA_CFLAGS) fi AM_CONDITIONAL(BUILD_PYTHON, test "x$enable_python" != xno) diff --git a/m4macros/Makefile.am b/m4macros/Makefile.am index d7c0e3b47f..9538a578a3 100644 --- a/m4macros/Makefile.am +++ b/m4macros/Makefile.am @@ -2,7 +2,7 @@ installed_m4 = gimp-2.0.m4 -uinstalled_m4 = alsa.m4 gimpprint.m4 gtk-doc.m4 pythondev.m4 +uinstalled_m4 = alsa.m4 gimpprint.m4 gtk-doc.m4 pythondev.m4 detectcflags.m4 EXTRA_DIST = $(installed_m4) $(uninstalled_m4) diff --git a/m4macros/detectcflags.m4 b/m4macros/detectcflags.m4 new file mode 100644 index 0000000000..ad8a099873 --- /dev/null +++ b/m4macros/detectcflags.m4 @@ -0,0 +1,20 @@ +dnl GIMP_DETECT_CFLAGS(RESULT, FLAGSET) +dnl Detect if the compiler supports a set of flags + +AC_DEFUN([GIMP_DETECT_CFLAGS], +[ + $1= + for flag in $2; do + if test -z "[$]$1"; then + $1_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $flag" + AC_MSG_CHECKING([whether [$]CC understands [$]flag]) + AC_TRY_COMPILE([], [], [$1_works=yes], [$1_works=no]) + AC_MSG_RESULT([$]$1_works) + CFLAGS="[$]$1_save_CFLAGS" + if test "x[$]$1_works" = "xyes"; then + $1="$flag" + fi + fi + done +])