1
2# Waveform seekbar plugin for the DeaDBeeF audio player
3#
4# Copyright (C) 2013 Christian Boxdörfer <christian.boxdoerfer@posteo.de>
5#
6# Based on sndfile-tools waveform by Erik de Castro Lopo.
7#     waveform.c - v1.04
8#     Copyright (C) 2007-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
9#     Copyright (C) 2012 Robin Gareus <robin@gareus.org>
10#     Copyright (C) 2013 driedfruit <driedfruit@mindloop.net>
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation; either version 2
15# of the License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
25
26
27OUT_GTK2?=ddb_misc_waveform_GTK2.so
28OUT_GTK3?=ddb_misc_waveform_GTK3.so
29
30GTK2_CFLAGS?=`pkg-config --cflags gtk+-2.0`
31GTK3_CFLAGS?=`pkg-config --cflags gtk+-3.0`
32
33GTK2_LIBS?=`pkg-config --libs gtk+-2.0`
34GTK3_LIBS?=`pkg-config --libs gtk+-3.0`
35
36SQLITE_LIBS?=-lsqlite3
37
38CC?=gcc
39CFLAGS+=-Wall -fPIC -std=c99 -D_GNU_SOURCE
40LDFLAGS+=-shared
41
42GTK2_DIR?=gtk2
43GTK3_DIR?=gtk3
44
45SOURCES?=$(wildcard *.c)
46OBJ_GTK2?=$(patsubst %.c, $(GTK2_DIR)/%.o, $(SOURCES))
47OBJ_GTK3?=$(patsubst %.c, $(GTK3_DIR)/%.o, $(SOURCES))
48
49define compile
50	echo $(CC) $(CFLAGS) $1 $2 $< -c -o $@
51	$(CC) $(CFLAGS) $1 $2 $< -c -o $@
52endef
53
54define link
55	echo $(CC) $(LDFLAGS) $1 $2 $3 -o $@
56	$(CC) $(LDFLAGS) $1 $2 $3 -o $@
57endef
58
59# Builds both GTK+2 and GTK+3 versions of the plugin.
60all: gtk2 gtk3
61
62# Builds GTK+2 version of the plugin.
63gtk2: mkdir_gtk2 $(SOURCES) $(GTK2_DIR)/$(OUT_GTK2)
64
65# Builds GTK+3 version of the plugin.
66gtk3: mkdir_gtk3 $(SOURCES) $(GTK3_DIR)/$(OUT_GTK3)
67
68mkdir_gtk2:
69	@echo "Creating build directory for GTK+2 version"
70	@mkdir -p $(GTK2_DIR)
71
72mkdir_gtk3:
73	@echo "Creating build directory for GTK+3 version"
74	@mkdir -p $(GTK3_DIR)
75
76$(GTK2_DIR)/$(OUT_GTK2): $(OBJ_GTK2)
77	@echo "Linking GTK+2 version"
78	$(call link, $(OBJ_GTK2), $(GTK2_LIBS), $(SQLITE_LIBS))
79	@echo "Done!"
80
81$(GTK3_DIR)/$(OUT_GTK3): $(OBJ_GTK3)
82	@echo "Linking GTK+3 version"
83	$(call link, $(OBJ_GTK3), $(GTK3_LIBS), $(SQLITE_LIBS))
84	@echo "Done!"
85
86$(GTK2_DIR)/%.o: %.c
87	@echo "Compiling $(subst $(GTK2_DIR)/,,$@)"
88	$(call compile, $(GTK2_CFLAGS))
89
90$(GTK3_DIR)/%.o: %.c
91	@echo "Compiling $(subst $(GTK3_DIR)/,,$@)"
92	$(call compile, $(GTK3_CFLAGS))
93
94clean:
95	@echo "Cleaning files from previous build..."
96	@rm -r -f $(GTK2_DIR) $(GTK3_DIR)
97