-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
57 lines (40 loc) · 1002 Bytes
/
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
CFLAGS = -g3 -fPIC -Wall
all_DEPS = \
libnsdp.a \
nsdp_client \
nsdp_client_DEPS = \
nsdp_client.o \
libnsdp.a \
nsdp_client_LDFLAGS = \
-L. \
nsdp_client_LIBS = \
-lnsdp -levent \
libnsdp.a_DEPS = \
nsdp_socket_posix.o \
nsdp_iface_sysfs.o \
nsdp_packet.o \
nsdp_property.o \
nsdp_property_types.o \
nsdp_properties.o \
all: $(all_DEPS)
clean:
rm -f *.o *.so
all_FLAGS = CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LIBS
define goal_flag
$(1) $($(1)_DEPS): $(2) += $($(1)_$(2))
endef
define goal
$(1): $($(1)_DEPS) Makefile
$(foreach flag,$(all_FLAGS),$(eval $(call goal_flag,$(1),$(flag))))
endef
$(foreach dep,$(all_DEPS),$(eval $(call goal,$(dep))))
%.o: %.c Makefile
$(CROSS_COMPILE)$(CC) -o $@ -c $< $(CPPFLAGS) $(CFLAGS)
%.so:
$(CROSS_COMPILE)$(CC) -o $@ -shared $(filter %.o,$($*.so_DEPS)) $(LDFLAGS) $(LIBS)
%.a:
rm -f $@
$(CROSS_COMPILE)$(AR) rs $@ $(filter %.o,$($*.a_DEPS))
%:
$(CROSS_COMPILE)$(CC) -o $@ $(filter %.o,$($*_DEPS)) $(LDFLAGS) $(LIBS)
.PHONY: all clean