dajobe / raptor

Redland Raptor RDF syntax library
https://librdf.org/raptor/
Other
156 stars 62 forks source link

Fixes for OpenBSD #32

Closed dajobe closed 9 years ago

artob commented 9 years ago

Looks exciting, so I gave building this a try on an OpenBSD 5.6 box. To run ./autogen.sh and ./configure, I had to first do:

sudo pkg_add gmake autoconf automake libtool gtk-doc flex bison
export AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.14

Running make initially bailed out at generating the Turtle lexer with flex:

Making all in src
make: don't know how to make turtle_lexer.c (prerequisite of: all)
Stop in src
*** Error 1 in ~/raptor (Makefile:542 'all-recursive')

I used the commands from appveyor.yml to manually generate the lexer, though a snag in the road was that I needed to explicitly specify gflex (as in /usr/local/bin/gflex, via pkg_add), since flex (as in /usr/bin/flex) is an ancient 2.5.4 version that can't handle the input file:

$ flex -oturtle_lexer.c turtle_lexer.l
"turtle_lexer.l", line 47: unrecognized %option: header-file
"turtle_lexer.l", line 53: unrecognized %option: unistd
"turtle_lexer.l", line 66: unrecognized %option: yyalloc
"turtle_lexer.l", line 69: unrecognized %option: reentrant
"turtle_lexer.l", line 71: unrecognized %option: extra-type
"turtle_lexer.l", line 74: unrecognized %option: bison-bridge

$ gflex -oturtle_lexer.c turtle_lexer.l

The adventure ended at problems generating the Turtle parser, however:

Making all in src
make: don't know how to make turtle_parser.c (prerequisite of: all)
Stop in src
*** Error 1 in ~/raptor (Makefile:542 'all-recursive')

...since the Bison version in OpenBSD Ports remains permanently at 2.3 (due to licensing reasons):

$ bison turtle_parser.y
turtle_parser.y:112.10-14: require bison 3.0, but have 2.3

I stopped here, for now, but would certainly re-try with a release tarball that doesn't require these development dependencies.

dajobe commented 9 years ago

Yeah there a few more gotchas. You need

export LEX=glex
export M4=gm4

as well as the automake and autoconf vars you set

I separately compiled bison3, which I have to do on most systems now because it's rare to see it in the default install.

dajobe commented 9 years ago

Oh, I'm working on OpenBSD 5.7 since it was just released.

artob commented 9 years ago

Not sure actually about the need for the GNU M4 specifically, since OpenBSD's base M4 does ostensibly have some GNU compatibility extensions (according to their man page) and did seem to work fine.

But I went ahead and installed the m4 package, too, now, as well as built Bison 3.0.4 from source--dancing around Bison's tricky build dependency on help2man, which doesn't build on OpenBSD.

With those prerequisites in place, I confirm that the following all works on OpenBSD 5.6:

sudo pkg_add gmake m4 autoconf automake libtool gtk-doc flex bison
export AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.14 M4=gm4 LEX=gflex BISON=/usr/local/bin/bison
./autogen.sh
./configure
# manually generate src/turtle_lexer.{c,h}
# manually generate src/turtle_parser.{c,h}
# manually generate src/parsedate.{c,h}
make
make check

I'm unclear on why the manual steps were still needed, with all dependencies and environment variables in place; but in any case, what I did for those was the following:

# manually generate src/turtle_lexer.{c,h}:
$LEX -oturtle_lexer.t src/turtle_lexer.l
scripts/fix-flex.pl turtle_lexer.t > src/turtle_lexer.c
mv -f turtle_lexer.h src/turtle_lexer.h
rm -f turtle_lexer.t

# manually generate src/turtle_parser.{c,h}:
$BISON src/turtle_parser.y
scripts/fix-bison.pl turtle_parser.tab.c > src/turtle_parser.c
mv -f turtle_parser.tab.h src/turtle_parser.h
rm -f turtle_parser.tab.c turtle_parser.output

# manually generate src/parsedate.{c,h}:
$BISON src/parsedate.y
scripts/fix-bison.pl parsedate.tab.c > src/parsedate.c
mv -f parsedate.tab.h src/parsedate.h
rm -f parsedate.tab.c parsedate.output