This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
59 lines (48 loc) · 1.67 KB
/
Makefile
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
OUT_GTK2=vkontakte_gtk2.so
OUT_GTK3=vkontakte_gtk3.so
CC?=gcc
PREFIX?=/usr/local
GTK2_CFLAGS?=$(shell pkg-config --cflags gtk+-2.0 --silence-errors)
GTK2_LIBS?=$(shell pkg-config --libs gtk+-2.0 --silence-errors)
GTK3_CFLAGS?=$(shell pkg-config --cflags gtk+-3.0 --silence-errors)
GTK3_LIBS?=$(shell pkg-config --libs gtk+-3.0 --silence-errors)
JANSSON_CFLAGS?=`pkg-config --cflags jansson`
JANSSON_LIBS?=`pkg-config --libs jansson`
CURL_CFLAGS?=`pkg-config --cflags libcurl`
CURL_LIBS?=`pkg-config --libs libcurl`
CFLAGS+=-Wall -fPIC -D_GNU_SOURCE -g -O0 -std=c99 $(JANSSON_CFLAGS) $(CURL_CFLAGS)
LDFLAGS+=-shared $(JANSSON_LIBS) $(CURL_LIBS) -lssl
SOURCES=$(wildcard src/*.c)
OBJECTS_GTK2=$(SOURCES:.c=_gtk2.o)
OBJECTS_GTK3=$(SOURCES:.c=_gtk3.o)
ifneq ($(strip $(GTK2_CFLAGS)),)
TARGETS+=$(OUT_GTK2)
endif
ifneq ($(strip $(GTK3_CFLAGS)),)
TARGETS+=$(OUT_GTK3)
endif
ifndef TARGETS
$(error Need at least on of GTK2 or GTK3 to build the plugin)
endif
$(info Building $(TARGETS))
.PHONY: install all clean
all: $(TARGETS)
install: all
@if [ -f $(OUT_GTK2) ]; then \
echo Installing $(PREFIX)/lib/deadbeef/$(OUT_GTK2); \
install -D $(OUT_GTK2) $(PREFIX)/lib/deadbeef/$(OUT_GTK2); \
fi
@if [ -f $(OUT_GTK3) ]; then \
echo Installing $(PREFIX)/lib/deadbeef/$(OUT_GTK3) \
install -D $(OUT_GTK3) $(PREFIX)/lib/deadbeef/$(OUT_GTK3); \
fi
$(OUT_GTK2): $(OBJECTS_GTK2)
$(CC) $(OBJECTS_GTK2) $(LDFLAGS) $(GTK2_LIBS) -o $@
$(OUT_GTK3): $(OBJECTS_GTK3)
$(CC) $(OBJECTS_GTK3) $(LDFLAGS) $(GTK3_LIBS) -o $@
%_gtk2.o: %.c
$(CC) $(CFLAGS) $(GTK2_CFLAGS) $< -c -o $@
%_gtk3.o: %.c
$(CC) $(CFLAGS) $(GTK3_CFLAGS) $< -c -o $@
clean:
rm -f $(OBJECTS_GTK2) $(OBJECTS_GTK3) $(OUT_GTK2) $(OUT_GTK3)