If you build www/w3m on amd64+clang you get this error:

/usr/bin/ld: terms.o: relocation R_X86_64_PC32 against `COLS ' can not be used 
when making a shared object; recompile with -fPIC

That's because w3m defines global variables COLS and LINES that
clash with those exported by libcurses.  The patch below fixes this
by renaming w3m's variables.  I used #define rather than manually
patching all occurrences.

Rationale: termcap(3) and curses(3) are different interfaces,
although our implementation includes them in the same library (which
is available under five different names).  COLS and LINES are part
of curses(3).  w3m doesn't use the operating system's version of
curses(3); it uses termcap(3) to implement its own variant of curses,
so the COLS and LINES variables it defines are its own.  It does
not try to use the ones exported from libcurses.  See w3m/terms.c.
Switching COLS and LINES to "extern int" would not be correct
(although it would happen to work).

w3m users might want to test this to make sure there are no
unintentional side effects.

ok?


Index: Makefile
===================================================================
RCS file: /cvs/ports/www/w3m/Makefile,v
retrieving revision 1.88
diff -u -p -r1.88 Makefile
--- Makefile    21 Dec 2016 20:54:16 -0000      1.88
+++ Makefile    16 Apr 2017 22:05:11 -0000
@@ -3,7 +3,7 @@
 COMMENT=       pager/text-based web browser
 
 DISTNAME=      w3m-0.5.3
-REVISION=      5
+REVISION=      6
 CATEGORIES=    www
 HOMEPAGE=      http://w3m.sourceforge.net/
 
Index: patches/patch-terms_h
===================================================================
RCS file: patches/patch-terms_h
diff -N patches/patch-terms_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-terms_h       16 Apr 2017 22:05:11 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+--- terms.h.orig       Thu Jul 15 18:32:39 2004
++++ terms.h    Mon Apr 17 00:04:46 2017
+@@ -2,6 +2,10 @@
+ #ifndef TERMS_H
+ #define TERMS_H
+ 
++/* rename because libtermcap -> libcurses also exports LINES and COLS */
++#define LINES Lines
++#define COLS  Cols
++
+ extern int LINES, COLS;
+ #if defined(__CYGWIN__)
+ extern int LASTLINE;
-- 
Christian "naddy" Weisgerber                          [email protected]

Reply via email to