aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: b177653e5e6f728fcabebb68d13b400bb4ba8309 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
.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_absolute_axis_names__.o\
	libgamepad_button_names__.o\
	libgamepad_close_device.o\
	libgamepad_close_superdevice.o\
	libgamepad_construct_constant_force_feedback_effect.o\
	libgamepad_construct_damper_force_feedback_effect.o\
	libgamepad_construct_force_feedback_effect__.o\
	libgamepad_construct_friction_force_feedback_effect.o\
	libgamepad_construct_inertia_force_feedback_effect.o\
	libgamepad_construct_periodic_force_feedback_effect.o\
	libgamepad_construct_ramp_force_feedback_effect.o\
	libgamepad_construct_rumble_force_feedback_effect.o\
	libgamepad_construct_spring_force_feedback_effect.o\
	libgamepad_create_attachment_monitor.o\
	libgamepad_destroy_attachment_monitor.o\
	libgamepad_disable_force_feedback_autocenter.o\
	libgamepad_find_sound_devices.o\
	libgamepad_get_absolute_axis_by_name.o\
	libgamepad_get_absolute_axis_info.o\
	libgamepad_get_absolute_axis_name.o\
	libgamepad_get_attachment_event.o\
	libgamepad_get_button_by_name.o\
	libgamepad_get_button_is_pressed.o\
	libgamepad_get_button_name.o\
	libgamepad_get_force_feedback_max_concurrency.o\
	libgamepad_get_relative_axis_by_name.o\
	libgamepad_get_relative_axis_name.o\
	libgamepad_grab.o\
	libgamepad_install_force_feedback_effect.o\
	libgamepad_is_force_feedback_effect_supported.o\
	libgamepad_list_superdevices.o\
	libgamepad_next_event.o\
	libgamepad_open_device.o\
	libgamepad_open_superdevice.o\
	libgamepad_play_force_feedback_effect.o\
	libgamepad_relative_axis_names__.o\
	libgamepad_set_clock.o\
	libgamepad_set_force_feedback_autocenter.o\
	libgamepad_set_force_feedback_master_gain.o\
	libgamepad_stop_force_feedback_effect.o\
	libgamepad_ungrab.o\
	libgamepad_uninstall_force_feedback_effect.o\
	libgamepad_update_force_feedback_effect.o

HDR =\
	common.h\
	libgamepad.h\
	button.count\
	absolute-axis.count\
	relative-axis.count

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

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


all: libgamepad.a libgamepad.$(LIBEXT) $(TESTS)
$(OBJ): $(HDR)
$(LOBJ): $(HDR)
$(TESTS:=.o): $(HDR)
$(TESTS): libgamepad.a
libgamepad_button_names__.o: button.names
libgamepad_absolute_axis_names__.o: absolute-axis.names
libgamepad_relative_axis_names__.o: relative-axis.names

button.names: names.sh
	./names.sh '0x%03X' BTN KEY < $(INPUT_EVENT_CODES_H) > $@

absolute-axis.names: names.sh
	./names.sh '0x%02X' ABS < $(INPUT_EVENT_CODES_H) > $@

relative-axis.names: names.sh
	./names.sh '0x%02X' REL < $(INPUT_EVENT_CODES_H) > $@

.names.count:
	wc -l < $< > $@

.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 *.names *.count
	-rm -f -- *.gch *.gcov *.gcno *.gcda *.$(LIBEXT) $(TESTS)

.SUFFIXES:
.SUFFIXES: .lo .o .c .names .count

.PHONY: all install uninstall clean