[vdr] [Makefile] `-fPIC` not added to externally defined `C[XX]FLAGS` of PLUGINS if `Make.config` not available
Paul Menzel
paulepanter at users.sourceforge.net
Mon Jan 25 23:43:11 CET 2010
Dear VDR users,
in `Make.config.template` [1] which if renamed to `Make.config` gets
included in all Makefiles there is
ifdef PLUGIN
CFLAGS += -fPIC
CXXFLAGS += -fPIC
DEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
endif
which just gets included if `PLUGIN` is defined, which is normally done
in the Makefile of a plugin as for example in `Makefile` [3] belonging
to the plugin hello [2].
Additionally in each Makefile of a plugin `C[XX]FLAGS` is set to
CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
if it has not been defined yet for example in the environment.
As far as I understand plugins have to be compiled with the `-fPIC`
flag, so that the VDR can be linked against them [4]. Otherwise it would
give an error message as the following example.
ld: hello.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
hello.o: could not read symbols: Bad value
The problem now is, that if `Make.config` does not contain the snippet
from the top and `C[XX]FLAGS` are defined before without `-fPIC`
building the plugins fails. This scenario is typical in cross
compilation [5].
I do not know if the `DEFINES` from above are required, so I just
concentrate on the `-fPIC` issue because this flag is needed for a
successful build.
I thought of two solutions. Maybe you see something better.
1. Each `Makefile` of a plugin gets rewritten to always append `-fPIC`
to `C[XX]FLAGS`. Here is an example for the plugin hello.
diff --git a/PLUGINS/src/hello/Makefile b/PLUGINS/src/hello/Makefile
index ea5b806..a02d6c2 100644
--- a/PLUGINS/src/hello/Makefile
+++ b/PLUGINS/src/hello/Makefile
@@ -18,7 +18,8 @@ VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ pri
### The C++ compiler and options:
CXX ?= g++
-CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+CXXFLAGS ?= -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses
+CXXFLAGS += -fPIC
### The directory environment:
2. If `DEFINES` from the beginning is also needed, that we should factor
the snippet out into a file `Make.plugins` and every plugin has to
include it in its Makefile.
What do you think? What alternative is preferable? When this is decided
I would create a patch to change that in VDR.
Thanks,
Paul
[1] http://git.gekrumbel.de/vdr.git?p=vdr.git;a=blob;f=Make.config.template
[2] http://git.gekrumbel.de/vdr.git?p=vdr.git;a=tree;f=PLUGINS/src/hello
[3] http://git.gekrumbel.de/vdr.git?p=vdr.git;a=blob;f=PLUGINS/src/hello/Makefile#l31
[4] http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3
[5] http://lists.linuxtogo.org/pipermail/openembedded-devel/2010-January/016213.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://www.linuxtv.org/pipermail/vdr/attachments/20100125/b1cb8a37/attachment.pgp>
More information about the vdr
mailing list