2 # Copyright (C) 2023 Michael Zucchi
4 # This is the copyright for antlr4.make
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # This processes antlr4 files. Include after java.make, before maven.make.
22 # <module>_ANTLR4 = list of grammar files without '.g4' extension.
24 # They must be in src/<module>/gen/<grammar>.g4
25 # The sources are generated in the usual gen directory
27 antlr4 = org.antlr:antlr4:4.12.0 \
28 org.antlr:antlr4-runtime:4.12.0 \
29 org.antlr:antlr-runtime:3.5.3 \
32 maven_central_JARS += $(antlr4)
34 antlr4_CLASSPATH=.lib/antlr4-4.12.0.jar \
35 .lib/antlr4-runtime-4.12.0.jar \
36 .lib/antlr-runtime-3.5.3.jar \
39 dist_EXTRA+=antlr4.make
41 define antlr4_targets=
42 $(if $($1-$2_ANTLR4PACKAGE),,$(error src/gen/$1/gen/gen.make: no $1-$2_ANTLR4PACKAGE defined))
43 bin/status/$1-$2.antlr: src/$1/gen/$2.g4
44 mkdir -p bin/gen/$1/gen bin/status
46 $(JAVA) -cp $(subst $S,:,$(realpath $(antlr4_CLASSPATH))) \
48 -o ../../../bin/gen/$1/classes/$(subst .,/,$($1-$2_ANTLR4PACKAGE)) \
49 -package $($1-$2_ANTLR4PACKAGE) \
50 $($1-$2_ANTLR4FLAGS) \
53 bin/status/$1.depjava: bin/status/$1-$2.antlr
56 #$(foreach m,$(java_MODULES),$(foreach g,$($m_ANTLR4),$(info $(call antlr4_targets,$m,$g))))
57 $(foreach m,$(java_MODULES),$(foreach g,$($m_ANTLR4),$(eval $(call antlr4_targets,$m,$g))))