4 # File name: script/build_firm_jni
5 # Purpose: skript to build a java native interface for the public headers of firm.
6 # Author: Goetz Lindenmaier
10 # Copyright: (c) 2002 Universität Karlsruhe
13 top_srcdir=@top_srcdir@
18 # This is the list of firm headers a JNI interface is generated for
19 # If you change this list, also change FRIM_PATH_HEADERS and the list
21 FIRM_HEADERS="firm.h firm_common.h dbginfo.h ident.h tv.h
22 type.h entity.h type_or_entity.h tpop.h mangle.h
23 irprog.h irgraph.h irnode.h irmode.h irop.h ircons.h ircgcons.h
24 irflag.h irvrfy.h irdump.h iropt.h irgopt.h ircgopt.h
25 irouts.h irdom.h irloop.h cgana.h
27 # How to pass function pointers? Therefore removed.
28 # irgwalk.h typewalk.h
30 FIRM_PATH_HEADERS="common/firm.h common/firm_common.h
31 debug/dbginfo.h ident/ident.h tv/tv.h
32 tr/type.h tr/entity.h tr/type_or_entity.h tr/tpop.h tr/mangle.h
33 ir/irprog.h ir/irgraph.h ir/irnode.h ir/irmode.h ir/irop.h
34 ir/ircons.h ir/ircgcons.h ir/irflag.h ir/irvrfy.h ir/irdump.h
35 ir/iropt.h ir/irgopt.h ir/ircgopt.h
36 ana/irouts.h ana/irdom.h ana/irloop.h ana/cgana.h
37 ir/irgmod.h tr/typegmod.h"
39 # The directory containing crecoder.jar and, for now,
40 # remove_cpp_comands.perl
41 FIRM_JNI_TOOLS_DIR=$top_srcdir/tools
45 ###############################################################################
49 REMOVE_CPP_COMMANDS=$FIRM_JNI_TOOLS_DIR/remove_cpp_comands.perl
50 CRECODER=$FIRM_JNI_TOOLS_DIR/crecoder.jar
53 ###############################################################################
54 # Get all the necessary Firm headers.
60 for file in $FIRM_PATH_HEADERS; do
61 cp $top_srcdir/ir/$file $SOURCE_DIR
64 ###############################################################################
65 # Remove C preprocessor commands. Overwrite the header files.
66 # This part should be removed if crecoder integrates the preprocessor.
68 rm -f $SOURCE_DIR/firm_typedefs.h
69 for file in $FIRM_HEADERS; do
70 perl $REMOVE_CPP_COMMANDS $SOURCE_DIR/$file
72 # the perl script dumps this file in the dir it is called from
73 mv firm_typedefs.h $SOURCE_DIR
75 for file in $FIRM_HEADERS; do
76 gcc -E -C -P $SOURCE_DIR/$file -o $file
80 ###############################################################################
81 # Call crecoder to construct from each header a .java file specifying the
82 # java native interface. Further crecoder constructs an implementation of
83 # the java native interface in C calling the real libfirm functions.
84 # For a file "file.h" files "File.java" and "File.c" are generated.
86 export CLASSPATH=$FIRM_JNI_TOOLS_DIR/crecoder.jar:$CLASSPATH
87 for file in $FIRM_HEADERS; do
88 java crecoder/tools/jniBuilder/BuildJNI $file
91 # Remove the C headers which are no more needed. They contain
92 # nonsense no C compiler ever should see ;-)
95 # javah renames these files. the jnibuilder doesn't anticipate this
96 # and generates #includes with the original names.
97 ln -s Firm_0005fcommon.h Firm_common.h
98 ln -s Type_0005for_0005fentity.h Type_or_entity.h