summaryrefslogtreecommitdiff
blob: dc25bee65e94c8a901ef5ed16aea541d3c8b830e (plain)
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
This patch fixes three issues:
- http://bugs.gentoo.org/show_bug.cgi?id=292171
  respect DESTDIR, patch by Darik Horn
- don't inject random warning flags
- http://bugs.gentoo.org/show_bug.cgi?id=262973
  respect LDFLAGS and LIBS
- build a dynamic lib on Darwin also (not just only a static lib), patch
  by Fabian Groffen


--- make/linux/Makefile
+++ make/linux/Makefile
@@ -53,6 +53,8 @@
 LIBRARY=libebml.a
 LIBRARY_SO=libebml.so
 LIBRARY_SO_VER=libebml.so.0
+LIBRARY_DYLIB=libebml.dylib
+LIBRARY_DYLIB_VER=libebml.0.dylib
 
 # source-files
 sources:=$(wildcard ${SRC_DIR}*$(EXTENSION))
@@ -65,11 +67,11 @@
 objects_so:=$(patsubst %$(EXTENSION),%.lo,$(sources))
 
 WARNINGFLAGS=-Wall -Wno-unknown-pragmas -ansi -fno-gnu-keywords -Wshadow
-COMPILEFLAGS=$(WARNINGFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DEBUGFLAGS) $(INCLUDE)
+COMPILEFLAGS=$(CXXFLAGS) $(CPPFLAGS) $(DEBUGFLAGS) $(INCLUDE)
 DEPENDFLAGS  = $(CXXFLAGS) $(INCLUDE)
 
 ifeq (Darwin,$(shell uname -s))
-all: staticlib
+all: staticlib macholib
 else
 all: staticlib sharedlib
 endif
@@ -78,8 +80,10 @@
 
 sharedlib: $(LIBRARY_SO)
 
+macholib: $(LIBRARY_DYLIB)
+
 lib:
-	@echo "Use the 'staticlib', 'sharedlib' or 'all' targets."
+	@echo "Use the 'staticlib', 'sharedlib', 'macholib' or 'all' targets."
 	@false
 
 # Build rules
@@ -94,15 +98,22 @@
 	$(RANLIB) $@
 
 $(LIBRARY_SO): $(objects_so)
-	$(CXX) -shared -Wl,-soname,$(LIBRARY_SO_VER) -o $(LIBRARY_SO_VER) $(objects_so)
+	$(CXX) $(LDFLAGS) -shared -Wl,-soname,$(LIBRARY_SO_VER) -o $(LIBRARY_SO_VER) $(objects_so) $(LIBS)
 	rm -f $(LIBRARY_SO)
 	ln -s $(LIBRARY_SO_VER) $(LIBRARY_SO)
 
+$(LIBRARY_DYLIB): $(objects_so)
+	$(CXX) $(LDFLAGS) -dynamiclib -install_name $(libdir)/$(LIBRARY_DYLIB_VER) -o $(LIBRARY_DYLIB_VER) $(objects_so) $(LIBS)
+	rm -f $(LIBRARY_DYLIB)
+	ln -s $(LIBRARY_DYLIB_VER) $(LIBRARY_DYLIB)
+
 clean:
 	rm -f $(objects) $(objects_so)
 	rm -f $(LIBRARY)
 	rm -f $(LIBRARY_SO)
 	rm -f $(LIBRARY_SO_VER)
+	rm -f $(LIBRARY_DYLIB)
+	rm -f $(LIBRARY_DYLIB_VER)
 	rm -f CORE
 
 distclean dist-clean: clean
@@ -119,29 +130,34 @@
 	done
 
 ifeq (Darwin,$(shell uname -s))
-install: install_staticlib install_headers
+install: install_staticlib install_macholib install_headers
 else
 install: install_staticlib install_sharedlib install_headers
 endif
 
 install_headers:
-	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(includedir)
+	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(DESTDIR)$(includedir)
 	for i in $(INCLUDE_DIR)/*.h; do \
-		$(INSTALL) $(INSTALL_OPTS) $$i $(includedir) ; \
+		$(INSTALL) $(INSTALL_OPTS) $$i $(DESTDIR)$(includedir) ; \
 	done
-	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(includedir)/c
+	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(DESTDIR)$(includedir)/c
 	for i in $(INCLUDE_DIR)/c/*.h; do \
-		$(INSTALL) $(INSTALL_OPTS) $$i $(includedir)/c ; \
+		$(INSTALL) $(INSTALL_OPTS) $$i $(DESTDIR)$(includedir)/c ; \
 	done
 
 install_staticlib: $(LIBRARY)
-	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(libdir)
-	$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY) $(libdir)
+	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(DESTDIR)$(libdir)
+	$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY) $(DESTDIR)$(libdir)
 
 install_sharedlib: $(LIBRARY_SO)
-	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(libdir)
-	$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY_SO_VER) $(libdir)
-	ln -fs $(LIBRARY_SO_VER) $(libdir)/$(LIBRARY_SO)
+	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(DESTDIR)$(libdir)
+	$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY_SO_VER) $(DESTDIR)$(libdir)
+	ln -fs $(LIBRARY_SO_VER) $(DESTDIR)$(libdir)/$(LIBRARY_SO)
+
+install_macholib: $(LIBRARY_DYLIB)
+	$(INSTALL) $(INSTALL_DIR_OPTS) -d $(DESTDIR)$(libdir)
+	$(INSTALL) $(INSTALL_OPTS_LIB) $(LIBRARY_DYLIB_VER) $(DESTDIR)$(libdir)
+	ln -fs $(LIBRARY_DYLIB_VER) $(DESTDIR)$(libdir)/$(LIBRARY_DYLIB)
 
 
 ifneq ($(wildcard .depend),)