From 2cfd5ce48a68f420c8c308bb7e3ac68c0a373616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Thu, 9 Oct 2008 21:56:22 +0000 Subject: [PATCH] Make tvheadend installable. --- Makefile | 25 ++++++++++++++++++++++++- main.c | 18 +++++++++++------- version.c | 7 +++++++ webui/webui.c | 10 ++++++++-- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 646d3a08..67129291 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,31 @@ DLIBS += $(FFMPEG_DLIBS) SLIBS += $(FFMPEG_SLIBS) CFLAGS += $(FFMPEG_CFLAGS) -DLIBS += -lpthread +DLIBS += -lpthread -lm -lz include ../build/prog.mk +# +# Install +# +prefix ?= $(INSTALLPREFIX) +INSTBIN= $(prefix)/bin +INSTMAN= $(prefix)/share/man1 +INSTSHARE= $(prefix)/share/hts/tvheadend + +install: ${PROG} + mkdir -p $(INSTBIN) + cd $(.OBJDIR) && install -s ${PROG} $(INSTBIN) + + mkdir -p $(INSTMAN) + cd man && install ${MAN} $(INSTMAN) + + mkdir -p $(INSTSHARE)/docs/html + cp docs/html/*.html $(INSTSHARE)/docs/html + + mkdir -p $(INSTSHARE)/docs/docresources + cp docs/docresources/*.png $(INSTSHARE)/docs/docresources + + find webui/static/ -type d |grep -v .svn | awk '{print "$(INSTSHARE)/"$$0}' | xargs mkdir -p + find webui/static/ -type f |grep -v .svn | awk '{print $$0 " $(INSTSHARE)/"$$0}' | xargs -n2 cp diff --git a/main.c b/main.c index 3c903bce..d8f00ddc 100644 --- a/main.c +++ b/main.c @@ -54,13 +54,13 @@ #include #include - int running; extern const char *htsversion; +extern const char *htsversion_full; time_t dispatch_clock; static LIST_HEAD(, gtimer) gtimers; pthread_mutex_t global_lock; - +const char *contentpath = HTS_INSTALL_PREFIX "/share/hts/tvheadend/"; static void @@ -197,7 +197,7 @@ main(int argc, char **argv) signal(SIGPIPE, handle_sigpipe); - while((c = getopt(argc, argv, "fu:g:s:")) != -1) { + while((c = getopt(argc, argv, "fu:g:s:c:")) != -1) { switch(c) { case 'f': forkaway = 1; @@ -211,6 +211,9 @@ main(int argc, char **argv) case 's': settingspath = optarg; break; + case 'c': + contentpath = optarg; + break; } } @@ -319,12 +322,13 @@ main(int argc, char **argv) syslog(LOG_NOTICE, "HTS Tvheadend version %s started, " "running as pid:%d uid:%d gid:%d, settings located in '%s'", - htsversion, getpid(), getuid(), getgid(), hts_settings_get_root()); + htsversion_full, + getpid(), getuid(), getgid(), hts_settings_get_root()); if(!forkaway) - fprintf(stderr, "\nHTS Tvheadend version %s started, " - "settings located in '%s'\n", - htsversion, hts_settings_get_root()); + fprintf(stderr, "\nHTS Tvheadend version %s started.\n" + "Settings located in '%s'\n", + htsversion_full, hts_settings_get_root()); mainloop(); diff --git a/version.c b/version.c index 48d005e9..92295788 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,10 @@ #include "version.h" +#include "config.h" +#ifdef HTS_RELEASE_TAG +const char *htsversion=HTS_RELEASE_TAG; +const char *htsversion_full=HTS_RELEASE_TAG " (" HTS_VERSION ")"; +#else const char *htsversion=HTS_VERSION; +const char *htsversion_full=HTS_VERSION; +#endif diff --git a/webui/webui.c b/webui/webui.c index f994821c..275826e0 100644 --- a/webui/webui.c +++ b/webui/webui.c @@ -71,11 +71,17 @@ page_root(http_connection_t *hc, const char *remain, void *opaque) /** * Static download of a file from the filesystem */ +extern char *contentpath; + static int page_static(http_connection_t *hc, const char *remain, void *opaque) { int fd; - const char *rootpath = HTS_BUILD_ROOT "/tvheadend/webui/static"; +#ifdef HTS_BUILD_ROOT + const char *rootpath = HTS_BUILD_ROOT "/tvheadend"; +#else + const char *rootpath = contentpath; +#endif char path[500]; struct stat st; const char *content = NULL, *postfix; @@ -90,7 +96,7 @@ page_static(http_connection_t *hc, const char *remain, void *opaque) content = "text/javascript; charset=UTF-8"; } - snprintf(path, sizeof(path), "%s/%s", rootpath, remain); + snprintf(path, sizeof(path), "%s/webui/static/%s", rootpath, remain); if((fd = open(path, O_RDONLY)) < 0) return 404;