X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=firmjni%2FMakefile.in;h=59c5dccbbe6d21561166dd5bb4b0e6ee2bfb65ee;hb=534b324d67b91c9131c8eaba0b763c7ca66987f7;hp=c4d7a9f11c037ea203c0c39410d952512e28900e;hpb=95af0a8da6ee81b607da91eab80cda44b2165768;p=libfirm diff --git a/firmjni/Makefile.in b/firmjni/Makefile.in index c4d7a9f11..59c5dccbb 100644 --- a/firmjni/Makefile.in +++ b/firmjni/Makefile.in @@ -1,16 +1,35 @@ - -# $Id$ +# +# Project: libFIRM +# File name: firmjni/Makefile.in +# Purpose: +# Author: Till Riedel, Goetz Lindenmaier +# Modified by: +# Created: 2002 +# CVS-ID: $Id$ +# Copyright: (c) 2002 Universität Karlsruhe +# Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. +# top_srcdir := @top_srcdir@ srcdir = @srcdir@ topdir = .. subdir = firmjni +enable_heapanal := @enable_heapanalysis@ +enable_libcore := @enable_libcore@ +enable_external_effects := @enable_external_effects@ +disable_libiberty := @disable_libiberty@ + # The library implementing the JNI methods. This name is also # known to the generator for the JNI interface and used in the # static initializer. LIBNAME = libfirmjni.so +# The name of the package containing the Firm JNI +PACKAGENAME = firmjni + +include $(topdir)/MakeRules + # where to put libfirmjni.so libdir = @libdir@ # where to put the directory firmjni containing the generated @@ -19,54 +38,253 @@ libdir = @libdir@ .PHONY: default all clean realclean depend -MEMBERS = Firm.m Firm.m Firm_common.m Dbginfo.m Ident.m Tv.m \ - Type.m Entity.m Type_or_entity.m Tpop.m Mangle.m \ - Irprog.m Irgraph.m Irnode.m Irmode.m Irop.m Ircons.m Ircgcons.m \ - Irflag.m Irvrfy.m Irdump.m Iropt.m Irgopt.m Ircgopt.m \ - Irouts.m Irdom.m Irloop.m Cgana.m \ - Irgmod.m Typegmod.m -# How to pass function pointers? Or how to obtain them? -# Irgwalk.m Typewalk.m +SHELL_TOUPPER = awk '{for (i=1;i<(NF+1);i=i+1) {printf(toupper(substr($$i,1,1)) substr($$i,2)" ")}}' +SHELL_TOLOWER = awk '{for (i=1;i<(NF+1);i=i+1) {printf(tolower(substr($$i,1,1)) substr($$i,2)" ")}}' OFILES = $(MEMBERS:.m=.o) HFILES = $(MEMBERS:.m=.h) +JAVAFILES = $(MEMBERS:.m=.java) CLASSFILES = $(MEMBERS:.m=.class) -CPPFLAGS = -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \ +CPPFLAGS += -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \ -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr \ -I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/debug \ - -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st @CPPFLAGS@ + -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/opt \ + -I$(top_srcdir)/ir/st -I$(top_srcdir)/ir/stat \ + -I$(top_srcdir)/ir/arch -I$(top_srcdir)/ir/lower \ + -I$(topdir)/ir/config \ + -I$(topdir) + +LDFLAGS += -L$(libdir) + +ifeq ($(enable_heapanal),yes) +LDFLAGS += -lfirmlower -labor -lheapanal +endif + +ifeq ($(enable_libcore),yes) +LDFLAGS += -lcore +endif + +ifeq ($(enable_external_effects),yes) +LDFLAGS += -lxml2 +endif + +ifeq ($(disable_libiberty),yes) +LDFLAGS += -liberty +endif + + +FIRM_HEADERS=$(notdir $(FIRM_PATH_HEADERS)) +MEMBERS=$(subst .h,.m,$(shell echo $(FIRM_HEADERS)|$(SHELL_TOUPPER))) +MEMBERS += $(IMPL_MEMBERS) + +# How to pass function pointers? Therefore removed. +# irgwalk.h typewalk.h firmwalk.h + +# How to pass function pointers? Or how to obtain them? +# Irgwalk.m Typewalk.m +# + +# common/debug.h requieres libcore +# ir/irprintf.h crecoder cannot handle va_list +# +FIRM_PATH_HEADERS= \ + common/firm_types.h \ + common/firm_common.h \ + common/firm.h \ + \ + ident/ident.h \ + \ + ana/irouts.h \ + ana/trouts.h \ + ana/irdom.h \ + ana/cgana.h \ + ana/irloop.h \ + ana/irtypeinfo.h \ + ana/irsimpletype.h \ + ana/callgraph.h \ + ana/rta.h \ + ana/interval_analysis.h \ + ana/field_temperature.h \ + ana/execution_frequency.h \ + ana/irextbb.h \ + ana/irconsconfirm.h \ + ana/analyze_irg_args.h \ + \ + ir/irprog.h \ + ir/irgraph.h \ + ir/irnode.h \ + ir/irmode.h \ + ir/irop.h \ + ir/ircons.h \ + ir/irflag.h \ + ir/irvrfy.h \ + ir/irgmod.h \ + ir/iropt.h \ + ir/irdump.h \ + ir/irgopt.h \ + ir/ircgcons.h \ + ir/ircgopt.h \ + ir/irhooks.h \ + ir/irarch.h \ + ir/pseudo_irg.h \ + ir/iredges.h \ + \ + opt/cfopt.h \ + opt/gvn_pre.h \ + opt/tailrec.h \ + opt/ldstopt.h \ + opt/reassoc.h \ + opt/loop_unrolling.h \ + opt/funccall.h \ + opt/opt_polymorphy.h \ + opt/ifconv.h \ + opt/return.h \ + opt/tropt.h \ + opt/scalar_replace.h \ + opt/escape_ana.h \ + opt/proc_cloning.h \ + opt/opt_confirms.h \ + opt/opt_frame.h \ + opt/opt_osr.h \ + \ + tr/entity.h \ + tr/mangle.h \ + tr/tpop.h \ + tr/type.h \ + tr/type_or_entity.h \ + tr/typegmod.h \ + tr/type_identify.h \ + tr/tr_inheritance.h \ + \ + arch/archop.h \ + \ + tv/tv.h \ + \ + lower/lower_intrinsics.h \ + lower/lower_calls.h \ + lower/lower_dw.h + +FIRM_SOURCE_DIR_HEADERS=$(addprefix $(SOURCE_DIR)/,$(FIRM_HEADERS)) + +# hand implemented members +IMPL_MEMBERS = Dbginfo.m + +ifeq ($(enable_heapanal),yes) +IMPL_MEMBERS += Heapanal.m +endif + +# The directory containing crecoder.jar and, for now, +# remove_cpp_comands.perl +FIRM_JNI_TOOLS_DIR=$(top_srcdir)/tools + +WORK_DIR=. + +############################################################################### -LDFLAGS += $(topdir) +SOURCE_DIR=sources -all: classfiles jni +REMOVE_CPP_COMMANDS=$(FIRM_JNI_TOOLS_DIR)/remove_cpp_comands.perl +CRECODER=$(FIRM_JNI_TOOLS_DIR)/crecoder.jar -# call the generator to make the implementation files -#impl: -# -sh build_firm_jni +all: classfiles javafiles jni classfiles: $(CLASSFILES) +javafiles: $(JAVAFILES) %.class: %.java - javac $< + javac -classpath .. $< + +# javah renames these files. the jnibuilder doesn't anticipate this +# and generates #includes with the original names. +Firm_common.h: Firm_common.class + ln -sf Firm_0005fcommon.h Firm_common.h + javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=) + +Type_or_entity.h: Type_or_entity.class + ln -sf Type_0005for_0005fentity.h Type_or_entity.h + javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=) + + +Dbginfo.java: + cp $(top_srcdir)/firmjni/auxilliary/Dbginfo.java $(top_srcdir)/firmjni/auxilliary/Dbginfo.c . + +Heapanal.java: + cp $(top_srcdir)/firmjni/auxilliary/Heapanal.java $(top_srcdir)/firmjni/auxilliary/Heapanal.c . %.h: %.class - javah $(<:.class=) + javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=) %.o: %.c %.h - gcc $(CPPFLAGS) -c $< -o $@ + $(CC) $(CPPFLAGS) -c $< -o $@ -jni: $(HFILES) $(OFILES) # ../libfirm.a - gcc -shared -fPIC -o $(LIBNAME) *.o -lfirm -L.. +$(OFILES): + $(CC) $(CPPFLAGS) -c $(@:.o=.c) -o $@ + +# We need firmlower and abor for heap analysis stuff, which is called from auxilliary/Heapanal.java +# BY the way, what is ../../sw/lib/ can this be removed? Probaly, so I did. +jni: $(HFILES) $(OFILES) # ../libfirm.a + $(CC) -shared -fPIC -o $(LIBNAME) *.o -lfirm -L.. $(LDFLAGS) install: cp libfirmjni.so $(libdir) # mkdir $(javadir) # cp *.java @javadir@ # cp *.class @javadir@ + +test: jni + $(MAKE) -C testprograms test + clean: rm -rf sources *.c *.h *.o realclean: clean rm -f *~ libfirmjni.so *.vcg *.java *.class + + +$(SOURCE_DIR): + rm -rf $(SOURCE_DIR) + mkdir $(SOURCE_DIR) + +$(SOURCE_DIR)/firm_typedefs.h: $(FIRM_SOURCE_HEADERS) + mv firm_typedefs.h $@ + +############################################################################### +# Get all the necessary Firm headers. +############################################################################### +# Remove C preprocessor commands. Overwrite the header files. +# This part should be removed if crecoder integrates the preprocessor. + +FIRM_SRC_HEADER=$(top_srcdir)/ir/$(filter %/$(notdir $@),$(FIRM_PATH_HEADERS)) + + +# recode: remove "a from C code... +$(FIRM_SOURCE_DIR_HEADERS): $(SOURCE_DIR) + recode ISO-8859-1..ascii < $(FIRM_SRC_HEADER) > $(SOURCE_DIR)/$(notdir $@) + perl $(REMOVE_CPP_COMMANDS) $@ + +# cp $(FIRM_SRC_HEADER) $(SOURCE_DIR)/$(notdir $@) +# recode ISO-8859-1..ascii < $@ > $@.x +# cp $@.x $@ + +# generiert leere dateien ;-( +# troff -a -C -z $(FIRM_SRC_HEADER) > $(SOURCE_DIR)/$(notdir $@) + +$(FIRM_HEADERS):$(FIRM_SOURCE_DIR_HEADERS) $(SOURCE_DIR)/firm_typedefs.h + $(CC) $(CPPFLAGS) -E -C -P $(SOURCE_DIR)/$@ -o $@ + +############################################################################### +# Call crecoder to construct from each header a .java file specifying the +# java native interface. Further crecoder constructs an implementation of +# the java native interface in C calling the real libfirm functions. +# For a file "file.h" files "File.java" and "File.c" are generated. + + +H_FROM_JAVA=$(subst .java,.h,$(shell echo $@|$(SHELL_TOLOWER))) + +%.java: $(FIRM_SOURCE_DIR_HEADERS) $(SOURCE_DIR)/firm_typedefs.h + $(CC) $(CPPFLAGS) -E -C -P $(SOURCE_DIR)/$(H_FROM_JAVA) -o $(H_FROM_JAVA) + env CLASSPATH=$(FIRM_JNI_TOOLS_DIR)/crecoder.jar:$$CLASSPATH java crecoder/tools/jniBuilder/BuildJNI $(H_FROM_JAVA) ;\ + rm $(H_FROM_JAVA); +# remove the patched header so that further compilation finds the proper firm headers