[Flex-help] Some flex patch snippets for Solaris.
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Rich B. <ric...@or...> - 2016-05-20 15:02:14
|
Hi, In trying to get flex 2.6.1 working in the build environment we use for FOSS components in Solaris, I encountered three problems which I was easily able to patch around. Please consider these changes for a future version of flex. 1/ In flex-2.6.1/src/Makefile.am there is a rule: stage1scan.l: scan.l cp $(srcdir)/scan.l $(srcdir)/stage1scan.l For Solaris, we don't build things directly in the original source directories, but use a separate build directory. So we need to apply the following patch: --- flex-2.6.1/src/Makefile.am.orig 2016-05-19 06:21:16.631609293 -0700 +++ flex-2.6.1/src/Makefile.am 2016-05-19 14:19:29.394717203 -0700 @@ -87,7 +87,7 @@ mv skel.c.tmp $(srcdir)/skel.c stage1scan.l: scan.l - cp $(srcdir)/scan.l $(srcdir)/stage1scan.l + cp $(srcdir)/scan.l $(top_builddir)/src/stage1scan.l stage1scan.c: stage1scan.l stage1flex$(EXEEXT) $(top_builddir)/src/stage1flex$(EXEEXT) -o $@ $< 2/ Similarly, in flex-2.6.1/doc/Makefile.am we need to run help2man on a flex file that's been created in the build directory not the source directory, so we need to apply this patch: --- flex-2.6.1/doc/Makefile.am.orig 2016-05-19 06:45:26.670565152 -0700 +++ flex-2.6.1/doc/Makefile.am 2016-05-19 06:45:45.734263762 -0700 @@ -26,5 +26,5 @@ for i in $(dist_man_MANS) ; do \ $(help2man) --name='$(PACKAGE_NAME)' \ --section=`echo $$i | sed -e 's/.*\.\([^.]*\)$$/\1/'` \ - $(top_srcdir)/src/flex$(EXEEXT) > $$i || rm -f $$i ; \ + $(top_builddir)/src/flex$(EXEEXT) > $$i || rm -f $$i ; \ done 3/ The third one is a Solaris specific problem. In /usr/bin, the Solaris version of m4 doesn't understand the -P command line option, so fails when it's part of the chain in flex. We have the GNU m4 binary under /usr/gnu/bin. We can't rely on the M4 environment variable always being set, or that /usr/gnu/bin will be found in the PATH environment variable before /usr/bin, so the existing logic in flex-2.6.1/src/main.c to find m4 doesn't work correctly on Solaris. I've fixed this by using the following patch: --- flex-2.6.1/src/main.c.orig 2016-05-19 14:36:18.569346881 -0700 +++ flex-2.6.1/src/main.c 2016-05-20 07:59:04.169569771 -0700 @@ -348,6 +348,7 @@ /* Setup the filter chain. */ output_chain = filter_create_int(NULL, filter_tee_header, headerfilename); +#ifndef __sun if ( !(m4 = getenv("M4"))) { char *slash; m4 = M4; @@ -389,6 +390,9 @@ } } filter_create_ext(output_chain, m4, "-P", 0); +#else + filter_create_ext(output_chain, "/usr/gnu/bin/m4", "-P", 0); +#endif filter_create_int(output_chain, filter_fix_linedirs, NULL); /* For debugging, only run the requested number of filters. */ Thanks. |