# Tests by default. No tests: rpm -ba --define 'dotests 0' *.spec
%{!?dotests: %define dotests 1}

%global devrel 1

# Use --define 'nossl 1' on the command line to disable SSL detection
%{!?nossl:%define SSL 1}
%{?nossl:%define SSL 0}
%define ssldir %{_prefix}

Summary: A text-based Web browser.
Name: lynx
Version:	2.9.0
Release:	2
License: GPLv2
Group: Applications/Internet
Source:	https://invisible-island.net/archives/lynx/tarballs/lynx%{version}.tar.gz
URL: https://lynx.browser.org/
Prefix: %{_prefix}

BuildRequires:  zlib-devel >= 1.2.13
BuildRequires:  ncurses-devel >= 6.4
BuildRequires:  bzip2 >= 1.0.8

Requires:	zlib >= 1.2.13
Requires:	libiconv >= 1.17
Requires:	ncurses >= 6.4
Requires:	bzip2 >= 1.0.8

%ifarch ia64
  %define DEFCCIA cc
  %define DEFCC %{DEFCCIA}
%else
  %define DEFCC cc
%endif

%description
Lynx is a text-based Web browser. Lynx does not display any images,
but it does support frames, tables and most other HTML tags. Lynx's
advantage over graphical browsers is its speed--Lynx starts and exits
quickly and swiftly displays Web pages.

Install lynx if you would like to try this fast, non-graphical browser
(you may learn to appreciate its strengths).

%prep
# Following is taken from the "%setup -q" behavior
%setup -q -n lynx2.9.0

#Point to the help documents
perl -pi -e "s,^HELPFILE:.*,HELPFILE:file://localhost/opt/freeware/doc/lynx-%{version}/lynx_help/lynx_help_main.html,g" lynx.cfg
perl -pi -e "s,^DEFAULT_INDEX_FILE:.*,DEFAULT_INDEX_FILE:http://www.google.com/,g" lynx.cfg


# Duplicate source for 32 & 64 bits
rm -rf /tmp/%{name}-%{version}-32bit
mkdir  /tmp/%{name}-%{version}-32bit
mv *   /tmp/%{name}-%{version}-32bit
mkdir 32bit
mv     /tmp/%{name}-%{version}-32bit/* 32bit
rm -rf /tmp/%{name}-%{version}-32bit
mkdir 64bit
cp -rp 32bit/* 64bit/

%build
# Use the default compiler for this platform - gcc otherwise
#if [[ -z "$CC" ]]
#then
#    if test "X`type %{DEFCC} 2>/dev/null`" != 'X'; then
#       export CC=%{DEFCC}
#    else
#       export CC=gcc
#    fi
#fi
#if test "X$CC" != "Xgcc"
#then
#       export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed 's:-fsigned-char::'`
#       export CFLAGS="$RPM_OPT_FLAGS"
#fi

%if %{SSL} == 1
    export CFLAGS="$CFLAGS -I/usr/include/openssl"
%endif

# first build the 64-bit version
cd 64bit

export CC="%{__cc__} -O2 -maix64"
export LDFLAGS="-L/opt/freeware/lib64 -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib"
export OBJECT_MODE=64
./configure --prefix=/opt/freeware --libdir=/opt/freeware/etc \
	--enable-externs --enable-prettysrc \
	--enable-source-cache \
	--enable-kbd-layout --with-zlib \
	--enable-file-upload \
	--enable-cgi-links --enable-read-eta \
	--enable-addrlist-page \
%if %{SSL} == 1
	--with-ssl
%endif

make

if [ "%{dotests}" == 1 ]
then
    (gmake -k check || true)
fi

# first build the 32-bit version
cd ../32bit

export CC="%{__cc__} -O2 -maix32 -D_LARGE_FILES"
export LDFLAGS="-L/opt/freeware/lib -Wl,-bmaxdata:0x80000000 -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib"
export OBJECT_MODE=32
./configure --prefix=/opt/freeware --libdir=/opt/freeware/etc \
        --enable-externs --enable-prettysrc \
        --enable-source-cache \
        --enable-kbd-layout --with-zlib \
        --enable-file-upload \
        --enable-cgi-links --enable-read-eta \
        --enable-addrlist-page \
%if %{SSL} == 1
        --with-ssl
%endif

make

if [ "%{dotests}" == 1 ]
then
    (gmake -k check || true)
fi


%install
rm -rf $RPM_BUILD_ROOT

cd 64bit
export AR="/usr/bin/ar -X64"
export OBJECT_MODE=64
%makeinstall mandir=$RPM_BUILD_ROOT%{_mandir}/man1 libdir=$RPM_BUILD_ROOT/%{prefix}/etc
strip $RPM_BUILD_ROOT%{prefix}/bin || :
(
    cd  $RPM_BUILD_ROOT%{prefix}/bin
    for fic in $(ls -1| grep -v -e _32 -e _64)
    do
	mv $fic "$fic"_64
    done
)

cd ../32bit
export AR="/usr/bin/ar -X32"
export OBJECT_MODE=32
%makeinstall mandir=$RPM_BUILD_ROOT%{_mandir}/man1 libdir=$RPM_BUILD_ROOT/%{prefix}/etc
strip $RPM_BUILD_ROOT%{prefix}/bin || :
(
    cd  $RPM_BUILD_ROOT%{prefix}/bin
    for fic in $(ls -1| grep -v -e _32 -e _64)
    do
        mv $fic "$fic"_32
        ln -sf "$fic"_64 $fic
    done
)
 

%files
%defattr(-,root,system)
%doc 32bit/docs 32bit/README 32bit/INSTALLATION 32bit/samples
%doc 32bit/test 32bit/lynx.hlp 32bit/lynx_help
%{prefix}/bin/lynx*
%{prefix}/man/man1/*
%config(noreplace) %{prefix}/etc/lynx.cfg 
%{prefix}/etc/lynx.lss

%changelog
* Tue Aug 27 2024 Ayappan Perumal <ayappap2@in.ibm.com> - 2.9.0-2
- Add noreplace for config file

* Tue Mar 05 2024 Raghu N Arava <raghuara@in.ibm.com> - 2.9.0-1 
- Update to version 2.9.0

* Fri Feb 26 2021 Rishita Saha <risaha16@in.ibm.com> 2.8.9-1
- Update to version 2.8.9
- No longer shipping files in /usr 

* Fri Feb 02 2018 Sushma M Bhat <susmbhat@in.ibm.com> 2.8.8-1
- Built 64-bit version and updated to 2.8.8
 
* Mon Jan 21 2008 Reza Arbab <arbab@austin.ibm.com> 2.8.4-3
- Rebuild using system-provided OpenSSL.

* Tue Dec 27 2005 Reza Arbab <arbab@austin.ibm.com> 2.8.4-2
- Add security patch for CAN-2005-3120.
- Add security patch for CAN-2005-2929.
- Add security patch for CAN-2002-1405.

* Thu Aug 30 2001 David Clissold <cliss@austin.ibm.com>
- Update to stable 2.8.4 release

* Fri Apr 20 2001 David Clissold <cliss@austin.ibm.com>
- first build for AIX toolbox (back to 2.8.3, stable release)

* Fri Mar  2 2001 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new environment

* Thu Jan  4 2001 Nalin Dahyabhai <nalin@redhat.com>
- Fix up more of the i18ncfg patch

* Wed Jan  3 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.8.4dev16
- Fix up the i18ncfg patch - segfaulting on startup is not exactly
  a nice feature.
- Mark locale related files as such
- Mark /etc/lynx.cfg.ja as %%lang(ja)
- Add BuildRequires

* Thu Dec 21 2000 Yukihiro Nakai <ynakai@redhat.com>
- Add -enable-nls --with-included-gettext
- Add i18ncfg patch
- Add Japanese resources

* Thu Oct  5 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Update build URL
- Fix help (Bug #18394)
- Replace the "index page link" (pointing to a Mosaic site with thousands
  of dead links) with a link to Google

* Sat Sep 23 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Add https:// support (#17554)
- Update to dev10

* Fri Aug  4 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Add Swedish and German translations to desktop file, Bug 15322

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jul 11 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.8.4.dev.4

* Mon Jul 10 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix up location of standard page and help page in lynx.cfg (still
  pointed at /usr/doc instead of /usr/share/doc, Bug #13227)

* Thu Jun 8 2000 Tim Powers <timp@redhat.com>
- fixed man page lolcation to be FHS compliant
- use predefined RPM macros wherever possible
- use %%makeinstall
- cleaned up files list

* Wed Apr 26 2000 Florian La Roche <Florian.LaRoche@redhat.com>
- 2.8.3rel.1

* Tue Mar 28 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 2.8.3dev23
- add URL header

* Mon Feb 07 2000 Preston Brown <pbrown@redhat.com>
- wmconfig -> desktop

* Sat Feb 05 2000 Cristian Gafton <gafton@redhat.com>
- version 2.8.3dev18
- drop the RFC compliance patch - they seemed to have done theiir own
- pray that ported patches are okay

* Mon Jan 31 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Add "passive mode ftp" option, activated by PASSIVE:TRUE in /etc/lynx.cfg
- turn on "PASSIVE:TRUE" by default
- deal with the fact that RPM compresses man pages.

* Sun Jan 16 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Add "view with less" download option

* Wed Nov  3 1999 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix compliance with RFCs describing FTP.
  We can now connect to wu-ftpd >= 2.6.0 based servers.

* Wed Aug 25 1999 Bill Nottingham <notting@redhat.com>
- fix path to help file.
- turn off font switching
- disable args to telnet.

* Tue Jun 15 1999 Bill Nottingham <notting@redhat.com>
- update to 2.8.2

* Mon Mar 29 1999 Bill Nottingham <notting@redhat.com>
- apply some update patches from the lynx folks
- set user's TEMP dir to their home dir to avoid /tmp races

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 10)

* Wed Feb 24 1999 Bill Nottingham <notting@redhat.com>
- return of wmconfig

* Mon Nov 30 1998 Bill Nottingham <notting@redhat.com>
- create cookie file 0600

* Fri Nov  6 1998 Bill Nottingham <notting@redhat.com>
- update to 2.8.1rel2

* Thu Oct 29 1998 Bill Nottingham <notting@redhat.com>
- build for Raw Hide (slang-1.2.2)

* Sat Oct 10 1998 Cristian Gafton <gafton@redhat.com>
- 2.8.1pre9
- strip binaries

* Mon Oct 05 1998 Cristian Gafton <gafton@redhat.com>
- updated to lynx2.8.1pre.7.tar.gz

* Fri May 08 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Mon May 04 1998 Cristian Gafton <gafton@redhat.com>
- upgraded to 2.8rel3
- fixed mailto: buffer overflow (used Alan's patch)

* Fri Mar 20 1998 Cristian Gafton <gafton@redhat.com>
- updated to 2.8
- added buildroot

* Tue Jan 13 1998 Erik Troan <ewt@redhat.com>
- updated to 2.7.2
- enabled lynxcgi

* Thu Oct 23 1997 Donnie Barnes <djb@redhat.com>
- updated from 2.6 to 2.7.1
- moved /usr/lib/lynx.cfg to /etc/lynx.cfg
- build with slang instead of ncurses
- made default startup file be file:/usr/doc/HTML/index.html
