llvmpipe: add initial autoconf support.
authorDave Airlie <airlied@redhat.com>
Thu, 22 Apr 2010 04:59:29 +0000 (14:59 +1000)
committerDave Airlie <airlied@redhat.com>
Sat, 24 Apr 2010 08:55:50 +0000 (18:55 +1000)
allows the swrastg_dri.so to be built with llvmpipe, also links llvm
to all dri drivers

use --enable-gallium-llvm to use it.

Signed-off-by: Dave Airlie <airlied@redhat.com>
configs/autoconf.in
configure.ac
src/gallium/Makefile.template
src/gallium/drivers/llvmpipe/Makefile
src/gallium/targets/Makefile.dri

index b6cc9b3b73edda9449e7bbf9969947e3889c3c01..3ef385a8a66189da419142c05feab6c16c34fed5 100644 (file)
@@ -26,6 +26,10 @@ INTEL_LIBS = @INTEL_LIBS@
 INTEL_CFLAGS = @INTEL_CFLAGS@
 X11_LIBS = @X11_LIBS@
 X11_CFLAGS = @X11_CFLAGS@
+LLVM_CFLAGS = @LLVM_CFLAGS@
+LLVM_LDFLAGS = @LLVM_LDFLAGS@
+LLVM_LIBS = @LLVM_LIBS@
+
 
 # Assembler
 MESA_ASM_SOURCES = @MESA_ASM_SOURCES@
@@ -157,3 +161,11 @@ OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@
 
 EGL_DRI2_CFLAGS = @EGL_DRI2_CFLAGS@
 EGL_DRI2_LIBS = @EGL_DRI2_LIBS@
+
+MESA_LLVM = @MESA_LLVM@
+
+LLVM_VERSION = @LLVM_VERSION@
+ifneq ($(LLVM_VERSION),)
+  HAVE_LLVM := 0x0$(subst .,0,$(LLVM_VERSION:svn=))
+  DEFINES += -DHAVE_LLVM=$(HAVE_LLVM)
+endif
index 0e777074339b930b909b38837c10de505a5011f7..bcf4104515e5f96e83f510704e395ce3a499a790 100644 (file)
@@ -488,6 +488,7 @@ AC_SUBST([GALLIUM_TARGET_DIRS])
 AC_SUBST([GALLIUM_WINSYS_DIRS])
 AC_SUBST([GALLIUM_DRIVERS_DIRS])
 AC_SUBST([GALLIUM_STATE_TRACKERS_DIRS])
+AC_SUBST([MESA_LLVM])
 
 dnl
 dnl User supplied program configuration
@@ -1181,8 +1182,26 @@ AC_ARG_ENABLE([gallium],
     [enable_gallium=yes])
 if test "x$enable_gallium" = xyes; then
     SRC_DIRS="$SRC_DIRS gallium gallium/winsys gallium/targets"
+    AC_CHECK_HEADER([udis86.h], [HAS_UDIS86="yes"],
+                [HAS_UDIS86="no"])
+    AC_PATH_PROG([LLVM_CONFIG], [llvm-config], [no])
+    if test "x$LLVM_CONFIG" != xno; then
+       LLVM_VERSION=`$LLVM_CONFIG --version`
+       LLVM_CFLAGS=`$LLVM_CONFIG --cflags`
+       LLVM_LIBS="`$LLVM_CONFIG --libs jit interpreter nativecodegen bitwriter` -lstdc++"
+
+       if test "x$HAS_UDIS86" != xno; then
+               LLVM_LIBS="$LLVM_LIBS -ludis86"
+       fi
+       LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
+    fi
 fi
 
+AC_SUBST([LLVM_CFLAGS])
+AC_SUBST([LLVM_LIBS])
+AC_SUBST([LLVM_LDFLAGS])
+AC_SUBST([LLVM_VERSION])
+
 dnl
 dnl Gallium state trackers configuration
 dnl
@@ -1316,6 +1335,29 @@ AC_ARG_WITH([max-height],
            [AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
 )
 
+dnl
+dnl Gallium LLVM
+dnl
+AC_ARG_ENABLE([gallium-llvm],
+    [AS_HELP_STRING([--enable-gallium-llvm],
+        [build gallium LLVM support @<:@default=disabled@:>@])],
+    [enable_gallium_llvm="$enableval"],
+    [enable_gallium_llvm=auto])
+if test "x$enable_gallium_llvm" = xyes; then
+       if test "x$LLVM_CONFIG" != xno; then
+               GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS llvmpipe"
+               DEFINES="$DEFINES -DMESA_LLVM -D__STDC_CONSTANT_MACROS"
+               if test "x$HAS_UDIS86" != xno; then
+                       DEFINES="$DEFINES -DHAVE_UDIS86"
+               fi
+               MESA_LLVM=1
+       else
+               MESA_LLVM=0
+       fi
+else
+       MESA_LLVM=0
+fi
+
 dnl
 dnl Gallium helper functions
 dnl
index b5a9938c74093637d272f2e277a592f36f9213f3..1ba0724949a71dd7aed1a5be758e676f881ae65e 100644 (file)
@@ -37,7 +37,7 @@ depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURC
        $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null
 
 $(PROGS): % : %.o
-       $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group  $(LIBS) -Wl,--end-group
+       $(LD) $(LDFLAGS) $(filter %.o,$^) -o $@ -Wl,--start-group  $(LIBS) -Wl,--end-group
 
 # Emacs tags
 tags:
index 4a3fc036c490fc768c84d548b8e6932cd93b5773..7bf5b09762865b820b7221c8f6165cba0cab5214 100644 (file)
@@ -58,8 +58,9 @@ include ../../Makefile.template
 lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_pack.py ../../auxiliary/util/u_format.csv
        python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
 
-
-LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium libllvmpipe.a
+LDFLAGS += $(LLVM_LDFLAGS)
+LIBS += $(GL_LIB_DEPS) -L../../auxiliary/ -lgallium libllvmpipe.a $(LLVM_LIBS)
+LD=g++
 
 $(PROGS): lp_test_main.o libllvmpipe.a
 
index 8efbf4e828c68ce535b5c20467a027765abe0542..3cbaf615e2f7b299fb0e3ad87d3d25700fdf2566 100644 (file)
@@ -1,5 +1,14 @@
 # -*-makefile-*-
 
+ifeq ($(MESA_LLVM),1)
+DRIVER_DEFINES += -DGALLIUM_LLVMPIPE
+PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+LDFLAGS += $(LLVM_LDFLAGS)
+LD = g++
+DRIVER_EXTRAS = $(LLVM_LIBS)
+USE_CXX=1
+endif
+
 MESA_MODULES = \
        $(TOP)/src/mesa/libmesagallium.a \
        $(GALLIUM_AUXILIARIES)
@@ -69,7 +78,11 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
                $(OBJECTS) $(PIPE_DRIVERS) \
                 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
                  $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
-       $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
+       if [ "x${USE_CXX}" == "x" ]; then \
+               $(CC) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \
+       else \
+               $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS); \
+       fi
        @rm -f $@.test
        mv -f $@.tmp $@