Skip to content

Commit 001bfb9

Browse files
author
Dimitri Stolnikov
committed
add autotools based build system
1 parent 37bb5ca commit 001bfb9

18 files changed

+2340
-17
lines changed

AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Steve Markgraf <steve@steve-m.de>
2+
Dimitri Stolnikov <horiz0n@gmx.net>

COPYING

+339
Large diffs are not rendered by default.

Doxyfile.in

+1,716
Large diffs are not rendered by default.

Makefile.am

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
2+
ACLOCAL_AMFLAGS = -I m4
3+
4+
INCLUDES = $(all_includes) -I$(top_srcdir)/include
5+
SUBDIRS = include src
6+
7+
pkgconfigdir = $(libdir)/pkgconfig
8+
pkgconfig_DATA = librtlsdr.pc
9+
10+
BUILT_SOURCES = $(top_srcdir)/.version
11+
$(top_srcdir)/.version:
12+
echo $(VERSION) > $@-t && mv $@-t $@
13+
dist-hook:
14+
echo $(VERSION) > $(distdir)/.tarball-version
15+
16+
EXTRA_DIST = git-version-gen
17+
18+
if HAVE_DOXYGEN
19+
20+
pkgdocdir=$(docdir)/$(PACKAGE)-$(VERSION)
21+
doc_htmldir=$(pkgdocdir)/html
22+
23+
doc_html_DATA = $(top_builddir)/doc/html.tar
24+
25+
$(doc_html_DATA): $(top_builddir)/doc/html/index.html
26+
cd $(top_builddir)/doc && tar cf html.tar html
27+
28+
$(top_builddir)/doc/html/index.html: $(SOURCES) Doxyfile
29+
@rm -rf doc
30+
mkdir -p doc
31+
$(DOXYGEN) Doxyfile
32+
33+
install-data-hook:
34+
cd $(DESTDIR)$(doc_htmldir) && tar xf html.tar --strip-components 1 && rm -f html.tar
35+
36+
uninstall-hook:
37+
cd $(DESTDIR) && rm -rf $(doc_htmldir)
38+
39+
DX_CLEAN = doc/{html,latex}/* doc/html.tar
40+
41+
endif
42+
43+
MOSTLYCLEANFILES = $(DX_CLEAN)

README

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
rtl-sdr
2-
Software to turn the Realtek RTL2832U into a SDR
2+
Software to turn Realtek RTL2832U based DVB-T receivers into SDR
33
======================================================================
44

55
For more information see:

configure.ac

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
AC_INIT([librtlsdr],
2+
m4_esyscmd([./git-version-gen .tarball-version]),
3+
[osmosdr@lists.osmocom.org])
4+
5+
AM_INIT_AUTOMAKE([dist-bzip2])
6+
7+
dnl kernel style compile messages
8+
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
9+
10+
dnl checks for programs
11+
AC_PROG_MAKE_SET
12+
AC_PROG_CC
13+
AC_PROG_INSTALL
14+
LT_INIT
15+
AC_PROG_LIBTOOL
16+
17+
PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0)
18+
LIBS="$LIBS $LIBUSB_LIBS"
19+
CFLAGS="$CFLAGS $LIBUSB_CFLAGS"
20+
21+
AC_PATH_PROG(DOXYGEN,doxygen,false)
22+
AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false)
23+
24+
AC_CONFIG_MACRO_DIR([m4])
25+
26+
dnl checks for header files
27+
AC_HEADER_STDC
28+
AC_CHECK_HEADERS(sys/types.h)
29+
30+
# The following test is taken from WebKit's webkit.m4
31+
saved_CFLAGS="$CFLAGS"
32+
CFLAGS="$CFLAGS -fvisibility=hidden "
33+
AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
34+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
35+
[ AC_MSG_RESULT([yes])
36+
SYMBOL_VISIBILITY="-fvisibility=hidden"],
37+
AC_MSG_RESULT([no]))
38+
CFLAGS="$saved_CFLAGS"
39+
AC_SUBST(SYMBOL_VISIBILITY)
40+
41+
dnl Generate the output
42+
AM_CONFIG_HEADER(config.h)
43+
44+
AC_OUTPUT(
45+
librtlsdr.pc
46+
include/Makefile
47+
src/Makefile
48+
Makefile
49+
Doxyfile
50+
)

git-version-gen

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/bin/sh
2+
# Print a version string.
3+
scriptversion=2010-01-28.01
4+
5+
# Copyright (C) 2007-2010 Free Software Foundation, Inc.
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
20+
# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
21+
# It may be run two ways:
22+
# - from a git repository in which the "git describe" command below
23+
# produces useful output (thus requiring at least one signed tag)
24+
# - from a non-git-repo directory containing a .tarball-version file, which
25+
# presumes this script is invoked like "./git-version-gen .tarball-version".
26+
27+
# In order to use intra-version strings in your project, you will need two
28+
# separate generated version string files:
29+
#
30+
# .tarball-version - present only in a distribution tarball, and not in
31+
# a checked-out repository. Created with contents that were learned at
32+
# the last time autoconf was run, and used by git-version-gen. Must not
33+
# be present in either $(srcdir) or $(builddir) for git-version-gen to
34+
# give accurate answers during normal development with a checked out tree,
35+
# but must be present in a tarball when there is no version control system.
36+
# Therefore, it cannot be used in any dependencies. GNUmakefile has
37+
# hooks to force a reconfigure at distribution time to get the value
38+
# correct, without penalizing normal development with extra reconfigures.
39+
#
40+
# .version - present in a checked-out repository and in a distribution
41+
# tarball. Usable in dependencies, particularly for files that don't
42+
# want to depend on config.h but do want to track version changes.
43+
# Delete this file prior to any autoconf run where you want to rebuild
44+
# files to pick up a version string change; and leave it stale to
45+
# minimize rebuild time after unrelated changes to configure sources.
46+
#
47+
# It is probably wise to add these two files to .gitignore, so that you
48+
# don't accidentally commit either generated file.
49+
#
50+
# Use the following line in your configure.ac, so that $(VERSION) will
51+
# automatically be up-to-date each time configure is run (and note that
52+
# since configure.ac no longer includes a version string, Makefile rules
53+
# should not depend on configure.ac for version updates).
54+
#
55+
# AC_INIT([GNU project],
56+
# m4_esyscmd([build-aux/git-version-gen .tarball-version]),
57+
# [bug-project@example])
58+
#
59+
# Then use the following lines in your Makefile.am, so that .version
60+
# will be present for dependencies, and so that .tarball-version will
61+
# exist in distribution tarballs.
62+
#
63+
# BUILT_SOURCES = $(top_srcdir)/.version
64+
# $(top_srcdir)/.version:
65+
# echo $(VERSION) > $@-t && mv $@-t $@
66+
# dist-hook:
67+
# echo $(VERSION) > $(distdir)/.tarball-version
68+
69+
case $# in
70+
1) ;;
71+
*) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version"; exit 1;;
72+
esac
73+
74+
tarball_version_file=$1
75+
nl='
76+
'
77+
78+
# First see if there is a tarball-only version file.
79+
# then try "git describe", then default.
80+
if test -f $tarball_version_file
81+
then
82+
v=`cat $tarball_version_file` || exit 1
83+
case $v in
84+
*$nl*) v= ;; # reject multi-line output
85+
[0-9]*) ;;
86+
*) v= ;;
87+
esac
88+
test -z "$v" \
89+
&& echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2
90+
fi
91+
92+
if test -n "$v"
93+
then
94+
: # use $v
95+
elif
96+
v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
97+
|| git describe --abbrev=4 HEAD 2>/dev/null` \
98+
&& case $v in
99+
[0-9]*) ;;
100+
v[0-9]*) ;;
101+
*) (exit 1) ;;
102+
esac
103+
then
104+
# Is this a new git that lists number of commits since the last
105+
# tag or the previous older version that did not?
106+
# Newer: v6.10-77-g0f8faeb
107+
# Older: v6.10-g0f8faeb
108+
case $v in
109+
*-*-*) : git describe is okay three part flavor ;;
110+
*-*)
111+
: git describe is older two part flavor
112+
# Recreate the number of commits and rewrite such that the
113+
# result is the same as if we were using the newer version
114+
# of git describe.
115+
vtag=`echo "$v" | sed 's/-.*//'`
116+
numcommits=`git rev-list "$vtag"..HEAD | wc -l`
117+
v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`;
118+
;;
119+
esac
120+
121+
# Change the first '-' to a '.', so version-comparing tools work properly.
122+
# Remove the "g" in git describe's output string, to save a byte.
123+
v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
124+
else
125+
v=UNKNOWN
126+
fi
127+
128+
v=`echo "$v" |sed 's/^v//'`
129+
130+
# Don't declare a version "dirty" merely because a time stamp has changed.
131+
git status > /dev/null 2>&1
132+
133+
dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
134+
case "$dirty" in
135+
'') ;;
136+
*) # Append the suffix only if there isn't one already.
137+
case $v in
138+
*-dirty) ;;
139+
*) v="$v-dirty" ;;
140+
esac ;;
141+
esac
142+
143+
# Omit the trailing newline, so that m4_esyscmd can use the result directly.
144+
echo "$v" | tr -d '\012'
145+
146+
# Local variables:
147+
# eval: (add-hook 'write-file-hooks 'time-stamp)
148+
# time-stamp-start: "scriptversion="
149+
# time-stamp-format: "%:y-%02m-%02d.%02H"
150+
# time-stamp-end: "$"
151+
# End:

include/Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rtlsdr_HEADERS = rtl-sdr.h
2+
3+
noinst_HEADERS = i2c.h tuner_e4000.h tuner_fc0013.h
4+
5+
rtlsdrdir = $(includedir)

src/i2c.h include/i2c.h

File renamed without changes.

src/rtl-sdr.h include/rtl-sdr.h

File renamed without changes.
File renamed without changes.
File renamed without changes.

librtlsdr.pc.in

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
prefix=@prefix@
2+
exec_prefix=@exec_prefix@
3+
libdir=@libdir@
4+
includedir=@includedir@
5+
6+
Name: RTL-SDR Library
7+
Description: C Utility Library
8+
Version: @VERSION@
9+
Libs: -L${libdir} -lrtlsdr -lusb-1.0
10+
Cflags: -I${includedir}/

m4/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/libtool.m4
2+
/lt*.m4

src/Makefile

-10
This file was deleted.

src/Makefile.am

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This is _NOT_ the library release version, it's an API version.
2+
# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
3+
LIBVERSION=0:0:0
4+
5+
INCLUDES = $(all_includes) -I$(top_srcdir)/include
6+
AM_CFLAGS = -fPIC -Wall
7+
8+
lib_LTLIBRARIES = librtlsdr.la
9+
10+
librtlsdr_la_SOURCES = rtl-sdr.c tuner_e4000.c tuner_fc0013.c
11+
librtlsdr_la_LDFALGS = -version-info $(LIBVERSION)
12+
13+
bin_PROGRAMS = rtl_sdr
14+
rtl_sdr_SOURCES = main.c
15+
rtl_sdr_LDADD = librtlsdr.la

src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int do_exit = 0;
3232

3333
void usage(void)
3434
{
35-
printf("rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
35+
printf("rtl-sdr, an I/Q recorder for RTL2832 based DVB-T receivers\n\n"
3636
"Usage:\t -f frequency to tune to [Hz]\n"
3737
"\t[-s samplerate (default: 2048000 Hz)]\n"
3838
"\toutput filename\n");
@@ -48,7 +48,7 @@ int main(int argc, char **argv)
4848
{
4949
struct sigaction sigact;
5050
int r, opt;
51-
char *filename;
51+
char *filename = NULL;
5252
uint32_t frequency = 0, samp_rate = 2048000;
5353
uint8_t buffer[READLEN];
5454
uint32_t n_read;

src/rtl-sdr.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ uint32_t rtlsdr_get_device_count(void)
399399
{
400400
int i, j;
401401
libusb_device **list;
402-
uint32_t device_count;
402+
uint32_t device_count = 0;
403403
struct libusb_device_descriptor dd;
404404

405405
ssize_t cnt = libusb_get_device_list(NULL, &list);
@@ -424,7 +424,7 @@ const char *rtlsdr_get_device_name(uint32_t index)
424424
libusb_device **list;
425425

426426
ssize_t cnt = libusb_get_device_list(NULL, &list);
427-
427+
428428
if (index > cnt - 1)
429429
return NULL;
430430

@@ -451,7 +451,7 @@ rtlsdr_dev_t *rtlsdr_open(int index)
451451
memset(dev, 0, sizeof(rtlsdr_dev_t));
452452

453453
ssize_t cnt = libusb_get_device_list(NULL, &list);
454-
454+
455455
for (i = 0; i < cnt; i++) {
456456
device = list[i];
457457

@@ -483,7 +483,7 @@ rtlsdr_dev_t *rtlsdr_open(int index)
483483
}
484484

485485
libusb_free_device_list(list, 0);
486-
486+
487487
unsigned char buffer[256];
488488

489489
libusb_get_string_descriptor_ascii(dev->devh, 0, buffer, sizeof(buffer) );

0 commit comments

Comments
 (0)