MacOSX/Framework/Makefile: Fix libintl.dylib link. Reported by Fabien Lydoire.
[vlc.git] / extras / MacOSX / Framework / Makefile
1 CC=gcc
2 CFLAGS=-g -O2
3 OBJCFLAGS=-fobjc-exceptions 
4 LDFLAGS=-single_module -read_only_relocs suppress
5
6 # We should set this properly.
7 top_srcdir=../../..
8 top_builddir=../../..
9
10 LIBVLC=$(top_builddir)/src/.libs/libvlc.1.dylib $(top_builddir)/src/.libs/libvlc-control.0.dylib
11 LIBVLC_HEADERS=$(top_srcdir)/include
12 VLCCONFIG=$(top_srcdir)/vlc-config
13
14 MODULES = $(patsubst %,$(SRC_DIR)/%,$(_MODULES))
15
16 HEADERS_DIR = Headers
17
18 _EXPORTED_HEADERS= \
19      VLC/VLC.h \
20      VLC/VLCMedia.h \
21      VLC/VLCMediaDiscoverer.h \
22      VLC/VLCMediaLibrary.h \
23      VLC/VLCPlaylist.h \
24      VLC/VLCPlaylistDataSource.h \
25      VLC/VLCServicesDiscoverer.h \
26      VLC/VLCTime.h \
27      VLC/VLCVideoView.h
28
29 EXPORTED_HEADERS = $(patsubst %,$(HEADERS_DIR)/%,$(_EXPORTED_HEADERS))
30
31 EXPORTED_RESOURCES= \
32      Resources/Info.plist \
33      Resources/version.plist
34
35 SRC_DIR = Sources
36
37 _SRC = \
38      test.m \
39      VLCEventManager.m \
40      VLCLibrary.m \
41          VLCMedia.m \
42          VLCMediaLibrary.m \
43      VLCMediaDiscoverer.m \
44          VLCPlaylist.m \
45      VLCPlaylistDataSource.m \
46      VLCServicesDiscoverer.m \
47      VLCTime.m \
48      VLCVideoView.m
49
50 SRC = $(patsubst %,$(SRC_DIR)/%,$(_SRC))
51
52 HEADERS = $(EXPORTED_HEADERS)
53
54 INCLUDES=  -I .  -I $(LIBVLC_HEADERS) -I $(HEADERS_DIR)
55
56 FRAMEWORKS= -framework Cocoa  
57
58 OBJECTS=$(SRC:.m=.o)
59
60 all: VLC.framework
61
62 $(OBJECTS): $(HEADERS)
63
64 .m.o: $<
65         $(CC) -c $(CFLAGS) $(OBJCFLAGS) $(INCLUDES) $< -o $@
66
67 DIR = VLC.framework \
68       VLC.framework/Version/Current/Framework \
69       VLC.framework/Version/Current/Headers \
70
71 VLC.framework/lib/libvlc.dylib: $(top_builddir)/src/.libs/libvlc.dylib VLC.framework/lib
72         cp -f $(top_builddir)/src/.libs/libvlc.1.dylib VLC.framework/lib/libvlc.dylib && \
73         install_name_tool -id `pwd`/VLC.framework/lib/libvlc.1.dylib \
74                            VLC.framework/lib/libvlc.dylib
75         install_name_tool -change @executable_path/lib/vlc_libintl.dylib \
76                                   `pwd`/VLC.framework/lib/vlc_libintl.dylib  $@
77
78 VLC.framework/lib/libvlc-control.dylib: $(top_builddir)/src/.libs/libvlc-control.dylib VLC.framework/lib
79         mkdir -p VLC.framework/Version/Current/lib && \
80         cp -f $< $@ && \
81         install_name_tool -id `pwd`/$@ $@ && \
82         install_name_tool -change /usr/local/lib/libvlc.1.dylib \
83                                   `pwd`/VLC.framework/lib/libvlc.dylib  $@
84         install_name_tool -change @executable_path/lib/vlc_libintl.dylib \
85                                   `pwd`/VLC.framework/lib/vlc_libintl.dylib  $@
86
87
88 VLC.framework/Headers: $(HEADERS)
89         mkdir -p VLC.framework/Version/Current/Headers && \
90         cp -f $(EXPORTED_HEADERS) VLC.framework/Version/Current/Headers && \
91         ln -sf Version/Current/Headers VLC.framework
92
93 VLC.framework/Resources:
94         mkdir -p VLC.framework/Version/Current/Resources && \
95         cp -f $(EXPORTED_RESOURCES) VLC.framework/Version/Current/Resources && \
96         ln -sf Version/Current/Resources VLC.framework
97
98
99 VLC.framework/modules:
100         /usr/bin/install -c -d ./VLC.framework/Version/Current/modules && \
101         for i in `top_builddir="$(top_builddir)" $(VLCCONFIG) --target plugin` ; do \
102           if test -n "$$i" ; \
103         then \
104             cp "`pwd`/`dirname $$i`/.libs/`basename $$i`.dylib" \
105                "./VLC.framework/Version/Current/modules" ; \
106                 module="./VLC.framework/Version/Current/modules/`basename $$i`.dylib"; \
107             install_name_tool -change /usr/local/lib/libvlc.1.dylib \
108                                   @loader_path/../lib/libvlc.dylib \
109                           "$$module"; \
110             echo "changing install name of $$module";\
111             for lib in `otool -L "$$module" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do \
112                 install_name_tool -change "$$lib" \
113                                        `echo "$$lib" | sed 's:executable_path:loader_path/../:'` \
114                               "$$module"; \
115             done; \
116           fi \
117     done && \
118         ln -sf Version/Current/modules VLC.framework
119         
120
121 VLC.framework/share:
122         cp -R $(top_builddir)/share ./VLC.framework/Version/Current && \
123         ln -sf Version/Current/share ./VLC.framework
124
125 VLC.framework/lib: 
126         mkdir -p VLC.framework/Version/Current/lib && \
127         if test -d $(top_builddir)/extras/contrib/vlc-lib; then \
128           for i in $(top_builddir)/extras/contrib/vlc-lib/*.dylib ; do \
129                 module="VLC.framework/Version/Current/lib/`basename $${i}`"; \
130             cp `pwd`/$${i}  $${module} ; \
131                 install_name_tool -change /usr/local/lib/libvlc.1 @loader_path/../lib/libvlc.dylib \
132                                   $${module}; \
133             echo "changing install name of $$module";\
134             for lib in `otool -L "$$module" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do \
135                 install_name_tool -change "$$lib" \
136                                        `echo "$$lib" | sed 's:executable_path:loader_path/../:'` \
137                               "$$module"; \
138             done; \
139           done \
140     fi && \
141         ln -sf Version/Current/lib VLC.framework
142     
143 VLC.framework/VLC:
144         ln -sf Version/Current/VLC VLC.framework
145
146 VLC.framework/Version/Current/VLC: $(OBJECTS) VLC.framework/Headers VLC.framework/Resources VLC.framework/lib/libvlc-control.dylib VLC.framework/lib/libvlc.dylib VLC.framework/modules VLC.framework/share VLC.framework/VLC
147         mkdir -p VLC.framework/Version/Current/Framework && \
148         $(CXX) -dynamiclib $(LDFLAGS) $(OBJECTS) $(FRAMEWORKS) $(LIBVLC) $(MODULES) $(LIBS) -install_name @loader_path/../Frameworks/VLC.framework/Version/Current/VLC -o VLC.framework/Version/Current/VLC && \
149         install_name_tool -change /usr/local/lib/libvlc-control.0.dylib \
150                                   `pwd`/VLC.framework/lib/libvlc-control.dylib \
151                            VLC.framework/Version/Current/VLC && \
152         install_name_tool -change /usr/local/lib/libvlc.1.dylib \
153                                   `pwd`/VLC.framework/lib/libvlc.dylib \
154                            VLC.framework/Version/Current/VLC && \
155         touch VLC.framework
156
157 VLC.framework:: VLC.framework/Version/Current/VLC
158  
159 .PHONY: clean
160
161 clean:
162         rm -Rf VLC.framework
163         rm -Rf $(OBJECTS) *.o $(SRC_DIR)/*.o