aboutsummaryrefslogtreecommitdiff
path: root/configure
blob: 42dfa9ad06d8ed781734599a85de70098e4ef915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/usr/bin/env bash
#
# ToscoConf 0.04
# Copyright (c) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br>
# All rights reserved.
#
# This script is in the Tosco Public License. It may be copied and/or
# modified, in whole or in part, provided that all copies must retain the
# above copyright notice, this condition and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#
# (yes, I did a copy&paste from the BSD license, eat me)
#
# ---------------------------------------------------------------------------

PACKAGE=`basename ${PWD} | cut -d"-" -f1`;
VERSION=`basename ${PWD} | cut -d"-" -f2`;

if [ "$PACKAGE" == "$VERSION" ]; then
	VERSION=$(printf "SVN_%d" $(LC_ALL=C svn -R info|grep Revision|cut -d: -f2|sort -n|tail -n1))
	RELEASE=0
else
	RELEASE=1
fi

echo "ToscoConf (version 0.04) for $PACKAGE version $VERSION"

# ---------------------------------------------------------------------------

echo "Determining system architecture."
OS=`uname`
case $OS in		
	Linux)
		;;
	*)
		echo "$OS (not supported, yet!)"
		exit ;;
esac	

PROC=`uname -m`
case $PROC in
	i?86)
		ln -sf linux/x86 arch/this
		ARCH="ARCH_i386" ;;
	ppc*)
		ln -sf linux/ppc arch/this
		ARCH="ARCH_PPC" ;;
	x86_64)
		ln -sf linux/x86_64 arch/this
		ARCH="ARCH_x86_64" ;;
	mips*)
		ln -sf linux/mips arch/this
		ARCH="ARCH_MIPS" ;;
	parisc*)
		ln -sf linux/parisc arch/this
		ARCH="ARCH_PARISC" ;;
	sparc*)
		ln -sf linux/sparc arch/this
		ARCH="ARCH_SPARC" ;;
	armv*)
		ln -sf linux/armv4l arch/this
		ARCH="ARCH_ARMV4L" ;;
        ia64)
                ln -sf linux/ia64  arch/this
                ARCH="ARCH_IA64" ;;
        alpha)
                ln -sf linux/alpha  arch/this
                ARCH="ARCH_ALPHA" ;;
        s390)
                ln -sf linux/s390  arch/this
                ARCH="ARCH_S390" ;;
	m68k)
		ln -sf linux/m68k arch/this
		ARCH="ARCH_m68k" ;;
esac

if [ "x$ARCH" == "x" ]; then
	echo "Your architecture is not supported yet. Please send the"
	echo "output of the following commands to leandro@linuxmag.com.br:"
	echo ""
	echo "  $ cat /proc/cpuinfo"
	echo "  $ uname -a"
	echo "  $ uname -m"
	exit 1
fi

# ---------------------------------------------------------------------------

echo "Compiling $PACKAGE for $OS $PROC ($ARCH)."
echo ""

# ---------------------------------------------------------------------------

echo -n "Checking for lspci... "
LSPCIPATH="/sbin/lspci /usr/sbin/lspci /bin/lspci /usr/bin/lspci `which lspci 2>/dev/null`"
for i in $LSPCIPATH; do
	if [ -x "$i" ]; then
		LSPCI=$i
		break
	fi
done

if [ -e "$LSPCI" ]; then
	echo $LSPCI
else
	echo "lspci cannot be found"
	exit
fi

# ---------------------------------------------------------------------------

GTK2=-1
MIN_VERSION="2.6.0"
echo -n "Checking for GTK version >= ${MIN_VERSION}... "
for i in `which pkg-config`; do
	$i --errors-to-stdout gtk+-2.0 \
		--atleast-version=$MIN_VERSION > /dev/null
	case $? in
		0)
			GTK_FLAGS=`pkg-config gtk+-2.0 --cflags`
			GTK_LIBS=`pkg-config gtk+-2.0 --libs`
			echo "found `pkg-config gtk+-2.0 --modversion`"
			GTK2=1
			break ;;
		*)
			echo "not found." ;;
	esac
done

# --------------------------------------------------------------------------

if [ $GTK2 -eq -1 ]; then
	echo -e "\nYou need the GTK libraries, including the development stuff."
	echo "If you're using Debian, running the command as root:"
	echo -e "\n\taptitude install libgtk2.0-dev\n"
	echo "Will do the trick."
	exit 1
fi

# ---------------------------------------------------------------------------

SOUP=-1
MIN_VERSION="2.2.7"
echo -n "Checking for libsoup version >= ${MIN_VERSION}... "
for i in `which pkg-config`; do
	$i --errors-to-stdout libsoup-2.2 \
		--atleast-version=$MIN_VERSION > /dev/null
	case $? in
		0)
			SOUP_FLAGS=`pkg-config libsoup-2.2 --cflags --static`
			SOUP_LIBS=`pkg-config libsoup-2.2 --libs --static`
			echo "found `pkg-config libsoup-2.2 --modversion`"
			SOUP=1
			break ;;
		*)
			echo "not found." ;;
	esac
done

# --------------------------------------------------------------------------

if [ $SOUP -eq -1 ]; then
	echo "Disabling libsoup support. (Network Manager won't be available.)"
fi

# --------------------------------------------------------------------------

echo -e "\nWriting config.h..."
rm -f config.h
echo -e "#ifndef __CONFIG_H__\n#define __CONFIG_H__\n" > config.h

echo "#define VERSION \"$VERSION\"" >> config.h

echo "#define LSPCI \"$LSPCI -v\"" >> config.h
echo "#define $ARCH" >> config.h
echo "#define ARCH     \"$ARCH\"" >> config.h

echo "#define PLATFORM \"`uname`\"" >> config.h
echo "#define KERNEL   \"`uname -r`\"" >> config.h
echo "#define HOSTNAME \"`hostname`\"" >> config.h

echo "#define PREFIX \"/usr/share/hardinfo/\"" >> config.h
echo "#define LIBPREFIX \"/usr/lib/hardinfo/\"" >> config.h

if [ "$SOUP" == "1" ]; then
	echo "#define HAS_LIBSOUP" >> config.h
fi

if [ "$RELEASE" == "1" ]; then
	echo "#define DEBUG(...)" >> config.h
else
	echo '#define DEBUG(msg,...) fprintf(stderr, "*** %s:%d (%s) *** " msg "\n", \'  >> config.h
        echo '                               __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)' >> config.h
fi

echo "#define ENABLE_BINRELOC 1" >> config.h
echo "#define RELEASE $RELEASE" >> config.h

echo -e "\n#endif	/* __CONFIG_H__ */" >> config.h

echo "Writing Makefile..."
rm -f Makefile

echo "GTK_LIBS = ${GTK_LIBS}" > Makefile
echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile
echo "SOUP_LIBS = ${SOUP_LIBS}" >> Makefile
echo "SOUP_CFLAGS = ${SOUP_FLAGS}" >> Makefile
echo "PACKAGE = `basename ${PWD}`" >> Makefile
echo "ARCHOPTS = " >> Makefile

cat Makefile.in >> Makefile

echo -e "\nDone. Type \"make\" to compile the program.\n"


if [ "$RELEASE" == 0 ]; then
	cat << EOF
*********************************************************
* This is work in progress! Please report bugs at:      *
*      http://developer.berlios.de/bugs/?group_id=5897  *
* Or send patches to:                                   *
*      http://developer.berlios.de/patch/?group_id=5897 *
*********************************************************
EOF
else
	cat << EOF
If you get errors, probably you don't have the right libraries,
includes or utilities. However, if you're sure this is a bug in my
code, please send a patch (use "diff -u") to <leandro@linuxmag.com.br>.
EOF
fi