[Mesa-dev] [PATCH v3] mesa: Optionally build a dricore support library (v3)

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Wed Feb 2 16:19:32 PST 2011


This an adds --enable-shared-dricore option to configure.  When enabled,
DRI modules will link against a shared copy of the common mesa routines
rather than statically linking these.

This saves about 30MB on disc with a full complement of classic DRI
drivers.

v2: Only enable with a gcc-compatible compiler that handles rpath
    Handle DRI_CFLAGS without filter-out magic
    Build shared libraries with the full mklib voodoo
    Fix typos
v3: Resolve conflicts with talloc removal patches

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
---
 configs/autoconf.in                    |   14 ++++++--
 configs/default                        |    3 ++
 configs/freebsd-dri                    |    4 ++-
 configs/linux-dri                      |    4 ++-
 configs/linux-dri-xcb                  |    4 ++-
 configs/linux-egl                      |    4 ++-
 configs/linux-indirect                 |    3 +-
 configure.ac                           |   59 ++++++++++++++++++++++++++++---
 src/glsl/Makefile                      |   34 +++++++++++++++++--
 src/mesa/Makefile                      |   52 +++++++++++++++++++++++----
 src/mesa/drivers/dri/Makefile.template |   12 +++----
 src/mesa/x86/read_rgba_span_x86.S      |    8 ++++
 12 files changed, 169 insertions(+), 32 deletions(-)

diff --git a/configs/autoconf.in b/configs/autoconf.in
index b7137a0..e8193d7 100644
--- a/configs/autoconf.in
+++ b/configs/autoconf.in
@@ -16,10 +16,12 @@ PIC_FLAGS = @PIC_FLAGS@
 DEFINES = @DEFINES@
 API_DEFINES = @API_DEFINES@
 SHARED_GLAPI = @SHARED_GLAPI@
-CFLAGS = @CPPFLAGS@ @CFLAGS@ \
+CFLAGS_NOVISIBILITY = @CPPFLAGS@ @CFLAGS@ \
 	$(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
-CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ \
+CXXFLAGS_NOVISIBILITY = @CPPFLAGS@ @CXXFLAGS@ \
 	$(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+CFLAGS = $(CFLAGS_NOVISIBILITY) @VISIBILITY_CFLAGS@
+CXXFLAGS = $(CXXFLAGS_NOVISIBILITY) @VISIBILITY_CXXFLAGS@
 LDFLAGS = @LDFLAGS@
 EXTRA_LIB_PATH = @EXTRA_LIB_PATH@
 RADEON_CFLAGS = @RADEON_CFLAGS@
@@ -34,6 +36,8 @@ LLVM_LIBS = @LLVM_LIBS@
 GLW_CFLAGS = @GLW_CFLAGS@
 GLUT_CFLAGS = @GLUT_CFLAGS@
 GLX_TLS = @GLX_TLS@
+DRI_CFLAGS = @DRI_CFLAGS@
+DRI_CXXFLAGS = @DRI_CXXFLAGS@
 
 # dlopen
 DLOPEN_LIBS = @DLOPEN_LIBS@
@@ -104,7 +108,10 @@ GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
 
 # Driver specific build vars
-DRI_DIRS = @DRI_DIRS@ 
+DRI_DIRS = @DRI_DIRS@
+DRICORE_GLSL_LIBS = @DRICORE_GLSL_LIBS@
+DRICORE_LIBS = @DRICORE_LIBS@
+DRICORE_LIB_DEPS = @DRICORE_LIB_DEPS@
 EGL_PLATFORMS = @EGL_PLATFORMS@
 EGL_CLIENT_APIS = @EGL_CLIENT_APIS@
 
@@ -133,6 +140,7 @@ VG_LIB_DEPS = $(EXTRA_LIB_PATH) @VG_LIB_DEPS@
 GLAPI_LIB_DEPS = $(EXTRA_LIB_PATH) @GLAPI_LIB_DEPS@
 
 # DRI dependencies
+MESA_MODULES = @MESA_MODULES@
 DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@
 LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
 LIBDRM_LIB = @LIBDRM_LIBS@
diff --git a/configs/default b/configs/default
index b05e9ff..98cd437 100644
--- a/configs/default
+++ b/configs/default
@@ -86,6 +86,9 @@ GLESv2_LIB_GLOB = $(GLESv2_LIB_NAME)*
 VG_LIB_GLOB = $(VG_LIB_NAME)*
 GLAPI_LIB_GLOB = $(GLAPI_LIB_NAME)*
 
+DRI_CFLAGS = $(CFLAGS)
+DRI_CXXFLAGS = $(CXXFLAGS)
+
 # Optional assembly language optimization files for libGL
 MESA_ASM_SOURCES = 
 
diff --git a/configs/freebsd-dri b/configs/freebsd-dri
index a4aa82e..23cf58a 100644
--- a/configs/freebsd-dri
+++ b/configs/freebsd-dri
@@ -30,9 +30,11 @@ ASM_SOURCES =
 MESA_ASM_SOURCES = 
 
 # Library/program dependencies
+MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
+
 LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
 LIBDRM_LIB = `pkg-config --libs libdrm`
-DRI_LIB_DEPS = -L/usr/local/lib -lm -pthread -lexpat $(LIBDRM_LIB)
+DRI_LIB_DEPS = $(MESA_MODULES) -L/usr/local/lib -lm -pthread -lexpat $(LIBDRM_LIB)
 GL_LIB_DEPS = -L/usr/local/lib -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
 	-lm -pthread $(LIBDRM_LIB)
 
diff --git a/configs/linux-dri b/configs/linux-dri
index 1c94ed0..22190bf 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -43,9 +43,11 @@ MESA_ASM_SOURCES =
 # Library/program dependencies
 EXTRA_LIB_PATH=-L/usr/X11R6/lib
 
+MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
+
 LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
 LIBDRM_LIB = $(shell pkg-config --libs libdrm)
-DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
+DRI_LIB_DEPS  = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
 		-lm -lpthread -ldl $(LIBDRM_LIB)
 
diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb
index 8092a04..7518080 100644
--- a/configs/linux-dri-xcb
+++ b/configs/linux-dri-xcb
@@ -41,9 +41,11 @@ MESA_ASM_SOURCES =
 # Library/program dependencies
 EXTRA_LIB_PATH=$(shell pkg-config --libs-only-L x11)
 
+MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
+
 LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
 LIBDRM_LIB = $(shell pkg-config --libs libdrm)
-DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
+DRI_LIB_DEPS  = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \
                 $(LIBDRM_LIB) $(shell pkg-config --libs xcb) $(shell pkg-config --libs x11-xcb) $(shell pkg-config --libs xcb-glx)
 
diff --git a/configs/linux-egl b/configs/linux-egl
index 6393e94..216bcba 100644
--- a/configs/linux-egl
+++ b/configs/linux-egl
@@ -38,9 +38,11 @@ MESA_ASM_SOURCES =
 # Library/program dependencies
 EXTRA_LIB_PATH=-L/usr/X11R6/lib
 
+MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
+
 LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
 LIBDRM_LIB = $(shell pkg-config --libs libdrm)
-DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
+DRI_LIB_DEPS  = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
 		-lm -lpthread -ldl \
                 $(LIBDRM_LIB)
diff --git a/configs/linux-indirect b/configs/linux-indirect
index 272d34e..507382a 100644
--- a/configs/linux-indirect
+++ b/configs/linux-indirect
@@ -42,7 +42,8 @@ MESA_ASM_SOURCES =
 # Library/program dependencies
 EXTRA_LIB_PATH=-L/usr/X11R6/lib
 
-DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl
+MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
+DRI_LIB_DEPS  = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl
 
 
diff --git a/configure.ac b/configure.ac
index 46938f4..a84e2ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,9 +151,13 @@ if test "x$GCC" = xyes; then
     # Enable -fvisibility=hidden if using a gcc that supports it
     save_CFLAGS="$CFLAGS"
     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
-    CFLAGS="$CFLAGS -fvisibility=hidden"
+    VISIBILITY_CFLAGS="-fvisibility=hidden"
+    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
-		   [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]);
+		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
+
+    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
+    CFLAGS=$save_CFLAGS
 
     # Work around aliasing bugs - developers should comment this out
     CFLAGS="$CFLAGS -fno-strict-aliasing"
@@ -164,14 +168,21 @@ if test "x$GXX" = xyes; then
     # Enable -fvisibility=hidden if using a gcc that supports it
     save_CXXFLAGS="$CXXFLAGS"
     AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
-    CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
+    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
+    CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
-		   [CXXFLAGS="$save_CXXFLAGS" ; AC_MSG_RESULT([no])]);
+		   [VISIBILITY_CXXFLAGS="" ; AC_MSG_RESULT([no])]);
+
+    # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
+    CXXFLAGS=$save_CXXFLAGS
 
     # Work around aliasing bugs - developers should comment this out
     CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
 fi
 
+AC_SUBST([VISIBILITY_CFLAGS])
+AC_SUBST([VISIBILITY_CXXFLAGS])
+
 dnl These should be unnecessary, but let the user set them if they want
 AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
     Default is to use CFLAGS.])
@@ -815,6 +826,41 @@ AC_SUBST([GLESv2_PC_LIB_PRIV])
 GLAPI_LIB_DEPS="-lpthread"
 AC_SUBST([GLAPI_LIB_DEPS])
 
+
+dnl Setup default DRI CFLAGS
+DRI_CFLAGS='$(CFLAGS)'
+DRI_CXXFLAGS='$(CXXFLAGS)'
+DRI_LIB_DEPS='$(TOP)/src/mesa/libmesa.a'
+MESA_MODULES='$(TOP)/src/mesa/libmesa.a'
+
+AC_ARG_ENABLE([shared-dricore],
+    [AS_HELP_STRING([--enable-shared-dricore],
+        [link DRI modules with shared core DRI routines @<:@default=disabled@:>@])],
+    [enable_dricore="$enableval"],
+    [enable_dricore=no])
+if test "$mesa_driver" = dri ; then
+   if test "$enable_dricore" = yes ; then
+      if test "$GCC$GXX" != yesyes ; then
+      	 AC_MSG_WARN([Shared dricore requires GCC-compatible rpath handling.  Disabling shared dricore])
+	 enable_dricore=no
+      else
+	 DRICORE_GLSL_LIBS='$(TOP)/$(LIB_DIR)/libglsl.so'
+	 DRICORE_LIBS='$(TOP)/$(LIB_DIR)/libdricore.so'
+	 DRICORE_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -lglsl'
+      	 DRI_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -ldricore -lglsl'
+      	 DRI_CFLAGS='$(CFLAGS_NOVISIBILITY) -DUSE_DRICORE'
+      	 DRI_CXXFLAGS='$(CXXFLAGS_NOVISIBILITY) -DUSE_DRICORE'
+      	 MESA_MODULES='$(DRICORE_LIBS) $(DRICORE_GLSL_LIBS)'
+      fi
+   fi
+fi
+AC_SUBST([DRICORE_LIBS])
+AC_SUBST([DRICORE_GLSL_LIBS])
+AC_SUBST([DRICORE_LIB_DEPS])
+AC_SUBST([DRI_CXXFLAGS])
+AC_SUBST([DRI_CFLAGS])
+AC_SUBST([MESA_MODULES])
+
 AC_SUBST([HAVE_XF86VIDMODE])
 
 PKG_CHECK_MODULES([LIBDRM_RADEON],
@@ -985,8 +1031,8 @@ if test "$mesa_driver" = dri -o "$mesa_driver" = no; then
             [AC_MSG_ERROR([Expat required for DRI.])])
     fi
 
-    # put all the necessary libs together
-    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
+    # put all the necessary libs together, including possibly libdricore
+    DRI_LIB_DEPS="$DRI_LIB_DEPS $SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
 fi
 AC_SUBST([DRI_DIRS])
 AC_SUBST([EXPAT_INCLUDES])
@@ -1785,6 +1831,7 @@ if test "$mesa_driver" != no; then
         fi
         echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
         echo "        Use XCB:         $enable_xcb"
+        echo "        Shared dricore:  $enable_dricore"
     fi
 fi
 echo ""
diff --git a/src/glsl/Makefile b/src/glsl/Makefile
index 4f30742..04509fe 100644
--- a/src/glsl/Makefile
+++ b/src/glsl/Makefile
@@ -1,3 +1,4 @@
+
 #src/glsl/pp/Makefile
 
 TOP = ../..
@@ -111,6 +112,9 @@ OBJECTS = \
 	$(C_SOURCES:.c=.o) \
 	$(CXX_SOURCES:.cpp=.o)
 
+DRICORE_OBJ_DIR = obj-visible
+OBJECTS_DRICORE = $(addprefix $(DRICORE_OBJ_DIR)/,$(OBJECTS))
+
 INCLUDES = \
 	-I. \
 	-I../mesa \
@@ -126,7 +130,13 @@ ALL_SOURCES = \
 
 ##### TARGETS #####
 
-default: depend lib$(LIBNAME).a $(APPS)
+default: depend lib$(LIBNAME).a $(APPS) $(DRICORE_GLSL_LIBS)
+
+$(TOP)/$(LIB_DIR)/libglsl.so: $(OBJECTS_DRICORE) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
+	$(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
+		-cplusplus -noprefix \
+		-install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/$@.dylib \
+		$(OBJECTS_DRICORE) builtin_function.o
 
 lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
 	$(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o
@@ -137,14 +147,24 @@ depend: $(ALL_SOURCES) Makefile
 	$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
 
 # Remove .o and backup files
-clean:
+clean: clean-dricore
 	rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler
 	-rm -f $(APPS)
 
+clean-dricore:
+	-rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so
+
+ifneq (,$(DRICORE_GLSL_LIBS))
+DRICORE_INSTALL_TARGET = install-dricore
+endif
+
 # Dummy target
-install:
+install: $(DRICORE_INSTALL_TARGET)
 	@echo -n ""
 
+install-dricore: default
+	$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+	$(INSTALL) -m 755 $(DRICORE_GLSL_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
 
 ##### RULES #####
 
@@ -160,6 +180,14 @@ glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a
 .c.o:
 	$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
 
+$(DRICORE_OBJ_DIR)/%.o : %.cpp
+	@mkdir -p $(dir $@)
+	$(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DEFINES) $< -o $@
+
+$(DRICORE_OBJ_DIR)/%.o : %.c
+	@mkdir -p $(dir $@)
+	$(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DEFINES) $< -o $@
+
 glsl_lexer.cpp: glsl_lexer.lpp
 	flex --nounistd -o$@  $<
 
diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index a6025e9..48f79a5 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -7,7 +7,7 @@ MESA_LIBS := libmesa.a libmesagallium.a
 DEPENDS := depend
 
 MESA_OBJ_DIR := .
-
+DRICORE_OBJ_DIR := objs-dricore
 
 include sources.mak
 
@@ -15,27 +15,35 @@ include sources.mak
 MESA_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_OBJECTS))
 MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
 
+DRICORE_OBJECTS := $(addprefix $(DRICORE_OBJ_DIR)/, $(MESA_OBJECTS))
+
 # define preprocessor flags
 MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES)
 
 # append include dirs
 MESA_CPPFLAGS += $(INCLUDE_DIRS)
 
+DRICORE_CPPFLAGS = $(MESA_CPPFLAGS)
+
 # tidy compiler flags
 CFLAGS := $(filter-out $(DEFINES), $(CFLAGS))
 CXXFLAGS := $(filter-out $(DEFINES), $(CXXFLAGS))
 
 # LLVM is needed for the state tracker
-MESA_CFLAGS := $(LLVM_CFLAGS)
+MESA_CFLAGS := $(LLVM_CFLAGS) $(CFLAGS)
+DRICORE_CFLAGS := $(LLVM_CFLAGS) $(DRI_CFLAGS)
+
+MESA_CXXFLAGS := $(LLVM_CFLAGS) $(CXXFLAGS)
+DRICORE_CXXFLAGS := $(LLVM_CFLAGS) $(DRI_CXXFLAGS)
 
 define mesa-cc-c
 	@mkdir -p $(dir $@)
-	$(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_CFLAGS) $(CFLAGS)
+	$(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_CFLAGS)
 endef
 
 define mesa-cxx-c
 	@mkdir -p $(dir $@)
-	$(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_CFLAGS) $(CXXFLAGS)
+	$(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_CFLAGS) $($(1)_CXXFLAGS)
 endef
 
 $(MESA_OBJ_DIR)/%.o: %.c
@@ -47,9 +55,18 @@ $(MESA_OBJ_DIR)/%.o: %.cpp
 $(MESA_OBJ_DIR)/%.o: %.S
 	$(call mesa-cc-c,MESA)
 
+$(DRICORE_OBJ_DIR)/%.o: %.c
+	$(call mesa-cc-c,DRICORE)
+
+$(DRICORE_OBJ_DIR)/%.o: %.cpp
+	$(call mesa-cxx-c,DRICORE)
+
+$(DRICORE_OBJ_DIR)/%.o: %.S
+	$(call mesa-cc-c,DRICORE)
+
 # Default: build dependencies, then asm_subdirs, GLSL built-in lib,
 # then convenience libs (.a) and finally the device drivers:
-default: $(DEPENDS) asm_subdirs $(MESA_LIBS) driver_subdirs
+default: $(DEPENDS) asm_subdirs $(MESA_LIBS) $(DRICORE_LIBS) driver_subdirs
 
 main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
 	$(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES1.1 > $@
@@ -64,13 +81,20 @@ main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py m
 libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS)
 	@ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS)
 
+# Shared dricore library for classic DRI drivers
+$(TOP)/$(LIB_DIR)/libdricore.so: $(DRICORE_OBJECTS) $(DRICORE_GLSL_LIBS)
+	@$(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
+		-cplusplus -noprefix \
+		-install $(TOP)/$(LIB_DIR) -id $(DRI_DRIVER_INSTALL_DIR)/$@.dylib \
+		$(DRICORE_LIB_DEPS) $(DRICORE_OBJECTS)
+
 # Make archive of subset of core mesa object files for gallium
 libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
 	@ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
 
 ######################################################################
 # Device drivers
-driver_subdirs: $(MESA_LIBS)
+driver_subdirs: $(MESA_LIBS) $(DRICORE_LIBS)
 	@ (cd drivers && $(MAKE))
 
 
@@ -102,9 +126,12 @@ depend: $(ALL_SOURCES)
 new_install:
 	(cd drivers && $(MAKE) install)
 
+ifneq (,$(DRICORE_LIBS))
+DRICORE_INSTALL_TARGET = install-dricore
+endif
 
 # XXX replace this with new_install above someday
-install: default
+install: default $(DRICORE_INSTALL_TARGET)
 	@for driver in $(DRIVER_DIRS) ; do \
 	  case "$$driver" in \
 	    osmesa) if [ "$(DRIVER_DIRS)" = osmesa ]; then \
@@ -166,13 +193,22 @@ install-osmesa: default osmesa.pc
 install-dri: default
 	cd drivers/dri && $(MAKE) install
 
+# We don't need MINSTALL here because we're not installing symbolic links
+install-dricore: default
+	$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+	$(INSTALL) -m 755 $(DRICORE_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
 
 
 # Emacs tags
 tags:
 	etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
 
-clean:
+clean-dricore:
+	-rm -f libdricore.so
+	-rm -f $(DRICORE_LIBS)
+	-rm -rf $(DRICORE_OBJ_DIR)
+
+clean: clean-dricore
 	-rm -f */*.o
 	-rm -f */*/*.o
 	-rm -f depend depend.bak libmesa.a libmesagallium.a
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
index 4ecddbc..6ba4431 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -1,7 +1,5 @@
 # -*-makefile-*-
 
-MESA_MODULES = $(TOP)/src/mesa/libmesa.a
-
 COMMON_GALLIUM_SOURCES = \
         ../common/utils.c \
         ../common/vblank.c \
@@ -39,13 +37,13 @@ CXXFLAGS += $(API_DEFINES)
 ##### RULES #####
 
 .c.o:
-	$(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
+	$(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DRIVER_DEFINES) $< -o $@
 
 .cpp.o:
-	$(CC) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
+	$(CC) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
 
 .S.o:
-	$(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
+	$(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DRIVER_DEFINES) $< -o $@
 
 
 ##### TARGETS #####
@@ -57,10 +55,10 @@ default: subdirs lib
 lib: symlinks subdirs depend
 	@$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
 
-$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \
+$(LIBNAME): $(OBJECTS) $(EXTRA_MODULES) $(MESA_MODULES) Makefile \
 		$(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o
 	$(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
-		$(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS)
+		$(OBJECTS) $(EXTRA_MODULES) $(DRI_LIB_DEPS)
 	$(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS)
 	@rm -f $@.test
 	mv -f $@.tmp $@
diff --git a/src/mesa/x86/read_rgba_span_x86.S b/src/mesa/x86/read_rgba_span_x86.S
index 8177299..3be4515 100644
--- a/src/mesa/x86/read_rgba_span_x86.S
+++ b/src/mesa/x86/read_rgba_span_x86.S
@@ -77,7 +77,9 @@
  */
 
 .globl _generic_read_RGBA_span_BGRA8888_REV_MMX
+#ifndef USE_DRICORE
 .hidden _generic_read_RGBA_span_BGRA8888_REV_MMX
+#endif
 	.type	_generic_read_RGBA_span_BGRA8888_REV_MMX, @function
 _generic_read_RGBA_span_BGRA8888_REV_MMX:
 	pushl	%ebx
@@ -172,7 +174,9 @@ _generic_read_RGBA_span_BGRA8888_REV_MMX:
  */
 
 .globl _generic_read_RGBA_span_BGRA8888_REV_SSE
+#ifndef USE_DRICORE
 .hidden _generic_read_RGBA_span_BGRA8888_REV_SSE
+#endif
 	.type	_generic_read_RGBA_span_BGRA8888_REV_SSE, @function
 _generic_read_RGBA_span_BGRA8888_REV_SSE:
 	pushl	%esi
@@ -335,7 +339,9 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE:
 
 	.text
 .globl _generic_read_RGBA_span_BGRA8888_REV_SSE2
+#ifndef USE_DRICORE
 .hidden _generic_read_RGBA_span_BGRA8888_REV_SSE2
+#endif
 	.type	_generic_read_RGBA_span_BGRA8888_REV_SSE2, @function
 _generic_read_RGBA_span_BGRA8888_REV_SSE2:
 	pushl	%esi
@@ -494,7 +500,9 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE2:
 
 	.text
 	.globl	_generic_read_RGBA_span_RGB565_MMX
+#ifndef USE_DRICORE
         .hidden _generic_read_RGBA_span_RGB565_MMX
+#endif
 	.type	_generic_read_RGBA_span_RGB565_MMX, @function
 
 _generic_read_RGBA_span_RGB565_MMX:
-- 
1.7.2.3



More information about the mesa-dev mailing list