forked from RossBencina/oscpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (116 loc) · 4.77 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
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
144
145
146
147
# oscpack makefile
# the source code should auto-detect endianess for most systems
# (see osc/OscHostEndianness.h)
# otherwise you need to explicitly set ENDIANESS below
# to either OSC_HOST_BIG_ENDIAN or OSC_HOST_LITTLE_ENDIAN
# Apple Mac OS X (PowerPC): OSC_HOST_BIG_ENDIAN
# Apple Mac OS X (Intel): OSC_HOST_LITTLE_ENDIAN
# Win32: OSC_HOST_LITTLE_ENDIAN
# i386 GNU/Linux: OSC_HOST_LITTLE_ENDIAN
ENDIANESS=OSC_DETECT_ENDIANESS #source code will detect using preprocessor
#ENDIANESS=OSC_HOST_LITTLE_ENDIAN
UNAME := $(shell uname)
CXX := g++
INCLUDES := -I.
COPTS := -Wall -Wextra -O3
CDEBUG := -Wall -Wextra -g
CXXFLAGS := $(COPTS) $(INCLUDES) -D$(ENDIANESS)
BINDIR := bin
PREFIX := /usr/local
INSTALL := install -c
#Name definitions
UNITTESTS := $(BINDIR)/OscUnitTests
SENDTESTS := $(BINDIR)/OscSendTests
RECEIVETEST := $(BINDIR)/OscReceiveTest
SIMPLESEND := $(BINDIR)/SimpleSend
SIMPLERECEIVE := $(BINDIR)/SimpleReceive
DUMP := $(BINDIR)/OscDump
INCLUDEDIR := oscpack
LIBNAME := liboscpack
LIBSONAME := $(LIBNAME).so
LIBFILENAME := $(LIBSONAME).1.1.0
# Common source groups
RECEIVESOURCES := osc/OscReceivedElements.cpp osc/OscPrintReceivedElements.cpp
SENDSOURCES := osc/OscOutboundPacketStream.cpp
NETSOURCES := ip/posix/UdpSocket.cpp ip/IpEndpointName.cpp ip/posix/NetworkingUtils.cpp
COMMONSOURCES := osc/OscTypes.cpp
RECEIVEOBJECTS := $(RECEIVESOURCES:.cpp=.o)
SENDOBJECTS := $(SENDSOURCES:.cpp=.o)
NETOBJECTS := $(NETSOURCES:.cpp=.o)
COMMONOBJECTS := $(COMMONSOURCES:.cpp=.o)
# Test source
UNITTESTSOURCES := tests/OscUnitTests.cpp
UNITTESTOBJECTS := $(UNITTESTSOURCES:.cpp=.o)
SENDTESTSSOURCES := tests/OscSendTests.cpp
SENDTESTSOBJECTS := $(SENDTESTSSOURCES:.cpp=.o)
RECEIVETESTSOURCES := tests/OscReceiveTest.cpp
RECEIVETESTOBJECTS := $(RECEIVETESTSOURCES:.cpp=.o)
# Example source
SIMPLESENDSOURCES := examples/SimpleSend.cpp
SIMPLESENDOBJECTS := $(SIMPLESENDSOURCES:.cpp=.o)
SIMPLERECEIVESOURCES := examples/SimpleReceive.cpp
SIMPLERECEIVEOBJECTS := $(SIMPLERECEIVESOURCES:.cpp=.o)
DUMPSOURCES := examples/OscDump.cpp
DUMPOBJECTS := $(DUMPSOURCES:.cpp=.o)
#Library objects
LIBOBJECTS := $(COMMONOBJECTS) $(SENDOBJECTS) $(RECEIVEOBJECTS) $(NETOBJECTS)
.PHONY: all unittests sendtests receivetest simplesend simplereceive dump library clean install install-local
all: unittests sendtests receivetest simplesend simplereceive dump
unittests : $(UNITTESTS)
sendtests: $(SENDTESTS)
receivetest : $(RECEIVETEST)
simplesend : $(SIMPLESEND)
simplereceive : $(SIMPLERECEIVE)
dump : $(DUMP)
# Build rule and common dependencies for all programs
# | specifies an order-only dependency so changes to bin dir modified date don't trigger recompile
$(UNITTESTS) $(SENDTESTS) $(RECEIVETEST) $(SIMPLESEND) $(SIMPLERECEIVE) $(DUMP) : $(COMMONOBJECTS) | $(BINDIR)
$(CXX) -o $@ $^
# Additional dependencies for each program (make accumulates dependencies from multiple declarations)
$(UNITTESTS) : $(UNITTESTOBJECTS) $(SENDOBJECTS) $(RECEIVEOBJECTS)
$(SENDTESTS) : $(SENDTESTSOBJECTS) $(SENDOBJECTS) $(NETOBJECTS)
$(RECEIVETEST) : $(RECEIVETESTOBJECTS) $(RECEIVEOBJECTS) $(NETOBJECTS)
$(SIMPLESEND) : $(SIMPLESENDOBJECTS) $(SENDOBJECTS) $(NETOBJECTS)
$(SIMPLERECEIVE) : $(SIMPLERECEIVEOBJECTS) $(RECEIVEOBJECTS) $(NETOBJECTS)
$(DUMP) : $(DUMPOBJECTS) $(RECEIVEOBJECTS) $(NETOBJECTS)
$(BINDIR):
mkdir $@
clean:
rm -rf $(BINDIR) $(UNITTESTOBJECTS) $(SENDTESTSOBJECTS) $(RECEIVETESTOBJECTS) $(DUMPOBJECTS) $(LIBOBJECTS) $(SIMPLESENDOBJECTS) $(SIMPLERECEIVEOBJECTS) $(LIBFILENAME) include lib oscpack &> /dev/null
$(LIBFILENAME): $(LIBOBJECTS)
ifeq ($(UNAME), Darwin)
#Mac OS X case
$(CXX) -dynamiclib -Wl,-install_name,$(LIBSONAME) -o $(LIBFILENAME) $(LIBOBJECTS) -lc
else
#GNU/Linux case
$(CXX) -shared -Wl,-soname,$(LIBSONAME) -o $(LIBFILENAME) $(LIBOBJECTS) -lc
endif
lib: $(LIBFILENAME)
#Installs the library on a system global location
install: $(LIBFILENAME)
@$(INSTALL) -m 755 $(LIBFILENAME) $(PREFIX)/lib/$(LIBFILENAME)
@ln -s -f $(PREFIX)/lib/$(LIBFILENAME) $(PREFIX)/lib/$(LIBSONAME)
@mkdir -p $(PREFIX)/include/oscpack/ip $(PREFIX)/include/oscpack/osc
@$(INSTALL) -m 644 ip/*.h $(PREFIX)/include/oscpack/ip
@$(INSTALL) -m 644 osc/*.h $(PREFIX)/include/oscpack/osc
@echo "SUCCESS! oscpack has been installed in $(PREFIX)/lib and $(PREFIX)/include/ospack/"
ifneq ($(UNAME), Darwin)
@echo "now doing ldconfig..."
@ldconfig
endif
#Installs the include/lib structure locally
install-local: $(LIBFILENAME)
@echo ""
@echo " Installing in local directory <$(INCLUDEDIR)>"
@echo " > Creating symbolic link"
@ln -s $(LIBFILENAME) $(LIBSONAME)
@echo " > Creating directories"
@mkdir -p oscpack/lib
@mkdir -p oscpack/include/ip
@mkdir -p oscpack/include/osc
@echo " > Copying files"
@mv $(LIBFILENAME) $(LIBSONAME) oscpack/lib
@cp ip/*.h oscpack/include/ip
@cp osc/*.h oscpack/include/osc
@echo ""
@echo " > Success!"