From 45ab885e00990acc5da891489537f7994a9dc25d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Thu, 3 Jul 2014 22:01:40 +0200
Subject: [PATCH] Remove some hardcoding of libraries and flags

---
 src/Makefile | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 95fe549..085fdea 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -21,6 +21,12 @@ SONAME_OPT=-Wl,-soname,
 # Use EXTRA_LIBS=-lm on Solaris
 EXTRA_LIBS =
 
+# Default libstdc++
+LIB_STDCPP = -lstdc++
+
+# Default pthread library
+LIB_PTHREAD = -lpthread
+
 INSTALL = install
 LN_SF = /bin/ln -sf
 MKDIR = mkdir -p
@@ -83,18 +89,19 @@ libespeak_SOURCES = speak_lib.cpp compiledict.cpp dictionary.cpp intonation.cpp
 
 SRCS1=$(speak_SOURCES)
 OBJS1=$(patsubst %.cpp,%.o,$(SRCS1))
-LIBS1=-lstdc++ $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
+LIBS1=$(LIB_STDCPP) $(LIB_AUDIO) $(LIB_PTHREAD) $(EXTRA_LIBS)
 
 SRCS2=$(libespeak_SOURCES)
 OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2))
-LIBS2=-lstdc++ $(LIB_AUDIO) -lpthread
+LIBS2=$(LIB_STDCPP) $(LIB_AUDIO) $(LIB_PTHREAD)
 
 SRCS3 = espeak.cpp
 OBJS3=$(patsubst %.cpp,%.o,$(SRCS3))
-LIBS3=-lstdc++ -L . -lespeak
+LIBS3=$(LIB_STDCPP) -L . -lespeak
 
 CXXFLAGS=-O2
 
+VISIBILITY_FLAG=-fvisibility=hidden
 
 all: $(BIN_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
 
@@ -110,7 +117,7 @@ $(BIN2_NAME): $(OBJS3) $(LIB_NAME)
 
 
 x_%.o: %.cpp
-	$(CXX) $(CXXFLAGS) $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -fpic -fvisibility=hidden -pedantic \
+	$(CXX) $(CXXFLAGS) $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -fpic $(VISIBILITY_FLAG) -pedantic \
 	-I. -D LIBRARY -c -fno-exceptions  $<  -o x_$*.o
 
 $(LIB_NAME): $(OBJS2)
-- 
1.8.3.4

