Fixed compiler for Java code generation (not heavily tested yet, but fixes include...
[iot2.git] / iotjava / Makefile
1 BASE := ..
2
3 include $(BASE)/common.mk
4
5 all: tree parser compiler rmi runtime installer
6
7 infra: runtime installer
8
9 # Parser compilation and run
10 PHONY += tree
11 tree:
12         $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotpolicy/tree/*.java
13
14 PHONY += parser
15 parser:
16         $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotpolicy/parser/*.java
17
18 PHONY += compiler
19 compiler:
20         $(JAVAC) -cp .:$(PARSERJARS) -d $(BIN_DIR) iotpolicy/*.java
21
22 PHONY += run-compiler-dev
23 run-compiler-dev:
24         cp ../localconfig/iotpolicy/development/*.pol $(BIN_DIR)/iotpolicy/
25         #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy.pol testclassrequires.pol callbackpolicy.pol callbackrequires.pol -cplus Cplus -java Java
26         #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler callbackpolicy.pol callbackrequires.pol testclasspolicy_advanced.pol testclassrequires_advanced.pol -cplus Cplus -java Java
27         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler callbackpolicy.pol callbackrequires.pol testclasspolicy_callbacks.pol testclassrequires_callbacks.pol -cplus Cplus -java Java
28
29 PHONY += run-compiler-lbtest
30 run-compiler-lbtest:
31         cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
32         cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
33         #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -java Java
34         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol lifxtest.req -cplus Cplus
35
36 # SmartLightsController
37 PHONY += run-compiler-lifx
38 run-compiler-lifx:
39         cp ../localconfig/iotpolicy/LifxLightBulb/*.pol $(BIN_DIR)/iotpolicy/
40         cp ../localconfig/iotpolicy/LifxLightBulb/*.req $(BIN_DIR)/iotpolicy/
41         #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req -java Java
42         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler lifxlightbulb.pol smartlightsbulb.req -cplus C++
43
44 PHONY += run-compiler-room
45 run-compiler-room:
46         cp ../localconfig/iotpolicy/Room/*.pol $(BIN_DIR)/iotpolicy/
47         cp ../localconfig/iotpolicy/Room/*.req $(BIN_DIR)/iotpolicy/
48         #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler room.pol roomsmart.req -java Java
49         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler room.pol roomsmart.req -cplus C++
50
51 PHONY += run-compiler-cam
52 run-compiler-cam:
53         cp ../localconfig/iotpolicy/AmcrestCamera/*.pol $(BIN_DIR)/iotpolicy/
54         cp ../localconfig/iotpolicy/AmcrestCamera/*.req $(BIN_DIR)/iotpolicy/
55         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler amcrestcamera.pol smartlightscam.req motiondetection.pol motiondetection.req -java Java
56
57 # IrrigationController
58 PHONY += run-compiler-lawn
59 run-compiler-lawn:
60         cp ../localconfig/iotpolicy/GreenLawn/*.pol $(BIN_DIR)/iotpolicy/
61         cp ../localconfig/iotpolicy/GreenLawn/*.req $(BIN_DIR)/iotpolicy/
62         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler greenlawn.pol smartlawn.req -java Java
63
64 PHONY += run-compiler-sprk
65 run-compiler-sprk:
66         cp ../localconfig/iotpolicy/EspSprinkler/*.pol $(BIN_DIR)/iotpolicy/
67         cp ../localconfig/iotpolicy/EspSprinkler/*.req $(BIN_DIR)/iotpolicy/
68         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler espsprinkler.pol smartsprinkler.req -java Java
69
70 PHONY += run-compiler-wgw
71 run-compiler-wgw:
72         cp ../localconfig/iotpolicy/WeatherPhoneGateway/*.pol $(BIN_DIR)/iotpolicy/
73         cp ../localconfig/iotpolicy/WeatherPhoneGateway/*.req $(BIN_DIR)/iotpolicy/
74         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler weatherphonegateway.pol smartweathergateway.req weathergatewaycallback.pol smartweathergatewaycallback.req -java Java
75
76 PHONY += run-compiler-moist
77 run-compiler-moist:
78         cp ../localconfig/iotpolicy/SpruceSensor/*.pol $(BIN_DIR)/iotpolicy/
79         cp ../localconfig/iotpolicy/SpruceSensor/*.req $(BIN_DIR)/iotpolicy/
80         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler sprucesensor.pol smartsensor.req moisturesensorcallback.pol moisturesensorcallback.req -java Java
81
82 # SpeakerController
83 PHONY += run-compiler-spkr
84 run-compiler-spkr:
85         cp ../localconfig/iotpolicy/IHome/*.pol $(BIN_DIR)/iotpolicy/
86         cp ../localconfig/iotpolicy/IHome/*.req $(BIN_DIR)/iotpolicy/
87         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler ihome.pol smartspeaker.req speakercallback.pol smartspeakercallback.req -java Java
88
89 PHONY += run-compiler-ggw
90 run-compiler-ggw:
91         cp ../localconfig/iotpolicy/GPSPhoneGateway/*.pol $(BIN_DIR)/iotpolicy/
92         cp ../localconfig/iotpolicy/GPSPhoneGateway/*.req $(BIN_DIR)/iotpolicy/
93         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler gpsphonegateway.pol smartgpsgateway.req gpsgatewaycallback.pol smartgpsgatewaycallback.req -java Java
94
95 # HomeSecurityController
96 PHONY += run-compiler-alarm
97 run-compiler-alarm:
98         cp ../localconfig/iotpolicy/EspAlarm/*.pol $(BIN_DIR)/iotpolicy/
99         cp ../localconfig/iotpolicy/EspAlarm/*.req $(BIN_DIR)/iotpolicy/
100         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler espalarm.pol smartalarm.req -java Java
101
102 PHONY += run-compiler-smart
103 run-compiler-smart:
104         cp ../localconfig/iotpolicy/SmartthingsSensor/*.pol $(BIN_DIR)/iotpolicy/
105         cp ../localconfig/iotpolicy/SmartthingsSensor/*.req $(BIN_DIR)/iotpolicy/
106         cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler smartthingssensor.pol smartthingssensor.req smartthingssensorcallback.pol smartthingssensorcallback.req -java Java
107
108 # TODO: Can remove this later - just to test-compile the resulted files from the compiler
109 PHONY += compile
110 compile:
111         cp ./iotrmi/Java/basics/* $(BIN_DIR)/iotpolicy/output_files/Java
112         cp ./iotrmi/C++/basics/* $(BIN_DIR)/iotpolicy/output_files/Cplus
113         cd $(BIN_DIR)/iotpolicy/output_files; cp *.java ./Java
114         cd $(BIN_DIR)/iotpolicy/output_files; cp *.hpp ./Cplus
115         cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClass_Skeleton.java
116 #       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassAdvanced_Stub.java
117         cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassCallbacks_Stub.java
118         cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassInterface_Skeleton.java
119         cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassComplete_Stub.java
120         cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_Stub.java
121         cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_Skeleton.java
122 #       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_CallbackSkeleton.java
123 #       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_CallbackStub.java
124
125 #       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
126 #       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassComplete_Stub.cpp -o ./TestClassComplete_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
127 #       cp ./iotrmi/C++/ConcurrentLinkedListQueue.cpp $(BIN_DIR)/iotpolicy/output_files/Cplus
128 #       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./ConcurrentLinkedListQueue.cpp -o ./ConcurrentLinkedListQueue.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
129
130         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassAdvanced_Stub.cpp -o ./TestClassAdvanced_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
131         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClass.hpp -o ./TestClass.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
132         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
133         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
134         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassCallbacks_Stub.cpp -o ./TestClassCallbacks_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
135         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassComplete_Stub.hpp --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
136         #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(ARM_G++) ./TestClassInterface_Skeleton.hpp --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
137
138 PHONY += run-java-skeleton
139 run-java-skeleton:
140         cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClass_Skeleton
141
142 PHONY += run-java-stub
143 run-java-stub:
144 #       cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClass_Stub
145 #       cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClassAdvanced_Stub
146         cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClassCallbacks_Stub
147
148 PHONY += run-cplus-skeleton
149 run-cplus-skeleton:
150         ../bin/iotpolicy/output_files/Cplus/TestClass_Skeleton.out
151
152 PHONY += run-cplus-stub
153 run-cplus-stub:
154 #       ../bin/iotpolicy/output_files/Cplus/TestClass_Stub.out
155 #       ../bin/iotpolicy/output_files/Cplus/TestClassAdvanced_Stub.out
156         ../bin/iotpolicy/output_files/Cplus/TestClassCallbacks_Stub.out
157
158 PHONY += folderclean
159 folderclean:
160         rm -rf $(BIN_DIR)/iotpolicy/output_files
161
162 PHONY += clean
163 clean:
164         cd $(BIN_DIR)/iotpolicy/output_files; rm -rf *.class *.gch
165         cd $(BIN_DIR)/iotpolicy/output_files/Java; rm -rf *.class
166         cd $(BIN_DIR)/iotpolicy/output_files/Cplus; rm -rf *.gch
167         cd $(BIN_DIR)/iotpolicy/output_files/Cplus; rm -rf *.out
168
169 # RMI compilation and run
170 PHONY += rmi
171 rmi:
172         mkdir -p $(BIN_DIR)
173         $(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/*.java
174         #$(JAVAC) -cp .:../$(BIN_DIR) -d $(BIN_DIR) iotrmi/Java/sample/*.java
175         #mkdir -p $(BIN_DIR)/iotrmi/C++/sample
176         #$(G++) iotrmi/C++/sample/TestClass_Stub.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Stub.out --std=c++11 -pthread -pg
177         #$(G++) iotrmi/C++/sample/TestClass_Skeleton.cpp -o $(BIN_DIR)/iotrmi/C++/sample/TestClass_Skeleton.out --std=c++11 -pthread -pg
178
179 PHONY += run-rmiserver
180 run-rmiserver:
181         $(JAVA) -cp .:$(BIN_DIR) iotrmi.Java.sample.TestClass_Skeleton
182
183 PHONY += run-rmiclient
184 run-rmiclient:
185         $(JAVA) -cp .:$(BIN_DIR) iotrmi.Java.sample.TestClass_Stub
186
187 PHONY += installer
188 installer:
189         $(JAVAC)  -d $(BIN_DIR) iotinstaller/*.java
190         cp ../localconfig/iotruntime/MySQLInterface.config $(BIN_DIR)/iotruntime/
191         cp ../localconfig/iotruntime/MySQLInterface.config $(BIN_DIR)/iotinstaller/
192
193 PHONY += runtime
194 runtime:
195         $(JAVAC) -classpath .:$(RUNTIMEJARS):$(PHONEJARS):$(ZIPJARS) iotruntime/*.java iotruntime/master/*.java iotruntime/slave/*.java iotruntime/messages/*.java iotruntime/stub/*.java iotruntime/zigbee/*.java -d $(BIN_DIR)
196         cp ../localconfig/iotruntime/IoTMaster.config $(BIN_DIR)/iotruntime/
197         cp ../localconfig/iotruntime/IoTSlave.config $(BIN_DIR)/iotruntime/
198         cp ../others/sslkey/*.jks $(BIN_DIR)/iotruntime/
199         cp -r ../localconfig/mysql $(BIN_DIR)/iotruntime/
200
201 PHONY += doc
202 doc: runtime installer rmi compiler
203         $(JAVADOC) -d $(DOCS_DIR) iotinstaller/*.java iotruntime/*.java iotrmi/*.java iotcompiler/*.java
204
205 .PHONY: $(PHONY)