Option to jump with up on keyboard.
[supertux.git] / mk / jam / bisonflex.jam
1 #============================================================================
2 # Rules for flex and bison
3 #============================================================================
4
5 if $(LEX)
6 {
7   rule LexRule
8   {
9     local cfile = [ LocateTarget $(<:S=.c) : $(SUBDIR) ] ;
10     local object = [ CompileObjects $(cfile) ] ;
11
12     Lex $(cfile) : $(<) ;
13     
14     return $(object) ;
15   }
16   RegisterFileType LexRule : .l ;
17   
18   rule Lex++Rule
19   {
20     local cppfile = [ LocateTarget $(<:S=.cpp) : $(SUBDIR) ] ;
21     local object = [ CompileObjects $(cppfile) ] ;
22
23     Lex $(cppfile) : $(<) ;
24
25     return $(object) ;
26   }
27   RegisterFileType Lex++Rule : .ll ;
28
29   if $(COMPILER_TYPE) != "GCC"
30   {
31     # compilers like msvc don't like #line statements.
32     LEX_FLAGS += -L ;
33   }
34
35   rule Lex
36   {
37     Depends $(<) : $(>) ;
38     LEX_FLAGS on $(cfile) += $(LEX_FLAGS) ;    
39     Clean clean : $(cfile) ;
40   }
41   
42   # Use -t and output redirection to avoid flex choosing stupid names for it's
43   # output files.
44   actions Lex
45   {
46     $(LEX) -t $(LEX_FLAGS) $(>) > $(<)
47   }
48 }
49
50 if $(BISON)
51 {
52   rule BisonRule
53   {
54     local cfile = [ LocateTarget $(<:S=.c) : $(SUBDIR) ] ;
55     local headerfile = [ LocateTarget $(<:S=.h) : $(SUBDIR) ] ;
56     local object = [ CompileObjects $(cfile) ] ;
57
58     Includes $(headerfile:G=) : $(headerfile) ;
59     
60     Bison $(cfile) : $(<) ;
61     # work around jam warning about independent target 
62     Includes $(cfile) : $(headerfile) ;
63
64     return $(object) ;
65   }
66   RegisterFileType BisonRule : .y ;
67
68   rule Bison++Rule
69   {
70     local cppfile = [ LocateTarget $(<:S=.cpp) : $(SUBDIR) ] ;
71     local headerfile = [ LocateTarget $(<:S=.hpp) : $(SUBDIR) ] ;
72     local object = [ CompileObjects $(cppfile) ] ;
73
74     # jams header file scannning doesn't use grist so we have to workaround this
75     # here
76     Includes $(headerfile:G=) : $(headerfile) ;
77
78     Bison $(cppfile) $(headerfile) : $(<) ;
79 #Includes $(cppfile) : $(headerfile:G=) ;
80
81     return $(object) ;
82   }
83   RegisterFileType Bison++Rule : .yy ;
84     
85   rule Bison
86   {
87     Depends $(<) : $(>) ;
88     BISON_FLAGS on $(<) += $(BISON_FLAGS) ;
89     Clean clean : $(<) ;
90   }
91   rule BisonFlags
92   {
93     local target ;
94     
95     if $(<:S) = .yy
96     {
97       target = [ LocateTarget $(<:S=.cpp) $(<:S=.hpp) ] ;
98     }
99     else
100     {
101       target = [ LocateTarget $(<:S=.c) $(<:S=.h) ] ;
102     }
103     BISON_FLAGS on $(target) += $(>) ;
104   }
105
106   if $(COMPILER_TYPE) != "GCC"
107   {
108     # compilers like msvc don't like #line statements.
109     BISON_FLAGS += --no-lines ;
110   }
111   actions Bison
112   {
113     $(BISON) -d $(BISON_FLAGS) -o $(<[1]) $(>)
114   }
115 }
116