don't emit vfp copies
[libfirm] / firmjni / Makefile.in
1 #
2 # Project:     libFIRM
3 # File name:   firmjni/Makefile.in
4 # Purpose:
5 # Author:      Till Riedel, Goetz Lindenmaier
6 # Modified by:
7 # Created:     2002
8 # CVS-ID:      $Id$
9 # Copyright:   (c) 2002 Universität Karlsruhe
10 # Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11 #
12
13 top_srcdir := @top_srcdir@
14 srcdir = @srcdir@
15 topdir = ..
16 subdir = firmjni
17
18 enable_heapanal         := @enable_heapanalysis@
19 enable_libcore          := @enable_libcore@
20 enable_external_effects := @enable_external_effects@
21 disable_libiberty       := @disable_libiberty@
22
23 # The library implementing the JNI methods.  This name is also
24 # known to the generator for the JNI interface and used in the
25 # static initializer.
26 LIBNAME = libfirmjni.so
27
28 # The name of the package containing the Firm JNI
29 PACKAGENAME = firmjni
30
31 include $(topdir)/MakeRules
32
33 # where to put libfirmjni.so
34 libdir = @libdir@
35 # where to put the directory firmjni containing the generated
36 # .java and .class files
37 #javadir = @javadir@         @@@ how to specify a dir in configure.in?
38
39 .PHONY: default all clean realclean depend
40
41 SHELL_TOUPPER = awk '{for (i=1;i<(NF+1);i=i+1) {printf(toupper(substr($$i,1,1)) substr($$i,2)" ")}}'
42 SHELL_TOLOWER = awk '{for (i=1;i<(NF+1);i=i+1) {printf(tolower(substr($$i,1,1)) substr($$i,2)" ")}}'
43
44 OFILES  = $(MEMBERS:.m=.o)
45 HFILES  = $(MEMBERS:.m=.h)
46 JAVAFILES  = $(MEMBERS:.m=.java)
47 CLASSFILES = $(MEMBERS:.m=.class)
48
49 CPPFLAGS +=     -I$(top_srcdir)/ir/ir  -I$(top_srcdir)/ir/common        \
50                 -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr          \
51                 -I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/debug          \
52                 -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/opt           \
53                 -I$(top_srcdir)/ir/st -I$(top_srcdir)/ir/stat           \
54                 -I$(top_srcdir)/ir/arch -I$(top_srcdir)/ir/lower        \
55                 -I$(topdir)/ir/config                                   \
56                 -I$(topdir)
57
58 LDFLAGS += -L$(libdir)
59
60 ifeq ($(enable_heapanal),yes)
61 LDFLAGS += -lfirmlower -labor -lheapanal
62 endif
63
64 ifeq ($(enable_libcore),yes)
65 LDFLAGS += -lcore
66 endif
67
68 ifeq ($(enable_external_effects),yes)
69 LDFLAGS += -lxml2
70 endif
71
72 ifeq ($(disable_libiberty),yes)
73 LDFLAGS += -liberty
74 endif
75
76
77 FIRM_HEADERS=$(notdir $(FIRM_PATH_HEADERS))
78 MEMBERS=$(subst .h,.m,$(shell echo $(FIRM_HEADERS)|$(SHELL_TOUPPER)))
79 MEMBERS += $(IMPL_MEMBERS)
80
81 # How to pass function pointers? Therefore removed.
82 # irgwalk.h typewalk.h firmwalk.h
83
84 # How to pass function pointers? Or how to obtain them?
85 #      Irgwalk.m Typewalk.m
86 #
87
88 # common/debug.h requieres libcore
89 # ir/irprintf.h crecoder cannot handle va_list
90 #
91 FIRM_PATH_HEADERS= \
92         common/firm_types.h \
93         common/firm_common.h \
94         common/firm.h \
95         \
96         ident/ident.h \
97         \
98         ana/irouts.h \
99         ana/trouts.h \
100         ana/irdom.h \
101         ana/cgana.h \
102         ana/irloop.h \
103         ana/irtypeinfo.h \
104         ana/irsimpletype.h \
105         ana/callgraph.h \
106         ana/rta.h \
107         ana/interval_analysis.h \
108         ana/field_temperature.h \
109         ana/execution_frequency.h \
110         ana/irextbb.h \
111         ana/irconsconfirm.h \
112         ana/analyze_irg_args.h \
113         \
114         ir/irprog.h \
115         ir/irgraph.h \
116         ir/irnode.h \
117         ir/irmode.h \
118         ir/irop.h \
119         ir/ircons.h \
120         ir/irflag.h \
121         ir/irvrfy.h \
122         ir/irgmod.h \
123         ir/iropt.h \
124         ir/irdump.h \
125         ir/irgopt.h \
126         ir/ircgcons.h \
127         ir/ircgopt.h \
128         ir/irhooks.h \
129         ir/irarch.h \
130         ir/pseudo_irg.h \
131         ir/iredges.h \
132         \
133         opt/cfopt.h \
134         opt/gvn_pre.h \
135         opt/tailrec.h \
136         opt/ldstopt.h \
137         opt/reassoc.h \
138         opt/loop_unrolling.h \
139         opt/funccall.h \
140         opt/opt_polymorphy.h \
141         opt/ifconv.h \
142         opt/return.h \
143         opt/tropt.h \
144         opt/scalar_replace.h \
145         opt/escape_ana.h \
146         opt/proc_cloning.h \
147         opt/opt_confirms.h \
148         opt/opt_frame.h \
149         opt/opt_osr.h \
150         \
151         tr/entity.h \
152         tr/mangle.h \
153         tr/tpop.h \
154         tr/type.h \
155         tr/type_or_entity.h \
156         tr/typegmod.h \
157         tr/type_identify.h \
158         tr/tr_inheritance.h \
159         \
160         arch/archop.h \
161         \
162         tv/tv.h \
163         \
164         lower/lower_intrinsics.h \
165         lower/lower_calls.h \
166         lower/lower_dw.h
167
168 FIRM_SOURCE_DIR_HEADERS=$(addprefix $(SOURCE_DIR)/,$(FIRM_HEADERS))
169
170 # hand implemented members
171 IMPL_MEMBERS = Dbginfo.m
172
173 ifeq ($(enable_heapanal),yes)
174 IMPL_MEMBERS += Heapanal.m
175 endif
176
177 # The directory containing crecoder.jar and, for now,
178 # remove_cpp_comands.perl
179 FIRM_JNI_TOOLS_DIR=$(top_srcdir)/tools
180
181 WORK_DIR=.
182
183 ###############################################################################
184
185 SOURCE_DIR=sources
186
187 REMOVE_CPP_COMMANDS=$(FIRM_JNI_TOOLS_DIR)/remove_cpp_comands.perl
188 CRECODER=$(FIRM_JNI_TOOLS_DIR)/crecoder.jar
189
190 all:    classfiles javafiles jni
191
192 classfiles: $(CLASSFILES)
193 javafiles: $(JAVAFILES)
194
195 %.class: %.java
196         javac -classpath .. $<
197
198 # javah renames these files.  the jnibuilder doesn't anticipate this
199 # and generates #includes with the original names.
200 Firm_common.h: Firm_common.class
201         ln -sf Firm_0005fcommon.h Firm_common.h
202         javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
203
204 Type_or_entity.h: Type_or_entity.class
205         ln -sf Type_0005for_0005fentity.h Type_or_entity.h
206         javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
207
208
209 Dbginfo.java:
210         cp $(top_srcdir)/firmjni/auxilliary/Dbginfo.java $(top_srcdir)/firmjni/auxilliary/Dbginfo.c .
211
212 Heapanal.java:
213         cp $(top_srcdir)/firmjni/auxilliary/Heapanal.java $(top_srcdir)/firmjni/auxilliary/Heapanal.c .
214
215 %.h:    %.class
216         javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
217
218 %.o:    %.c %.h
219         $(CC) $(CPPFLAGS) -c $< -o $@
220
221 $(OFILES):
222         $(CC) $(CPPFLAGS) -c $(@:.o=.c) -o $@
223
224
225 # We need firmlower and abor for heap analysis stuff, which is called from auxilliary/Heapanal.java
226 # BY the way, what is ../../sw/lib/  can this be removed? Probaly, so I did.
227 jni:    $(HFILES) $(OFILES)  # ../libfirm.a
228         $(CC) -shared -fPIC -o $(LIBNAME) *.o -lfirm -L.. $(LDFLAGS)
229 install:
230         cp libfirmjni.so $(libdir)
231 #       mkdir $(javadir)
232 #       cp *.java @javadir@
233 #       cp *.class @javadir@
234
235
236 test:   jni
237         $(MAKE) -C testprograms test
238
239 clean:
240         rm -rf sources *.c *.h *.o
241
242 realclean: clean
243         rm -f *~ libfirmjni.so *.vcg *.java *.class
244
245
246 $(SOURCE_DIR):
247         rm -rf $(SOURCE_DIR)
248         mkdir $(SOURCE_DIR)
249
250 $(SOURCE_DIR)/firm_typedefs.h: $(FIRM_SOURCE_HEADERS)
251         mv firm_typedefs.h $@
252
253 ###############################################################################
254 # Get all the necessary Firm headers.
255 ###############################################################################
256 # Remove C preprocessor commands.  Overwrite the header files.
257 # This part should be removed if crecoder integrates the preprocessor.
258
259 FIRM_SRC_HEADER=$(top_srcdir)/ir/$(filter %/$(notdir $@),$(FIRM_PATH_HEADERS))
260
261
262 # recode: remove "a from C code...
263 $(FIRM_SOURCE_DIR_HEADERS): $(SOURCE_DIR)
264         recode ISO-8859-1..ascii < $(FIRM_SRC_HEADER) > $(SOURCE_DIR)/$(notdir $@)
265         perl $(REMOVE_CPP_COMMANDS) $@
266
267 #       cp $(FIRM_SRC_HEADER) $(SOURCE_DIR)/$(notdir $@)
268 #       recode ISO-8859-1..ascii < $@ > $@.x
269 #       cp $@.x $@
270
271 # generiert leere dateien ;-(
272 #       troff -a -C -z  $(FIRM_SRC_HEADER) > $(SOURCE_DIR)/$(notdir $@)
273
274 $(FIRM_HEADERS):$(FIRM_SOURCE_DIR_HEADERS) $(SOURCE_DIR)/firm_typedefs.h
275         $(CC) $(CPPFLAGS) -E -C -P $(SOURCE_DIR)/$@ -o $@
276
277 ###############################################################################
278 # Call crecoder to construct from each header a .java file specifying the
279 # java native interface.  Further crecoder constructs an implementation of
280 # the java native interface in C calling the real libfirm functions.
281 # For a file "file.h" files "File.java" and "File.c" are generated.
282
283
284 H_FROM_JAVA=$(subst .java,.h,$(shell echo $@|$(SHELL_TOLOWER)))
285
286 %.java: $(FIRM_SOURCE_DIR_HEADERS) $(SOURCE_DIR)/firm_typedefs.h
287         $(CC) $(CPPFLAGS) -E -C -P $(SOURCE_DIR)/$(H_FROM_JAVA) -o $(H_FROM_JAVA)
288         env CLASSPATH=$(FIRM_JNI_TOOLS_DIR)/crecoder.jar:$$CLASSPATH java crecoder/tools/jniBuilder/BuildJNI $(H_FROM_JAVA) ;\
289         rm $(H_FROM_JAVA);
290 # remove the patched header so that further compilation finds the proper firm headers