troff generates empty files
[libfirm] / firmjni / Makefile.in
1
2 # $Id$
3
4 top_srcdir := @top_srcdir@
5 srcdir = @srcdir@
6 topdir = ..
7 subdir = firmjni
8
9 # The library implementing the JNI methods.  This name is also
10 # known to the generator for the JNI interface and used in the
11 # static initializer.
12 LIBNAME = libfirmjni.so
13
14 # The name of the package containing the Firm JNI
15 PACKAGENAME = firmjni
16
17 # where to put libfirmjni.so
18 libdir = @libdir@
19 # where to put the directory firmjni containing the generated
20 # .java and .class files
21 #javadir = @javadir@         @@@ how to specify a dir in configure.in?
22
23 .PHONY: default all clean realclean depend
24
25 SHELL_TOUPPER = awk '{for (i=1;i<(NF+1);i=i+1) {printf(toupper(substr($$i,1,1)) substr($$i,2)" ")}}'
26 SHELL_TOLOWER = awk '{for (i=1;i<(NF+1);i=i+1) {printf(tolower(substr($$i,1,1)) substr($$i,2)" ")}}'
27
28 OFILES  = $(MEMBERS:.m=.o)
29 HFILES  = $(MEMBERS:.m=.h)
30 JAVAFILES  = $(MEMBERS:.m=.java)
31 CLASSFILES = $(MEMBERS:.m=.class)
32
33 CPPFLAGS =      -I$(top_srcdir)/ir/ir  -I$(top_srcdir)/ir/common        \
34                 -I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr          \
35                 -I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/debug          \
36                 -I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st @CPPFLAGS@ \
37                 -D_SIZE_T_
38
39 LDFLAGS += $(topdir)
40
41 FIRM_HEADERS=$(notdir $(FIRM_PATH_HEADERS))
42 MEMBERS=$(subst .h,.m,$(shell echo $(FIRM_HEADERS)|$(SHELL_TOUPPER)))
43
44 # How to pass function pointers? Therefore removed.
45 # irgwalk.h typewalk.h
46
47 # How to pass function pointers? Or how to obtain them?
48 #      Irgwalk.m Typewalk.m
49 #
50 FIRM_PATH_HEADERS=common/firm.h common/firm_common.h \
51         debug/dbginfo.h ident/ident.h tv/tv.h \
52         tr/type.h tr/entity.h tr/type_or_entity.h tr/tpop.h tr/mangle.h \
53         ir/irprog.h ir/irgraph.h ir/irnode.h ir/irmode.h ir/irop.h \
54         ir/ircons.h ir/ircgcons.h ir/irflag.h ir/irvrfy.h ir/irdump.h \
55         ir/iropt.h ir/irgopt.h ir/ircgopt.h \
56         ana/irouts.h ana/irdom.h ana/irloop.h ana/cgana.h \
57         ir/irgmod.h tr/typegmod.h
58 FIRM_SOURCE_DIR_HEADERS=$(addprefix $(SOURCE_DIR)/,$(FIRM_HEADERS))
59
60 # The directory containing crecoder.jar and, for now,
61 # remove_cpp_comands.perl
62 FIRM_JNI_TOOLS_DIR=$(top_srcdir)/tools
63
64 WORK_DIR=.
65
66 ###############################################################################
67
68 SOURCE_DIR=sources
69
70 REMOVE_CPP_COMMANDS=$(FIRM_JNI_TOOLS_DIR)/remove_cpp_comands.perl
71 CRECODER=$(FIRM_JNI_TOOLS_DIR)/crecoder.jar
72
73 all:    classfiles javafiles jni
74
75 classfiles: $(CLASSFILES)
76 javafiles: $(JAVAFILES)
77
78 %.class: %.java
79         javac $<
80
81 # javah renames these files.  the jnibuilder doesn't anticipate this
82 # and generates #includes with the original names.
83 Firm_common.h: Firm_common.class
84         ln -sf Firm_0005fcommon.h Firm_common.h
85         javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
86
87 Type_or_entity.h: Type_or_entity.class
88         ln -sf Type_0005for_0005fentity.h Type_or_entity.h
89         javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
90
91 %.h:    %.class
92         javah -classpath $(topdir) -o $@ $(PACKAGENAME).$(<:.class=)
93
94 %.o:    %.c %.h
95         gcc $(CPPFLAGS) -c $< -o $@
96
97 $(OFILES):
98         gcc $(CPPFLAGS) -c $(@:.o=.c) -o $@
99
100 jni:    $(HFILES) $(OFILES)  # ../libfirm.a
101         gcc -shared -fPIC -o $(LIBNAME) *.o -lfirm -L..
102
103 install:
104         cp libfirmjni.so $(libdir)
105 #       mkdir $(javadir)
106 #       cp *.java @javadir@
107 #       cp *.class @javadir@
108
109 clean:
110         rm -rf sources *.c *.h *.o
111
112 realclean: clean
113         rm -f *~ libfirmjni.so *.vcg *.java *.class
114
115
116 $(SOURCE_DIR):
117         rm -rf $(SOURCE_DIR)
118         mkdir $(SOURCE_DIR)
119
120 $(SOURCE_DIR)/firm_typedefs.h: $(FIRM_SOURCE_HEADERS)
121         mv firm_typedefs.h $@
122
123 ###############################################################################
124 # Get all the necessary Firm headers.
125 ###############################################################################
126 # Remove C preprocessor commands.  Overwrite the header files.
127 # This part should be removed if crecoder integrates the preprocessor.
128
129 FIRM_SRC_HEADER=$(top_srcdir)/ir/$(filter %/$(notdir $@),$(FIRM_PATH_HEADERS))
130
131 $(FIRM_SOURCE_DIR_HEADERS): $(SOURCE_DIR)
132         cp $(FIRM_SRC_HEADER) $(SOURCE_DIR)/$(notdir $@)
133         perl $(REMOVE_CPP_COMMANDS) $@
134
135 # generiert leere dateien ;-(
136 #       troff -a -C -z  $(FIRM_SRC_HEADER) > $(SOURCE_DIR)/$(notdir $@)
137
138 $(FIRM_HEADERS):$(FIRM_SOURCE_DIR_HEADERS) $(SOURCE_DIR)/firm_typedefs.h
139         gcc $(CPPFLAGS) -E -C -P $(SOURCE_DIR)/$@ -o $@
140
141 ###############################################################################
142 # Call crecoder to construct from each header a .java file specifying the
143 # java native interface.  Further crecoder constructs an implementation of
144 # the java native interface in C calling the real libfirm functions.
145 # For a file "file.h" files "File.java" and "File.c" are generated.
146
147
148 H_FROM_JAVA=$(subst .java,.h,$(shell echo $@|$(SHELL_TOLOWER)))
149
150 %.java: $(FIRM_HEADERS)
151         env CLASSPATH=$(FIRM_JNI_TOOLS_DIR)/crecoder.jar:$$CLASSPATH java crecoder/tools/jniBuilder/BuildJNI $(H_FROM_JAVA);\