Skip to content

Commit

Permalink
Revamp build system
Browse files Browse the repository at this point in the history
autotools suck.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
felipec committed Jan 12, 2010
1 parent 9f8f20e commit 26d82fe
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 42 deletions.
78 changes: 78 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
CC := gcc
CXX := g++

CPPFLAGS := -ggdb -Wall -Wextra -Wno-unused-parameter

TAGLIB_CPPFLAGS := $(shell pkg-config --cflags taglib)
TAGLIB_LIBS := $(shell pkg-config --libs taglib)

prefix := /usr
version := $(shell ./get-version)

all:

libmtag.so: lib/mtag.o
libmtag.so: CPPFLAGS := $(CPPFLAGS) $(TAGLIB_CPPFLAGS) -I./lib
libmtag.so: LIBS := $(LIBS) $(TAGLIB_LIBS)
libmtag.so: LDFLAGS := $(LDFLAGS) -Wl,-soname,libmtag.so.0

mtag: src/mtag.o | libmtag.so
mtag: CPPFLAGS := $(CPPFLAGS) -I./lib
mtag: LIBS := $(LIBS) -L./ -lmtag
binaries += mtag

tests/reader: tests/reader.o | libmtag.so
tests/reader: CPPFLAGS := $(CPPFLAGS) -I./lib
tests/reader: LIBS := $(LIBS) -L./ -lmtag
binaries += tests/reader

all: libmtag.so $(binaries)

libmtag.pc: libmtag.pc.in
sed -e 's#@prefix@#$(prefix)#g' -e 's#@version@#$(version)#g' $< > $@

D = $(DESTDIR)

install: libmtag.so libmtag.pc
mkdir -p $(D)/$(prefix)/lib
install -m 755 libmtag.so $(D)/$(prefix)/lib/libmtag.so.0
ln -sf libmtag.so.0 $(D)/$(prefix)/lib/libmtag.so
mkdir -p $(D)/$(prefix)/include/libmtag
install -m 644 lib/mtag.h $(D)/$(prefix)/include/libmtag
mkdir -p $(D)/$(prefix)/lib/pkgconfig
install -m 644 libmtag.pc $(D)/$(prefix)/lib/pkgconfig/libmtag.pc

dist: base := libmtag-$(version)
dist:
git archive --format=tar --prefix=$(base)/ HEAD > /tmp/$(base).tar
mkdir -p $(base)
echo $(version) > $(base)/.version
chmod 664 $(base)/.version
tar --append -f /tmp/$(base).tar --owner root --group root $(base)/.version
rm -r $(base)
gzip /tmp/$(base).tar

# pretty print
V = @
Q = $(V:y=)
QUIET_CC = $(Q:@=@echo ' CC '$@;)
QUIET_CXX = $(Q:@=@echo ' CXX '$@;)
QUIET_LINK = $(Q:@=@echo ' LINK '$@;)
QUIET_CLEAN = $(Q:@=@echo ' CLEAN '$@;)

%.so::
$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)

$(binaries):
$(QUIET_LINK)$(CC) $(LDFLAGS) $(LIBS) -o $@ $^

%.o:: %.cpp
$(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -o $@ -c $<

%.o:: %.c
$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -o $@ -c $<

clean:
$(QUIET_CLEAN)$(RM) $(binaries) `find -name '[*.oad]'`

-include lib/*.d src/*.d tests/*.d
11 changes: 0 additions & 11 deletions Makefile.am

This file was deleted.

10 changes: 0 additions & 10 deletions build-aux/version-gen

This file was deleted.

8 changes: 8 additions & 0 deletions get-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

if test -f .version
then
cat .version
else
git describe --tags | sed 's/^v//'
fi
9 changes: 0 additions & 9 deletions lib/Makefile.am

This file was deleted.

7 changes: 3 additions & 4 deletions libmtag.pc.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libmtag
Description: Music tagging library
Version: @VERSION@
Version: @version@
Libs: -L${libdir} -lmtag
Cflags: -I${includedir}/libmtag
Empty file removed m4/.dummy
Empty file.
4 changes: 0 additions & 4 deletions src/Makefile.am

This file was deleted.

4 changes: 0 additions & 4 deletions tests/Makefile.am

This file was deleted.

0 comments on commit 26d82fe

Please sign in to comment.