[Mesa-dev] [PATCH] mesa: Add Haiku build support

kallisti5 at unixzen.com kallisti5 at unixzen.com
Thu Dec 22 14:54:05 PST 2011


From: Alexander von Gluck IV <kallisti5 at unixzen.com>

* Add Haiku as a platform to mklib
* Fix GLU to allow building static libGLU
* Remove a few existing Haiku defines that break the build
---
 Makefile                             |    1 +
 acinclude.m4                         |    2 +-
 bin/mklib                            |   37 ++++++++++++++++++++++++++++++++++
 src/gallium/auxiliary/os/os_thread.h |    2 +-
 src/gallium/auxiliary/util/u_debug.h |    2 -
 src/gallium/drivers/r300/Makefile    |    1 +
 src/glsl/link_uniforms.cpp           |    3 +-
 src/glu/sgi/Makefile                 |   15 +++++++------
 src/mesa/main/querymatrix.c          |    2 +-
 9 files changed, 51 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index cf6555c..4caa8ce 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@ freebsd \
 freebsd-dri \
 freebsd-dri-amd64 \
 freebsd-dri-x86 \
+haiku \
 hpux10 \
 hpux10-gcc \
 hpux10-static \
diff --git a/acinclude.m4 b/acinclude.m4
index a5b389d..33ed8a8 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -34,7 +34,7 @@ if test "$enable_pic" != no; then
         # see if we're using GCC
         if test "x$GCC" = xyes; then
             case "$host_os" in
-            aix*|beos*|cygwin*|irix5*|irix6*|osf3*|osf4*|osf5*)
+            aix*|cygwin*|haiku*|irix5*|irix6*|osf3*|osf4*|osf5*)
                 # PIC is the default for these OSes.
                 ;;
             mingw*|os2*|pw32*)
diff --git a/bin/mklib b/bin/mklib
index 70bd1a2..ca4b62c 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -959,6 +959,43 @@ case $ARCH in
         fi
 	;;
 
+    'Haiku')
+        if [ $STATIC = 1 ] ; then
+            LIBNAME="lib${LIBNAME}.a"
+            if [ "x$LINK" = "x" ] ; then
+                # -linker was not specified so set default link command now
+                if [ $CPLUSPLUS = 1 ] ; then
+                    LINK=g++
+                else
+                    LINK=gcc
+                fi
+            fi
+
+            OPTS="-ru"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
+
+            echo "mklib: Making static library for Haiku: " ${LIBNAME}
+
+            # expand .a into .o files
+            NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
+
+            # make static lib
+            FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
+
+            # remove temporary extracted .o files
+            rm -rf ${LIBNAME}.obj
+        else
+            LIBNAME="lib${LIBNAME}.so"  # prefix with "lib", suffix with ".so"
+            OPTS="-shared"
+
+            echo "mklib: Making shared library for Haiku: " ${LIBNAME}
+			${LINK} ${OPTS} ${LDFLAGS} ${OBJECTS} ${DEPS} -o ${LIBNAME}
+            FINAL_LIBS="${LIBNAME}"
+        fi
+    ;;
+
     'example')
 	# If you're adding support for a new architecture, you can
 	# start with this:
diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index d830129..3e1c273 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -314,7 +314,7 @@ typedef int64_t pipe_condvar;
  * pipe_barrier
  */
 
-#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)) && !defined(PIPE_OS_ANDROID)
+#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)) && !defined(PIPE_OS_ANDROID)
 
 typedef pthread_barrier_t pipe_barrier;
 
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index b5ea405..677e478 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -75,7 +75,6 @@ _debug_printf(const char *format, ...)
  * - avoid outputing large strings (512 bytes is the current maximum length
  * that is guaranteed to be printed in all platforms)
  */
-#if !defined(PIPE_OS_HAIKU)
 static INLINE void
 debug_printf(const char *format, ...) _util_printf_format(1,2);
 
@@ -92,7 +91,6 @@ debug_printf(const char *format, ...)
 #endif
 }
 
-#endif /* !PIPE_OS_HAIKU */
 
 /*
  * ... isn't portable so we need to pass arguments in parentheses.
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index 5f56fc4..3e3a765 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -15,6 +15,7 @@ C_SOURCES += \
 LIBRARY_INCLUDES = \
 	-I$(TOP)/include \
 	-I$(TOP)/src/mesa \
+	-I$(TOP)/src/mapi \
 	-I$(TOP)/src/glsl
 
 include ../../Makefile.template
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index c7de480..f2e6648 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -336,9 +336,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
       rzalloc_array(prog, struct gl_uniform_storage, num_user_uniforms);
    union gl_constant_value *data =
       rzalloc_array(uniforms, union gl_constant_value, num_data_slots);
-#ifndef NDEBUG
+
    union gl_constant_value *data_end = &data[num_data_slots];
-#endif
 
    parcel_out_uniform_storage parcel(prog->UniformHash, uniforms, data);
 
diff --git a/src/glu/sgi/Makefile b/src/glu/sgi/Makefile
index c8b29ed..d6d8571 100644
--- a/src/glu/sgi/Makefile
+++ b/src/glu/sgi/Makefile
@@ -124,24 +124,25 @@ OBJECTS = $(C_OBJECTS) $(CC_OBJECTS)
 ##### TARGETS #####
 
 default:
-	@if [ "${CONFIG_NAME}" = "beos" ] ; then \
-		echo "$(GLU_LIB_NAME) not build under BeOS, but integrated into ${GL_LIB_NAME}." ; \
-		exit 0 ; \
-	else \
-		$(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) || exit 1 ; \
-	fi
+	$(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) || exit 1 ;
 
 $(TOP)/$(LIB_DIR):
 	-mkdir $(TOP)/$(LIB_DIR)
 
 # Make the library:
-$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
+$(TOP)/$(LIB_DIR)/lib$(GLU_LIB).so: $(OBJECTS)
 	$(MKLIB) -o $(GLU_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
 		-major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
 		-cplusplus $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
 		-exports glu.exports -id $(INSTALL_LIB_DIR)/lib$(GLU_LIB).$(GLU_MAJOR).dylib \
 		$(GLU_LIB_DEPS) $(OBJECTS)
 
+$(TOP)/$(LIB_DIR)/lib$(GLU_LIB).a: $(OBJECTS)
+	$(MKLIB) -o $(GLU_LIB) -static -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
+		-major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
+		-cplusplus $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
+		-exports glu.exports -id $(INSTALL_LIB_DIR)/lib$(GLU_LIB).$(GLU_MAJOR).dylib \
+		$(GLU_LIB_DEPS) $(OBJECTS)
 
 clean:
 	-rm -f *.o */*.o */*/*.o
diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index eaedf7c..2843d55 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -73,7 +73,7 @@ fpclassify(double x)
 #elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
      defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
      (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \
-     (defined(__sun) && defined(__GNUC__)) || defined(ANDROID)
+     (defined(__sun) && defined(__GNUC__)) || defined(ANDROID) || defined(__HAIKU__)
 
 /* fpclassify is available. */
 
-- 
1.7.2.5



More information about the mesa-dev mailing list