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 | ;; |
---|
98 | pfSense) |
---|
99 | # we need to detect if PFRULE_INOUT_COUNTS macro is needed |
---|
100 | OS_URL=http://www.pfsense.com/ |
---|
101 | ;; |
---|
102 | NetBSD) |
---|
103 | OS_URL=http://www.netbsd.org/ |
---|
104 | ;; |
---|
105 | SunOS) |
---|
106 | echo "#define USE_IPF 1" >> ${CONFIGFILE} |
---|
107 | echo "#define LOG_PERROR 0" >> ${CONFIGFILE} |
---|
108 | echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE} |
---|
109 | echo "typedef uint64_t u_int64_t;" >> ${CONFIGFILE} |
---|
110 | echo "typedef uint32_t u_int32_t;" >> ${CONFIGFILE} |
---|
111 | echo "typedef uint16_t u_int16_t;" >> ${CONFIGFILE} |
---|
112 | echo "typedef uint8_t u_int8_t;" >> ${CONFIGFILE} |
---|
113 | OS_URL=http://www.sun.com/solaris/ |
---|
114 | ;; |
---|
115 | Linux) |
---|
116 | OS_URL=http://www.kernel.org/ |
---|
117 | KERNVERA=`echo $OS_VERSION | awk -F. '{print $1}'` |
---|
118 | KERNVERB=`echo $OS_VERSION | awk -F. '{print $2}'` |
---|
119 | KERNVERC=`echo $OS_VERSION | awk -F. '{print $3}'` |
---|
120 | KERNVERD=`echo $OS_VERSION | awk -F. '{print $4}'` |
---|
121 | #echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD" |
---|
122 | # NETGEAR ReadyNAS special case |
---|
123 | if [ -f /etc/raidiator_version ]; then |
---|
124 | OS_NAME=$(awk -F'!!|=' '{ print $1 }' /etc/raidiator_version) |
---|
125 | OS_VERSION=$(awk -F'!!|[=,.]' '{ print $3"."$4 }' /etc/raidiator_version) |
---|
126 | OS_URL="http://www.readynas.com/" |
---|
127 | LOG_PATH="/var/log" |
---|
128 | DB_PATH="/var/cache/minidlna" |
---|
129 | TIVO="#define TIVO_SUPPORT" |
---|
130 | NETGEAR="#define NETGEAR" |
---|
131 | READYNAS="#define READYNAS" |
---|
132 | PNPX="#define PNPX 5" |
---|
133 | # Debian GNU/Linux special case |
---|
134 | elif [ -f /etc/debian_version ]; then |
---|
135 | OS_NAME=Debian |
---|
136 | OS_VERSION=`cat /etc/debian_version` |
---|
137 | OS_URL=http://www.debian.org/ |
---|
138 | LOG_PATH="/var/log" |
---|
139 | # use lsb_release (Linux Standard Base) when available |
---|
140 | LSB_RELEASE=`which lsb_release 2>/dev/null` |
---|
141 | if [ 0 -eq $? ]; then |
---|
142 | OS_NAME=`${LSB_RELEASE} -i -s` |
---|
143 | OS_VERSION=`${LSB_RELEASE} -r -s` |
---|
144 | fi |
---|
145 | else |
---|
146 | # use lsb_release (Linux Standard Base) when available |
---|
147 | LSB_RELEASE=`which lsb_release 2>/dev/null` |
---|
148 | if [ 0 -eq $? ]; then |
---|
149 | OS_NAME=`${LSB_RELEASE} -i -s` |
---|
150 | OS_VERSION=`${LSB_RELEASE} -r -s` |
---|
151 | fi |
---|
152 | fi |
---|
153 | ;; |
---|
154 | *) |
---|
155 | echo "Unknown OS : $OS_NAME" |
---|
156 | exit 1 |
---|
157 | ;; |
---|
158 | esac |
---|
159 | |
---|
160 | echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE} |
---|
161 | echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE} |
---|
162 | echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE} |
---|
163 | echo "" >> ${CONFIGFILE} |
---|
164 | |
---|
165 | echo "/* full path of the file database */" >> ${CONFIGFILE} |
---|
166 | echo "#define DEFAULT_DB_PATH \"${DB_PATH}\"" >> ${CONFIGFILE} |
---|
167 | echo "" >> ${CONFIGFILE} |
---|
168 | |
---|
169 | echo "/* full path of the log directory */" >> ${CONFIGFILE} |
---|
170 | echo "#define DEFAULT_LOG_PATH \"${LOG_PATH}\"" >> ${CONFIGFILE} |
---|
171 | echo "" >> ${CONFIGFILE} |
---|
172 | |
---|
173 | echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE} |
---|
174 | echo " * of BSD daemon() */" >> ${CONFIGFILE} |
---|
175 | echo "#define USE_DAEMON" >> ${CONFIGFILE} |
---|
176 | echo "" >> ${CONFIGFILE} |
---|
177 | |
---|
178 | echo "/* Enable if the system inotify.h exists. Otherwise our own inotify.h will be used. */" >> ${CONFIGFILE} |
---|
179 | if [ -f /usr/include/sys/inotify.h ]; then |
---|
180 | echo "#define HAVE_INOTIFY_H" >> ${CONFIGFILE} |
---|
181 | else |
---|
182 | echo "/*#define HAVE_INOTIFY_H*/" >> ${CONFIGFILE} |
---|
183 | fi |
---|
184 | echo "" >> ${CONFIGFILE} |
---|
185 | |
---|
186 | echo "/* Enable if the system iconv.h exists. ID3 tag reading in various character sets will not work properly otherwise. */" >> ${CONFIGFILE} |
---|
187 | if [ -f /usr/include/iconv.h ]; then |
---|
188 | echo "#define HAVE_ICONV_H" >> ${CONFIGFILE} |
---|
189 | else |
---|
190 | echo -e "\nWARNING!! Iconv support not found. ID3 tag reading may not work." |
---|
191 | echo "/*#define HAVE_ICONV_H*/" >> ${CONFIGFILE} |
---|
192 | fi |
---|
193 | echo "" >> ${CONFIGFILE} |
---|
194 | |
---|
195 | echo "/* Enable if the system libintl.h exists for NLS support. */" >> ${CONFIGFILE} |
---|
196 | if [ -f /usr/include/libintl.h ]; then |
---|
197 | echo "#define ENABLE_NLS" >> ${CONFIGFILE} |
---|
198 | else |
---|
199 | echo "/*#define ENABLE_NLS*/" >> ${CONFIGFILE} |
---|
200 | fi |
---|
201 | echo "" >> ${CONFIGFILE} |
---|
202 | |
---|
203 | echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE} |
---|
204 | echo "${NETGEAR}" >> ${CONFIGFILE} |
---|
205 | echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE} |
---|
206 | echo "${READYNAS}" >> ${CONFIGFILE} |
---|
207 | echo "/* Compile in TiVo support. */" >> ${CONFIGFILE} |
---|
208 | echo "${TIVO}" >> ${CONFIGFILE} |
---|
209 | echo "/* Enable PnPX support. */" >> ${CONFIGFILE} |
---|
210 | echo "${PNPX}" >> ${CONFIGFILE} |
---|
211 | echo "" >> ${CONFIGFILE} |
---|
212 | |
---|
213 | echo "#endif" >> ${CONFIGFILE} |
---|
214 | |
---|
215 | exit 0 |
---|