Improved library handling in makefile, added WITH_THREADNAMES option.

This commit is contained in:
Thulinma 2014-01-17 16:53:14 +01:00
parent 3123aeb32a
commit 6b78cad546
3 changed files with 17 additions and 9 deletions

View file

@ -10,8 +10,14 @@ ifeq ($(PACKAGE_VERSION),Unknown)
$(warning Version is unknown - consider creating a VERSION file or fixing your git setup.)
endif
CPPFLAGS = -Wall -funsigned-char -g -O2 -DDEBUG="$(DEBUG)" -DPACKAGE_VERSION="\"$(PACKAGE_VERSION)\"" -DRELEASE="\"$(RELEASE)\""
CPPFLAGS = -Wall -g -O2
override CPPFLAGS += -funsigned-char -DDEBUG="$(DEBUG)" -DPACKAGE_VERSION="\"$(PACKAGE_VERSION)\"" -DRELEASE="\"$(RELEASE)\""
ifdef WITH_THREADNAMES
override CPPFLAGS += -DWITH_THREADNAMES=1
endif
THREADLIB = -lpthread
LDLIBS = -lmist
@ -35,7 +41,7 @@ MistPlayer: src/buffer/player.cpp
$(CXX) $(LDFLAGS) $(CPPFLAGS) $^ $(LDLIBS) -o $@
buffers: MistBuffer
MistBuffer: LDLIBS += -lpthread
MistBuffer: override LDLIBS += $(THREADLIB)
MistBuffer: src/buffer/buffer.cpp src/buffer/buffer_stream.h src/buffer/buffer_stream.cpp tinythread.o tinythread.h
$(CXX) $(LDFLAGS) $(CPPFLAGS) src/buffer/buffer.cpp src/buffer/buffer_stream.cpp tinythread.o $(LDLIBS) -o $@
@ -48,7 +54,7 @@ MistConnRTMP: src/connectors/conn_rtmp.cpp
$(CXX) $(LDFLAGS) $(CPPFLAGS) $^ $(LDLIBS) -o $@
connectors: MistConnHTTP
MistConnHTTP: LDLIBS += -lpthread
MistConnHTTP: override LDLIBS += $(THREADLIB)
MistConnHTTP: src/connectors/conn_http.cpp tinythread.o tinythread.h src/connectors/embed.js.h src/connectors/icon.h
$(CXX) $(LDFLAGS) $(CPPFLAGS) src/connectors/conn_http.cpp tinythread.o $(LDLIBS) -o $@

6
README
View file

@ -31,8 +31,10 @@ The makefile will listen to the following variables:
exec_prefix Prefix to install object code and binaries to. Defaults to $(prefix)
bindir Directory to install binaries to. Defaults to $(exec_prefix)/bin
DESTDIR Global prefix that will be put in front of any and all other file paths.
CPPFLAGS Flags for compiling object files. Defaults to -Wall -g -O2 -fPIC -DDEBUG="$(DEBUG)" -DPACKAGE_VERSION="\"$(PACKAGE_VERSION)\""
LDLIBS Libraries to include. Defaults to -lmist, adding -lpthread for some binaries.
CPPFLAGS Flags for compiling object files. Defaults to -Wall -g -O2
LDLIBS Libraries to include. Defaults to -lmist
THREADLIB Libraries to include for threaded binaries. Defaults to -lpthread
WITH_THREADNAMES If set, this will set names of threads in threaded binaries. Defaults to being unset.
Use "make var1=val1 var2=val2" to set these. For example:
make install DEBUG=0 prefix=/usr/local

View file

@ -27,7 +27,7 @@ namespace Buffer {
///\brief A function running in a thread to send all statistics.
///\param empty A null pointer.
void handleStats(void * empty){
#if defined(_TTHREAD_POSIX_) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
#if defined(_TTHREAD_POSIX_) && defined(WITH_THREADNAMES) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
pthread_setname_np(pthread_self(), "StatsHandler");
#endif
if (empty != 0){
@ -83,7 +83,7 @@ namespace Buffer {
if (empty != 0){
return;
}
#if defined(_TTHREAD_POSIX_) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
#if defined(_TTHREAD_POSIX_) && defined(WITH_THREADNAMES) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
pthread_setname_np(pthread_self(), "Standard Input");
#endif
long long int timeDiff = 0; //difference between local time and stream time
@ -123,7 +123,7 @@ namespace Buffer {
#if DEBUG >= 5
std::cerr << "Thread launched for user " << usr->sID << ", socket number " << usr->S.getSocket() << std::endl;
#endif
#if defined(_TTHREAD_POSIX_) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
#if defined(_TTHREAD_POSIX_) && defined(WITH_THREADNAMES) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
pthread_setname_np(pthread_self(), usr->sID.c_str());
#endif
usr->myRing = thisStream->getRing();
@ -292,7 +292,7 @@ namespace Buffer {
}
SS.setBlocking(false);
conf.activate();
#if defined(_TTHREAD_POSIX_) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
#if defined(_TTHREAD_POSIX_) && defined(WITH_THREADNAMES) && !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) || defined(_WIN32) || defined(__CYGWIN__))
pthread_setname_np(pthread_self(), "Main accepter");
#endif
thisStream = Stream::get();