-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
74 lines (53 loc) · 1.51 KB
/
makefile
File metadata and controls
74 lines (53 loc) · 1.51 KB
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
# default
EXE = testdcl
LIBS = -ldl
ifeq ($(OS),Windows_NT)
CC = g++
DYN = dll
LIBS =
# need import library to resolve DLL extern symbol factory (defined on testdcl.cc)
# http://stackoverflow.com/questions/17601949/building-a-shared-library-using-gcc-on-linux-and-mingw-on-windows
LINKFLAGS = -Wl,--out-implib,libtestdcl.a
else
UNAME_S = $(shell uname -s)
# Linux
ifeq ($(UNAME_S),Linux)
CC = g++
CCFLAGS = -rdynamic -fPIC
DYN = so
endif
# OS X
ifeq ($(UNAME_S),Darwin)
CC = clang++
DYN = dylib
endif
endif
#.cc.o:
# $(CC) -ggdb -c $<
%.o : %.cc
$(CC) -c $(CCFLAGS) $< -o $@
default:
make testdcl
$(EXE): testdcl.o
$(CC) $(CCFLAGS) -o testdcl testdcl.o $(LIBS) $(LINKFLAGS)
# Linux libs targets
libcircle.so: circle.o
$(CC) -shared -Wl,-soname,libcircle.so -o libcircle.so circle.o
libsquare.so: square.o
$(CC) -shared -Wl,-soname,libsquare.so -o libsquare.so square.o
# OSX libs targets
libcircle.dylib: circle.o
$(CC) -dynamiclib -install_name libcircle.dylib \
-o libcircle.dylib circle.o -undefined dynamic_lookup
libsquare.dylib: square.o
$(CC) -dynamiclib -install_name libsquare.dylib \
-o libsquare.dylib square.o -undefined dynamic_lookup
# MINGW32 libs targets
libcircle.dll: circle.o
$(CC) -shared -o libcircle.dll circle.o -L . -ltestdcl
libsquare.dll : square.o
$(CC) -shared -o libsquare.dll square.o -L . -ltestdcl
all: testdcl libcircle.$(DYN) libsquare.$(DYN)
libs: libcircle.$(DYN) libsquare.$(DYN)
clean:
rm -f *.so *.o testdcl *.dylib *.dll *.exe *.a