OSDN Git Service

libtxc_dxtn: stop depending on libstdc++.
authorRudolf Polzer <divverent@xonotic.org>
Sat, 19 Dec 2015 18:49:45 +0000 (19:49 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 19 Dec 2015 18:49:45 +0000 (19:49 +0100)
Makefile.am
configure.ac
s2tc_algorithm.cpp

index 14aacd2..e6853e8 100644 (file)
@@ -26,7 +26,7 @@ endif
 if ENABLE_LIB
 lib_LTLIBRARIES = libtxc_dxtn.la
 libtxc_dxtn_la_SOURCES = s2tc_algorithm.cpp s2tc_libtxc_dxtn.cpp s2tc_common.h s2tc_algorithm.h txc_dxtn.h s2tc_license.h
-libtxc_dxtn_la_LDFLAGS = -versioninfo 0:0:0
+libtxc_dxtn_la_LDFLAGS = -versioninfo 0:0:0 -nodefaultlibs
 libtxc_dxtn_la_LIBADD = -lm
 libtxc_dxtn_la_CFLAGS = -fvisibility=hidden -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
 library_includedir = $(includedir)
index 906eaca..ff27b6f 100644 (file)
@@ -4,6 +4,7 @@ AM_INIT_AUTOMAKE([-Wall foreign])
 
 have_CXXFLAGS=${CXXFLAGS+set}
 AC_PROG_CXX
+AM_PROG_AR
 # better default optimization flags for g++, please
 if test "$have_CXXFLAGS" != set; then
        if test "$GXX" = yes; then
@@ -13,6 +14,9 @@ fi
 
 AC_PROG_LIBTOOL
 
+# Disable dependency on libstdc++ for the .so library.
+postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ , ,g'`
+
 AC_ARG_ENABLE(runtime-linking, AS_HELP_STRING([--disable-runtime-linking], [Do not load the library at runtime (faster startup, more dependencies)]), [enable_runtime_linking=$enableval], [enable_runtime_linking=yes])
 AC_ARG_ENABLE(tools, AS_HELP_STRING([--disable-tools], [Do not build the s2tc_compress and s2_decompress tools]), [enable_tools=$enableval], [enable_tools=yes])
 AC_ARG_ENABLE(lib, AS_HELP_STRING([--disable-lib], [Do not build the included libtxc_dxtn library for S2TC]), [enable_lib=$enableval], [enable_lib=yes])
index e48977d..42238f2 100644 (file)
 #include <string.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <algorithm>
-#include <iostream>
 
 #include "s2tc_algorithm.h"
 #include "s2tc_common.h"
 
 namespace
 {
+       template<class T> void swap(T& a, T& b)
+       {
+               T h = a;
+               a = b;
+               b = h;
+       }
        template<class T> struct color_type_info
        {
        };
@@ -204,16 +208,6 @@ namespace
                }
        };
 
-       std::ostream &operator<<(std::ostream &ost, const color_t &c)
-       {
-               return ost << "make_color_t(" << int(c.r) << ", " << int(c.g) << ", " << int(c.b) << ")";
-       }
-
-       std::ostream &operator<<(std::ostream &ost, const bigcolor_t &c)
-       {
-               return ost << "bigcolor_t(" << c.r << ", " << c.g << ", " << c.b << ")";
-       }
-
        // 16 differences must fit in int
        // i.e. a difference must be lower than 2^27
 
@@ -692,7 +686,7 @@ namespace
 
                if(a1 < a0)
                {
-                       std::swap(a0, a1);
+                       swap(a0, a1);
                        for(int i = 0; i < 16; ++i) switch(out.get(i))
                        {
                                case 0:
@@ -738,7 +732,7 @@ namespace
 
                if(a1 < a0)
                {
-                       std::swap(a0, a1);
+                       swap(a0, a1);
                        for(int i = 0; i < 16; ++i) switch(out.get(i))
                        {
                                case 0:
@@ -761,7 +755,7 @@ namespace
        inline void s2tc_dxt5_encode_alpha_refine_never(bitarray<uint64_t, 16, 3> &out, const unsigned char *in, int iw, int w, int h, unsigned char &a0, unsigned char &a1)
        {
                if(a1 < a0)
-                       std::swap(a0, a1);
+                       swap(a0, a1);
                unsigned char ramp[6] = {
                        a0,
                        a1
@@ -812,7 +806,7 @@ namespace
 
                if(have_trans ? c1 < c0 : c0 < c1)
                {
-                       std::swap(c0, c1);
+                       swap(c0, c1);
                        for(int i = 0; i < 16; ++i)
                                if(!(out.get(i) & 2))
                                        out.do_xor(i, 1);
@@ -844,7 +838,7 @@ namespace
 
                if(have_trans ? c1 < c0 : c0 < c1)
                {
-                       std::swap(c0, c1);
+                       swap(c0, c1);
                        for(int i = 0; i < 16; ++i)
                                if(!(out.get(i) & 2))
                                        out.do_xor(i, 1);
@@ -856,7 +850,7 @@ namespace
        inline void s2tc_dxt1_encode_color_refine_never(bitarray<uint32_t, 16, 2> &out, const unsigned char *in, int iw, int w, int h, color_t &c0, color_t &c1)
        {
                if(have_trans ? c1 < c0 : c0 < c1)
-                       std::swap(c0, c1);
+                       swap(c0, c1);
                color_t ramp[2] = {
                        c0,
                        c1