summaryrefslogtreecommitdiff
path: root/Makefile
blob: bac3dc0049577f6473862cd7abe2fd6e94480760 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#
# Copyright (C) 2015 David Härdeman <david@hardeman.nu>
#

#
# Generic settings
#
CC              = gcc
GENERIC_CFLAGS	= -g -Wall -Werror -D_FILE_OFFSET_BITS=64 \
		  -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -flto
EXTRA_CFLAGS	=
GENERIC_LDFLAGS	=
EXTRA_LDFLAGS	=

COMMON_HEADERS	= linux-input-keycodes.h linux-input.h shared.h

RCM_PACKAGES	= libudev libsystemd libevdev sqlite3
RCM_CFLAGS	= ${GENERIC_CFLAGS} ${EXTRA_CFLAGS} $(shell pkg-config --cflags ${RCM_PACKAGES})
RCM_LDFLAGS	= ${GENERIC_LDFLAGS} ${EXTRA_LDFLAGS} $(shell pkg-config --libs ${RCM_PACKAGES})
RCM_COMPILE	= $(CC) $(RCM_CFLAGS)
RCM_LINK	= $(CC) $(RCM_CFLAGS) $(RCM_LDFLAGS)
RCM_OBJECTS	= rcm-server-main.o rcm-server-keymap.o rcm-server-udev.o \
		  rcm-server-rcdev.o rcm-server-lirc.o rcm-server-evdev.o \
		  rcm-server-kdb.o shared.o
RCM_HEADERS	= rcm-server-main.h rcm-server-keymap.h rcm-server-udev.h \
		  rcm-server-rcdev.h rcm-server-lirc.h rcm-server-evdev.h \
		  rcm-server-kdb.h utils.h $(COMMON_HEADERS)

RCC_PACKAGES	= gtk+-3.0 gmodule-2.0
RCC_CFLAGS	= ${GENERIC_CFLAGS} ${EXTRA_CFLAGS} $(shell pkg-config --cflags ${RCC_PACKAGES})
RCC_LDFLAGS	= ${GENERIC_LDFLAGS} ${EXTRA_LDFLAGS} $(shell pkg-config --libs ${RCC_PACKAGES})
RCC_COMPILE	= $(CC) $(RCC_CFLAGS)
RCC_LINK	= $(CC) $(RCC_CFLAGS) $(RCC_LDFLAGS)
RCC_OBJECTS	= rcm-client-main.o rcm-client-hardware-list.o rcm-client-receive.o rcm-client-advanced.o rcm-client-resources.o generated.o shared.o
RCC_HEADERS	= rcm-client-main.h rcm-client-hardware-list.h rcm-client-receive.h rcm-client-advanced.h rcm-client-resources.h generated.h $(COMMON_HEADERS)

INSTALL         = install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA    = ${INSTALL} -m 644

DESTDIR        ?=
prefix         	= /usr
usrbindir       = ${prefix}/bin
mandir          = ${prefix}/share/man

.SUFFIXES:

#
# Targets
#

all: rcm-server rcm-client
.DEFAULT: all

shared.o: shared.c shared.h
	$(CC) $(GENERIC_CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<

linux-input-keycodes.o: linux-input-keycodes.c $(COMMON_HEADERS)
	$(CC) $(GENERIC_CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<

rcm-client-resources.c: rcm-client.gresource.xml $(shell glib-compile-resources --generate-dependencies rcm-client.gresource.xml)
	glib-compile-resources --target=$@ --generate-source --c-name rcm rcm-client.gresource.xml

rcm-client-resources.h: rcm-client.gresource.xml $(shell glib-compile-resources --generate-dependencies rcm-client.gresource.xml)
	glib-compile-resources --target=$@ --generate-header --c-name rcm rcm-client.gresource.xml

rcm-client-%.o: rcm-client-%.c $(RCC_HEADERS)
	$(RCC_COMPILE) -o $@ -c $<

generated.o: generated.c generated.h
	$(RCC_COMPILE) -o $@ -c $<

generated.c generated.h: RemoteControlManager.xml
	gdbus-codegen --interface-prefix org.gnome --c-generate-object-manager --generate-c-code generated RemoteControlManager.xml

rcm-client: $(RCC_OBJECTS)
	$(RCC_LINK) -o $@ $^

rcm-server-%.o: rcm-server-%.c $(RCM_HEADERS)
	$(RCM_COMPILE) -o $@ -c $<

rcm-server: $(RCM_OBJECTS)
	$(RCM_LINK) -o $@ $^

install: all
	$(INSTALL_PROGRAM) -D rcm-server $(DESTDIR)$(usrbindir)/rcm-server

uninstall:
	- rm -f $(DESTDIR)$(usrbindir)/rcm-server

clean:
	- rm -f generated.[ch] *.o rcm-server rcm-client

.PHONY: install uninstall clean all