Difference between revisions of "OutOfTreeCompile"

From VideoLAN Wiki
Jump to navigation Jump to search
(typo)
Line 6: Line 6:
 
If you're taking a module from VLC source code, you may need to modify it slightly.
 
If you're taking a module from VLC source code, you may need to modify it slightly.
 
===Internationalization===
 
===Internationalization===
You can't use the main VLC "domain". So you can either add your own domain  declaration or disable any i18n.
+
You can't use the main VLC internationalization (gettext) "domain".
#define _(str) (str)
+
So you can either add your own domain declaration:
#define N_(str) (str)
+
 
 +
<pre>
 +
#define DOMAIN  "vlc-myplugin"
 +
#define _(str) dgettext(DOMAIN, str)
 +
#define N_(str) (str)
 +
 
 +
/* ... */
 +
 
 +
vlc_module_begin()
 +
  set_text_domain (DOMAIN)
 +
  set_description (N_("My plugin"))
 +
  /* ... */
 +
vlc_module_end()
 +
</pre>
 +
or disable internationalization completely:
 +
<pre>
 +
#define _(str) (str)
 +
#define N_(str) (str)
 +
</pre>
  
 
==Building==
 
==Building==
  
 +
===With plain makefile====
 
The following Makefile is an example based on the x264 module of VLC. You will need to adapt to your module.
 
The following Makefile is an example based on the x264 module of VLC. You will need to adapt to your module.
 +
 +
<pre>
 +
prefix = /usr/local
 +
libdir = $(prefix)/lib
 +
vlclibdir = $(libdir)/vlc
 +
 +
all: libx264_plugin.so
 
   
 
   
all: libx264_plugin.so
+
libx264_plugin.so: libx264_plugin.o
 +
        gcc -shared -std=gnu99 $< `pkg-config  --libs vlc-plugin x264`  -Wl,-soname -Wl,$@ -o $@
 
   
 
   
 +
libx264_plugin.o: x264.c
 +
        gcc -c -std=gnu99  $< `pkg-config  --cflags vlc-plugin x264` -D__PLUGIN__  -DMODULE_STRING=\"x264\" -o $@ 
 
   
 
   
libx264_plugin.so: libx264_plugin.o
+
clean:
        gcc -shared -std=gnu99 $< `pkg-config  --libs vlc-plugin x264`  -Wl,-soname -Wl,$@ -Wl,-no-undefined -o $@
+
        rm -f libx264_plugin.o libx264_plugin.so
+
 
libx264_plugin.o: x264.c
+
install: all
        gcc -c -std=gnu99  $< `pkg-config  --cflags vlc-plugin x264` -D__PLUGIN__  -DMODULE_STRING=\"x264\" -o $
+
        install -m 0755 libx264_plugin.so $(DESTDIR)$(vlclibdir)/
+
 
clean:
+
install-strip: all
        rm -f libx264_plugin.o libx264_plugin.so
+
        install -s -m 0755 libx264_plugin.so $(DESTDIR)$(vlclibdir)/
+
 
.PHONY: all clean
+
uninstall: all
 +
        rm -f -- $(DESTDIR)$(vlclibdir)/libx264_plugin.so
 +
 
 +
.PHONY: all clean install uninstall
 +
</pre>
 +
 
 +
===With autotools===
 +
If using automake and libtool, you can follow this example Makefile.am instead:
 +
 
 +
<pre>
 +
vlclibdir = $(libdir)/vlc
  
Then you should install the plugin with the other VLC modules
+
vlclib_libx264_plugin_la_SOURCES = x264.c
 +
vlclib_libx264_plugin_la_CFLAGS = $(VLC_PLUGIN_CFLAGS) $(X264_CFLAGS) \
 +
      -D__PLUGIN__ -DMODULE_STRING=\"x264\"
 +
vlclib_libx264_plugin_la_LIBADD = $(VLC_PLUGIN_LIBS) $(X264_LIBS)
 +
vlclib_libx264_plugin_la_LDFLAGS = \
 +
      -avoid-version -module -export-symbol-regex ^vlc_entry
 +
</pre>

Revision as of 15:34, 18 January 2009

Aim

Being able to build a vlc module without needing to build the whole vlc source. It can be used if you develop a new module, if your module can't be distributed at the same time as VLC due to some IP issues or to reduce the number of build-dependancies for a source package

Preparation

If you're taking a module from VLC source code, you may need to modify it slightly.

Internationalization

You can't use the main VLC internationalization (gettext) "domain". So you can either add your own domain declaration:

#define DOMAIN  "vlc-myplugin"
#define _(str)  dgettext(DOMAIN, str)
#define N_(str) (str)

/* ... */

vlc_module_begin()
   set_text_domain (DOMAIN)
   set_description (N_("My plugin"))
   /* ... */
vlc_module_end()

or disable internationalization completely:

#define _(str)  (str)
#define N_(str) (str)

Building

With plain makefile=

The following Makefile is an example based on the x264 module of VLC. You will need to adapt to your module.

prefix = /usr/local
libdir = $(prefix)/lib
vlclibdir = $(libdir)/vlc

all: libx264_plugin.so
 
libx264_plugin.so: libx264_plugin.o
        gcc -shared -std=gnu99 $< `pkg-config  --libs vlc-plugin x264`  -Wl,-soname -Wl,$@ -o $@
 
libx264_plugin.o: x264.c
        gcc -c -std=gnu99  $< `pkg-config  --cflags vlc-plugin x264` -D__PLUGIN__  -DMODULE_STRING=\"x264\" -o $@  
 
clean:
        rm -f libx264_plugin.o libx264_plugin.so

install: all
        install -m 0755 libx264_plugin.so $(DESTDIR)$(vlclibdir)/

install-strip: all
        install -s -m 0755 libx264_plugin.so $(DESTDIR)$(vlclibdir)/

uninstall: all
        rm -f -- $(DESTDIR)$(vlclibdir)/libx264_plugin.so

.PHONY: all clean install uninstall

With autotools

If using automake and libtool, you can follow this example Makefile.am instead:

vlclibdir = $(libdir)/vlc

vlclib_libx264_plugin_la_SOURCES = x264.c
vlclib_libx264_plugin_la_CFLAGS = $(VLC_PLUGIN_CFLAGS) $(X264_CFLAGS) \
      -D__PLUGIN__ -DMODULE_STRING=\"x264\"
vlclib_libx264_plugin_la_LIBADD = $(VLC_PLUGIN_LIBS) $(X264_LIBS)
vlclib_libx264_plugin_la_LDFLAGS = \
      -avoid-version -module -export-symbol-regex ^vlc_entry