aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 0ccc316d4c380b79c7f7a737af1f7969a9795bbc (plain) (blame)
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
96
97
98
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

OS = linux
# Linux:   linux
# Mac OS:  macos
# Windows: windows
include mk/$(OS).mk


LIB_MAJOR = 1
LIB_MINOR = 0
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
LIB_NAME = gamepad


OBJ =\
	libgamepad_close_device.o\
	libgamepad_close_superdevice.o\
	libgamepad_create_attachment_monitor.o\
	libgamepad_destroy_attachment_monitor.o\
	libgamepad_get_absolute_axis_info.o\
	libgamepad_get_absolute_axis_name.o\
	libgamepad_get_attachment_event.o\
	libgamepad_get_button_is_pressed.o\
	libgamepad_get_button_name.o\
	libgamepad_get_relative_axis_name.o\
	libgamepad_grab.o\
	libgamepad_list_superdevices.o\
	libgamepad_next_event.o\
	libgamepad_open_device.o\
	libgamepad_open_superdevice.o\
	libgamepad_set_clock.o\
	libgamepad_ungrab.o

HDR =\
	common.h\
	libgamepad.h

TESTS =\
	test-attachments\
	test-details\
	test-input\
	test-list

LOBJ = $(OBJ:.o=.lo)


all: libgamepad.a libgamepad.$(LIBEXT) $(TESTS)
$(OBJ): $(HDR)
$(LOBJ): $(HDR)
$(TESTS:=.o): $(HDR)
$(TESTS): libgamepad.a

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) $(LIBS_CFLAGS)

.c.lo:
	$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) $(LIBS_CFLAGS)

.o:
	$(CC) -o $@ $< libgamepad.a $(LDFLAGS) $(LIBS_LDFLAGS)

libgamepad.a: $(OBJ)
	@rm -f -- $@
	$(AR) rc $@ $(OBJ)
	$(AR) ts $@ > /dev/null

libgamepad.$(LIBEXT): $(LOBJ)
	$(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS) $(LIBS_LDFLAGS)

install: libgamepad.a libgamepad.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	cp -- libgamepad.a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- libgamepad.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBMINOREXT)"
	$(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBMINOREXT)"
	ln -sf -- libgamepad.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBMAJOREXT)"
	ln -sf -- libgamepad.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBEXT)"
	cp -- libgamepad.h "$(DESTDIR)$(PREFIX)/include/"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libgamepad.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libgamepad.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libgamepad.h"

clean:
	-rm -f -- *.o *.a *.lo *.su *.so *.so.* *.dll *.dylib
	-rm -f -- *.gch *.gcov *.gcno *.gcda *.$(LIBEXT) $(TESTS)

.SUFFIXES:
.SUFFIXES: .lo .o .c

.PHONY: all install uninstall clean