3 # http://sourceforge.net/projects/minidlna/
5 # MiniDLNA media server
6 # Copyright (C) 2008-2009 Justin Maggard
8 # This file is part of MiniDLNA.
10 # MiniDLNA is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License version 2 as
12 # published by the Free Software Foundation.
14 # MiniDLNA is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
24 CONFIGMACRO
="__CONFIG_H__"
27 DB_PATH
="/tmp/minidlna"
31 # detecting the OS name and version
34 TIVO
="/*#define TIVO_SUPPORT*/"
35 NETGEAR
="/*#define NETGEAR*/"
36 READYNAS
="/*#define READYNAS*/"
41 # Detect if there are missing headers
42 # NOTE: This check only works with a normal distro
43 [ ! -e "/usr/include/sqlite3.h" ] && MISSING
="libsqlite3 $MISSING"
44 [ ! -e "/usr/include/jpeglib.h" ] && MISSING
="libjpeg $MISSING"
45 [ ! -e "/usr/include/libexif/exif-loader.h" ] && MISSING
="libexif $MISSING"
46 [ ! -e "/usr/include/id3tag.h" ] && MISSING
="libid3tag $MISSING"
47 [ ! -e "/usr/include/ogg/ogg.h" ] && MISSING
="libogg $MISSING"
48 [ ! -e "/usr/include/vorbis/codec.h" ] && MISSING
="libvorbis $MISSING"
49 [ ! -e "/usr/include/FLAC/metadata.h" ] && MISSING
="libflac $MISSING"
50 [ ! -e "/usr/include/ffmpeg/avutil.h" -a \
51 ! -e "/usr/include/libavutil/avutil.h" -a \
52 ! -e "/usr/include/ffmpeg/libavutil/avutil.h" ] && MISSING
="libavutil $MISSING"
53 [ ! -e "/usr/include/ffmpeg/avformat.h" -a \
54 ! -e "/usr/include/libavformat/avformat.h" -a \
55 ! -e "/usr/include/ffmpeg/libavformat/avformat.h" ] && MISSING
="libavformat $MISSING"
56 [ ! -e "/usr/include/ffmpeg/avcodec.h" -a \
57 ! -e "/usr/include/libavcodec/avcodec.h" -a \
58 ! -e "/usr/include/ffmpeg/libavcodec/avcodec.h" ] && MISSING
="libavcodec $MISSING"
59 if [ -n "$MISSING" ]; then
60 echo -e "\nERROR! Cannot continue."
61 echo -e "The following required libraries are either missing, or are missing development headers:\n"
66 echo "/* MiniDLNA Project" >> ${CONFIGFILE}
67 echo " * http://sourceforge.net/projects/minidlna/" >> ${CONFIGFILE}
68 echo " * (c) 2008-2009 Justin Maggard" >> ${CONFIGFILE}
69 echo " * generated by $0 on `date` */" >> ${CONFIGFILE}
70 echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
71 echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
72 echo "" >> ${CONFIGFILE}
77 MAJORVER
=`echo $OS_VERSION | cut -d. -f1`
78 MINORVER
=`echo $OS_VERSION | cut -d. -f2`
79 #echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER"
80 # rtableid was introduced in OpenBSD 4.0
81 if [ $MAJORVER -ge 4 ]; then
82 echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE}
84 # from the 3.8 version, packets and bytes counters are double : in/out
85 if [ \
( $MAJORVER -ge 4 \
) -o \
( $MAJORVER -eq 3 -a $MINORVER -ge 8 \
) ]; then
86 echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
88 OS_URL
=http
://www.openbsd.org
/
91 VER
=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
92 if [ $VER -ge 700049 ]; then
93 echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
95 OS_URL
=http
://www.freebsd.org
/
98 # we need to detect if PFRULE_INOUT_COUNTS macro is needed
99 OS_URL
=http
://www.pfsense.com
/
102 OS_URL
=http
://www.netbsd.org
/
105 echo "#define USE_IPF 1" >> ${CONFIGFILE}
106 echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
107 echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE}
108 echo "typedef uint64_t u_int64_t;" >> ${CONFIGFILE}
109 echo "typedef uint32_t u_int32_t;" >> ${CONFIGFILE}
110 echo "typedef uint16_t u_int16_t;" >> ${CONFIGFILE}
111 echo "typedef uint8_t u_int8_t;" >> ${CONFIGFILE}
112 OS_URL
=http
://www.sun.com
/solaris
/
115 OS_URL
=http
://www.kernel.org
/
116 KERNVERA
=`echo $OS_VERSION | awk -F. '{print $1}'`
117 KERNVERB
=`echo $OS_VERSION | awk -F. '{print $2}'`
118 KERNVERC
=`echo $OS_VERSION | awk -F. '{print $3}'`
119 KERNVERD
=`echo $OS_VERSION | awk -F. '{print $4}'`
120 #echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD"
121 # NETGEAR ReadyNAS special case
122 if [ -f /etc
/raidiator_version
]; then
123 OS_NAME
=$
(awk -F'!!|=' '{ print $1 }' /etc
/raidiator_version
)
124 OS_VERSION
=$
(awk -F'!!|[=,.]' '{ print $3"."$4 }' /etc
/raidiator_version
)
125 OS_URL
="http://www.readynas.com/"
127 DB_PATH
="/var/cache/minidlna"
128 TIVO
="#define TIVO_SUPPORT"
129 NETGEAR
="#define NETGEAR"
130 READYNAS
="#define READYNAS"
131 PNPX
="#define PNPX 5"
132 # Debian GNU/Linux special case
133 elif [ -f /etc
/debian_version
]; then
135 OS_VERSION
=`cat /etc/debian_version`
136 OS_URL
=http
://www.debian.org
/
138 # use lsb_release (Linux Standard Base) when available
139 LSB_RELEASE
=`which lsb_release 2>/dev/null`
140 if [ 0 -eq $?
]; then
141 OS_NAME
=`${LSB_RELEASE} -i -s`
142 OS_VERSION
=`${LSB_RELEASE} -r -s`
145 # use lsb_release (Linux Standard Base) when available
146 LSB_RELEASE
=`which lsb_release 2>/dev/null`
147 if [ 0 -eq $?
]; then
148 OS_NAME
=`${LSB_RELEASE} -i -s`
149 OS_VERSION
=`${LSB_RELEASE} -r -s`
154 echo "Unknown OS : $OS_NAME"
159 echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE}
160 echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}
161 echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE}
162 echo "" >> ${CONFIGFILE}
164 echo "/* full path of the file database */" >> ${CONFIGFILE}
165 echo "#define DEFAULT_DB_PATH \"${DB_PATH}\"" >> ${CONFIGFILE}
166 echo "" >> ${CONFIGFILE}
168 echo "/* full path of the log directory */" >> ${CONFIGFILE}
169 echo "#define DEFAULT_LOG_PATH \"${LOG_PATH}\"" >> ${CONFIGFILE}
170 echo "" >> ${CONFIGFILE}
172 echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
173 echo " * of BSD daemon() */" >> ${CONFIGFILE}
174 echo "#define USE_DAEMON" >> ${CONFIGFILE}
175 echo "" >> ${CONFIGFILE}
177 echo "/* Enable if the system inotify.h exists. Otherwise our own inotify.h will be used. */" >> ${CONFIGFILE}
178 if [ -f /usr
/include
/sys
/inotify.h
]; then
179 echo "#define HAVE_INOTIFY_H" >> ${CONFIGFILE}
181 echo "/*#define HAVE_INOTIFY_H*/" >> ${CONFIGFILE}
183 echo "" >> ${CONFIGFILE}
185 echo "/* Enable if the system iconv.h exists. ID3 tag reading in various character sets will not work properly otherwise. */" >> ${CONFIGFILE}
186 if [ -f /usr
/include
/iconv.h
]; then
187 echo "#define HAVE_ICONV_H" >> ${CONFIGFILE}
189 echo -e "\nWARNING!! Iconv support not found. ID3 tag reading may not work."
190 echo "/*#define HAVE_ICONV_H*/" >> ${CONFIGFILE}
192 echo "" >> ${CONFIGFILE}
194 echo "/* Enable if the system libintl.h exists for NLS support. */" >> ${CONFIGFILE}
195 if [ -f /usr
/include
/libintl.h
]; then
196 echo "#define ENABLE_NLS" >> ${CONFIGFILE}
198 echo "/*#define ENABLE_NLS*/" >> ${CONFIGFILE}
200 echo "" >> ${CONFIGFILE}
202 echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE}
203 echo "${NETGEAR}" >> ${CONFIGFILE}
204 echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE}
205 echo "${READYNAS}" >> ${CONFIGFILE}
206 echo "/* Compile in TiVo support. */" >> ${CONFIGFILE}
207 echo "${TIVO}" >> ${CONFIGFILE}
208 echo "/* Enable PnPX support. */" >> ${CONFIGFILE}
209 echo "${PNPX}" >> ${CONFIGFILE}
210 echo "" >> ${CONFIGFILE}
212 echo "#endif" >> ${CONFIGFILE}