Ensure libvlc only export symbols from libvlc API
[vlc.git] / src / Makefile.am
1 ###############################################################################
2 # Automake targets and declarations
3 ###############################################################################
4
5 AUTOMAKE_OPTIONS = subdir-objects
6
7 NULL =
8 SUBDIRS =
9
10 EXTRA_DIST = extras/COPYING misc/modules_builtin.h.in
11
12 BUILT_SOURCES = $(DISTCLEANFILES) $(CLEANFILES)
13 DISTCLEANFILES = stamp-api
14 CLEANFILES = misc/modules_builtin.h
15 MOSTLYCLEANFILES = $(DATA_noinst_libvlc) stamp-builtins
16
17 TOOLBOX = srcdir=$(top_srcdir) builddir=$(top_builddir) $(top_srcdir)/toolbox
18
19 ###############################################################################
20 # Headers
21 ###############################################################################
22
23 pkgincludedir = $(includedir)/vlc
24
25 dist_pkginclude_HEADERS = \
26         ../include/vlc/vlc.h \
27         ../include/vlc/libvlc.h \
28         ../include/vlc/aout.h \
29         ../include/vlc/vout.h \
30         ../include/vlc/sout.h \
31         ../include/vlc/decoder.h \
32         ../include/vlc/input.h \
33         ../include/vlc/intf.h \
34         ../include/vlc/mediacontrol.h \
35         ../include/vlc/mediacontrol_structures.h \
36         $(NULL)
37
38 noinst_HEADERS = $(HEADERS_include)
39 noinst_DATA = $(DATA_noinst_libvlc)
40
41 HEADERS_include = \
42         ../include/aout_internal.h \
43         ../include/audio_output.h \
44         ../include/beos_specific.h \
45         ../include/charset.h \
46         ../include/codecs.h \
47         ../include/configuration.h \
48         ../include/darwin_specific.h \
49         ../include/intf_eject.h \
50         ../include/iso_lang.h \
51         ../include/main.h \
52         ../include/mmx.h \
53         ../include/modules.h \
54         ../include/modules_inner.h \
55         ../include/mtime.h \
56         ../include/network.h \
57         ../include/os_specific.h \
58         ../include/snapshot.h \
59         ../include/stream_output.h \
60         ../include/vlc_streaming.h \
61         ../include/variables.h \
62         ../include/video_output.h \
63         ../include/vlc_access.h \
64         ../include/vlc_acl.h \
65         ../include/vlc_bits.h \
66         ../include/vlc_block.h \
67         ../include/vlc_block_helper.h \
68         ../include/vlc_codec.h \
69         ../include/vlc_common.h \
70         ../include/vlc_config.h \
71         ../include/vlc_cpu.h \
72         ../include/vlc_demux.h \
73         ../include/vlc_error.h \
74         ../include/vlc_es.h \
75         ../include/vlc_es_out.h \
76         ../include/vlc_filter.h \
77         ../include/vlc_config_cat.h \
78         ../include/vlc_httpd.h \
79         ../include/vlc_tls.h \
80         ../include/vlc_md5.h \
81         ../include/vlc_devices.h \
82         ../include/vlc_image.h \
83         ../include/vlc_input.h \
84         ../include/vlc_interaction.h \
85         ../include/vlc_interface.h \
86         ../include/vlc_intf_strings.h \
87         ../include/vlc_keys.h \
88         ../include/vlc_messages.h \
89         ../include/vlc_meta.h \
90         ../include/vlc_objects.h \
91         ../include/vlc_osd.h \
92         ../include/vlc_playlist.h \
93         ../include/vlc_spu.h \
94         ../include/vlc_stream.h \
95         ../include/vlc_strings.h \
96         ../include/vlc_symbols.h \
97         ../include/vlc_threads_funcs.h \
98         ../include/vlc_threads.h \
99         ../include/vlc_update.h \
100         ../include/vlc_url.h \
101         ../include/vlc_video.h \
102         ../include/vlc_vlm.h \
103         ../include/vlc_vod.h \
104         ../include/vlc_xml.h \
105         ../include/vout_synchro.h \
106         ../include/win32_specific.h \
107         ../include/libvlc_internal.h \
108         ../include/mediacontrol_internal.h
109         $(NULL)
110
111 misc/modules_builtin.h: Makefile misc/modules_builtin.h.in ../vlc-config
112         $(TOOLBOX) --update-includes
113         touch $@
114
115 misc/modules.c: misc/modules_builtin.h
116
117 ###############################################################################
118 # Building builtin modules
119 ###############################################################################
120 #
121 # As long as we use builtins with a shared libvlc, we must build them before
122 # we build libvlc. Maybe one day, libvlc will handle multiple modules per
123 # shared object, which will make builtins fairly redumdant. Until then, we
124 # need this workaround.
125
126 stamp-builtins: Makefile ../vlc-config ../config.status
127 if USE_LIBTOOL
128         @for c in `$(VLC_CONFIG) --libs builtin`; do \
129                 case $$c in \
130                         ../modules/*.a) echo $$c ;; \
131                 esac ; \
132         done | \
133         sed -e 's,^\(.*\)/\([^/]*\)\.a$$,cd \1 \&\& $(MAKE) \2_builtin.la,g' | \
134         while read cmd; do echo $$cmd; eval "($$cmd)" || exit $$? ; done
135 endif
136 if BUILD_SHARED
137         @for c in `$(VLC_CONFIG) --libs builtin`; do \
138                 case $$c in \
139                         ../modules/*.a) echo $$c ;; \
140                 esac ; \
141         done | \
142         sed -e 's,^\(.*\)/\([^/]*\)\.a$$,cd \1 \&\& $(MAKE) \2,g' | \
143         while read cmd; do echo $$cmd.a; eval "($$cmd.a)" || exit $$? ; done
144 endif
145         touch $@
146
147 ###############################################################################
148 # Building libvlc
149 ###############################################################################
150
151 libvlc_a_SOURCES = $(SOURCES_libvlc)
152 libvlc_a_CFLAGS = `$(VLC_CONFIG) --cflags vlc $(pic)`
153 libvlc_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc $(pic)`
154 libvlc_a_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc $(pic)`
155
156 libvlc_la_SOURCES = $(SOURCES_libvlc)
157 libvlc_la_LIBADD = $(INCLUDED_LIBINTL)
158 libvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags vlc`
159 libvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc`
160 libvlc_la_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc`
161 libvlc_la_LDFLAGS = `$(VLC_CONFIG) --libs vlc builtin|sed -e 's/\(modules\/[^ ]*\)\.a /\1_builtin.la /g'` -no-undefined -export-symbols libvlc.sym
162 libvlc_la_DEPENDENCIES = stamp-builtins stamp-api
163
164
165 if HAVE_BEOS
166 OPT_SOURCES_libvlc_beos = $(SOURCES_libvlc_beos)
167 endif
168 if HAVE_DARWIN
169 OPT_SOURCES_libvlc_darwin = $(SOURCES_libvlc_darwin)
170 endif
171 if HAVE_WIN32
172 OPT_SOURCES_libvlc_win32 = $(SOURCES_libvlc_win32)
173 endif
174 if HAVE_WINCE
175 OPT_SOURCES_libvlc_win32 = $(SOURCES_libvlc_win32)
176 endif
177 if BUILD_DIRENT
178 OPT_SOURCES_libvlc_dirent = $(SOURCES_libvlc_dirent)
179 endif
180 if BUILD_GETOPT
181 OPT_SOURCES_libvlc_getopt = $(SOURCES_libvlc_getopt)
182 endif
183
184 # Build libvlc as a shared library
185 if USE_LIBTOOL
186 lib_LTLIBRARIES = libvlc.la
187 else
188 lib_LIBRARIES = libvlc.a
189 endif
190
191 if HAVE_WIN32
192 if BUILD_SHARED
193 DATA_noinst_libvlc = libvlc$(LIBEXT) libvlc$(LIBEXT).a
194 endif
195
196 libvlc.dll.a: libvlc$(LIBEXT)
197         $(DLLTOOL) --export-all-symbols -l $@ -D $< $(libvlc_a_OBJECTS)
198
199 libvlc$(LIBEXT): $(OBJECTS_libvlc_so) stamp-builtins
200         @ldfl="`$(VLC_CONFIG) --libs plugin vlc builtin $(pic)` $(INCLUDED_LIBINTL)" ; \
201         case `$(VLC_CONFIG) --linkage vlc builtin` in \
202           c++)  ld="$(CXXLINK)" ;; \
203           objc) ld="$(OBJCLINK)" ;; \
204           c|*)  ld="$(LINK)" ;; \
205         esac ; \
206         echo $$ld $(OBJECTS_libvlc_so) $(LDFLAGS_libvlc_so) $$ldfl; \
207         $$ld $(libvlc_a_OBJECTS) \
208                 $$ldfl
209 # It sucks big time, but we have to do that to link vlc properly
210 # on non-PIC OSes, otherwise ld will favor builtins-less libvlc.a over
211 # libvlc$(LIBEXT)
212         rm -f libvlc.a
213 # Cygwin libtool work-around
214         @if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi
215 endif
216
217 EXTRA_DIST += \
218         $(SOURCES_libvlc_beos) \
219         $(SOURCES_libvlc_darwin) \
220         $(SOURCES_libvlc_win32) \
221         $(SOURCES_libvlc_dirent) \
222         $(SOURCES_libvlc_getopt) \
223         $(NULL)
224
225 SOURCES_libvlc_beos = \
226         misc/beos_specific.cpp \
227         $(NULL)
228
229 SOURCES_libvlc_darwin = \
230         misc/darwin_specific.m \
231         $(NULL)
232
233 SOURCES_libvlc_win32 = \
234         misc/win32_specific.c \
235         $(NULL)
236
237 SOURCES_libvlc_dirent = \
238         extras/dirent.c \
239         $(NULL)
240
241 SOURCES_libvlc_getopt = \
242         extras/getopt.c \
243         extras/getopt.h \
244         extras/getopt1.c \
245         $(NULL)
246
247 SOURCES_libvlc_common = \
248         libvlc.c \
249         libvlc.h \
250         interface/interface.c \
251         interface/intf_eject.c \
252         interface/interaction.c \
253         playlist/playlist_internal.h \
254         playlist/thread.c \
255         playlist/control.c \
256         playlist/engine.c \
257         playlist/sort.c \
258         playlist/loadsave.c \
259         playlist/tree.c \
260         playlist/item.c \
261         playlist/search.c \
262         playlist/services_discovery.c \
263         input/item.c \
264         input/access.c \
265         input/clock.c \
266         input/control.c \
267         input/decoder.c \
268         input/demux.c \
269         input/es_out.c \
270         input/input.c \
271         input/input_internal.h \
272         input/stream.c \
273         input/mem_stream.c \
274         input/subtitles.c \
275         input/var.c \
276         video_output/video_output.c \
277         video_output/vout_pictures.c \
278         video_output/vout_pictures.h \
279         video_output/video_text.c \
280         video_output/video_widgets.c \
281         video_output/vout_subpictures.c \
282         video_output/vout_synchro.c \
283         video_output/vout_intf.c \
284         audio_output/common.c \
285         audio_output/dec.c \
286         audio_output/filters.c \
287         audio_output/input.c \
288         audio_output/mixer.c \
289         audio_output/output.c \
290         audio_output/intf.c \
291         stream_output/stream_output.c \
292         stream_output/announce.c \
293         stream_output/profiles.c \
294         stream_output/sap.c \
295         osd/osd.c \
296         osd/osd_parser.c \
297         osd/osd_text.c \
298         osd/osd_widgets.c \
299         network/acl.c \
300         network/getaddrinfo.c \
301         network/io.c \
302         network/error.c \
303         network/tcp.c \
304         network/udp.c \
305         network/httpd.c \
306         network/rootwrap.c \
307         network/tls.c \
308         misc/charset.c \
309         misc/md5.c \
310         misc/mtime.c \
311         misc/block.c \
312         misc/modules.c \
313         misc/threads.c \
314         misc/stats.c \
315         misc/strings.c \
316         misc/unicode.c \
317         misc/cpu.c \
318         misc/configuration.c \
319         misc/image.c \
320         misc/iso_lang.c \
321         misc/iso-639_def.h \
322         misc/messages.c \
323         misc/objects.c \
324         misc/variables.c \
325         misc/error.c \
326         misc/update.c \
327         misc/vlm.c \
328         misc/xml.c \
329         misc/dict.c \
330         misc/devices.c \
331         extras/libc.c \
332         control/core.c \
333         control/playlist.c \
334         control/vlm.c \
335         control/input.c \
336         control/video.c \
337         control/audio.c \
338         control/mediacontrol_core.c \
339         control/mediacontrol_util.c \
340         control/mediacontrol_audio_video.c \
341         $(NULL)
342
343 # These should be distributed, but not compiled
344 EXTRA_DIST += control/mediacontrol_init.c control/mediacontrol_plugin.c
345
346 SOURCES_libvlc = \
347         $(SOURCES_libvlc_common) \
348         $(OPT_SOURCES_libvlc_beos) \
349         $(OPT_SOURCES_libvlc_darwin) \
350         $(OPT_SOURCES_libvlc_win32) \
351         $(OPT_SOURCES_libvlc_dirent) \
352         $(OPT_SOURCES_libvlc_getopt) \
353         $(NULL)
354
355 if !USE_LIBTOOL
356 if !BUILD_SHARED
357 SOURCES_libvlc += misc/version.c
358 CLEANFILES += misc/version.c
359 endif
360
361 # Install shared libvlc
362 install-exec-local:
363         test -z "$(DATA_noinst_libvlc)" || $(INSTALL_PROGRAM) "$(DATA_noinst_libvlc)" "$(DESTDIR)$(libdir)"
364
365 # the opposite of install-{data,exec}-local
366 uninstall-local:
367         test -z "$(DATA_noinst_libvlc)" || rm -f "$(DESTDIR)$(libdir)/$(DATA_noinst_libvlc)"
368 endif
369
370 misc/version.c: FORCE
371         $(TOOLBOX) --update-version
372
373 ###############################################################################
374 # Stamp rules
375 ###############################################################################
376 stamp-api: Makefile.in $(HEADERS_include) ../vlc-api.pl
377         ( cd $(srcdir) && cat $(HEADERS_include) ) | \
378           top_srcdir="$(top_srcdir)" perl $(top_srcdir)/vlc-api.pl
379         touch stamp-api
380
381 libvlc.sym:
382         rm -f stamp-api
383         $(MAKE) stamp-api
384
385 ###############################################################################
386 # Unit/regression test
387 ###############################################################################
388 if USE_LIBTOOL
389 check_PROGRAMS = test_i18n_atof test_url
390 TESTS = $(check_PROGRAMS)
391
392 CFLAGS_tests = `$(VLC_CONFIG) --cflags vlc`
393
394 test_i18n_atof_SOURCES = test/i18n_atof.c
395 test_i18n_atof_LDADD = libvlc.la
396 test_i18n_atof_CFLAGS = $(CFLAGS_tests)
397
398 test_url_SOURCES = test/url.c
399 test_url_LDADD = libvlc.la
400 test_url_CFLAGS = $(CFLAGS_tests)
401 endif
402
403 FORCE: