Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: linuxtv-dvb-make-defs (updated)




Guido Draheim wrote:

Johannes Stezenbach wrote:

Guido Draheim wrote:

here is a patch that will make `dvbscan` to list the series of
initial-data-files being installed in the system. It works on
all of /etc/dvb/dvb-?/* /usr/share/dvb/dvb-?/* and of course
that /usr/share/doc/packages/dvb/dvb-?/* ... it may help user
to get a clue (it's shown when no cmdline arguments are given).

Btw, I was thinking over to give this function its own getopt
but hey "-l" is taken :-/ ... and what makes me wonder, why
is there "q:" while the usagedoc says it does not require an
argument (i.e. --quiet)?


Hm, that's a bug.


+static void show_existing_tuning_data_files(void)
+{
+#ifndef PREFIX
+#define PREFIX "/usr/local"
+#endif
+ static const char* prefixlist[] = { PREFIX"/share/dvb", + "/usr/share/dvb", "/etc/dvb", + "/usr/share/doc/packages/dvb", 0 };


Hm, I don't like that.

The correct way to do it would be to have a configure script,
and have the executable look in the configured location.

But I don't like that either :-(

Sigh...

:-) Rejoice, because it can be done!

We introduce a DEFS make-var into all Makefiles. A packager (or user for
local installation) can now override _globally_ that DEFS make-var and
see all .c.o pick them up during compilation. That allows to write just
a `make "DEFS=-DDATADIR=%_datadir -DSYSCONFDIR=%_sysconfdir"` and see
all the binaries pick them up.

In fact, it is even simpler since the patch pushes some default DEFS
in each Makefile such that one only needs to override the make-vars
for `make -Ddatadir=%_datadir -Dsysconfdir=%_sysconfdir`. And out of
sheer luck, I am doing that anyway now in the rpm spec and most
probably all other packagers will pick up the same approach.

Now we can modify the source-files to take advantage of these compile
flag DEFS, by using the following construction in the source:
#ifndef DATADIR
#define DATADIR "/usr/local/share"
#endif

Example:
In the case of 'scan' initial-config files, we see this:
(a) rpm .spec contains
    make datadir=%_datadir
(b) scan/Makefile contains
    DEFS = -DDATADIR=$(datadir)
    datadir = /usr/local/share
(c) scan/scan.c contains
    #ifndef DATADIR
    #define DATADIR "/usr/local/share"
    #endif
    [...]
    const char* initialconfigdir = DATADIR "/dvb";

patch attached, (w/o scan.c changes, goes separate)
the same patch, but with each $(DEFS) goes an $(ARCH) which allows
to set _additional_ CFLAGS globally while not overriding the default
DEFS in each makefile. Nice for make ARCH=-mpentiumpro or similar
stuff but anything else is okay as well, e.g. -fno-writable-strings
-fstack-check -W -msse2 -fomit-leaf-frame-pointer etc.pp.






Index: test/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/test/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- test/Makefile	14 Feb 2004 22:04:51 -0000	1.3
+++ test/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,7 +1,7 @@
 # Makefile for Linux DVB API Version 3 test programs
 
 CC = gcc
-CFLAGS = -g -O2 -W -Wall
+CFLAGS = -g -O2 -W -Wall $(DEFS) $(ARCH)
 CPPFLAGS = -I../include
 
 TARGETS = \
Index: util/av7110_loadkeys/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/av7110_loadkeys/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- util/av7110_loadkeys/Makefile	15 Feb 2004 00:31:08 -0000	1.3
+++ util/av7110_loadkeys/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,5 +1,6 @@
 CC = gcc
-CFLAGS = -g -Wall -O2
+CFLAGS = -g -Wall -O2 $(DEFS) $(ARCH)
+DEFS = -DDATADIR=$(datadir)
 bindir  = /usr/local/bin
 datadir = /usr/local/share
 
Index: util/dvbdate/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/dvbdate/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- util/dvbdate/Makefile	14 Feb 2004 22:04:52 -0000	1.3
+++ util/dvbdate/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,6 +1,6 @@
 
 CC      = gcc
-CFLAGS  = -g -O2 -Wall
+CFLAGS  = -g -O2 -Wall $(DEFS) $(ARCH)
 CPPFLAGS= -MD -I../../include
 LFLAGS  =
 
Index: util/dvbnet/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/dvbnet/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- util/dvbnet/Makefile	14 Feb 2004 22:04:52 -0000	1.3
+++ util/dvbnet/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,8 +1,9 @@
 
 CC      = gcc
-CFLAGS  = -g -O2 -Wall
+CFLAGS  = -g -O2 -Wall $(DEFS) $(ARCH)
 CPPFLAGS= -MD -I. -I../../include
 LFLAGS  =
+DEFS = -DSYSCONFDIR=$(sysconfdir)
 bindir = /usr/local/bin
 sysconfdir = /usr/local/etc
 
Index: util/dvbtraffic/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/dvbtraffic/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- util/dvbtraffic/Makefile	14 Feb 2004 22:04:52 -0000	1.4
+++ util/dvbtraffic/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,4 +1,4 @@
-CFLAGS   = -g -O2 -Wall
+CFLAGS   = -g -O2 -Wall $(DEFS) $(ARCH)
 CPPFLAGS = -MD -I../../include
 bindir = /usr/local/bin
 
Index: util/lib/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/lib/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- util/lib/Makefile	14 Feb 2004 22:04:52 -0000	1.3
+++ util/lib/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,6 +1,6 @@
 
 CC = gcc
-CFLAGS = -g -Wall -O2
+CFLAGS = -g -Wall -O2 $(DEFS) $(ARCH)
 CPPFLAGS = -MD -I../../include -I.
 bindir = /usr/local/bin
 
Index: util/scan/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/scan/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- util/scan/Makefile	15 Feb 2004 00:31:08 -0000	1.5
+++ util/scan/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,8 +1,9 @@
 
 CC = gcc
-CFLAGS = -g -Wall -O2
+CFLAGS = -g -Wall -O2 $(DEFS) $(ARCH)
 CPPFLAGS = -MD -I../../include -I../lib
 LFLAGS = -g -Wall
+DEFS = -DDATADIR=$(datadir)
 bindir = /usr/local/bin
 datadir = /usr/local/share
 
Index: util/szap/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/szap/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- util/szap/Makefile	15 Feb 2004 00:31:08 -0000	1.4
+++ util/szap/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,8 +1,9 @@
 CC = gcc
-CFLAGS = -Wall -g -O2
+CFLAGS = -Wall -g -O2 $(DEFS) $(ARCH)
 CPPFLAGS = -MD -I../../include -I../lib
 LFLAGS = -Wall -g -O2
 RM = rm -f
+DEFS = -DDATADIR=$(datadir)
 bindir = /usr/local/bin
 datadir = /usr/local/share
 
Index: util/ttusb_dec_reset/Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/ttusb_dec_reset/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- util/ttusb_dec_reset/Makefile	14 Feb 2004 22:04:52 -0000	1.2
+++ util/ttusb_dec_reset/Makefile	15 Feb 2004 08:48:32 -0000
@@ -1,6 +1,6 @@
 CC	= gcc
 RM	= rm -f
-CFLAGS	= -g -Wall -O2
+CFLAGS	= -g -Wall -O2 $(DEFS) $(ARCH)
 LFLAGS	= -g -Wall
 LDFLAGS = -lusb
 bindir  = /usr/local/bin

Home | Main Index | Thread Index