| 1 |
#! /bin/sh |
| 2 |
# $Id: genconfig.sh,v 1.20 2011/02/17 23:17:24 jmaggard Exp $ |
| 3 |
# MiniDLNA project |
| 4 |
# http://sourceforge.net/projects/minidlna/ |
| 5 |
# |
| 6 |
# MiniDLNA media server |
| 7 |
# Copyright (C) 2008-2009 Justin Maggard |
| 8 |
# |
| 9 |
# This file is part of MiniDLNA. |
| 10 |
# |
| 11 |
# MiniDLNA is free software; you can redistribute it and/or modify |
| 12 |
# it under the terms of the GNU General Public License version 2 as |
| 13 |
# published by the Free Software Foundation. |
| 14 |
# |
| 15 |
# MiniDLNA is distributed in the hope that it will be useful, |
| 16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
# GNU General Public License for more details. |
| 19 |
# |
| 20 |
# You should have received a copy of the GNU General Public License |
| 21 |
# along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
|
| 23 |
RM="rm -f" |
| 24 |
CONFIGFILE="config.h" |
| 25 |
CONFIGMACRO="__CONFIG_H__" |
| 26 |
|
| 27 |
# Database path |
| 28 |
DB_PATH="/tmp/minidlna" |
| 29 |
# Log path |
| 30 |
LOG_PATH="${DB_PATH}" |
| 31 |
|
| 32 |
# detecting the OS name and version |
| 33 |
OS_NAME=`uname -s` |
| 34 |
OS_VERSION=`uname -r` |
| 35 |
TIVO="/*#define TIVO_SUPPORT*/" |
| 36 |
NETGEAR="/*#define NETGEAR*/" |
| 37 |
READYNAS="/*#define READYNAS*/" |
| 38 |
PNPX="#define PNPX 0" |
| 39 |
|
| 40 |
${RM} ${CONFIGFILE} |
| 41 |
|
| 42 |
# Detect if there are missing headers |
| 43 |
# NOTE: This check only works with a normal distro |
| 44 |
[ ! -e "/usr/include/sqlite3.h" ] && MISSING="libsqlite3 $MISSING" |
| 45 |
[ ! -e "/usr/include/jpeglib.h" ] && MISSING="libjpeg $MISSING" |
| 46 |
[ ! -e "/usr/include/libexif/exif-loader.h" ] && MISSING="libexif $MISSING" |
| 47 |
[ ! -e "/usr/include/id3tag.h" ] && MISSING="libid3tag $MISSING" |
| 48 |
[ ! -e "/usr/include/ogg/ogg.h" ] && MISSING="libogg $MISSING" |
| 49 |
[ ! -e "/usr/include/vorbis/codec.h" ] && MISSING="libvorbis $MISSING" |
| 50 |
[ ! -e "/usr/include/FLAC/metadata.h" ] && MISSING="libflac $MISSING" |
| 51 |
[ ! -e "/usr/include/ffmpeg/avutil.h" -a \ |
| 52 |
! -e "/usr/include/libavutil/avutil.h" -a \ |
| 53 |
! -e "/usr/include/ffmpeg/libavutil/avutil.h" ] && MISSING="libavutil $MISSING" |
| 54 |
[ ! -e "/usr/include/ffmpeg/avformat.h" -a \ |
| 55 |
! -e "/usr/include/libavformat/avformat.h" -a \ |
| 56 |
! -e "/usr/include/ffmpeg/libavformat/avformat.h" ] && MISSING="libavformat $MISSING" |
| 57 |
[ ! -e "/usr/include/ffmpeg/avcodec.h" -a \ |
| 58 |
! -e "/usr/include/libavcodec/avcodec.h" -a \ |
| 59 |
! -e "/usr/include/ffmpeg/libavcodec/avcodec.h" ] && MISSING="libavcodec $MISSING" |
| 60 |
if [ -n "$MISSING" ]; then |
| 61 |
echo -e "\nERROR! Cannot continue." |
| 62 |
echo -e "The following required libraries are either missing, or are missing development headers:\n" |
| 63 |
echo -e "$MISSING\n" |
| 64 |
exit 1 |
| 65 |
fi |
| 66 |
|
| 67 |
echo "/* MiniDLNA Project" >> ${CONFIGFILE} |
| 68 |
echo " * http://sourceforge.net/projects/minidlna/" >> ${CONFIGFILE} |
| 69 |
echo " * (c) 2008-2009 Justin Maggard" >> ${CONFIGFILE} |
| 70 |
echo " * generated by $0 on `date` */" >> ${CONFIGFILE} |
| 71 |
echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE} |
| 72 |
echo "#define $CONFIGMACRO" >> ${CONFIGFILE} |
| 73 |
echo "" >> ${CONFIGFILE} |
| 74 |
|
| 75 |
# OS Specific stuff |
| 76 |
case $OS_NAME in |
| 77 |
OpenBSD) |
| 78 |
MAJORVER=`echo $OS_VERSION | cut -d. -f1` |
| 79 |
MINORVER=`echo $OS_VERSION | cut -d. -f2` |
| 80 |
#echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER" |
| 81 |
# rtableid was introduced in OpenBSD 4.0 |
| 82 |
if [ $MAJORVER -ge 4 ]; then |
| 83 |
echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE} |
| 84 |
fi |
| 85 |
# from the 3.8 version, packets and bytes counters are double : in/out |
| 86 |
if [ \( $MAJORVER -ge 4 \) -o \( $MAJORVER -eq 3 -a $MINORVER -ge 8 \) ]; then |
| 87 |
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE} |
| 88 |
fi |
| 89 |
OS_URL=http://www.openbsd.org/ |
| 90 |
;; |
| 91 |
*FreeBSD) |
| 92 |
VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'` |
| 93 |
if [ $VER -ge 700049 ]; then |
| 94 |
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE} |
| 95 |
fi |
| 96 |
OS_URL=http://www.freebsd.org/ |
| 97 |
if [ -f /etc/debian_version ]; then |
| 98 |
OS_NAME=Debian |
| 99 |
OS_VERSION=`cat /etc/debian_version` |
| 100 |
OS_URL=http://www.debian.org/ |
| 101 |
DB_PATH="/var/lib/minidlna" |
| 102 |
LOG_PATH="/var/log" |
| 103 |
# use lsb_release (Linux Standard Base) when available |
| 104 |
LSB_RELEASE=`which lsb_release 2>/dev/null` |
| 105 |
if [ 0 -eq $? ]; then |
| 106 |
OS_NAME=`${LSB_RELEASE} -i -s` |
| 107 |
OS_VERSION=`${LSB_RELEASE} -r -s` |
| 108 |
fi |
| 109 |
fi |
| 110 |
;; |
| 111 |
pfSense) |
| 112 |
# we need to detect if PFRULE_INOUT_COUNTS macro is needed |
| 113 |
OS_URL=http://www.pfsense.com/ |
| 114 |
;; |
| 115 |
NetBSD) |
| 116 |
OS_URL=http://www.netbsd.org/ |
| 117 |
;; |
| 118 |
SunOS) |
| 119 |
echo "#define USE_IPF 1" >> ${CONFIGFILE} |
| 120 |
echo "#define LOG_PERROR 0" >> ${CONFIGFILE} |
| 121 |
echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE} |
| 122 |
echo "typedef uint64_t u_int64_t;" >> ${CONFIGFILE} |
| 123 |
echo "typedef uint32_t u_int32_t;" >> ${CONFIGFILE} |
| 124 |
echo "typedef uint16_t u_int16_t;" >> ${CONFIGFILE} |
| 125 |
echo "typedef uint8_t u_int8_t;" >> ${CONFIGFILE} |
| 126 |
OS_URL=http://www.sun.com/solaris/ |
| 127 |
;; |
| 128 |
Linux) |
| 129 |
OS_URL=http://www.kernel.org/ |
| 130 |
KERNVERA=`echo $OS_VERSION | awk -F. '{print $1}'` |
| 131 |
KERNVERB=`echo $OS_VERSION | awk -F. '{print $2}'` |
| 132 |
KERNVERC=`echo $OS_VERSION | awk -F. '{print $3}'` |
| 133 |
KERNVERD=`echo $OS_VERSION | awk -F. '{print $4}'` |
| 134 |
#echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD" |
| 135 |
# NETGEAR ReadyNAS special case |
| 136 |
if [ -f /etc/raidiator_version ]; then |
| 137 |
OS_NAME=$(awk -F'!!|=' '{ print $1 }' /etc/raidiator_version) |
| 138 |
OS_VERSION=$(awk -F'!!|[=,.]' '{ print $3"."$4 }' /etc/raidiator_version) |
| 139 |
OS_URL="http://www.readynas.com/" |
| 140 |
LOG_PATH="/var/log" |
| 141 |
DB_PATH="/var/cache/minidlna" |
| 142 |
TIVO="#define TIVO_SUPPORT" |
| 143 |
NETGEAR="#define NETGEAR" |
| 144 |
READYNAS="#define READYNAS" |
| 145 |
PNPX="#define PNPX 5" |
| 146 |
# Debian GNU/Linux special case |
| 147 |
elif [ -f /etc/debian_version ]; then |
| 148 |
OS_NAME=Debian |
| 149 |
OS_VERSION=`cat /etc/debian_version` |
| 150 |
OS_URL=http://www.debian.org/ |
| 151 |
DB_PATH="/var/lib/minidlna" |
| 152 |
LOG_PATH="/var/log" |
| 153 |
# use lsb_release (Linux Standard Base) when available |
| 154 |
LSB_RELEASE=`which lsb_release 2>/dev/null` |
| 155 |
if [ 0 -eq $? ]; then |
| 156 |
OS_NAME=`${LSB_RELEASE} -i -s` |
| 157 |
OS_VERSION=`${LSB_RELEASE} -r -s` |
| 158 |
fi |
| 159 |
else |
| 160 |
# use lsb_release (Linux Standard Base) when available |
| 161 |
LSB_RELEASE=`which lsb_release 2>/dev/null` |
| 162 |
if [ 0 -eq $? ]; then |
| 163 |
OS_NAME=`${LSB_RELEASE} -i -s` |
| 164 |
OS_VERSION=`${LSB_RELEASE} -r -s` |
| 165 |
fi |
| 166 |
fi |
| 167 |
;; |
| 168 |
GNU) |
| 169 |
OS_URL=http://hurd.gnu.org/ |
| 170 |
if [ -f /etc/debian_version ]; then |
| 171 |
OS_NAME=Debian |
| 172 |
OS_VERSION=`cat /etc/debian_version` |
| 173 |
OS_URL=http://www.debian.org/ |
| 174 |
DB_PATH="/var/lib/minidlna" |
| 175 |
LOG_PATH="/var/log" |
| 176 |
# use lsb_release (Linux Standard Base) when available |
| 177 |
LSB_RELEASE=`which lsb_release 2>/dev/null` |
| 178 |
if [ 0 -eq $? ]; then |
| 179 |
OS_NAME=`${LSB_RELEASE} -i -s` |
| 180 |
OS_VERSION=`${LSB_RELEASE} -r -s` |
| 181 |
fi |
| 182 |
fi |
| 183 |
;; |
| 184 |
*) |
| 185 |
echo "Unknown OS : $OS_NAME" |
| 186 |
exit 1 |
| 187 |
;; |
| 188 |
esac |
| 189 |
|
| 190 |
echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE} |
| 191 |
echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE} |
| 192 |
echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE} |
| 193 |
echo "" >> ${CONFIGFILE} |
| 194 |
|
| 195 |
echo "/* full path of the file database */" >> ${CONFIGFILE} |
| 196 |
echo "#define DEFAULT_DB_PATH \"${DB_PATH}\"" >> ${CONFIGFILE} |
| 197 |
echo "" >> ${CONFIGFILE} |
| 198 |
|
| 199 |
echo "/* full path of the log directory */" >> ${CONFIGFILE} |
| 200 |
echo "#define DEFAULT_LOG_PATH \"${LOG_PATH}\"" >> ${CONFIGFILE} |
| 201 |
echo "" >> ${CONFIGFILE} |
| 202 |
|
| 203 |
echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE} |
| 204 |
echo " * of BSD daemon() */" >> ${CONFIGFILE} |
| 205 |
echo "#define USE_DAEMON" >> ${CONFIGFILE} |
| 206 |
echo "" >> ${CONFIGFILE} |
| 207 |
|
| 208 |
echo "/* Enable if the system inotify.h exists. Otherwise our own inotify.h will be used. */" >> ${CONFIGFILE} |
| 209 |
if [ -f /usr/include/sys/inotify.h ]; then |
| 210 |
echo "#define HAVE_INOTIFY_H" >> ${CONFIGFILE} |
| 211 |
else |
| 212 |
echo "/*#define HAVE_INOTIFY_H*/" >> ${CONFIGFILE} |
| 213 |
fi |
| 214 |
echo "" >> ${CONFIGFILE} |
| 215 |
|
| 216 |
echo "/* Enable if the system iconv.h exists. ID3 tag reading in various character sets will not work properly otherwise. */" >> ${CONFIGFILE} |
| 217 |
if [ -f /usr/include/iconv.h ]; then |
| 218 |
echo "#define HAVE_ICONV_H" >> ${CONFIGFILE} |
| 219 |
else |
| 220 |
echo -e "\nWARNING!! Iconv support not found. ID3 tag reading may not work." |
| 221 |
echo "/*#define HAVE_ICONV_H*/" >> ${CONFIGFILE} |
| 222 |
fi |
| 223 |
echo "" >> ${CONFIGFILE} |
| 224 |
|
| 225 |
echo "/* Enable if the system libintl.h exists for NLS support. */" >> ${CONFIGFILE} |
| 226 |
if [ -f /usr/include/libintl.h ]; then |
| 227 |
echo "#define ENABLE_NLS" >> ${CONFIGFILE} |
| 228 |
else |
| 229 |
echo "/*#define ENABLE_NLS*/" >> ${CONFIGFILE} |
| 230 |
fi |
| 231 |
echo "" >> ${CONFIGFILE} |
| 232 |
|
| 233 |
echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE} |
| 234 |
echo "${NETGEAR}" >> ${CONFIGFILE} |
| 235 |
echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE} |
| 236 |
echo "${READYNAS}" >> ${CONFIGFILE} |
| 237 |
echo "/* Compile in TiVo support. */" >> ${CONFIGFILE} |
| 238 |
echo "${TIVO}" >> ${CONFIGFILE} |
| 239 |
echo "/* Enable PnPX support. */" >> ${CONFIGFILE} |
| 240 |
echo "${PNPX}" >> ${CONFIGFILE} |
| 241 |
echo "" >> ${CONFIGFILE} |
| 242 |
|
| 243 |
echo "#endif" >> ${CONFIGFILE} |
| 244 |
|
| 245 |
exit 0 |