File: Makefile

package info (click to toggle)
libaria 2.8.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,628 kB
  • ctags: 16,574
  • sloc: cpp: 135,490; makefile: 925; python: 597; java: 570; ansic: 182
file content (775 lines) | stat: -rw-r--r-- 23,225 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
####
#### Aria top level makefile
####
####
#### Internal variables:
####
#### CFILEEXT -- This is to denote the file extension that is used. This is
####             used by the build rules to figure out which files to build.
####               ie: cpp
####               ie: cxx
####               ie: cc

# Make sure we're using a compiler (we probably don't need to define
# it but we have been so here it is unless it was already set)
ifndef CXX
CXX:=g++
endif

####
#### General variables
####

CFILEEXT:=cpp
# this is set up with the extra layer since the python wrapper needs exceptions
# but I didn't want to have two sets of defines
BARECXXFLAGS:=-g -Wall -D_REENTRANT  #-pg -fprofile-arcs
CXXFLAGS+=$(CPPFLAGS) $(BARECXXFLAGS) -fno-exceptions 
CXXINC:=-Iinclude
CXXLINK=$(LDFLAGS) -Llib -lAria
CXXSTATICLINK:=$(LDFLAGS) -Llib -Xlinker -Bstatic -lAria -Xlinker -Bdynamic 

host:=$(shell uname | cut -d _ -f 1)
ifeq ($(host),MINGW32)
  $(info Building on MinGW)
	#CXXFLAGS+=-mwindows -mms-bitfields -D__MINGW__ -DMINGW
	CXXFLAGS+=-mms-bitfields -D__MINGW__ -DMINGW
	CXXLINK+=-lpthreadGC2 -lwinmm -lws2_32 -lstdc++
	CXXSTATICLINK+=-Wl,-Bstatic -lpthread -Wl,-Bdynamic -lwinmm -lws2_32 -lstdc++
	binsuffix:=.exe
else
	BARECXXFLAGS+=-fPIC
	CXXLINK+=-lpthread -ldl -lrt
	CXXSTATICLINK+=-Xlinker -Bdynamic -lpthread -ldl -lrt -Xlinker -Bstatic -lstdc++ -Xlinker -Bdynamic
	binsuffix:=
endif


ifndef JAVAC
ifdef JAVA_BIN
JAVAC:=$(JAVA_BIN)/javac
else
JAVAC:=javac
endif #ifdef JAVA_BIN
endif #ifndef JAVAC

ifndef JAR
ifdef JAVA_BIN
JAR:=$(JAVA_BIN)/jar
else
JAR:=jar
endif #ifdef JAVA_BIN
endif #ifndef JAR

####
#### Aria build variables
####

# Default targets to build in the default rule:
TARGETS:=lib/libAria.so examples/demo$(binsuffix)

# Default static libraries and examples:
STATIC_TARGETS:=lib/libAria.a examples/demoStatic$(binsuffix)

# Lots of targets, to build in the everything rule:
ALL_TARGETS:=lib/libAria.so utils examples tests docs params lib/libArNetworking.so swig arnetworking_docs arnetworking_swig clib/libArNetworking.a $(STATIC_TARGETS)

CFILES:= \
	ArAction.cpp \
	ArActionAvoidFront.cpp \
	ArActionAvoidSide.cpp \
	ArActionBumpers.cpp \
	ArActionColorFollow.cpp \
	ArActionConstantVelocity.cpp \
	ArActionDeceleratingLimiter.cpp \
	ArActionDesired.cpp \
	ArActionDriveDistance.cpp \
	ArActionGoto.cpp \
	ArActionGotoStraight.cpp \
	ArActionGroup.cpp \
	ArActionGroups.cpp \
	ArActionInput.cpp \
	ArActionIRs.cpp \
	ArActionJoydrive.cpp \
	ArActionKeydrive.cpp \
	ArActionLimiterBackwards.cpp \
	ArActionLimiterForwards.cpp \
	ArActionLimiterRot.cpp \
	ArActionLimiterTableSensor.cpp \
	ArActionMovementParameters.cpp \
	ArActionMovementParametersDebugging.cpp \
	ArActionRatioInput.cpp \
	ArActionRobotJoydrive.cpp \
	ArActionStallRecover.cpp \
	ArActionStop.cpp \
	ArActionTriangleDriveTo.cpp \
	ArActionTurn.cpp \
	ArACTS.cpp \
	ArAMPTU.cpp \
	ArAnalogGyro.cpp \
	ArArg.cpp \
	ArArgumentBuilder.cpp \
	ArArgumentParser.cpp \
	ArASyncTask.cpp \
	ArBasePacket.cpp \
	ArBatteryConnector.cpp \
	ArBatteryMTX.cpp \
	ArBumpers.cpp \
	ArCameraCommands.cpp \
	ArCameraCollection.cpp \
	ArCondition_LIN.cpp \
	ArConfig.cpp \
	ArConfigArg.cpp \
	ArConfigGroup.cpp \
	ArDataLogger.cpp \
	ArDeviceConnection.cpp \
	ArDPPTU.cpp \
	ArFileParser.cpp \
	ArForbiddenRangeDevice.cpp \
	ArFunctorASyncTask.cpp \
	ArGPS.cpp \
	ArGPSConnector.cpp \
	ArGPSCoords.cpp \
	ArGripper.cpp \
	ArInterpolation.cpp \
	ArIrrfDevice.cpp \
	ArIRs.cpp \
	ArJoyHandler.cpp \
	ArKeyHandler.cpp \
	ArLaser.cpp \
	ArLaserConnector.cpp \
	ArLaserFilter.cpp \
	ArLaserLogger.cpp \
	ArLaserReflectorDevice.cpp \
	ArLCDConnector.cpp \
	ArLCDMTX.cpp \
	ArLineFinder.cpp \
	ArLMS1XX.cpp \
	ArLMS2xx.cpp \
	ArLMS2xxPacket.cpp \
	ArLMS2xxPacketReceiver.cpp \
	ArLog.cpp \
	ArLogFileConnection.cpp \
	ArMap.cpp \
	ArMapComponents.cpp \
	ArMapInterface.cpp \
	ArMapObject.cpp \
	ArMapUtils.cpp \
	ArMD5Calculator.cpp \
	ArMode.cpp \
	ArModes.cpp \
	ArModule.cpp \
	ArModuleLoader.cpp \
	ArMutex.cpp \
	ArMutex_LIN.cpp \
	ArNetServer.cpp \
	ArNMEAParser.cpp \
	ArNovatelGPS.cpp \
	ArP2Arm.cpp \
	ArPriorityResolver.cpp \
	ArPTZ.cpp \
  ArPTZConnector.cpp \
	ArRangeBuffer.cpp \
	ArRangeDevice.cpp \
	ArRangeDeviceThreaded.cpp \
	ArRatioInputKeydrive.cpp \
	ArRatioInputJoydrive.cpp \
	ArRatioInputRobotJoydrive.cpp \
	ArRecurrentTask.cpp \
	ArRobot.cpp \
	ArRobotBatteryPacketReader.cpp \
	ArRobotConfig.cpp \
	ArRobotConfigPacketReader.cpp \
	ArRobotConnector.cpp \
	ArRobotJoyHandler.cpp \
	ArRobotPacket.cpp \
	ArRobotPacketReceiver.cpp \
	ArRobotPacketReaderThread.cpp \
	ArRobotPacketSender.cpp \
	ArRobotParams.cpp \
	ArRobotTypes.cpp \
	ArRVisionPTZ.cpp \
	ArS3Series.cpp \
	ArSZSeries.cpp \
	ArSick.cpp \
	ArSimpleConnector.cpp \
	ArSimulatedLaser.cpp \
	ArSocket.cpp \
	ArSonarConnector.cpp \
	ArSonarDevice.cpp \
	ArSonarMTX.cpp \
	ArSensorReading.cpp \
	ArSonyPTZ.cpp \
	ArSoundsQueue.cpp \
	ArSoundPlayer.cpp \
	ArStringInfoGroup.cpp \
	ArSyncLoop.cpp \
	ArSyncTask.cpp \
	ArSystemStatus.cpp \
	ArSonarAutoDisabler.cpp \
	ArSpeech.cpp \
	ArTCM2.cpp \
	ArTCMCompassDirect.cpp \
	ArTCMCompassRobot.cpp \
	ArTcpConnection.cpp \
	ArThread.cpp \
	ArThread_LIN.cpp \
	ArTransform.cpp \
	ArTrimbleGPS.cpp \
	ArUrg.cpp \
	ArUrg_2_0.cpp \
	ArVCC4.cpp \
	Aria.cpp \
	ariaUtil.cpp \
	md5.cpp

# Omit some Linux-only classes, and replace others with Win32 implementations.
ifeq ($(host),MINGW32)
	CFILES+=ArSocket_WIN.cpp \
		ArJoyHandler_WIN.cpp \
		ArSerialConnection_WIN.cpp \
		ArSignalHandler_WIN.cpp
else
	CFILES+=ArSocket_LIN.cpp \
		ArJoyHandler_LIN.cpp \
		ArSerialConnection_LIN.cpp \
		ArSignalHandler_LIN.cpp \
		ArVersalogicIO.cpp \
    ArMTXIO.cpp
endif




####
#### Utility variables. No need to touch these.
####

OTFILES:=$(patsubst %.$(CFILEEXT),%.o,$(CFILES))
OFILES:=$(patsubst %,obj/%,$(OTFILES))
EXAMPLES_CPP:=$(shell find examples -name "*.$(CFILEEXT)" | grep -v Mod.cpp | grep -v proprietary)
EXAMPLES:=$(patsubst %.$(CFILEEXT),%$(binsuffix),$(EXAMPLES_CPP))
EXAMPLES_STATIC:=$(patsubst %,%Static$(binsuffix),$(EXAMPLES))
MOD_EXAMPLES_CPP:=$(shell find examples -name "*.$(CFILEEXT)" | grep Mod.cpp)
MOD_EXAMPLES:=$(patsubst %.$(CFILEEXT),%.so,$(MOD_EXAMPLES_CPP))
TESTS_CPP:=$(shell find tests -name "*.$(CFILEEXT)" | grep -v Mod.cpp | grep -v proprietary)
MOD_TESTS_CPP:=$(shell find tests -name "*Mod.$(CFILEEXT)")
MOD_TESTS:=$(patsubst %.$(CFILEEXT),%.so,$(MOD_TESTS_CPP))
TESTS:=$(patsubst %.$(CFILEEXT),%$(binsuffix),$(TESTS_CPP))
TESTS_STATIC:=$(patsubst %,%Static$(binsuffix),$(TESTS))
ADVANCED_CPP:=$(shell find advanced -name "*.$(CFILEEXT)" | grep -v Mod.cpp | grep -v proprietary)
ADVANCED:=$(patsubst %.$(CFILEEXT),%,$(ADVANCED_CPP))
UTILS_CPP:=$(shell find utils -name "*.$(CFILEEXT)")
UTILS:=$(patsubst %.$(CFILEEXT),%$(binsuffix),$(UTILS_CPP))
SRC_FILES:=$(patsubst %,src/%,$(CFILES))
HEADER_FILES:=$(shell find include -type f -name \*.h)
# Tests to run for the testsuite
TESTS_TO_RUN:=\
	tests/actionArgumentTest \
	tests/angleBetweenTest \
	tests/angleFixTest \
	tests/angleTest \
	tests/lineTest \
	tests/mathTests \
	tests/robotListTest




####
#### General rules for user invocation
####

# Default Rule
all: dirs $(TARGETS) params python python-doc

# Build all targets, docs, params, etc. etc.
everything: dirs $(ALL_TARGETS) 

static: dirs $(STATIC_TARGETS)

# Build everything required for distribution packages
dist-all: lib/libAria.so params docs CommandLineOptions.txt.in \
  lib/libArNetworking.so ArNetworking/CommandLineOptions.txt.in examples/demo \
  examples/demoStatic ArNetworking/examples/serverDemo \
  ArNetworking/examples/serverDemoStatic ArNetworking/examples/clientDemo \
  ArNetworking/examples/clientDemoStatic java python  arnetworking_swig \
  arnetworking_docs

examples: $(EXAMPLES) 

modExamples: $(MOD_EXAMPLES)

tests: $(TESTS) $(MOD_TESTS)

test: $(TESTS_TO_RUN)
	for test in $(TESTS_TO_RUN); do \
	  LD_LIBRARY_PATH=lib $$test; \
	done

advanced: $(ADVANCED)

utils: $(UTILS)

cleanDep:
	-rm Makefile.dep `find . -name Makefile.dep`

# directories that might not exist:
dirs:
	@mkdir -p -v obj
	@mkdir -p -v lib

docs: doc
doc: docs/index.html
docs/index.html: $(SRC_FILES) $(HEADER_FILES) $(EXAMPLES_CPP) docs/overview.dox docs/options/all_options.dox docs/params.dox
	doxygen doxygen.conf
	
arnetworking_swig:
	$(MAKE) -C ArNetworking java python

arnetworking_docs:
	$(MAKE) -C ArNetworking docs

help:
	@echo To make most things, run \'make\' or \'make all\'
	@echo Some useful targets include: 
	@echo "  allLibs, cleanAllLibs, depAllLibs (do all subdirectories)"
	@echo "  clean"
	@echo "  dep"
	@echo "  cleanDep"
	@echo "  docs"
	@echo "  cleanAll (also cleans ArNetworking, java, python, etc.)"
	@echo "  examples"
	@echo "  tests"
	@echo "  utils"
	@echo "  python" 
	@echo "  cleanPython"
	@echo "  java" 
	@echo "  cleanJava"
	@echo "  examples/<Some Example>, where examples/<Some Example>.cpp is an example program source file."
	@echo "  tests/<Some Test>, where tests/<Some Test>.cpp is a test program source file."
	@echo "  allLibs (try to build all auxilliary libraries that you have installed by running make in each directory starting with \"Ar\")"
	@echo "  cleanAllLibs, depAllLibs (do make clean or make dep in the \"Ar*\" auxilliary libraries)"
	@echo "  install (if this is a source tar.gz package)"

info:
	@echo ARIA=$(ARIA)
	@echo CXX=$(CXX)
	@echo CXXFLAGS=$(CXXFLAGS)
	@echo CXXINC=$(CXXINC)
	@echo CXXLINK=$(CXXLINK)
	@echo CXXSTATICLINK=$(CXXSTATICLINK)
	@echo ALL_TARGETS=$(ALL_TARGETS)
	@echo
	@echo JAVAC=$(JAVAC)
	@echo JAR=$(JAR)
	@echo
	@echo Use \'make moreinfo\' for info about individual files, etc.

moreinfo:
	@echo CFILES=$(CFILES)
	@echo
	@echo EXAMPLES=$(EXAMPLES)
	@echo
	@echo MOD_EXAMPLES=$(MOD_EXAMPLES)
	@echo
	@echo TESTS=$(TESTS)
	@echo
	@echo MOD_TESTS=$(MOD_TESTS)
	@echo
	@echo ADVANCED=$(ADVANCED)
	@echo
	@echo UTILS=$(UTILS)
	@echo
	@echo SRC_FILES=$(SRC_FILES)
	@echo
	@echo HEADER_FILES=$(HEADER_FILES)



clean: cleanUtils cleanExamples cleanModules cleanTests cleanAdvanced 
	-rm -f lib/libAria.a lib/libAria.so $(OFILES) `find . -name core` `find . -name '*~'` obj/AriaPy.o obj/AriaJava.o

cleanUtils:
	-rm -f $(UTILS)

cleanExamples:
	-rm -f $(EXAMPLES) $(EXAMPLES_STATIC)

cleanTests:
	-rm -f $(TESTS) $(TESTS_STATIC)

cleanAdvanced:
	-rm -f $(ADVANCED)

cleanModules:
	-rm -f $(MOD_EXAMPLES)

cleanDoc:
	find docs/ -path docs/figures -prune -o -type d \! -name docs -exec rm -rf \{\} +
	find docs/ -path docs/figures -prune -o \! \( -name "*.dox" -o -name docs \) -execdir rm \{\} +

cleanParams:
	-rm -rf params

cleandoc: cleanDoc

cleanPython:
	-rm python/_AriaPy.so
	-rm python/AriaPy.py
	-rm python/AriaPy.pyc
	-rm python/AriaPy_wrap.cpp
	-rm python/AriaPy_wrap.h
	-rm obj/AriaPy_wrap.o

cleanpython: cleanPython

dep: clean 
	if [ -f `echo src/*.cpp | cut -d' ' -f1` ]; then \
	$(CXX) $(CXXFLAGS) $(CXXINC) -MM src/*.cpp | \
	awk '$$1 ~ /:/{printf "obj/%s\n", $$0} $$1 !~ /:/' > Makefile.dep; fi
	if [ -f `echo examples/*.cpp | cut -d' ' -f1` ]; then \
	$(CXX) $(CXXFLAGS) $(CXXINC) -MM examples/*.cpp | \
	awk '$$1 ~ /:/{printf "examples/%s$(binsuffix)\n", $$0} $$1 !~ /:/' | \
	sed 's/\.o//' >> Makefile.dep; fi
	if [ -f `echo utils/*.cpp | cut -d' ' -f1` ]; then \
	$(CXX) $(CXXFLAGS) $(CXXINC) -MM utils/*.cpp | \
	awk '$$1 ~ /:/{printf "utils/%s$(binsuffix)\n", $$0} $$1 !~ /:/' | \
	sed 's/\.o//' >> Makefile.dep; fi
	if [ -f `echo tests/*.cpp | cut -d' ' -f1` ]; then \
	$(CXX) $(CXXFLAGS) $(CXXINC) -MM tests/*.cpp | \
	awk '$$1 ~ /:/{printf "tests/%s$(binsuffix)\n", $$0} $$1 !~ /:/' | \
	sed 's/\.o//' >> Makefile.dep; fi
	if [ -f `echo advanced/*.cpp | cut -d' ' -f1` ]; then \
	$(CXX) $(CXXFLAGS) $(CXXINC) -MM advanced/*.cpp | \
	awk '$$1 ~ /:/{printf "advanced/%s$(binsuffix)\n", $$0} $$1 !~ /:/' | \
	sed 's/\.o//' >> Makefile.dep; fi

Makefile.dep:
	$(MAKE) dep

depAll: cleanDep
	make dep;
	for dir in `find . -maxdepth 1 -name "Ar*" -xtype d`; do cd $$dir; make dep; cd ..; done

cleanAll: clean 
	rm -f lib/lib*.so*
	for dir in `find . -maxdepth 1 -name "Ar*" -xtype d`; do cd $$dir; make clean; cd ..; done

fullCleanAll: cleanAll cleanJava cleanPython 
	rm -f lib/lib*.so*
	rm -f obj/*.o*
	for dir in `find . -maxdepth 1 -name "Ar*" -xtype d`; do cd $$dir; make fullClean; cd ..; done




params: utils/makeParams$(binsuffix)
	-mkdir params
	LD_LIBRARY_PATH=lib utils/makeParams$(binsuffix)

CommandLineOptions.txt.in docs/options/all_options.dox: utils/genCommandLineOptionDocs$(binsuffix) src/ArSimpleConnector.cpp src/ArGPSConnector.cpp src/ArTCM2.cpp
	-mkdir docs/options
	LD_LIBRARY_PATH=lib utils/genCommandLineOptionDocs$(binsuffix)

alllibs: allLibs

allLibs: all 
	find . -type d -and -name Ar\* -maxdepth 1 -exec $(MAKE) -C \{\}  \;

cleanAllLibs: clean cleanJava cleanPython cleanDep
	for dir in `find . -maxdepth 1 -name "Ar*" -xtype d`; do $(MAKE) -C $$dir clean cleanAll; done

cleanalllibs: cleanAllLibs

checkAll:
	$(MAKE) everything > checkAll.log 2>&1
	$(MAKE) allLibs >> checkAll.log 2>&1
	grep -n -v 'Error 1 (ignored)' checkAll.log | grep -C 4 'Error' > checkAll-Errors.log
	@echo
	@echo Errors were:
	@echo
	@cat checkAll-Errors.log
	@echo
	@echo Error log also saved as checkAll-Errors.log.  Full log saved as checkAll.log.

####
#### Swig wrappers
####

ifndef SWIG
SWIG=swig
endif

### Python wrapper: ###


ifdef PYTHON_INCLUDE
PYTHON_INCLUDE_FLAGS=-I$(PYTHON_INCLUDE)
else
ifdef DIST_INSTALL
$(warning WARNING using default value of /usr/include/python2.5 for PYTHON_INCLUDE directory. Set PYTHON_INCLUDE environment variable if you would like to use a different version of the Python C development library to build the Python ARIA wrapper.)
endif
PYTHON_INCLUDE:=/usr/include/python2.5
PYTHON_INCLUDE_FLAGS=-I/usr/include/python2.5
endif

python: python/_AriaPy.so python/AriaPy.py

py: python

python-doc: python/AriaPy.html

python/AriaPy.html: python/_AriaPy.so python/AriaPy.py
	cd python; LD_LIBRARY_PATH=../lib pydoc -w AriaPy

python/AriaPy_wrap.cpp python/AriaPy.py: include/wrapper.i include/*.h
	-rm -f `find python -maxdepth 1 -xtype f -name "*Aria*" | grep -v .ds | grep -v .sln | grep -v .vcproj`
	cd python; $(SWIG) -Wall -c++ -python -modern -module AriaPy -Dlinux -DAREXPORT -o AriaPy_wrap.cpp -I../include ../include/wrapper.i 

python/_AriaPy.so: obj/AriaPy_wrap.o lib/libAria.so Makefile.dep
	$(CXX) -shared -o $(@) obj/AriaPy_wrap.o $(LDFLAGS) $(CXXLINK)

obj/AriaPy_wrap.o: python/AriaPy_wrap.cpp
	mkdir -p obj
	$(CXX) -c $(CPPFLAGS) -O2 $(BARECXXFLAGS) $(CXXINC) $(shell python-config --includes) $< -o $@


### Java Wrapper: ###



java:  lib/libAriaJava.so java/Aria.jar

java/Aria.jar: java/com/mobilerobots/Aria/ArRobot.class
	cd java; $(JAR) cf Aria.jar com/mobilerobots/Aria/*.class

cleanJava:
	-rm -f `find java -xtype f -maxdepth 1 | grep -v .ds | grep -v .sln | grep -v .vcproj` 
	-rm lib/libAriaJava.so
	-rm java/AriaJava_wrap.cpp
	-rm java/AriaJava_wrap.h
	-rm obj/AriaJava_wrap.o

cleanjava: cleanJava

cleanSwigJava:
	-rm -r java/Aria.jar java/com/mobilerobots/Aria

lib/libAriaJava.so: obj/AriaJava_wrap.o lib/libAria.so Makefile.dep
	$(CXX) -shared -o $(@) obj/AriaJava_wrap.o $(CXXLINK) 

obj/AriaJava_wrap.o: java/AriaJava_wrap.cpp
	@ if test -z "$(JAVA_INCLUDE)"; then echo "Error: JAVA_INCLUDE is not set, compiling AriaJava_wrap.cpp will fail!"; fi
	@ test -n "$(JAVA_INCLUDE)"
	@ if test \! -d "$(JAVA_INCLUDE)"; then echo "Error: JAVA_INCLUDE directory $(JAVA_INCLUDE) does not exist, compiling AriaJava_wrap.cpp will fail!"; fi
	@ test -d "$(JAVA_INCLUDE)" 
	mkdir -p obj
	$(CXX) -c $(BARECXXFLAGS) $(CXXINC) -I$(JAVA_INCLUDE) -I$(JAVA_INCLUDE)/linux $< -o $@

java/AriaJava_wrap.cpp java/com/mobilerobots/Aria/ArRobot.java: include/wrapper.i $(HEADER_FILES)
	-mkdir -p java/com/mobilerobots/Aria; rm java/com/mobilerobots/Aria/*.java java/AriaJava_wrap.cpp java/AriaJava_wrap.h;  $(SWIG) -Wall -c++ -java -package com.mobilerobots.Aria -outdir java/com/mobilerobots/Aria -module AriaJava -Dlinux -DAREXPORT -o java/AriaJava_wrap.cpp -Iinclude include/wrapper.i 
    
# The sed script is a hack to let subclasses outside of Aria work for ArFunctor;
# for some reason SWIG doesn't use my %typmeap(javabody) for ArFunctor. 
#    \
#	  && sed 's/protected static long getCPtr/public ArFunctor() { this(0, false); }     public static long getCPtr/' java/com/mobilerobots/Aria/ArFunctor.java > ArFunctor.java.tmp  \
#		&& mv ArFunctor.java.tmp java/com/mobilerobots/Aria/ArFunctor.java

# It is much faster to compile them all at once. Use ArRobot.java/class as a
# stand-in for all java files and all class files.
java/com/mobilerobots/Aria/ArRobot.class: java/com/mobilerobots/Aria/ArRobot.java
		rm java/com/mobilerobots/Aria/*.class; $(JAVAC) -classpath java java/com/mobilerobots/Aria/*.java 


java/ArNetworking.jar: FORCE
	$(MAKE) -C ArNetworking ../$@

lib/libArNetworkingJava.so: FORCE
	$(MAKE) -C ArNetworking ../$@

python/ArNetworkingPy.py: FORCE
	$(MAKE) -C ArNetworking ../$@

python/_ArNetworkingPy.so: FORCE
	$(MAKE) -C ArNetworking ../$@


####
#### Targets to actually build binaries (libraries, programs)
####

lib/libAria.so: $(OFILES) Makefile.dep 
	$(CXX) -shared -Wl,-soname,libAria.so.2 $(LDFLAGS) -o $(@).2.8.0 $(OFILES)
	ln -s libAria.so.2.8.0 lib/libAria.so.2
	ln -s libAria.so.2 lib/libAria.so

lib/libAria.a: $(OFILES) Makefile.dep 
	ar -cr $(@) $(OFILES)
	ranlib $(@)

examples/%.so: examples/%.$(CFILEEXT) lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) -shared $< -o $@

examples/%$(binsuffix): examples/%.$(CFILEEXT) lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXLINK)

examples/%Static$(binsuffix): examples/%.$(CFILEEXT) lib/libAria.a Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXSTATICLINK)
	if test -n "$$NOSTRIP"; then strip $@; fi

tests/%.so: tests/%.$(CFILEEXT) lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) -shared $< -o $@

tests/%$(binsuffix): tests/%.$(CFILEEXT) lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXLINK)

tests/%Static$(binsuffix): tests/%.$(CFILEEXT) lib/libAria.a Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXSTATICLINK)
	if test -n "$$NOSTRIP"; then strip $@; fi

advanced/%.so: advanced/%.$(CFILEEXT) lib/libAria.so
	$(CXX) $(CXXFLAGS) $(CXXINC) -shared $< -o $@

advanced/%$(binsuffix): advanced/%.$(CFILEEXT) lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXLINK)

advanced/%Static$(binsuffix): advanced/%.$(CFILEEXT) lib/libAria.a Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXSTATICLINK)
	#strip $@

utils/%$(binsuffix): utils/%.$(CFILEEXT) lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXLINK)

utils/%Static$(binsuffix): utils/%.$(CFILEEXT) lib/libAria.a Makefile.dep
	$(CXX) $(CXXFLAGS) $(CXXINC) $< -o $@ $(CXXSTATICLINK)
	#strip $@

utils/genCommandLineOptionDocs$(binsuffix): utils/genCommandLineOptionDocs.cpp lib/libAria.so Makefile.dep
	$(CXX) $(CXXFLAGS) -DFOR_ARIA $(CXXINC) $< -o $@ $(CXXLINK)

ifneq ($(binsuffix),)
examples/%: examples/%$(binsuffix)
utils/%: utils/%$(binsuffix)
advanced/%: advanced/%$(binsuffix)
tests/%: tests/$(binsuffix)
endif

obj/%.o : src/%.cpp Makefile.dep
	@mkdir -p obj
	$(CXX) -c $(CXXFLAGS) $(CXXINC) $< -o $@

obj/%.o : src/%.c Makefile.dep
	@mjdir -p obj
	$(CXX) -c $(CXXFLAGS) $(CXXINC) $< -o $@

include/%.i: include/%.h Makefile.dep
	$(CXX) -E $(CXXFLAGS) $(CXXINC) $< -o $@
	
src/%.i: src/%.cpp Makefile.dep
	$(CXX) -E $(CXXFLAGS) $(CXXINC) $< -o $@
	
# Don't build .o files if their library is up to date with respect to source files:
.INTERMEDIATE: $(OFILES)

# But don't delete .o files if we do make them in order to make a library:
.PRECIOUS: $(OFILES)


# To build things in the ArNetworking subdirectory:

lib/libArNetworking.so: FORCE
	$(MAKE) -C ArNetworking ../$@

lib/libArNetworking.a: FORCE 
	$(MAKE) -C ArNetworking ../$@

ArNetworking/examples/%: ArNetworking/examples/%.cpp lib/libArNetworking.so
	$(MAKE) -C ArNetworking examples/$*

ArNetworking/examples/%Static: ArNetworking/examples/%.cpp lib/libArNetworking.a
	$(MAKE) -C ArNetworking examples/$*Static

#ArNetworking/docs/index.html: FORCE
#	$(MAKE) -C ArNetworking docs/index.html

ArNetworking/%: FORCE
	$(MAKE) -C ArNetworking $*

# This rule doesn't actually produce its target, so anything depending on it
# will always get remade.
FORCE:


####
#### Installation and distribution 
####


ifndef INSTALL_DIR
INSTALL_DIR=/usr/local/Aria
endif

ifndef SYSTEM_ETC_DIR
SYSTEM_ETC_DIR=/etc
endif

# What to put in /etc/Aria:
ifndef STORED_INSTALL_DIR
STORED_INSTALL_DIR=$(INSTALL_DIR)/share/Aria
endif

# How to run 'install' for the install rule:
ifndef INSTALL
INSTALL:=install --preserve-timestamps
endif


dist: FORCE
	dist/dist.sh

dist-install: install

# Install rule.  This can be used by users or ARIA developers; in the latter
# case it also installs various files needed to make a release distribution.
# Override installation locations with INSTALL_DIR environment variable.
# Things are installed group-writable so as to be hacked upon.
install:
	$(INSTALL) -m 755 -d $(DESTDIR)$(INSTALL_DIR)
	$(INSTALL) -d -m 755 $(DESTDIR)$(INSTALL_DIR)/include/Aria
	$(INSTALL) -D -m 644 include/*.h $(DESTDIR)$(INSTALL_DIR)/include/Aria
	$(INSTALL) -d -m 755 $(DESTDIR)$(INSTALL_DIR)/share/Aria/params
	$(INSTALL) -D -m 644 params/* $(DESTDIR)$(INSTALL_DIR)/share/Aria/params
	$(INSTALL) -d -m 755 $(DESTDIR)$(INSTALL_DIR)/lib/$(DEB_HOST_MULTIARCH)
	$(INSTALL) -D -m 644 lib/libAria.so.2.8.0 $(DESTDIR)$(INSTALL_DIR)/lib/$(DEB_HOST_MULTIARCH)
	cp --no-dereference lib/libAria.so.2 $(DESTDIR)$(INSTALL_DIR)/lib/$(DEB_HOST_MULTIARCH)
	cp --no-dereference lib/libAria.so $(DESTDIR)$(INSTALL_DIR)/lib/$(DEB_HOST_MULTIARCH)
	@if test -z "$(DIST_INSTALL)"; then \
		if test \! -d $(DESTDIR)$(SYSTEM_ETC_DIR); then install -d $(DESTDIR)$(SYSTEM_ETC_DIR); fi ;\
		echo $(STORED_INSTALL_DIR) > $(DESTDIR)$(SYSTEM_ETC_DIR)/Aria ;\
	fi
	$(INSTALL) -D -m 755 examples/demo $(DESTDIR)$(INSTALL_DIR)/bin/aria-demo
	$(INSTALL) -D -m 644 python/_AriaPy.so debian/
	$(INSTALL) -D -m 644 python/AriaPy.py debian/

#		echo ;\
#		echo       The files are owned by the group \"users\", and all members of that group ;\
#		echo       can enter the directory, read files, and modify the \"examples\" directory. ;\

###
### Make optimization, tell it what rules aren't files:
###
.PHONY: all everything examples modExamples tests advanced utils cleanDep docs doc dirs help info moreinfo clean cleanUtils cleanExamples cleanTests cleanAdvanced cleanModules cleanDoc cleanPython dep depAll cleanAll params allLibs python python-doc java cleanJava install alllibs arnetworking_swig arnetworking_docs params swig help info moreinfo py python-doc cleanSwigJava checkAll

### Autogenerated dependencies:
# Just see if there is a Makefile.dep, if so include one... there
# should be one because various rules above depend on Makefile.dep.
# Note, use this ifeq/wildcard hacok rather than "-include" directive to 
# prevent Make from trying to create Makefile.dep itself if missing during the
# recursive call to $(MAKE) dep.  (it just keeps
# calling make dep recursively).
ifeq (Makefile.dep,$(wildcard Makefile.dep))
include Makefile.dep
# End of the Makefile.dep check
endif