Thursday, March 15, 2018

Building GNU Screen 4.6.2

Working on the command line interface is a typical UNIX administrator routine. GNU screen offers one interesting alternative for working with multiple terminals within a single text-mode display or X (or other GUI environment) window. But the whole set of functionalities are far more extensive. GNU screen delves into a lot of terminal complexities which can become quite difficult to master, specially nowadays where one usually surf many layers above the bare-bones foundations.

Of course there are alternatives to GNU Screen. Some are roughly equivalent, such as tmux, while others, such as Terminator (blog) just specializes in splitting one X window into multiple terminals each running an independent shell session. What seems more interesting is combining the facilities of Terminator and Screen.

Solaris 11.3 GA offers a rather outdated versions, 4.0.3, while Solaris 11.4 Beta is packaging version 4.6.1. Perhaps, until Solaris 11.4 official launch that gets better; we'll see. But for now I'm going to build myself version 4.6.2, the latest. By doing this I hope to empower me on building later versions as I please.

The basic building strategy and general assumptions have been detailed on a previous post: Staged Building, so I'll (hopefully) get more straight to the point:

$ pwd
/stage/build

$ ./gnu-build-preparation ../source/.../screen-4.6.2.tar.gz
...

$ cd screen/screen-4.6.2-64

$ source ../setenv 64

CONFIG_SHELL=

CC=/usr/bin/gcc CFLAGS=-m64 -march=core2 -std=gnu89
 

CXX=/usr/bin/g++ CXXFLAGS=-m64 -march=core2 -std=gnu++03
 

LD=/usr/bin/ld LDFLAGS=-m64 -march=core2

PATH=/usr/gnu/bin:/usr/bin:/usr/sbin
 

PKG_CONFIG_PATH=

Suggested build sequence:
 
$ ./configure \
  --build=x86_64-pc-solaris2.11 \
  --prefix=/opt/... \

  --enable-pam \
  --enable-colors256
 
$ gmake -j3
 
For IPS package:

$ sudo gmake DESTDIR=/stage/prototype/screen/4.6.2/64 install

For immediate use:

$ sudo gmake install
$ sudo zfs snapshot -r .../opt/...@screen-4.6.2

But before actually starting the building process it will be necessary to manually adjust a few gaps which otherwise would result in build failures or suspicious points:
  1. To avoid the following warning message:    
    tic: Warning: near line 80: terminal 'screen-256color|VT 100/ANSI X3.64 virtual terminal', 's/screen-256color' filename too long, truncating to 's/screen-256colo'
    Edit line 74 of ./terminfo/screeninfo.src adjusting the screen-256colors terminal name to less than 14 chars, which I set to screen-256c. But I'm sure it won't indeed enable 256 colors and cause other negative impacts as I've found out that before getting all the benefits I must update GNU ncurses (which will build a newer version of tic), perhaps manually tweak my terminfo database as well as my TERM environment variable before entering any shell. But for now, it will silence the warning message and let the build proceed smoothly. Later, on another post, I'll come back to this pending issue.
      
  2. Edit line 2123 of ./doc/screen.texinfo in order to add a missing "," right after the @xref{Split} on this line. It should be @xref{Split},
      
  3. Edit ./config.h.in as follows:
     
    Add the 3 following new lines after line 94:
     
    95
    96 #define PTYMODE 0620
    97 
     

    Add the 2 following new lines to the bottom of the file:
     
    #define _XOPEN_SOURCE
    #define _XOPEN_SOURCE_EXTENDED 1
      
  4. Edit ./Makefile.in as follows:
     
    Add what's highlighted below.
    Make sure to use tabs (\t), not spaces, on line starts.
     
     96 ###############################################################################
     97 install: installdirs install_bin
     98   cd doc ; $(MAKE) install
     99   -if [ -d $(DESTDIR)/usr/lib/terminfo ]; then \ 
    100     PATH="$$PATH:/usr/5bin" tic ${srcdir}/terminfo/screeninfo.src; \
    101     chmod 644 $(DESTDIR)/usr/lib/terminfo/s/screen*; \ 
    102   fi
    103 
    104   -if [ ! -d ${prefix}/share/lib/terminfo ]; then \ 
    105     mkdir -p ${prefix}/share/lib/terminfo; \ 
    106   fi 
    107   -if [ -d ${prefix}/share/lib/terminfo ]; then \ 
    108     TERMINFO="${prefix}/share/lib/terminfo" tic ${srcdir}/terminfo/screeninfo.src; \ 
    109   fi 
    110   -if [ ! -z $(DESTDIR) ] && [ ! -d $(DESTDIR)/etc ]; then \ 
    111     mkdir $(DESTDIR)/etc; \  
    112   fi 
    113
     

    114 # Better do this by hand. E.g. under RCS...
    115 # cat ${srcdir}/terminfo/screencap >> /etc/termcap

    116 # @echo "termcap entry ... should be installed manually."
    117 # @echo "You may ... install $(srcdir)/etc/etcscreenrc in" $(ETCSCREENRC)
    118 
    119   -if [ ! -z $(DESTDIR) ] && [ -d $(DESTDIR)/etc ]; then \  
    120     cat $(srcdir)/terminfo/screencap >> $(DESTDIR)/etc/termcap; \ 
    121     cp $(srcdir)/etc/etcscreenrc $(DESTDIR)/etc/screenrc; \ 
    122   fi

NOTE
Don't use --disable-socket-dir.
This option may reduce functionality and create security issues.
NOTE
Using --enable-pam may make screen more relocatable (no C-a-x issue). In this case, be sure to adjust /etc/pam.d/screen as follows:


# For GNU screen "lockscreen" integration.
#

auth    required        pam_passwd_auth.so.1

NOTE
On this post I've initially pointed to /opt/software. Later on, after publishing I've realized a better option would have been /opt/gnu because I believe it's better to group all GNU software together. On the other hand, it may be better to group other (non-GNU) software on specific subdirectories of /opt/software or perhaps /opt/sfw or yet /opt/application or /opt/app.

Now it should be OK to proceed as suggested:

$ ./configure \ 
    --build=x86_64-pc-solaris2.11 \
    --prefix=/opt/software \
    --enable-pam \
    --enable-colors256
this is screen version 4.6.2
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for grep that handles long lines and -e... /usr/gnu/bin/grep
checking for egrep... /usr/gnu/bin/grep -E
checking whether /usr/bin/gcc needs -traditional... no
checking for library containing strerror... none required
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gawk... gawk
checking for a BSD-compatible install... /usr/gnu/bin/install -c
configure: checking for buggy tools...
- sh  is 'GNU bash, version 4.1.17(1)-release (i386-pc-solaris2.11)'.
- sed is 'GNU sed version 4.2.1'.
checking if a system-wide socket dir should be used... yes
checking for the socket dir... (eff_uid ? "/tmp/uscreens" : "/tmp/screens")
configure: checking for MIPS...
configure: checking for Ultrix...
configure: checking for butterfly...
configure: checking for POSIX.1...
- you have a POSIX system
configure: checking for System V...
configure: checking for sequent/ptx...
configure: checking SVR4...
checking dwarf.h usability... no
checking dwarf.h presence... no
checking for dwarf.h... no
checking elf.h usability... yes
checking elf.h presence... yes
checking for elf.h... yes
checking stropts.h usability... yes
checking stropts.h presence... yes
checking for stropts.h... yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
configure: checking for Solaris 2.x...
configure: checking BSD job jontrol...
- you have jobcontrol
configure: checking setresuid...
configure: checking setreuid...
configure: checking seteuid...
configure: checking execvpe...
configure: checking select...
configure: checking fifos...
- your fifos are usable
configure: checking for broken fifo implementation...
- your implementation is ok
configure: checking sockets...
- your sockets are usable
configure: checking socket implementation...
- you are normal
- select can't count
configure: checking for tgetent...
configure: checking libcurses...
- you use the terminfo database
configure: checking ospeed...
configure: checking for /dev/ptc...
configure: checking for SVR4 ptys...
checking for getpt... no
configure: checking for ptyranges...
configure: checking default tty permissions/group...
checking for write... /usr/bin/write
checking for xterm... /usr/bin/xterm
- pty mode: 0620, group: 7
configure: checking getutent...
configure: checking ut_host...
checking utempter.h usability... no
checking utempter.h presence... no
checking for utempter.h... no
configure: checking for libutil(s)...
configure: checking getloadavg...
assuming posix signal definition
configure: checking for crypt and sec libraries...
configure: checking crypt...
configure: checking IRIX sun library...
configure: checking syslog...
configure: checking wait union...
configure: checking for termio or termios...
configure: checking getspnam...
configure: checking getttyent...
configure: checking fdwalk...
configure: checking whether memcpy/memmove/bcopy handles overlapping arguments...
checking for long file names... yes
checking for vsprintf... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for setenv... checking for nl_langinfo(CODESET)... yes
checking for library containing gethostname... none required
checking for rename... yes
checking for fchmod... yes
checking for fchown... yes
checking for strerror... yes
checking for lstat... yes
checking for _exit... yes
checking for utimes... yes
checking for vsnprintf... yes
checking for getcwd... yes
checking for setlocale... yes
checking for strftime... yes
checking for PAM support... yes
checking for the global screenrc file... configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing default commands

Now please check the pathnames in the Makefile and in the user
configuration section in config.h.
Then type 'make' to make screen. Good luck.


$ gmake -j3
CPP="/usr/bin/gcc -E -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"'" srcdir=. sh ./osdef.sh
AWK=gawk CC="/usr/bin/gcc -m64 -march=core2 -std=gnu89" srcdir=. sh ./comm.sh
AWK=gawk srcdir=. sh ./term.sh
sh ./tty.sh tty.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 putenv.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 term.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 kmapdef.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 comm.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 screen.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 ansi.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 fileio.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 mark.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 misc.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 resize.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 socket.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 search.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 tty.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 window.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 utmp.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 loadav.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 help.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 termcap.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 input.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 attacher.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 pty.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 process.c
attacher.c:865:5: warning: initialization from incompatible pointer type [enabled by default]
     &PAM_conv,
     ^
attacher.c:865:5: warning: (near initialization for ‘PAM_conversation.conv’) [enabled by default]
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 display.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 acls.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 braille.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 braille_tsi.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 logfile.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 layer.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 list_generic.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 list_display.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 list_window.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 sched.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 teln.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 nethack.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 encoding.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 canvas.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 layout.c
/usr/bin/gcc -c -I. -I.  -DETCSCREENRC='"/opt/software/etc/screenrc"' -DSCREENENCODINGS='"/opt/software/share/screen/utf8encodings"' -DHAVE_CONFIG_H -DGIT_REV=\"\" \
     -m64 -march=core2 -std=gnu89 viewport.c
/usr/bin/gcc -m64 -march=core2 -o screen screen.o ansi.o fileio.o mark.o misc.o resize.o socket.o search.o tty.o term.o window.o utmp.o loadav.o putenv.o help.o termcap.o input.o attacher.o pty.o process.o display.o comm.o kmapdef.o acls.o braille.o braille_tsi.o logfile.o layer.o list_generic.o list_display.o list_window.o sched.o teln.o nethack.o encoding.o canvas.o layout.o viewport.o -lcurses  -lelf -lsocket -lnsl -lkstat -lcrypt -lpam


$ sudo gmake DESTDIR=/stage/prototype/screen/4.6.2/64 install
Password:
./etc/mkinstalldirs /stage/prototype/screen/4.6.2/64/opt/software/bin /stage/prototype/screen/4.6.2/64/opt/software/share/screen/utf8encodings
mkdir /stage/prototype/screen/4.6.2/64/opt
mkdir /stage/prototype/screen/4.6.2/64/opt/software
mkdir /stage/prototype/screen/4.6.2/64/opt/software/bin
mkdir /stage/prototype/screen/4.6.2/64/opt/software/share
mkdir /stage/prototype/screen/4.6.2/64/opt/software/share/screen
mkdir /stage/prototype/screen/4.6.2/64/opt/software/share/screen/utf8encodings
cd doc ; gmake installdirs
gmake[1]: Entering directory `/stage/build/screen/screen-4.6.2-64/doc'
./../etc/mkinstalldirs /stage/prototype/screen/4.6.2/64/opt/software/share/man/man1 /stage/prototype/screen/4.6.2/64/opt/software/share/info
mkdir /stage/prototype/screen/4.6.2/64/opt/software/share/man
mkdir /stage/prototype/screen/4.6.2/64/opt/software/share/man/man1
mkdir /stage/prototype/screen/4.6.2/64/opt/software/share/info
gmake[1]: Leaving directory `/stage/build/screen/screen-4.6.2-64/doc'
if [ -f /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2 ] && [ ! -f /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2.old ]; \
    then mv /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2 /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2.old; fi
/usr/gnu/bin/install -c screen /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2
chown root /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2 && chmod 4755 /stage/prototype/screen/4.6.2/64/opt/software/bin/screen-4.6.2
if [ -f /stage/prototype/screen/4.6.2/64/opt/software/bin/screen ] && [ ! -f /stage/prototype/screen/4.6.2/64/opt/software/bin/screen.old ]; then mv /stage/prototype/screen/4.6.2/64/opt/software/bin/screen /stage/prototype/screen/4.6.2/64/opt/software/bin/screen.old; fi
rm -f /stage/prototype/screen/4.6.2/64/opt/software/bin/screen
(cd /stage/prototype/screen/4.6.2/64/opt/software/bin && ln -f -s screen-4.6.2 screen)
cp ./utf8encodings/?? /stage/prototype/screen/4.6.2/64/opt/software/share/screen/utf8encodings
cd doc ; gmake install
gmake[1]: Entering directory `/stage/build/screen/screen-4.6.2-64/doc'
./../etc/mkinstalldirs /stage/prototype/screen/4.6.2/64/opt/software/share/man/man1 /stage/prototype/screen/4.6.2/64/opt/software/share/info
/usr/gnu/bin/install -c -m 644 ./screen.1 /stage/prototype/screen/4.6.2/64/opt/software/share/man/man1/screen.1
gmake screen.info
gmake[2]: Entering directory `/stage/build/screen/screen-4.6.2-64/doc'
makeinfo ./screen.texinfo -o screen.info
gmake[2]: Leaving directory `/stage/build/screen/screen-4.6.2-64/doc'
if test -f screen.info; then d=.; else d=.; fi; \
if test -f $d/screen.info; then \
for f in $d/screen.info*; do /usr/gnu/bin/install -c -m 644 $f /stage/prototype/screen/4.6.2/64/opt/software/share/info;done; \
if /bin/sh -c 'install-info --version' >/dev/null 2>&1; then \
  install-info --info-dir=/stage/prototype/screen/4.6.2/64/opt/software/share/info $d/screen.info; \
else true; fi; \
fi
gmake[1]: Leaving directory `/stage/build/screen/screen-4.6.2-64/doc'
if [ -d /stage/prototype/screen/4.6.2/64/usr/lib/terminfo ]; then \
    PATH="$PATH:/usr/5bin" tic ./terminfo/screeninfo.src; \
    chmod 644 /stage/prototype/screen/4.6.2/64/usr/lib/terminfo/s/screen*; \
fi
if [ ! -d /opt/software/share/lib/terminfo ]; then \
    mkdir -p /opt/software/share/lib/terminfo; \
fi 
if [ -d /opt/software/share/lib/terminfo ]; then \
    TERMINFO="/opt/software/share/lib/terminfo" tic ./terminfo/screeninfo.src; \
fi 
if [ ! -z /stage/prototype/screen/4.6.2/64 ] && [ ! -d /stage/prototype/screen/4.6.2/64/etc ]; then \
    mkdir /stage/prototype/screen/4.6.2/64/etc; \
fi
if [ ! -z /stage/prototype/screen/4.6.2/64 ] && [ -d /stage/prototype/screen/4.6.2/64/etc ]; then \
    cat ./terminfo/screencap >> /stage/prototype/screen/4.6.2/64/etc/termcap; \
    cp ./etc/etcscreenrc /stage/prototype/screen/4.6.2/64/etc/screenrc; \
fi


The staging directory contents will look like:

$ l /stage/prototype/screen/4.6.2/64/{etc,opt/software/*}
/stage/prototype/screen/4.6.2/64/etc:
total 9
-rw-r--r--   1 root  root ... screenrc
-rw-r--r--   1 root  root ... termcap

/stage/prototype/screen/4.6.2/64/opt/software/bin:
total 714
lrwxrwxrwx   1 root  root ... screen -> screen-4.6.2
-rwsr-xr-x   1 root  root ... screen-4.6.2

/stage/prototype/screen/4.6.2/64/opt/software/share:
total 9
drwxr-xr-x   2 root  root ... info
drwxr-xr-x   3 root  root ... man
drwxr-xr-x   3 root  root ... screen


As seen above the contents expected to be delivered to /etc will have to be considered more carefully, specially when building an IPS package. But this shouldn't be a major issue as the IPS package delivery rules depicted on pkg(5) are flexible enough to cope with virtually all the possibilities.

NOTE
On this post I don't go beyond the staging area intended for a final packaging of the generated artifacts. Otherwise I could immediately deploy (sudo gmake install followed by a sudo zfs snapshot -r ...) as per the last suggestion on the preceeding setenv script. But note that the Makefile.in tweak (#4) will do nothing related to etc because DESTDIR will be empty in this case.

The process for building a 32-bits version is entirely analogous.
Just replace 64 with 32 and use i386-pc-solaris2.11 instead.

Let's rock with the lastest GNU screen!
Even while in the stage area it seems to work mostly right.
Add the /stage/prototype/screen/4.6.2/64/opt/software/bin to PATH.
And just invoke the program:

$ screen