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
14 ###############################################################################
15 # Set this variable to the directory which shall contain the JNI implementation
16 FIRM_JNI_DIR=/ben/goetz/proj/libfirm/firm-jni/
18 # Set these directories to point to a libfirm installation:
20 FIRM_INCLUDE_DIR=/ben/goetz/proj/libfirm/i686/include
21 FIRM_LIB_DIR=/ben/goetz/proj/libfirm/i686
22 FIRM_JNI_TOOLS_DIR=/ben/goetz/proj/libfirm/firm-jni/tools
24 # Set this directory to a directory with sufficient space.
25 WORK_DIR=/ben/goetz/proj/libfirm/firm-jni/tmp
27 # This is the list of firm headers a JNI interface is generated for
28 FIRM_HEADERS="firm.h firm_common.h dbginfo.h ident.h tv.h
29 type.h entity.h type_or_entity.h tpop.h mangle.h
30 irprog.h irgraph.h irnode.h irmode.h irop.h ircons.h ircgcons.h irflag.h irvrfy.h
31 irdump.h iropt.h irgopt.h ircgopt.h
32 irouts.h irdom.h irloop.h cgana.h
33 irgwalk.h irgmod.h typewalk.h typegmod.h"
35 ###############################################################################
43 ARCH_DIR=$MACHINE-$SYS_OS
45 LOG_FILE=compile-log.txt
47 REMOVE_CPP_COMMANDS=$FIRM_JNI_TOOLS_DIR/remove_cpp_comands.perl
50 # shell initialization
52 source /afs/info.uni-karlsruhe.de/public/tools/Modules/init/sh
66 ###############################################################################
69 while [ $# -gt 0 ]; do
71 --verbose) verbose="y";;
72 *) echo "Unknown option "$1;;
80 ###############################################################################
83 ###############################################################################
84 # Get all the necessary Firm headers.
90 for file in $FIRM_HEADERS; do
91 cp $FIRM_INCLUDE_DIR/$file $SOURCE_DIR
97 ###############################################################################
98 # Remove C preprocessor commands. Overwrite the header files.
99 # This part should be removed if crecoder integrates the preprocessor.
101 rm -f firm_typedefs.h
102 for file in $FIRM_HEADERS; do
103 perl $REMOVE_CPP_COMMANDS $file
106 for file in $FIRM_HEADERS; do
107 gcc -E -C -P $file -o ../$PUREC_DIR/$file
113 ###############################################################################
114 # Call crecoder to construct from each header a .java file specifying the
115 # java native interface. Further crecoder constructs an implementation of
116 # the java native interface in C calling the real libfirm functions.
117 # For a file "file.h" files "File.java" and "File.c" are generated.
119 module add jdk-1.3.1-sun
120 export CLASSPATH=$FIRM_JNI_TOOLS_DIR/crecoder.jar:$CLASSPATH
121 for file in $FIRM_HEADERS; do
122 java crecoder/tools/jniBuilder/BuildJNI $file
125 # Remove the C headers which are no more needed. They contain
126 # nonsense no C compiler ever should see ;-)
128 # Make the JNI Implementation
130 export CPPFLAGS="-I. -I/usr/public2/java/jdk1.3-sun/include/ -I/usr/public2/java/jdk1.3-sun/include/linux/ -I$FIRM_INCLUDE_DIR"
131 export LDFLAGS="-L$FIRM_LIB_DIR"
133 make -f $FIRM_JNI_TOOLS_DIR/Makefile
134 mv libfirmjni.so $FIRM_JNI_DIR
136 #mv *.java *.class $FIRM_JNI_DIR