b473f473cf95746a2609f8205e97098906e751db
[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
76 VLC.framework/lib/libvlc-control.dylib: $(top_builddir)/src/.libs/libvlc-control.dylib VLC.framework/lib
77         mkdir -p VLC.framework/Version/Current/lib && \
78         cp -f $< $@ && \
79         install_name_tool -id `pwd`/$@ $@ && \
80         install_name_tool -change /usr/local/lib/libvlc.1.dylib \
81                                   `pwd`/VLC.framework/lib/libvlc.dylib  $@
82         install_name_tool -change @executable_path/lib/vlc_libintl.dylib \
83                                   `pwd`/VLC.framework/lib/vlc_libintl.dylib  $@
84
85
86 VLC.framework/Headers: $(HEADERS)
87         mkdir -p VLC.framework/Version/Current/Headers && \
88         cp -f $(EXPORTED_HEADERS) VLC.framework/Version/Current/Headers && \
89         ln -sf Version/Current/Headers VLC.framework
90
91 VLC.framework/Resources:
92         mkdir -p VLC.framework/Version/Current/Resources && \
93         cp -f $(EXPORTED_RESOURCES) VLC.framework/Version/Current/Resources && \
94         ln -sf Version/Current/Resources VLC.framework
95
96
97 VLC.framework/modules:
98         /usr/bin/install -c -d ./VLC.framework/Version/Current/modules && \
99         for i in `top_builddir="$(top_builddir)" $(VLCCONFIG) --target plugin` ; do \
100           if test -n "$$i" ; \
101         then \
102             cp "`pwd`/`dirname $$i`/.libs/`basename $$i`.dylib" \
103                "./VLC.framework/Version/Current/modules" ; \
104                 module="./VLC.framework/Version/Current/modules/`basename $$i`.dylib"; \
105             install_name_tool -change /usr/local/lib/libvlc.1.dylib \
106                                   @loader_path/../lib/libvlc.dylib \
107                           "$$module"; \
108             echo "changing install name of $$module";\
109             for lib in `otool -L "$$module" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do \
110                 install_name_tool -change "$$lib" \
111                                        `echo "$$lib" | sed 's:executable_path:loader_path/../:'` \
112                               "$$module"; \
113             done; \
114           fi \
115     done && \
116         ln -sf Version/Current/modules VLC.framework
117         
118
119 VLC.framework/share:
120         cp -R $(top_builddir)/share ./VLC.framework/Version/Current && \
121         ln -sf Version/Current/share ./VLC.framework
122
123 VLC.framework/lib: 
124         mkdir -p VLC.framework/Version/Current/lib && \
125         if test -d $(top_builddir)/extras/contrib/vlc-lib; then \
126           for i in $(top_builddir)/extras/contrib/vlc-lib/*.dylib ; do \
127                 module="VLC.framework/Version/Current/lib/`basename $${i}`"; \
128             cp `pwd`/$${i}  $${module} ; \
129                 install_name_tool -change /usr/local/lib/libvlc.1 @loader_path/../lib/libvlc.dylib \
130                                   $${module}; \
131             echo "changing install name of $$module";\
132             for lib in `otool -L "$$module" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do \
133                 install_name_tool -change "$$lib" \
134                                        `echo "$$lib" | sed 's:executable_path:loader_path/../:'` \
135                               "$$module"; \
136             done; \
137           done \
138     fi && \
139         ln -sf Version/Current/lib VLC.framework
140     
141 VLC.framework/VLC:
142         ln -sf Version/Current/VLC VLC.framework
143
144 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
145         mkdir -p VLC.framework/Version/Current/Framework && \
146         $(CXX) -dynamiclib $(LDFLAGS) $(OBJECTS) $(FRAMEWORKS) $(LIBVLC) $(MODULES) $(LIBS) -install_name @loader_path/../Frameworks/VLC.framework/Version/Current/VLC -o VLC.framework/Version/Current/VLC && \
147         install_name_tool -change /usr/local/lib/libvlc-control.0.dylib \
148                                   `pwd`/VLC.framework/lib/libvlc-control.dylib \
149                            VLC.framework/Version/Current/VLC && \
150         install_name_tool -change /usr/local/lib/libvlc.1.dylib \
151                                   `pwd`/VLC.framework/lib/libvlc.dylib \
152                            VLC.framework/Version/Current/VLC && \
153         touch VLC.framework
154
155 VLC.framework:: VLC.framework/Version/Current/VLC
156  
157 .PHONY: clean
158
159 clean:
160         rm -Rf VLC.framework
161         rm -Rf $(OBJECTS) *.o $(SRC_DIR)/*.o