Skip to content

Commit

Permalink
Put VERSION macros in global.h
Browse files Browse the repository at this point in the history
Configure derives the version and then ensures it is assigned and used
where necessary.

A dist target for Makefile thus not duplicating version determination
logic.

Dedup'd findsrc.pl into a Ruby module.
  • Loading branch information
mxcl committed Jun 14, 2009
1 parent 09dc6cb commit e0488db
Show file tree
Hide file tree
Showing 16 changed files with 182 additions and 214 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/admin/dist.sh export-ignore
/admin/cleansrc.sh export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
47 changes: 34 additions & 13 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ Fork it: http://github.com/mxcl/liblastfm

Dependencies
============
The build process requires ruby, Qt>=4.4 and GNU make (or MS nmake).
liblastfm dynamically links to:

* Qt 4.4
http://www.qtsoftware.com
* FFTW 3.2
Compiled with single precision
http://www.fftw.org
* Secret Rabbit code (aka libsamplerate)
http://www.mega-nerd.com/SRC

Additionally, to build you will need Ruby and GNU make (or Microsoft nmake).

Mac OS X
--------
Expand All @@ -24,37 +34,48 @@ Mac OS X
qt4-mac-devel will take a long time to build. So you may want to install the
Trolltech binary package instead.

Macports carries liblastfm now, so you may have downloaded this package simply
to perform this next line:

sudo port install liblastfm

Linux
-----
For Ubuntu 9.04 (some are build deps, eg. Ruby is used during configure):
Do something like this:

sudo apt-get install qt4-qmake pkg-config libsamplerate-dev libfftw3-dev ruby g++ libqt4-dev

The configure process also requires lsb_release on Linux. This is usually
already installed (correct me if I'm wrong).
Additionally on Linux the configure process requires lsb_release. This is
usually already installed (correct me if I'm wrong).

Windows
-------
Best of luck to you. You'll need Ruby, GNU Make and the Windows Server 2003
Platform SDK r2:
Install Ruby. Install Visual Studio 2005 or higher. Install Qt. Install the
Windows Server 2003 Platform SDK r2:

http://www.microsoft.com/Downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a

Set up your environment variables so all include paths and tools are
available.

http://www.microsoft.com/Downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a&displaylang=en
Build and install FFTW and Secret Rabbit Code.

liblastfm should build under both cygwin and regular Windows shell.
Open a plain Windows shell (Cygwin will work but we don't recommend it), and
see the next section.


Installing liblastfm
====================
./configure --release --prefix /usr/local && make && sudo make install
ruby configure --release --prefix /usr/local && make && sudo make install

Packaging liblastfm
-------------------
DESTDIR is supported.

The library is split into liblastfm and liblastfm_fingerprint. The
fingerprinting part is separate as it links to libfftw3. So if you want to
package it separately then you can. Sadly because there is simply no good
configuration system in the world, you still have to build both…
liblastfm builds to two dynamic libraries (liblastfm.so and
liblastfm_fingerprint.so). liblastfm.so links only to Qt, but the
fingerprinting part has additional dependencies. So ideally, you would
distribute two packages.


Using liblastfm
Expand Down
55 changes: 31 additions & 24 deletions admin/Makefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
######################################################################### defs
case Platform::IMPL
when :mswin
$cp='ruby -e "require \'FileUtils\'; FileUtils.copy_file(ARGV[0], ARGV[1])" --'
$ln=$cp
$mkdir='ruby -e "require \'FileUtils\'; FileUtils.mkpath ARGV[0]" --'
$orderonly=''
CP='ruby -e "require \'FileUtils\'; FileUtils.copy_file(ARGV[0], ARGV[1])" --'
LN=CP
MKDIR='ruby -e "require \'FileUtils\'; FileUtils.mkpath ARGV[0]" --'
ORDERONLY=''
else
$cp='cp'
$ln='cp' #'ln -sf' oddly doesn't work, the target is always remade
$mkdir='mkdir -p'
$orderonly='|'
CP='cp'
LN='cp' #'ln -sf' oddly doesn't work, the target is always remade
MKDIR='mkdir -p'
ORDERONLY='|'
end

def penis( path )
Expand All @@ -38,10 +38,10 @@ def penis( path )


######################################################################### main
INSTALL_PREFIX=ENV['LFM_PREFIX']
abort("Environment variable LFM_PREFIX not defined") if INSTALL_PREFIX.nil?
$install_headers=''
$headers=''
$install_prefix = ENV['LFM_PREFIX']
abort("Environment variable LFM_PREFIX not defined") if $install_prefix.nil?

puts <<-EOS
.PHONY: all
Expand Down Expand Up @@ -95,13 +95,13 @@ def penis( path )

begin
lhd='_include/lastfm'
ihd="$(DESTDIR)#{$install_prefix}/include/lastfm"
ihd="$(DESTDIR)#{INSTALL_PREFIX}/include/lastfm"
ARGV.each do |header|
penis "src/#{header}" do |path, classname|
puts "#{lhd}/#{classname}: #{path} #{$orderonly} #{lhd}"
puts " #{$ln} #{path} $@"
puts "#{ihd}/#{classname}: #{path} #{$orderonly} #{ihd}"
puts " #{$cp} #{path} $@"
puts "#{lhd}/#{classname}: #{path} #{ORDERONLY} #{lhd}"
puts " #{LN} #{path} $@"
puts "#{ihd}/#{classname}: #{path} #{ORDERONLY} #{ihd}"
puts " #{CP} #{path} $@"
puts
$headers+=" #{lhd}/#{classname}"
$install_headers+=" #{ihd}/#{classname}"
Expand All @@ -111,21 +111,28 @@ def penis( path )

puts <<-EOS
_include/lastfm:
#{$mkdir} $@
$(DESTDIR)#{$install_prefix}/include/lastfm:
#{$mkdir} $@
#{MKDIR} $@
$(DESTDIR)#{INSTALL_PREFIX}/include/lastfm:
#{MKDIR} $@
_include/lastfm.h: #{$headers} #{$orderonly} _include/lastfm
_include/lastfm.h: #{$headers} #{ORDERONLY} _include/lastfm
ruby admin/lastfm.h.rb $@
$(DESTDIR)#{$install_prefix}/include/lastfm.h: _include/lastfm.h #{$orderonly} $(DESTDIR)#{$install_prefix}/include/lastfm
#{$cp} _include/lastfm.h $@
$(DESTDIR)#{INSTALL_PREFIX}/include/lastfm.h: _include/lastfm.h #{ORDERONLY} $(DESTDIR)#{INSTALL_PREFIX}/include/lastfm
#{CP} _include/lastfm.h $@
.PHONY: headers
headers: #{$headers} _include/lastfm.h
.PHONY: install
install: #{$install_headers} $(DESTDIR)#{$install_prefix}/include/lastfm.h
cd src && make install "INSTALL_ROOT=$(DESTDIR)#{$install_prefix}"
cd src/fingerprint && make install "INSTALL_ROOT=$(DESTDIR)#{$install_prefix}"
install: #{$install_headers} $(DESTDIR)#{INSTALL_PREFIX}/include/lastfm.h
cd src && $(MAKE) install "INSTALL_ROOT=$(DESTDIR)#{INSTALL_PREFIX}"
cd src/fingerprint && $(MAKE) install "INSTALL_ROOT=$(DESTDIR)#{INSTALL_PREFIX}"
EOS

BASENAME='liblastfm-'+ENV['LFM_VERSION']
puts <<-EOS
.PHONY: dist
dist:
git archive --prefix=#{BASENAME}/ HEAD | bzip2 > #{BASENAME}.tar.bz2
EOS
6 changes: 2 additions & 4 deletions admin/cleansrc.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh

d=`dirname $0`

for x in `$d/findsrc cpp` `$d/findsrc h`
cd `dirname $0`/..
for x in `admin/findsrc.rb cpp h`
do
tab2space -unix $x $x
#(echo ',s/ *$//'; echo 'wq') | ed -s $x
Expand Down
12 changes: 0 additions & 12 deletions admin/dist.sh

This file was deleted.

44 changes: 0 additions & 44 deletions admin/findsrc

This file was deleted.

33 changes: 33 additions & 0 deletions admin/findsrc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/ruby
require 'find'
require "#{File.dirname __FILE__}/platform"

def findsrc dir='.'
excludes = ['.svn','.git','_include','tests','_build']
case Platform::IMPL
when :macosx then excludes<<'win'
when :mswin, :cygwin then excludes<<'mac'
else excludes<<'win'<<'mac'
end
Find.find dir do |path|
next if path == dir # oddly neccessary
path.sub! %r[^\./], ''
if File.directory? path
Find.prune if excludes.include? File.basename(path)
#don't recurse into dirs with pro files in
Find.prune if Dir["#{path}/*.pro"].length > 0 and $findsrc_prune_pro
elsif File.file? path
case Platform::IMPL
when :macosx then next if /_mac\.cpp$/.match path
when :mswin, :cygwin then next if /_win\.cpp$/.match path
end
yield( path, File.extname( path ) ) unless File.basename(path) == 'EXAMPLE.cpp'
end
end
end
if $0 == __FILE__
extnames=ARGV.collect {|extname| ".#{extname}"}
findsrc {|path,extname| puts path if extnames.include? extname}
end
3 changes: 1 addition & 2 deletions admin/lastfm.h.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/ruby

f = File.new(ARGV[0], "w")
Dir["_include/lastfm/*"].each do |h|
f.write %Q{#include "lastfm/#{File.basename h}"\n}
end
end
Loading

0 comments on commit e0488db

Please sign in to comment.