diff --git a/.gitignore b/.gitignore index daf0ef997..c0690f1c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,46 @@ +*.sig +stamp-* + +# Backup files generated by various editors *.orig *.rej -*.sig -*.tar.gz -*.tar.lz *~ -.deps -.libs -ABOUT-NLS -ChangeLog -Makefile + +# 'autoscan' log files +/autoscan.log +/configure.scan + +# Files generated by Autotools +/ABOUT-NLS +/ChangeLog +/aclocal.m4 +/autom4te.cache/ +/build-aux/ +/configure +/m4/ Makefile.in -aclocal.m4 -autom4te.cache -autoscan.log -build-aux/ -config.log -config.status -configure -configure.scan -flex-*/ -libtool -m4/ -stamp-* + +# Files generated by 'configure' +/config.cache +/config.log +/config.status +/libtool +Makefile + +# Built object files and support files +/flex +/flex.exe +/libfl.la +/stage1bin/ +/stage1flex +/stage1flex.exe +*.lo +*.o +*.obj +.deps/ +.libs/ + +# Distribution tarballs and directory +/flex-*/ +*.tar.gz +*.tar.lz diff --git a/Makefile.am b/Makefile.am index 848f7c8a3..1046b9bc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,33 +47,37 @@ dist_noinst_SCRIPTS = \ po/update_linguas.sh SUBDIRS = \ - src \ - doc \ - examples \ + . \ po \ - tests \ - tools + tests + +MOSTLYCLEANFILES = + +CLEANFILES = + +indentfiles = + +include doc/local.mk +include examples/local.mk +include src/local.mk +include tools/local.mk # Convenience targets to build libfl only # These are actually wrappers around automake- and libtool-generated targets -libfl: - cd src && $(MAKE) $(AM_MAKEFLAGS) libfl.la libfl.pc +libfl: libfl.la src/libfl.pc install-libfl: - cd src && \ $(MAKE) $(AM_MAKEFLAGS) lib_LTLIBRARIES=libfl.la \ - pkgconfig_DATA=libfl.pc install-libLTLIBRARIES install-pkgconfigDATA + pkgconfig_DATA=src/libfl.pc install-libLTLIBRARIES install-pkgconfigDATA uninstall-libfl: - cd src && \ $(MAKE) $(AM_MAKEFLAGS) \ - lib_LTLIBRARIES=libfl.la pkgconfig_DATA=libfl.pc \ + lib_LTLIBRARIES=libfl.la pkgconfig_DATA=src/libfl.pc \ uninstall-libLTLIBRARIES uninstall-pkgconfigDATA # libfl.pc is cleaned via 'distclean' target clean-libfl: - cd src && \ $(MAKE) $(AM_MAKEFLAGS) lib_LTLIBRARIES=libfl.la clean-libLTLIBRARIES \ clean-libtool @@ -84,8 +88,23 @@ ChangeLog: $(srcdir)/tools/git2cl $(srcdir)/tools/git2cl > $@ \ ; fi -indent: - cd src && $(MAKE) $(AM_MAKEFLAGS) indent +# Run GNU indent on sources. Don't run this unless all the sources compile cleanly. +# +# Whole idea: +# 1. Check for .indent.pro, otherwise indent will use unknown +# settings, or worse, the GNU defaults.) +# 2. Check that this is GNU indent. +# 3. Make sure to process only the NON-generated .c and .h files. +# 4. Run indent twice per file. The first time is a test. +# Otherwise, indent overwrites your file even if it fails! + +indent: .indent.pro + for f in $(indentfiles); do \ + echo indenting $$f; \ + INDENT_PROFILE=.indent.pro $(INDENT) <$$f >/dev/null && \ + INDENT_PROFILE=.indent.pro $(INDENT) $$f || \ + echo $$f FAILED to indent; \ + done; install-exec-hook: cd $(DESTDIR)$(bindir) && \ diff --git a/configure.ac b/configure.ac index e166c8af4..0eeaf38dd 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,10 @@ AC_PATH_PROG([HELP2MAN], help2man, [\${top_srcdir}/build-aux/missing help2man]) AC_MSG_WARN(help2man: program not found: building man page will not work) ) +AM_CONDITIONAL([AUTO_BUILD_MAN_PAGE], + [test "$HELP2MAN" != "\${top_srcdir}/build-aux/missing help2man" && + { test "x$enable_bootstrap" = xyes || test "$cross_compiling" = no; }]) + AC_PATH_PROGS([TEXI2DVI], [gtexi2dvi texi2dvi], [\${top_srcdir}/build-aux/missing texi2dvi]) AS_IF([test "$TEXI2DVI" = "\${top_srcdir}/build-aux/missing texi2dvi"], AC_MSG_WARN(texi2dvi: program not found: building pdf version of manual will not work) @@ -215,14 +219,8 @@ AS_IF([test "$cross_compiling" = yes], AC_CONFIG_FILES( Makefile -doc/Makefile -examples/Makefile -examples/fastwc/Makefile -examples/manual/Makefile po/Makefile.in src/libfl.pc -src/Makefile -tools/Makefile tests/Makefile ) diff --git a/doc/.gitignore b/doc/.gitignore index a685ba6e7..83b010866 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -25,6 +25,3 @@ flex.ps version.texi flex.html flex.t2p - -flex -flex.exe diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100755 index a32f81c60..000000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -if CROSS -FLEX = $(top_builddir)/src/stage1flex -else -FLEX = $(top_builddir)/src/flex$(EXEEXT) -endif - -TEXI2DVI = @TEXI2DVI@ -I $(srcdir)/../examples/manual/ -TEXI2PDF = @TEXI2PDF@ -I $(srcdir)/../examples/manual/ - -info_TEXINFOS = flex.texi -AM_MAKEINFOFLAGS = -I $(srcdir)/../examples/manual/ -dist_man_MANS = flex.1 -MAINTAINERCLEANFILES = flex.1 - -CLEANFILES = \ - *.aux \ - *.cp \ - *.cps \ - *.fn \ - *.fns \ - *.hk \ - *.hks \ - *.ky \ - *.log \ - *.op \ - *.ops\ - *.pg \ - *.toc \ - *.tp \ - *.tps \ - *.vr \ - *.vrs \ - flex - -# Use a fixed program name, without extension (such as ".exe"), for man -# page generation. 'help2man' strips directory prefix ("./") from the -# usage string, but not file extensions. - -flex.1: $(top_srcdir)/configure.ac $(top_srcdir)/src/cpp-flex.skl $(top_srcdir)/src/options.c $(top_srcdir)/src/options.h - ( cd $(top_builddir)/src && \ - prog_name=`echo '$(FLEX)' | sed 's|^$(top_builddir)/src/||'` && \ - $(MAKE) $(AM_MAKEFLAGS) $$prog_name \ - ) - $(INSTALL) -m 700 $(FLEX) flex$(EXEEXT) - $(HELP2MAN) \ - --name='$(PACKAGE_NAME)' \ - --section=1 \ - --source='The Flex Project' \ - --manual='Programming' \ - --output=$@ \ - ./flex diff --git a/doc/local.mk b/doc/local.mk new file mode 100644 index 000000000..dedcf6109 --- /dev/null +++ b/doc/local.mk @@ -0,0 +1,76 @@ +if CROSS +FLEX_FOR_DOC = stage1bin/flex +else +FLEX_FOR_DOC = flex +endif + +TEXI2DVI = @TEXI2DVI@ -I $(srcdir)/examples/manual/ +TEXI2PDF = @TEXI2PDF@ -I $(srcdir)/examples/manual/ + +info_TEXINFOS = doc/flex.texi +AM_MAKEINFOFLAGS = -I $(srcdir)/examples/manual/ +dist_man_MANS = doc/flex.1 +MAINTAINERCLEANFILES = doc/flex.1 + +CLEANFILES += \ + doc/*.aux \ + doc/*.cp \ + doc/*.cps \ + doc/*.fn \ + doc/*.fns \ + doc/*.hk \ + doc/*.hks \ + doc/*.ky \ + doc/*.log \ + doc/*.op \ + doc/*.ops \ + doc/*.pg \ + doc/*.toc \ + doc/*.tp \ + doc/*.tps \ + doc/*.vr \ + doc/*.vrs \ + doc/flex + +# Use a fixed program name, without extension (such as ".exe"), for man +# page generation. 'help2man' strips directory prefix from the usage +# string, but not file extensions. +# +# Note: Do NOT run the '$(FLEX_FOR_DOC)$(BUILD_EXEEXT)' target in +# another instance of 'make'! The scanner code also depends on the +# target and two 'make' instances may contest building the same file. + +if AUTO_BUILD_MAN_PAGE +doc/flex.1: $(FLEX_FOR_DOC)$(BUILD_EXEEXT) + $(MKDIR_P) doc + $(HELP2MAN) \ + --name='$(PACKAGE_NAME)' \ + --section=1 \ + --source='The Flex Project' \ + --manual='Programming' \ + --output=$@ \ + ./$(FLEX_FOR_DOC) +else +doc/flex.1: $(srcdir)/configure.ac $(srcdir)/src/cpp-flex.skl $(srcdir)/src/options.c $(srcdir)/src/options.h + @option_text=''; \ + { test '$(FLEX_FOR_DOC)' = flex || \ + : $${option_text=" with --enable-bootstrap'"}; }; \ + echo "error: flex man page outdated; please install help2man and rerun 'configure'$${option_text}" 1>&2; + @false +endif + +distclean-local: distclean-local-doc + +# Clean the man page in the build directory only if it is not the +# source directory. + +distclean-local-doc: + test '$(srcdir)' = . || { \ + if mv -f $(srcdir)/doc/flex.1 $(srcdir)/doc/flex.1.tmp; then \ + s=0; else s=$$? || :; fi; \ + rm -f doc/flex.1 || :; \ + test "$$s" -ne 0 || \ + mv -f $(srcdir)/doc/flex.1.tmp $(srcdir)/doc/flex.1; \ + } + +.PHONY: distclean-local-doc diff --git a/examples/fastwc/Makefile.am b/examples/fastwc/local.mk similarity index 82% rename from examples/fastwc/Makefile.am rename to examples/fastwc/local.mk index b2831d986..dfc07e442 100644 --- a/examples/fastwc/Makefile.am +++ b/examples/fastwc/local.mk @@ -19,11 +19,11 @@ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE. -EXTRA_DIST = \ - wc5.l \ - wc4.l \ - wc3.l \ - wc2.l \ - wc1.l \ - mywc.c \ - README +EXTRA_DIST += \ + examples/fastwc/wc5.l \ + examples/fastwc/wc4.l \ + examples/fastwc/wc3.l \ + examples/fastwc/wc2.l \ + examples/fastwc/wc1.l \ + examples/fastwc/mywc.c \ + examples/fastwc/README diff --git a/examples/Makefile.am b/examples/local.mk similarity index 86% rename from examples/Makefile.am rename to examples/local.mk index 62688babb..85d7741f7 100644 --- a/examples/Makefile.am +++ b/examples/local.mk @@ -19,11 +19,10 @@ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE. -EXTRA_DIST = \ - testxxLexer.l \ - debflex.awk \ - README +EXTRA_DIST += \ + examples/testxxLexer.l \ + examples/debflex.awk \ + examples/README -SUBDIRS = \ - manual \ - fastwc +include examples/fastwc/local.mk +include examples/manual/local.mk diff --git a/examples/manual/Makefile.am b/examples/manual/Makefile.am deleted file mode 100644 index 24affe1b9..000000000 --- a/examples/manual/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# This file is part of flex. - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: - -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. - -# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE. - -EXTRA_DIST = \ - ChangeLog \ - Makefile.examples \ - README \ - cat.lex \ - dates.lex \ - datetest.dat \ - eof_rules.lex \ - eof_test01.txt \ - eof_test02.txt \ - eof_test03.txt \ - example_er.lex \ - example_r.lex \ - example_nr.lex \ - expr.lex \ - expr.y \ - front.lex \ - front.y \ - j2t.lex \ - myname.lex \ - myname.txt \ - myname2.lex \ - numbers.lex \ - pas_include.lex \ - pascal.lex \ - reject.lex \ - replace.lex \ - string1.lex \ - string2.lex \ - strtest.dat \ - unput.lex \ - user_act.lex \ - userinit.lex \ - wc.lex \ - yymore.lex \ - yymore2.lex \ - yymoretest.dat diff --git a/examples/manual/local.mk b/examples/manual/local.mk new file mode 100644 index 000000000..726ddac54 --- /dev/null +++ b/examples/manual/local.mk @@ -0,0 +1,58 @@ +# This file is part of flex. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE. + +EXTRA_DIST += \ + examples/manual/ChangeLog \ + examples/manual/Makefile.examples \ + examples/manual/README \ + examples/manual/cat.lex \ + examples/manual/dates.lex \ + examples/manual/datetest.dat \ + examples/manual/eof_rules.lex \ + examples/manual/eof_test01.txt \ + examples/manual/eof_test02.txt \ + examples/manual/eof_test03.txt \ + examples/manual/example_er.lex \ + examples/manual/example_r.lex \ + examples/manual/example_nr.lex \ + examples/manual/expr.lex \ + examples/manual/expr.y \ + examples/manual/front.lex \ + examples/manual/front.y \ + examples/manual/j2t.lex \ + examples/manual/myname.lex \ + examples/manual/myname.txt \ + examples/manual/myname2.lex \ + examples/manual/numbers.lex \ + examples/manual/pas_include.lex \ + examples/manual/pascal.lex \ + examples/manual/reject.lex \ + examples/manual/replace.lex \ + examples/manual/string1.lex \ + examples/manual/string2.lex \ + examples/manual/strtest.dat \ + examples/manual/unput.lex \ + examples/manual/user_act.lex \ + examples/manual/userinit.lex \ + examples/manual/wc.lex \ + examples/manual/yymore.lex \ + examples/manual/yymore2.lex \ + examples/manual/yymoretest.dat diff --git a/po/.gitignore b/po/.gitignore index 3c6f57d67..c3e4c382f 100644 --- a/po/.gitignore +++ b/po/.gitignore @@ -1,18 +1,26 @@ -*.gmo -Makefile -Makefile.in -Makefile.in.in -Makevars.template -POTFILES -Rules-quot -boldquot.sed -en@boldquot.*header en@boldquot.po -en@quot.*header en@quot.po -flex.pot -insert-header.sin -quot.sed -remove-potcdate.sed -remove-potcdate.sin stamp-* + +# Files generated by Autotools +/Makefile.in.in +/Makevars.template +/Rules-quot +/boldquot.sed +/en@boldquot.header +/en@quot.header +/insert-header.sin +/quot.sed +/remove-potcdate.sin + +# Files generated by 'configure' +/Makefile +/Makefile.in +/POTFILES + +# Built object files and support files +/*.gmo +/en@boldquot.insert-header +/en@quot.insert-header +/flex.pot +/remove-potcdate.sed diff --git a/src/.gitignore b/src/.gitignore index cbae2e3b6..d5ae0af23 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,21 +1,18 @@ -*.la -*.lo -*.o -*-flex.h -config.h -config.h.in -config_for_build.h -flex -libfl.pc -parse.c -parse.h -scan.c -stage1scan.c -stage1flex -stage2compare -stage2scan.c +# Files generated by Autotools +/config.h.in -# for MSWindows +# Files generated by 'configure' +/config.h +/config_for_build.h +/libfl.pc -*.obj -*.exe +# Generated code, included in distribution tarball only +/parse.c +/parse.h +/scan.c + +# Built object files and support files +/*-flex.h +/stage1scan.c +/stage2compare +/stage2scan.c diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index b9ead0740..000000000 --- a/src/Makefile.am +++ /dev/null @@ -1,231 +0,0 @@ -AM_YFLAGS = -d -AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -AM_CFLAGS = $(WARNINGFLAGS) -LIBS = @LIBS@ -pkgconfigdir = @pkgconfigdir@ - -m4 = @M4@ - -bin_PROGRAMS = flex -if ENABLE_BOOTSTRAP -noinst_PROGRAMS = stage1flex -if !CROSS -noinst_DATA = stage2compare -endif -endif - -if ENABLE_LIBFL -lib_LTLIBRARIES = libfl.la -pkgconfig_DATA = libfl.pc -endif -libfl_la_SOURCES = \ - libmain.c \ - libyywrap.c -libfl_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ - -stage1flex_SOURCES = \ - scan.l \ - $(COMMON_SOURCES) - -nodist_stage1flex_SOURCES = \ - $(SKELINCLUDES) - -if CROSS -stage1flex_LDADD = -stage1flex_SOURCES += \ - ../lib/malloc.c \ - ../lib/realloc.c -stage1flex_LINK = $(LIBTOOL) --tag=CC --mode=link $(CC_FOR_BUILD) \ - $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ - -$(stage1flex_OBJECTS): CC=$(CC_FOR_BUILD) -$(stage1flex_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD) -DUSE_CONFIG_FOR_BUILD -$(stage1flex_OBJECTS): CPP=$(CPP_FOR_BUILD) -$(stage1flex_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD) -$(stage1flex_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD) -else -stage1flex_LDADD = $(LDADD) -stage1flex_LINK = $(LINK) -stage1flex_CFLAGS = $(AM_CFLAGS) -endif - -flex_SOURCES = \ - $(COMMON_SOURCES) - -nodist_flex_SOURCES = \ - $(SKELINCLUDES) - -if ENABLE_BOOTSTRAP -nodist_flex_SOURCES += stage1scan.c -else -flex_SOURCES += scan.l -endif - -COMMON_SOURCES = \ - buf.c \ - ccl.c \ - dfa.c \ - ecs.c \ - filter.c \ - flexdef.h \ - flexint.h \ - flexint_shared.h \ - gen.c \ - main.c \ - misc.c \ - nfa.c \ - options.c \ - options.h \ - parse.y \ - regex.c \ - scanflags.c \ - scanopt.c \ - scanopt.h \ - skeletons.c \ - sym.c \ - tables.c \ - tables.h \ - tables_shared.c \ - tables_shared.h \ - tblcmp.c \ - version.h \ - yylex.c - -LDADD = $(LIBOBJS) @LIBINTL@ - -$(LIBOBJS): $(LIBOBJDIR)$(am__dirstamp) - -include_HEADERS = \ - FlexLexer.h - -EXTRA_DIST = \ - c99-flex.skl \ - cpp-flex.skl \ - go-flex.skl \ - mkskel.sh \ - gettext.h \ - chkskel.sh - -MOSTLYCLEANFILES = \ - $(SKELINCLUDES) \ - stage1scan.c \ - stage2scan.c \ - stage2compare - -CLEANFILES = stage1flex$(EXEEXT) - -SKELINCLUDES = \ - cpp-flex.h \ - c99-flex.h \ - go-flex.h - -cpp-flex.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c - $(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp - $(SHELL) $(srcdir)/chkskel.sh $@.tmp - mv -f $@.tmp $@ - -c99-flex.h: c99-flex.skl mkskel.sh - $(SHELL) $(srcdir)/mkskel.sh c99 $(srcdir) $(m4) $(VERSION) > $@.tmp - $(SHELL) $(srcdir)/chkskel.sh $@.tmp - mv -f $@.tmp $@ - -go-flex.h: go-flex.skl mkskel.sh - $(SHELL) $(srcdir)/mkskel.sh go $(srcdir) $(m4) $(VERSION) > $@.tmp - $(SHELL) $(srcdir)/chkskel.sh $@.tmp - mv -f $@.tmp $@ - -# The input and output file names are fixed for deterministic scanner -# generation. If scan.l is not modified by builders, stage1scan.c should -# be bit-identical to the scan.c pregenerated on release. -stage1scan.c: scan.l stage1flex$(EXEEXT) - ( cd $(srcdir) && $(abs_builddir)/stage1flex$(EXEEXT) \ - $(AM_LFLAGS) $(LFLAGS) -o scan.c -t scan.l ) >$@ || \ - { s=$$?; rm -f $@; exit $$s; } - -# Unlike stage1scan.c, we leave stage2scan.c intact when the generation -# fails. This allow users to examine generation errors. -stage2scan.c: scan.l flex$(EXEEXT) stage1scan.c - ( cd $(srcdir) && $(abs_builddir)/flex$(EXEEXT) \ - $(AM_LFLAGS) $(LFLAGS) -o scan.c -t scan.l ) >$@ - -stage2compare: stage1scan.c - @rm -f stage2scan.c; \ - $(MAKE) $(AM_MAKEFLAGS) stage2scan.c; \ - echo Comparing stage1scan.c and stage2scan.c; \ - cmp stage1scan.c stage2scan.c || { \ - s=$$?; \ - echo "Bootstrap comparison failure!"; \ - exit $$s; \ - }; \ - echo Comparison successful.; \ - echo success >$@ - -dist-hook: scan.l flex$(EXEEXT) - chmod u+w $(distdir) && \ - chmod u+w $(distdir)/scan.c && \ - ( cd $(srcdir) && $(abs_builddir)/flex$(EXEEXT) \ - -o scan.c -t scan.l ) >scan.c && \ - mv -f scan.c $(distdir) - -# make needs to be told to make inclusions so that parallelized runs will -# not fail. - -stage1flex-skeletons.$(OBJEXT): $(SKELINCLUDES) -skeletons.$(OBJEXT): $(SKELINCLUDES) - -stage1flex-main.$(OBJEXT): parse.h -main.$(OBJEXT): parse.h - -stage1flex-yylex.$(OBJEXT): parse.h -yylex.$(OBJEXT): parse.h - -stage1flex-scan.$(OBJEXT): parse.h -stage1scan.$(OBJEXT): parse.h -scan.$(OBJEXT): parse.h - -# Run GNU indent on sources. Don't run this unless all the sources compile cleanly. -# -# Whole idea: -# 1. Check for .indent.pro, otherwise indent will use unknown -# settings, or worse, the GNU defaults.) -# 2. Check that this is GNU indent. -# 3. Make sure to process only the NON-generated .c and .h files. -# 4. Run indent twice per file. The first time is a test. -# Otherwise, indent overwrites your file even if it fails! -indentfiles = \ - buf.c \ - ccl.c \ - dfa.c \ - ecs.c \ - scanflags.c \ - filter.c \ - flexdef.h \ - gen.c \ - libmain.c \ - libyywrap.c \ - main.c \ - misc.c \ - nfa.c \ - options.c \ - options.h \ - regex.c \ - scanopt.c \ - scanopt.h \ - sym.c \ - tables.c \ - tables.h \ - tables_shared.c \ - tables_shared.h \ - tblcmp.c - -indent: $(top_srcdir)/.indent.pro - cd $(top_srcdir) && \ - for f in $(indentfiles); do \ - f=src/$$f; \ - echo indenting $$f; \ - INDENT_PROFILE=.indent.pro $(INDENT) <$$f >/dev/null && \ - INDENT_PROFILE=.indent.pro $(INDENT) $$f || \ - echo $$f FAILED to indent; \ - done; - -.PHONY: indent diff --git a/src/local.mk b/src/local.mk new file mode 100644 index 000000000..51ff3d78c --- /dev/null +++ b/src/local.mk @@ -0,0 +1,264 @@ +AM_YFLAGS = -d +AM_CPPFLAGS = -I$(srcdir)/src -DLOCALEDIR=\"$(localedir)\" +AM_CFLAGS = $(WARNINGFLAGS) +LIBS = @LIBS@ +pkgconfigdir = @pkgconfigdir@ + +m4 = @M4@ + +bin_PROGRAMS = flex + +EXTRA_PROGRAMS = stage1flex +if ENABLE_BOOTSTRAP +if !CROSS +noinst_DATA = src/stage2compare +endif +endif + +if ENABLE_LIBFL +lib_LTLIBRARIES = libfl.la +pkgconfig_DATA = src/libfl.pc +endif +libfl_la_SOURCES = \ + src/libmain.c \ + src/libyywrap.c +libfl_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ + +stage1flex_SOURCES = \ + src/scan.l \ + $(COMMON_SOURCES) + +nodist_stage1flex_SOURCES = \ + $(SKELINCLUDES) + +if CROSS + +stage1flex_SOURCES += \ + lib/malloc.c \ + lib/realloc.c + +stage1flex_CPPFLAGS = -DUSE_CONFIG_FOR_BUILD $(AM_CPPFLAGS) + +# This also overrides AM_LIBTOOLFLAGS and AM_LDFLAGS +stage1flex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(LIBTOOLFLAGS) \ + --mode=link $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) \ + $(LDFLAGS_FOR_BUILD) -o $@ + +stage1flex_LDADD = + +else + +stage1flex_CPPFLAGS = $(AM_CPPFLAGS) + +stage1flex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@ + +stage1flex_LDADD = $(LDADD) + +endif + +# Suppress build warnings when compiling and linking stage1flex. +stage1flex_CFLAGS = + +# Override the 'stage1flex$(EXEEXT)' target automake would generate. +# If the compiler is not $(CC_FOR_BUILD) when this target is invoked, +# delete the object files that would be linked to 'stage1flex' to force +# rebuild all of them. + +stage1flex$(EXEEXT): $(stage1flex_OBJECTS) $(stage1flex_DEPENDENCIES) $(EXTRA_stage1flex_DEPENDENCIES) + @rm -f stage1flex$(EXEEXT) + { test 'x$(CC)' = 'x$(CC_FOR_BUILD)' && \ + test 'x$(CPP)' = 'x$(CPP_FOR_BUILD)'; } || \ + { rm -f src/stage1flex-*.$(OBJEXT) \ + src/$(DEPDIR)/stage1flex-*.Po || :; } + @{ test 'x$(CC)' = 'x$(CC_FOR_BUILD)' && test 'x$(CPP)' = 'x$(CPP_FOR_BUILD)'; } || { \ + echo 'error: stage1flex must be built with a native compiler' 1>&2; \ + exit 1; \ + } + $(AM_V_CCLD)$(stage1flex_LINK) $(stage1flex_OBJECTS) $(stage1flex_LDADD) $(LIBS) + +# The 'stage1bin/flex$(BUILD_EXEEXT)' target is not managed by +# automake. We use a different file name from the automake-managed +# 'stage1flex$(EXEEXT)' target to avoid clashing. + +stage1bin/flex$(BUILD_EXEEXT): + @if test 'x$(EXEEXT)' != 'x$(BUILD_EXEEXT)'; then rm -f stage1flex$(EXEEXT); else :; fi + @if test 'x$(OBJEXT)' != 'x$(BUILD_OBJEXT)'; then rm -f src/stage1flex-*.$(OBJEXT); else :; fi + $(MAKE) $(AM_MAKEFLAGS) \ + CC='$(CC_FOR_BUILD)' \ + CPP='$(CPP_FOR_BUILD)' \ + CFLAGS='$(CFLAGS_FOR_BUILD)' \ + CPPFLAGS='$(CPPFLAGS_FOR_BUILD)' \ + LDFLAGS='$(LDFLAGS_FOR_BUILD)' \ + EXEEXT='$(BUILD_EXEEXT)' \ + OBJEXT='$(BUILD_OBJEXT)' \ + stage1flex$(BUILD_EXEEXT) + $(MKDIR_P) stage1bin + $(INSTALL) -m 700 stage1flex$(BUILD_EXEEXT) $@ + +flex_SOURCES = \ + $(COMMON_SOURCES) + +nodist_flex_SOURCES = \ + $(SKELINCLUDES) + +if ENABLE_BOOTSTRAP +nodist_flex_SOURCES += src/stage1scan.c +else +flex_SOURCES += src/scan.l +endif + +COMMON_SOURCES = \ + src/buf.c \ + src/ccl.c \ + src/dfa.c \ + src/ecs.c \ + src/filter.c \ + src/flexdef.h \ + src/flexint.h \ + src/flexint_shared.h \ + src/gen.c \ + src/main.c \ + src/misc.c \ + src/nfa.c \ + src/options.c \ + src/options.h \ + src/parse.y \ + src/regex.c \ + src/scanflags.c \ + src/scanopt.c \ + src/scanopt.h \ + src/skeletons.c \ + src/sym.c \ + src/tables.c \ + src/tables.h \ + src/tables_shared.c \ + src/tables_shared.h \ + src/tblcmp.c \ + src/version.h \ + src/yylex.c + +LDADD = $(LIBOBJS) @LIBINTL@ + +$(LIBOBJS): $(LIBOBJDIR)$(am__dirstamp) + +include_HEADERS = \ + src/FlexLexer.h + +EXTRA_DIST += \ + src/c99-flex.skl \ + src/cpp-flex.skl \ + src/go-flex.skl \ + src/mkskel.sh \ + src/gettext.h \ + src/chkskel.sh + +MOSTLYCLEANFILES += \ + $(SKELINCLUDES) \ + src/stage1flex-*.$(BUILD_OBJEXT) \ + src/stage1scan.c \ + src/stage2scan.c \ + src/stage2compare + +CLEANFILES += \ + stage1bin/flex$(BUILD_EXEEXT) \ + stage1flex$(BUILD_EXEEXT) \ + stage1flex$(EXEEXT) + +SKELINCLUDES = \ + src/cpp-flex.h \ + src/c99-flex.h \ + src/go-flex.h + +src/cpp-flex.h: src/cpp-flex.skl src/mkskel.sh src/flexint_shared.h src/tables_shared.h src/tables_shared.c + $(SHELL) $(srcdir)/src/mkskel.sh cpp $(srcdir)/src $(m4) $(VERSION) > $@.tmp + $(SHELL) $(srcdir)/src/chkskel.sh $@.tmp + mv -f $@.tmp $@ + +src/c99-flex.h: src/c99-flex.skl src/mkskel.sh + $(SHELL) $(srcdir)/src/mkskel.sh c99 $(srcdir)/src $(m4) $(VERSION) > $@.tmp + $(SHELL) $(srcdir)/src/chkskel.sh $@.tmp + mv -f $@.tmp $@ + +src/go-flex.h: src/go-flex.skl src/mkskel.sh + $(SHELL) $(srcdir)/src/mkskel.sh go $(srcdir)/src $(m4) $(VERSION) > $@.tmp + $(SHELL) $(srcdir)/src/chkskel.sh $@.tmp + mv -f $@.tmp $@ + +# The input and output file names are fixed for deterministic scanner +# generation. If scan.l is not modified by builders, stage1scan.c should +# be bit-identical to the scan.c pregenerated on release. +src/stage1scan.c: src/scan.l stage1bin/flex$(BUILD_EXEEXT) + ( cd $(srcdir)/src && $(abs_builddir)/stage1bin/flex$(BUILD_EXEEXT) \ + $(AM_LFLAGS) $(LFLAGS) -o scan.c -t scan.l ) >$@ || \ + { s=$$?; rm -f $@; exit $$s; } + +# Unlike stage1scan.c, we leave stage2scan.c intact when the generation +# fails. This allow users to examine generation errors. +src/stage2scan.c: src/scan.l flex$(EXEEXT) + ( cd $(srcdir)/src && $(abs_builddir)/flex$(EXEEXT) \ + $(AM_LFLAGS) $(LFLAGS) -o scan.c -t scan.l ) >$@ + + +src/stage2compare: src/stage1scan.c src/stage2scan.c + @echo Comparing stage1scan.c and stage2scan.c; \ + cmp src/stage1scan.c src/stage2scan.c || { \ + s=$$?; \ + echo "Bootstrap comparison failure!"; \ + exit $$s; \ + }; \ + echo Comparison successful.; \ + echo success >$@ + +dist-hook: dist-hook-src + +dist-hook-src: src/scan.l flex$(EXEEXT) + chmod u+w $(distdir)/src && \ + chmod u+w $(distdir)/src/scan.c && \ + ( cd $(srcdir)/src && $(abs_builddir)/flex$(EXEEXT) \ + -o scan.c -t scan.l ) >src/scan.c && \ + mv -f src/scan.c $(distdir)/src/scan.c + +# make needs to be told to make inclusions so that parallelized runs will +# not fail. + +src/stage1flex-skeletons.$(OBJEXT): $(SKELINCLUDES) +src/skeletons.$(OBJEXT): $(SKELINCLUDES) + +src/stage1flex-main.$(OBJEXT): src/parse.h +src/main.$(OBJEXT): src/parse.h + +src/stage1flex-yylex.$(OBJEXT): src/parse.h +src/yylex.$(OBJEXT): src/parse.h + +src/stage1flex-scan.$(OBJEXT): src/parse.h +src/stage1scan.$(OBJEXT): src/parse.h +src/scan.$(OBJEXT): src/parse.h + +indentfiles += \ + src/buf.c \ + src/ccl.c \ + src/dfa.c \ + src/ecs.c \ + src/scanflags.c \ + src/filter.c \ + src/flexdef.h \ + src/gen.c \ + src/libmain.c \ + src/libyywrap.c \ + src/main.c \ + src/misc.c \ + src/nfa.c \ + src/options.c \ + src/options.h \ + src/regex.c \ + src/scanopt.c \ + src/scanopt.h \ + src/sym.c \ + src/tables.c \ + src/tables.h \ + src/tables_shared.c \ + src/tables_shared.h \ + src/tblcmp.c + +.PHONY: dist-hook-src src/stage2scan.c diff --git a/tests/Makefile.am b/tests/Makefile.am index fd94e67d4..7d9e55f0f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -320,7 +320,7 @@ pthread_pthread_LDADD = @LIBPTHREAD@ TESTOPTS = -L -FLEX = $(top_builddir)/src/flex +FLEX = $(top_builddir)/flex .l.c: $(FLEX) $(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $< diff --git a/tools/Makefile.am b/tools/Makefile.am deleted file mode 100644 index 46743a669..000000000 --- a/tools/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -EXTRA_DIST = \ - git2cl diff --git a/tools/local.mk b/tools/local.mk new file mode 100644 index 000000000..f8b15be32 --- /dev/null +++ b/tools/local.mk @@ -0,0 +1,2 @@ +EXTRA_DIST += \ + tools/git2cl