[Mesa-dev] [PATCH 3/4] build: Factor out common gallium code into libgallium.so mirroring libdricore.

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Fri Aug 26 01:03:22 PDT 2011


This is enabled iff libdricore is enabled.

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
---

This could also be folded into libdricore, if that's considered more appropriate.

 configs/autoconf.in              |    3 +++
 configure.ac                     |    8 +++++++-
 src/gallium/Makefile.template    |   10 +++++-----
 src/gallium/auxiliary/Makefile   |    9 +++++++++
 src/gallium/targets/Makefile.dri |    9 +++++----
 src/mesa/Makefile                |   10 +++++++++-
 6 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/configs/autoconf.in b/configs/autoconf.in
index 406e339..271d4a0 100644
--- a/configs/autoconf.in
+++ b/configs/autoconf.in
@@ -121,6 +121,9 @@ DRI_DIRS = @DRI_DIRS@
 BUILD_DRICORE_GLSL_LIBS = @BUILD_DRICORE_GLSL_LIBS@
 DRICORE_LIBS = @DRICORE_LIBS@
 DRICORE_LIB_DEPS = @DRICORE_LIB_DEPS@
+BUILD_GALLIUMCORE_LIBS = @BUILD_GALLIUMCORE_LIBS@
+GALLIUM_LIBS = @GALLIUM_LIBS@
+GALLIUM_LIB_DEPS = @GALLIUM_LIB_DEPS@
 EGL_PLATFORMS = @EGL_PLATFORMS@
 EGL_CLIENT_APIS = @EGL_CLIENT_APIS@
 
diff --git a/configure.ac b/configure.ac
index 8033f47..812bc8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1032,12 +1032,12 @@ 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'
+GALLIUM_LIB_DEPS='$(TOP)/src/mesa/libmesagallium.a $(TOP)/src/gallium/auxiliary/libgallium.a'
 
 AC_ARG_ENABLE([shared-dricore],
     [AS_HELP_STRING([--enable-shared-dricore],
@@ -1053,6 +1053,9 @@ if test "x$enable_dri" = xyes ; then
 	 BUILD_DRICORE_GLSL_LIBS='libglslcore.a'
 	 DRICORE_LIBS='$(TOP)/$(LIB_DIR)/libdricore.so'
       	 DRI_LIB_DEPS='-L$(TOP)/$(LIB_DIR) -Wl,-R$(DRI_DRIVER_INSTALL_DIR) -ldricore'
+	 BUILD_GALLIUMCORE_LIBS='$(TOP)/src/mesa/libgalliumcore.a'
+	 GALLIUM_LIBS='$(TOP)/$(LIB_DIR)/libgallium.so'
+	 GALLIUM_LIB_DEPS='-lgallium'
       	 DRI_CFLAGS='$(CFLAGS_NOVISIBILITY) -DUSE_DRICORE'
       	 DRI_CXXFLAGS='$(CXXFLAGS_NOVISIBILITY) -DUSE_DRICORE'
       	 MESA_MODULES='$(DRICORE_LIBS)'
@@ -1061,6 +1064,9 @@ if test "x$enable_dri" = xyes ; then
 fi
 AC_SUBST([BUILD_DRICORE_GLSL_LIBS])
 AC_SUBST([DRICORE_LIBS])
+AC_SUBST([BUILD_GALLIUMCORE_LIBS])
+AC_SUBST([GALLIUM_LIBS])
+AC_SUBST([GALLIUM_LIB_DEPS])
 AC_SUBST([DRI_CXXFLAGS])
 AC_SUBST([DRI_CFLAGS])
 AC_SUBST([MESA_MODULES])
diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template
index 036c119..3f01d08 100644
--- a/src/gallium/Makefile.template
+++ b/src/gallium/Makefile.template
@@ -30,7 +30,7 @@ endif
 
 ##### TARGETS #####
 
-default: depend lib$(LIBNAME).a $(PROGS)
+default:: depend lib$(LIBNAME).a $(PROGS)
 
 lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
 	$(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS)
@@ -58,16 +58,16 @@ install:
 ##### RULES #####
 
 %.s: %.c
-	$(CC) -S $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+	$(CC) -S $(INCLUDES) $(DRI_CFLAGS) $(LIBRARY_DEFINES) $< -o $@
 
 %.o: %.c
-	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
+	$(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(LIBRARY_DEFINES) $< -o $@
 
 %.o: %.cpp
-	$(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
+	$(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
 
 %.o: %.S
-	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES)  $< -o $@
+	$(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(LIBRARY_DEFINES)  $< -o $@
 
 
 sinclude depend
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 896c058..e1ddc49 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -18,6 +18,13 @@ endif
 
 include ../Makefile.template
 
+# Shared gallium library for DRI drivers
+$(TOP)/$(LIB_DIR)/libgallium.so: $(OBJECTS) $(EXTRA_OBJECTS)
+	@$(MKLIB) -o $(notdir $@) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
+		-cplusplus -noprefix \
+		-install $(TOP)/$(LIB_DIR) -id $(DRI_DRIVER_INSTALL_DIR)/$@.dylib \
+		-whole-archive $(BUILD_GALLIUMCORE_LIBS) -no-whole-archive \
+		$(OBJECTS) $(EXTRA_OBJECTS)
 
 indices/u_indices_gen.c: indices/u_indices_gen.py
 	$(PYTHON2) $< > $@
@@ -34,3 +41,5 @@ util/u_format_table.c: util/u_format_table.py util/u_format_pack.py util/u_forma
 util/u_half.c: util/u_half.py
 	$(PYTHON2) util/u_half.py > $@
 # DO NOT DELETE
+
+default:: $(GALLIUM_LIBS)
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index 857ebfe..ce72545 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -9,7 +9,6 @@ LDFLAGS += -lstdc++
 endif
 
 MESA_MODULES = \
-	$(TOP)/src/mesa/libmesagallium.a \
 	$(GALLIUM_AUXILIARIES)
 
 COMMON_GALLIUM_SOURCES = \
@@ -74,12 +73,14 @@ LIBNAME_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
 default: depend symlinks $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING)
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
-		$(TOP)/src/mesa/drivers/dri/Makefile.targets $(TOP)/src/mesa/drivers/dri/common/dri_test.o
+		$(TOP)/src/mesa/drivers/dri/Makefile.targets $(TOP)/src/mesa/drivers/dri/common/dri_test.o \
+		$(GALLIUM_LIBS)
 	$(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
 		$(OBJECTS) $(PIPE_DRIVERS) \
                 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
-                 $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
-	$(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) $(LDFLAGS);
+                $(GALLIUM_LIB_DEPS) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
+	$(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(GALLIUM_LIB_DEPS) \
+		$(DRI_LIB_DEPS) $(LDFLAGS);
 	@rm -f $@.test
 	mv -f $@.tmp $@
 
diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index 95f3506..3cfc285 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -16,6 +16,9 @@ DRICORE_OBJECTS := $(addprefix $(DRICORE_OBJ_DIR)/, $(MESA_OBJECTS))
 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))
+GALLIUMCORE_OBJECTS := $(addprefix $(DRICORE_OBJ_DIR)/, $(filter-out $(MESA_OBJECTS), $(MESA_GALLIUM_OBJECTS)))
+
 # define preprocessor flags
 MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES)
 
@@ -65,7 +68,8 @@ $(DRICORE_OBJ_DIR)/%.o: %.S
 
 # 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) $(DRICORE_LIBS) driver_subdirs
+default: $(DEPENDS) asm_subdirs $(MESA_LIBS) $(DRICORE_LIBS) \
+	 $(notdir $(BUILD_GALLIUMCORE_LIBS)) driver_subdirs
 
 # include glapi_gen.mk for generating glapi headers for GLES
 GLAPI := $(TOP)/src/mapi/glapi/gen
@@ -147,6 +151,10 @@ depend: $(ALL_SOURCES)
 	@$(MKDEP) $(MKDEP_OPTIONS) -a -p$(DRICORE_OBJ_DIR)/ $(MESA_CPPFLAGS) \
 		$(ALL_SOURCES) > /dev/null 2>/dev/null
 
+# Make archive of subset of core mesa object files for gallium
+libgalliumcore.a: $(GALLIUMCORE_OBJECTS)
+	@ $(MKLIB) -o galliumcore -static $(GALLIUMCORE_OBJECTS)
+
 ######################################################################
 # Installation rules
 
-- 
1.7.5.4



More information about the mesa-dev mailing list