Home | History | Annotate | Download | only in src
      1 # Make bison/src.
      2 
      3 # Copyright (C) 2001-2012 Free Software Foundation, Inc.
      4 
      5 # This program is free software: you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation, either version 3 of the License, or
      8 # (at your option) any later version.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public License
     16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
     19 AM_CPPFLAGS = -I$(top_srcdir)/lib
     20 BISON = ../tests/bison
     21 # Use our own Bison to build the parser.  Of course, you ought to
     22 # keep a sane version of Bison nearby...
     23 YACC = $(BISON) -y
     24 AM_YFLAGS = -d -v --warnings=all,error --report=all
     25 
     26 LDADD = ../lib/libbison.a $(LIBINTL)
     27 
     28 bin_PROGRAMS = bison
     29 bin_SCRIPTS = $(YACC_SCRIPT)
     30 EXTRA_SCRIPTS = yacc
     31 
     32 bison_SOURCES =                                 \
     33   AnnotationList.c AnnotationList.h             \
     34   InadequacyList.c InadequacyList.h             \
     35   LR0.c LR0.h                                   \
     36   Sbitset.c Sbitset.h                           \
     37   assoc.c assoc.h                               \
     38   closure.c closure.h                           \
     39   complain.c complain.h                         \
     40   conflicts.c conflicts.h                       \
     41   derives.c derives.h                           \
     42   files.c files.h                               \
     43   flex-scanner.h                                \
     44   getargs.c getargs.h                           \
     45   gram.c gram.h                                 \
     46   lalr.h lalr.c                                 \
     47   ielr.h ielr.c                                 \
     48   location.c location.h                         \
     49   main.c                                        \
     50   muscle-tab.c muscle-tab.h                     \
     51   named-ref.c named-ref.h                       \
     52   nullable.c nullable.h                         \
     53   output.c output.h                             \
     54   parse-gram.y                                  \
     55   print.c print.h                               \
     56   print_graph.c print_graph.h                   \
     57   print-xml.c print-xml.h                       \
     58   reader.c reader.h                             \
     59   reduce.c reduce.h                             \
     60   relation.c relation.h                         \
     61   scan-code.h scan-code-c.c                     \
     62   scan-gram.h scan-gram-c.c                     \
     63   scan-skel.h scan-skel-c.c                     \
     64   state.c state.h                               \
     65   symlist.c symlist.h                           \
     66   symtab.c symtab.h                             \
     67   system.h                                      \
     68   tables.h tables.c                             \
     69   uniqstr.c uniqstr.h                           \
     70   graphviz.c graphviz.h
     71 
     72 EXTRA_bison_SOURCES = scan-code.l scan-skel.l scan-gram.l
     73 
     74 BUILT_SOURCES =                                 \
     75   parse-gram.c parse-gram.h                     \
     76   scan-code.c                                   \
     77   scan-skel.c                                   \
     78   scan-gram.c
     79 
     80 MOSTLYCLEANFILES = yacc
     81 
     82 yacc:
     83 	$(AM_V_GEN)echo '#! /bin/sh' >$@
     84 	$(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@
     85 	$(AM_V_at)chmod a+x $@
     86 
     87 
     88 # The following rule is not designed to be portable,
     89 # and relies on tools that not everyone has.
     90 
     91 # Most functions in src/*.c should have static scope.
     92 # Any that don't must be marked with `extern', but `main'
     93 # and `usage' are exceptions.  They're always extern, but
     94 # don't need to be marked.
     95 #
     96 # The second nm|grep checks for file-scope variables with `extern' scope.
     97 sc_tight_scope: $(all_programs)
     98 	@t=exceptions-$$$$;						\
     99 	trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15;			\
    100 	( printf '^main$$\n^usage$$\n';					\
    101 	  grep -h -A1 '^extern .*[^;]$$' $(SOURCES)			\
    102 	    | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t;	\
    103 	if nm -e *.$(OBJEXT)						\
    104 	    | sed -n 's/.* T //p'					\
    105 	    | grep -Ev -f $$t; then					\
    106 	  echo 'the above functions should have static scope' 1>&2;	\
    107 	  exit 1;							\
    108 	fi;								\
    109 	( printf '^program_name$$\n';					\
    110 	  sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
    111 	    $$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t;		\
    112 	if nm -e *.$(OBJEXT)						\
    113 	    | sed -n 's/.* [BD] //p'					\
    114 	    | grep -Ev -f $$t; then					\
    115 	  echo 'the above variables should have static scope' 1>&2;	\
    116 	  exit 1;							\
    117 	fi
    118