aboutsummaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 41851129cdf2ce280938ac25896dacbeb1e5858e (plain)
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
include bootstrap.mk

AUTOGENERATED_MAKEFILES=@OUTPUT_FILES@

EC_DIRS= \
	tools/EventClients

XBMCTEX_DIRS= \
	tools/TexturePacker

DVDPCODECS_DIRS= \
	lib \
	lib/libdvd

DVDPLAYER_ARCHIVES=xbmc/cores/dvdplayer/DVDPlayer.a \
                   xbmc/cores/dvdplayer/DVDCodecs/DVDCodecs.a \
                   xbmc/cores/dvdplayer/DVDCodecs/Audio/Audio.a \
                   xbmc/cores/dvdplayer/DVDCodecs/Overlay/Overlay.a \
                   xbmc/cores/dvdplayer/DVDCodecs/Video/Video.a \
                   xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxers.a \
                   xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreams.a \
                   xbmc/cores/dvdplayer/DVDSubtitles/DVDSubtitles.a

DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \
                   lib/SlingboxLib/SlingboxLib.a \
                   lib/libRTV/librtv.a \
                   lib/libXDAAP/libxdaap.a \
                   lib/libhts/libhts.a \
                   lib/libsquish/libsquish.a \
                   lib/xbmc-dll-symbols/dll-symbols.a \
                   xbmc/addons/addons.a \
                   xbmc/cdrip/cdrip.a \
                   xbmc/cores/AudioEngine/audioengine.a \
                   xbmc/cores/DllLoader/dllloader.a \
                   xbmc/cores/DllLoader/exports/exports.a \
                   xbmc/cores/DllLoader/exports/util/exports_utils.a \
                   xbmc/cores/ExternalPlayer/ExternalPlayer.a \
                   xbmc/cores/VideoRenderers/VideoRenderer.a \
                   xbmc/cores/VideoRenderers/VideoShaders/VideoShaders.a \
                   xbmc/cores/cores.a \
                   xbmc/cores/paplayer/paplayer.a \
                   xbmc/cores/playercorefactory/playercorefactory.a \
                   xbmc/dbwrappers/dbwrappers.a \
                   xbmc/dialogs/dialogs.a \
                   xbmc/epg/epg.a \
                   xbmc/filesystem/MusicDatabaseDirectory/musicdatabasedirectory.a \
                   xbmc/filesystem/VideoDatabaseDirectory/videodatabasedirectory.a \
                   xbmc/filesystem/filesystem.a \
                   xbmc/guilib/guilib.a \
                   xbmc/input/input.a \
                   xbmc/interfaces/generic/interfaces-generic.a \
                   xbmc/interfaces/info/info.a \
                   xbmc/interfaces/interfaces.a \
                   xbmc/interfaces/json-rpc/json-rpc.a \
                   xbmc/linux/linux.a \
                   xbmc/music/dialogs/musicdialogs.a \
                   xbmc/music/infoscanner/musicscanner.a \
                   xbmc/music/karaoke/karaoke.a \
                   xbmc/music/music.a \
                   xbmc/music/tags/musictags.a \
                   xbmc/music/windows/musicwindows.a \
                   xbmc/network/websocket/websocket.a \
                   xbmc/network/network.a \
                   xbmc/peripherals/bus/peripheral-bus.a \
                   xbmc/peripherals/devices/peripheral-devices.a \
                   xbmc/peripherals/dialogs/peripheral-dialogs.a \
                   xbmc/peripherals/peripherals.a \
                   xbmc/pictures/pictures.a \
                   xbmc/playlists/playlists.a \
                   xbmc/powermanagement/powermanagement.a \
                   xbmc/profiles/profiles.a \
                   xbmc/profiles/dialogs/profiles_dialogs.a \
                   xbmc/profiles/windows/profiles_windows.a \
                   xbmc/programs/programs.a \
                   xbmc/pvr/addons/pvraddons.a \
                   xbmc/pvr/channels/pvrchannels.a \
                   xbmc/pvr/dialogs/pvrdialogs.a \
                   xbmc/pvr/pvr.a \
                   xbmc/pvr/recordings/pvrrecordings.a \
                   xbmc/pvr/timers/pvrtimers.a \
                   xbmc/pvr/windows/pvrwindows.a \
                   xbmc/rendering/rendering.a \
                   xbmc/settings/settings.a \
                   xbmc/settings/dialogs/settings_dialogs.a \
                   xbmc/settings/windows/settings_windows.a \
                   xbmc/storage/storage.a \
                   xbmc/utils/utils.a \
                   xbmc/video/dialogs/videodialogs.a \
                   xbmc/video/video.a \
                   xbmc/video/windows/videowindows.a \
                   xbmc/view/view.a \
                   xbmc/windowing/windowing.a \
                   xbmc/windows/windows.a \
                   xbmc/xbmc.a \

NWAOBJSXBMC=	xbmc/threads/threads.a \
		xbmc/commons/commons.a


ifeq (@USE_WEB_SERVER@,1)
DIRECTORY_ARCHIVES += xbmc/network/httprequesthandler/httprequesthandlers.a
endif

DIRECTORY_ARCHIVES += xbmc/interfaces/legacy/legacy.a
DIRECTORY_ARCHIVES += xbmc/interfaces/python/python_binding.a

ifeq (@USE_OPENGL@,1)
DIRECTORY_ARCHIVES += xbmc/rendering/gl/rendering_gl.a
endif

ifeq (@USE_OPENGLES@,1)
DIRECTORY_ARCHIVES += xbmc/rendering/gles/rendering_gles.a
DIRECTORY_ARCHIVES += xbmc/windowing/egl/windowing_egl.a
DIRECTORY_ARCHIVES += xbmc/visualizations/EGLHelpers/eglhelpers.a
endif

ifeq (@USE_UPNP@,1)
DIRECTORY_ARCHIVES += lib/libUPnP/libupnp.a \
                      xbmc/network/upnp/upnp.a
endif

ifeq (@USE_MDNSEMBEDDED@,1)
DIRECTORY_ARCHIVES += xbmc/network/mdns/mdns.a
endif

ifeq ($(findstring osx,@ARCH@),osx)
DIRECTORY_ARCHIVES += xbmc/osx/osx.a
DIRECTORY_ARCHIVES += xbmc/network/osx/network.a
DIRECTORY_ARCHIVES += xbmc/network/linux/network_linux.a
DIRECTORY_ARCHIVES += xbmc/powermanagement/osx/powermanagement.a
DIRECTORY_ARCHIVES += xbmc/storage/osx/storage.a
DIRECTORY_ARCHIVES += xbmc/windowing/osx/windowing_osx.a
else
ifeq (@USE_ANDROID@,1)
DIRECTORY_ARCHIVES += xbmc/input/linux/input_linux.a
DIRECTORY_ARCHIVES += xbmc/input/touch/input_touch.a
DIRECTORY_ARCHIVES += xbmc/input/touch/generic/input_touch_generic.a
DIRECTORY_ARCHIVES += xbmc/network/linux/network_linux.a
DIRECTORY_ARCHIVES += xbmc/powermanagement/android/powermanagement_android.a
DIRECTORY_ARCHIVES += xbmc/storage/android/storage_android.a
DIRECTORY_ARCHIVES += xbmc/windowing/X11/windowing_X11.a
else
DIRECTORY_ARCHIVES += xbmc/input/linux/input_linux.a
DIRECTORY_ARCHIVES += xbmc/network/linux/network_linux.a
DIRECTORY_ARCHIVES += xbmc/powermanagement/linux/powermanagement_linux.a
DIRECTORY_ARCHIVES += xbmc/storage/linux/storage_linux.a
DIRECTORY_ARCHIVES += xbmc/windowing/X11/windowing_X11.a
endif
endif

ifeq ($(findstring freebsd,@ARCH@),freebsd)
DIRECTORY_ARCHIVES += xbmc/freebsd/freebsd.a
endif

ifeq (@HAVE_XBMC_NONFREE@,1)
DIRECTORY_ARCHIVES += lib/UnrarXLib/UnrarXLib.a
endif

BIN_DIRS = $(dir $(DIRECTORY_ARCHIVES)) $(dir $(NWAOBJSXBMC))

ifeq (@USE_ANDROID@,1)
DIRECTORY_ARCHIVES += xbmc/android/loader/AndroidDyload.a
DIRECTORY_ARCHIVES += xbmc/windowing/android/windowing_android.a
DIRECTORY_ARCHIVES += xbmc/android/activity/activity.a
DIRECTORY_ARCHIVES += xbmc/android/bionic_supplement/bionic_supplement.a
DIRECTORY_ARCHIVES += xbmc/android/jni/jni.a
endif

ifeq (@USE_AMLPLAYER@,1)
DIRECTORY_ARCHIVES += xbmc/cores/amlplayer/amlplayer.a
endif

ifeq (@USE_OMXPLAYER@,1)
DIRECTORY_ARCHIVES += xbmc/cores/omxplayer/omxplayer.a
endif

PAPCODECS_DIRS= \
	lib/xbadpcm \
	lib/nosefart \
	lib/timidity \
	lib/libsidplay2 \
	lib/stsound/StSoundLibrary \
	lib/snesapu/SNES/SNESAPU \
	lib/vgmstream

ifeq (@USE_ASAP_CODEC@,1)
PAPCODECS_DIRS+= \
	lib/asap
endif

LIB_DIRS=\
	lib/cximage-6.0 \
	lib/libexif \
	lib/libhdhomerun \
	lib/cpluff \
	lib/xbmc-dll-symbols

ifeq (@USE_MYSQL@,1)
LIB_DIRS += lib/cmyth
CMYTH=cmyth
endif

SS_DIRS=
ifneq (@DISABLE_RSXS@,1)
  SS_DIRS+= xbmc/screensavers/rsxs-0.9/xbmc
endif

VIS_DIRS=xbmc/visualizations/OpenGLSpectrum \
         xbmc/visualizations/WaveForm

ifneq (@DISABLE_FISHBMC@,1)
  VIS_DIRS+= xbmc/visualizations/fishBMC
endif

ifneq (@DISABLE_PROJECTM@,1)
  VIS_DIRS+= xbmc/visualizations/XBMCProjectM
endif

ifneq (@DISABLE_GOOM@,1)
  VIS_DIRS+=xbmc/visualizations/Goom
endif

LIBADDON_DIRS=\
	lib/addons/library.xbmc.addon \
	lib/addons/library.xbmc.codec \
	lib/addons/library.xbmc.pvr \
	lib/addons/library.xbmc.gui \

CONFLUENCE_MEDIA=addons/skin.confluence/media
SKIN_DIRS=$(CONFLUENCE_MEDIA)

ifeq (@USE_SKIN_TOUCHED@,1)
TOUCHED_MEDIA=addons/skin.touched/media
SKIN_DIRS+=$(TOUCHED_MEDIA)
endif

DIRS= $(BIN_DIRS) $(EC_DIRS) $(XBMCTEX_DIRS) $(DVDPCODECS_DIRS) $(PAPCODECS_DIRS) \
	$(LIB_DIRS) $(SS_DIRS) $(VIS_DIRS) $(LIBADDON_DIRS) $(SKIN_DIRS)

LIBS=@LIBS@
CFLAGS=@CFLAGS@
CXXFLAGS=@CXXFLAGS@
LDFLAGS=@LDFLAGS@
INCLUDES=$(sort @INCLUDES@)

CLEAN_FILES=xbmc.bin xbmc-xrandr libxbmc.so

DISTCLEAN_FILES=config.h config.log config.status tools/Linux/xbmc.sh \
        tools/Linux/xbmc-standalone.sh autom4te.cache config.h.in~ \
        system/libcpluff-@ARCH@.so

ifeq (@USE_LIBXBMC@,1)
FINAL_TARGETS+=libxbmc.so
ifeq (@USE_ANDROID@,1)
FINAL_TARGETS+=skins
endif
else
FINAL_TARGETS=xbmc.bin skins xbmc-xrandr
endif
FINAL_TARGETS+=Makefile externals

GTEST_DIR = lib/gtest
GTEST_INCLUDES = -I$(GTEST_DIR)/include
GTEST_LIBS = $(GTEST_DIR)/lib/.libs/libgtest.a

CHECK_DIRS = xbmc/filesystem/test \
             xbmc/utils/test \
             xbmc/threads/test \
             xbmc/interfaces/python/test \
             xbmc/test
CHECK_LIBS = xbmc/filesystem/test/filesystemTest.a \
             xbmc/utils/test/utilsTest.a \
             xbmc/threads/test/threadTest.a \
             xbmc/interfaces/python/test/pythonSwigTest.a \
             xbmc/test/xbmc-test.a
CHECK_PROGRAMS = xbmc-test

CLEAN_FILES += $(CHECK_PROGRAMS)

all : $(FINAL_TARGETS)
	@echo '-----------------------'
	@echo 'XBMC built successfully'
	@echo '-----------------------'

include Makefile.include

.PHONY : dllloader exports visualizations screensavers eventclients papcodecs \
	dvdpcodecs imagelib codecs externals force skins libaddon check \
	testframework testsuite

# hack targets to keep build system up to date
Makefile : config.status $(addsuffix .in, $(AUTOGENERATED_MAKEFILES))
	@echo "Regenerating Makefiles..."
	@./config.status &> /dev/null
	@echo "done"

config.status: configure

# skin textures
ifeq (@USE_TEXTUREPACKER@,1)
skins: tools/TexturePacker/TexturePacker force
	 $(MAKE) -C $(CONFLUENCE_MEDIA)
ifeq (@USE_SKIN_TOUCHED@,1)
	 $(MAKE) -C $(TOUCHED_MEDIA)
endif
else
skins:
endif

# Setup some dependencies for subdir makes
xbmc/cores/paplayer/paplayer.a: papcodecs
$(DVDPLAYER_ARCHIVES)         : dvdpcodecs

$(NWAOBJSXBMC): force
	@$(MAKE) $(if $(V),,-s) -C $(@D)

$(DIRECTORY_ARCHIVES): force
	@$(MAKE) $(if $(V),,-s) -C $(@D)

lib/cpluff/libcpluff/.libs/libcpluff.a: force
	$(MAKE) -C lib/cpluff/libcpluff
system/libcpluff-@ARCH@.so: lib/cpluff/libcpluff/.libs/libcpluff.a exports
ifeq ($(findstring osx,@ARCH@), osx)
  ifeq (@ARCH@, arm-osx)
	$(CXX) $(LDFLAGS) -all_load -bundle -flat_namespace -undefined dynamic_lookup -read_only_relocs suppress -o $@ $<
  else
	$(CXX) $(LDFLAGS) -all_load -bundle -flat_namespace -undefined dynamic_lookup -lexpat $(BUNDLE1_O) -o $@ $<
  endif
else
	$(CXX) $(LDFLAGS) -shared -o $@ -Wl,--whole-archive $< \
		-Wl,--no-whole-archive  \
		`cat xbmc/cores/DllLoader/exports/wrapper.def` xbmc/cores/DllLoader/exports/wrapper.o -lexpat
endif

exports: xbmc/cores/DllLoader/exports/exports.a xbmc/cores/DllLoader/exports/util/exports_utils.a
	$(MAKE) -C xbmc/cores/DllLoader/exports wrapper.def
dllloader: exports xbmc/cores/DllLoader/dllloader.a

ifeq (@USE_OPENGLES@,1)
EGLHELPERS=xbmc/visualizations/EGLHelpers/eglhelpers.a
endif

$(VIS_DIRS): force exports $(EGLHELPERS)
	$(MAKE) -C $@

$(SS_DIRS): force exports
	$(MAKE) -C $@

visualizations: $(VIS_DIRS)

screensavers: $(SS_DIRS)

libaddon: exports
	$(MAKE) -C lib/addons/library.xbmc.addon
	$(MAKE) -C lib/addons/library.xbmc.codec
	$(MAKE) -C lib/addons/library.xbmc.gui
	$(MAKE) -C lib/addons/library.xbmc.pvr
dvdpcodecs: dllloader
	$(MAKE) -C lib
	$(MAKE) -C lib/libdvd
eventclients:
ifeq ($(findstring osx,@ARCH@), osx)
ifneq ($(findstring arm,@ARCH@), arm)
	$(MAKE) -C tools/EventClients/Clients/OSXRemote
endif
else
	$(MAKE) -C tools/EventClients
endif
libexif: dllloader
	$(MAKE) -C lib/libexif
cmyth: dllloader
	$(MAKE) -C lib/cmyth
libhdhomerun: dllloader
	$(MAKE) -C lib/libhdhomerun
papcodecs: dllloader dvdpcodecs
	test -d system/players/paplayer || mkdir system/players/paplayer
	$(MAKE) -C lib/xbadpcm
	$(MAKE) -C lib/vgmstream
	$(MAKE) -C lib/timidity
	$(MAKE) -C lib/nosefart
ifneq ($(findstring arm-osx,@ARCH@), arm-osx)
	$(MAKE) -C lib/libsidplay2
endif
ifeq (@USE_ASAP_CODEC@,1)
  ifneq ($(findstring osx,@ARCH@), osx)
	$(MAKE) -C lib/asap asap-xbmc
  endif
endif
	$(MAKE) -C lib/stsound/StSoundLibrary
ifeq ($(or $(findstring powerpc,@ARCH@),$(findstring x86_64-linux,@ARCH@),$(findstring arm, @ARCH@),$(findstring freebsd,@ARCH@)),)
	$(MAKE) -C lib/snesapu/SNES/SNESAPU
endif
imagelib: dllloader
	$(MAKE) -C lib/cximage-6.0

pvraddons: exports
ifeq (@USE_PVR_ADDONS@,1)
	$(MAKE) -C pvr-addons
endif

codecs: papcodecs dvdpcodecs

libs: libhdhomerun imagelib libexif system/libcpluff-@ARCH@.so $(CMYTH)

externals: codecs libs visualizations screensavers libaddon pvraddons

xcode_depends: \
	codecs libs visualizations screensavers eventclients skins libaddon \
	lib/libsquish/libsquish.a \
	lib/libRTV/librtv.a \
	lib/libXDAAP/libxdaap.a \
	lib/SlingboxLib/SlingboxLib.a

OBJSXBMC =$(DIRECTORY_ARCHIVES)

DYNOBJSXBMC= \
	xbmc/linux/linux.a \
	xbmc/network/network.a \
	xbmc/video/windows/videowindows.a \
	xbmc/utils/utils.a \
	xbmc/cores/DllLoader/exports/util/exports_utils.a \
	xbmc/cores/DllLoader/exports/exports.a \
	xbmc/settings/settings.a \
	xbmc/video/video.a \
	xbmc/pvr/addons/pvraddons.a \
	xbmc/pvr/windows/pvrwindows.a \
	xbmc/guilib/guilib.a # must be dynamic to avoid linker errors

ifeq ($(findstring freebsd,@ARCH@),freebsd)
DYNOBJSXBMC+= xbmc/freebsd/freebsd.a
endif

OBJSXBMC:=$(filter-out $(DYNOBJSXBMC), $(OBJSXBMC))

MAINOBJS=xbmc/xbmc.o
ifeq (@USE_ANDROID@,1)
MAINOBJS+=xbmc/android/activity/android_main.o
endif
ifneq (@USE_LIBXBMC@,1)
MAINOBJS+=xbmc/main/main.o
endif

# sync these entries manually with tools/depends/target/xbmc-addon-bindings/Makefile
BINDINGS =xbmc/addons/include/xbmc_addon_cpp_dll.h
BINDINGS+=xbmc/addons/include/xbmc_addon_dll.h
BINDINGS+=xbmc/addons/include/xbmc_addon_types.h
BINDINGS+=xbmc/addons/include/xbmc_codec_types.h
BINDINGS+=xbmc/addons/include/xbmc_epg_types.h
BINDINGS+=xbmc/addons/include/xbmc_pvr_dll.h
BINDINGS+=xbmc/addons/include/xbmc_pvr_types.h
BINDINGS+=xbmc/addons/include/xbmc_scr_dll.h
BINDINGS+=xbmc/addons/include/xbmc_scr_types.h
BINDINGS+=xbmc/addons/include/xbmc_vis_dll.h
BINDINGS+=xbmc/addons/include/xbmc_vis_types.h
BINDINGS+=xbmc/addons/include/xbmc_stream_utils.hpp
BINDINGS+=addons/library.xbmc.addon/libXBMC_addon.h
BINDINGS+=addons/library.xbmc.gui/libXBMC_gui.h
BINDINGS+=addons/library.xbmc.pvr/libXBMC_pvr.h
BINDINGS+=addons/library.xbmc.codec/libXBMC_codec.h
BINDINGS+=xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPacket.h

libxbmc.so: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(MAINOBJS)
ifeq ($(findstring osx,@ARCH@), osx)
	$(SILENT_LD) $(CXX) $(LDFLAGS) -bundle -o $@ -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS)
else
	$(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -o $@ $(MAINOBJS) -Wl,--start-group $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--end-group -Wl,--no-undefined $(NWAOBJSXBMC) $(LIBS)
endif

xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(MAINOBJS) xbmc/main/main.a

ifeq ($(findstring osx,@ARCH@), osx)
	$(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
else
	$(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin $(MAINOBJS) -Wl,--start-group $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--end-group $(NWAOBJSXBMC) $(LIBS) -rdynamic
endif

xbmc-xrandr: xbmc-xrandr.c
ifneq (1,@USE_XRANDR@)
	# xbmc-xrandr.c gets picked up by the default make rules
	@echo "excluding xbmc-xrandr"
else
	$(SILENT_LD) $(CC) $(CFLAGS) $(LDFLAGS) -o xbmc-xrandr xbmc-xrandr.c -lXrandr -lX11 -lm
endif

tools/TexturePacker/TexturePacker: lib/libsquish/libsquish.a xbmc/guilib/XBTF.h
	$(MAKE) -C tools/TexturePacker/


install-bin: xbmc.bin # developement convenience target
	sudo install -d $(DESTDIR)$(libdir)
	sudo install xbmc.bin $(DESTDIR)$(libdir)/xbmc

ifeq ($(findstring osx,@ARCH@), osx)
	# TODO: add osx install
else
install: install-binaries install-arch install-datas

apk: install
	make -C tools/android/packaging

install-binaries: install-scripts
	@echo "Copying XBMC binary to $(DESTDIR)$(libdir)/xbmc/"
	@install -d $(DESTDIR)$(libdir)/xbmc
ifeq (1,@USE_XRANDR@)
	@install xbmc-xrandr $(DESTDIR)$(libdir)/xbmc/xbmc-xrandr
endif
ifeq (@USE_LIBXBMC@,1)
	@install libxbmc.so $(DESTDIR)$(libdir)/xbmc/libxbmc.so
else
	@install xbmc.bin $(DESTDIR)$(libdir)/xbmc/xbmc.bin
	@echo "You can run XBMC with the command 'xbmc'"
endif
endif

install-arch:
	@# Arch dependent files
ifeq (@USE_PVR_ADDONS@,1)
	$(MAKE) -C pvr-addons install
endif
ifeq ($(findstring freebsd,@ARCH@), freebsd)
	@find -E system addons -type f -not -iregex ".*svn.*" \
		-iregex ".*@ARCH@.*|.*\.vis|.*\.xbs" \
		-exec sh -c "install -d \"$(DESTDIR)$(libdir)/xbmc/\`dirname '{}'\`\"" \; \
		-and \
		-exec install "{}" $(DESTDIR)$(libdir)/xbmc/"{}" \; \
		-exec printf " -- %-75.75s\r" "{}" \;
else
ifeq ($(findstring Darwin,$(shell uname -s)),Darwin)
	@find -E system addons -type f -not -iregex ".*svn.*" \
		-iregex ".*@ARCH@.*|.*\.vis|.*\.xbs" \
		-exec sh -c "install -d \"$(DESTDIR)$(libdir)/xbmc/\`dirname '{}'\`\"" \; \
		-and \
		-exec install "{}" $(DESTDIR)$(libdir)/xbmc/"{}" \; \
		-exec printf " -- %-75.75s\r" "{}" \;
else
	@find system addons -regextype posix-extended -type f -not -iregex ".*svn.*" -iregex ".*\.so|.*\.vis|.*\.xbs|.*\.pvr" -exec install -D "{}" $(DESTDIR)$(libdir)/xbmc/"{}" \; -printf " -- %-75.75f\r"
endif
endif

install-scripts:
	@install -d $(DESTDIR)$(bindir)
	@install tools/Linux/xbmc.sh $(DESTDIR)$(bindir)/xbmc
	@install tools/Linux/xbmc-standalone.sh $(DESTDIR)$(bindir)/xbmc-standalone
	@install -d $(DESTDIR)$(datarootdir)/xbmc
	@install -m 0644 tools/Linux/FEH.py $(DESTDIR)$(datarootdir)/xbmc/FEH.py
	@install -d $(DESTDIR)$(datarootdir)/xsessions
	@install -m 0644 tools/Linux/xbmc-xsession.desktop $(DESTDIR)$(datarootdir)/xsessions/XBMC.desktop

install-datas: install-scripts
	@echo "Copying support and legal files..."
	@install -d $(DESTDIR)$(docdir)
	@for FILE in `ls LICENSE.GPL *.txt`; do \
		install -m 0644 "$$FILE" "$(DESTDIR)$(docdir)/$$FILE"; done
	@install -m 0644 "docs/README.linux" "$(DESTDIR)$(docdir)/README.linux"
	@echo "Done!"
	@echo "Copying system files to $(DESTDIR)$(datarootdir)/xbmc"
	@install -d $(DESTDIR)$(datarootdir)/xbmc
	@# Arch independent files
ifeq ($(findstring bsd,@ARCH@), bsd)
	@find -E addons language media sounds userdata system -type f \
		-not -iregex ".*@ARCH@.*|.*\.vis|.*\.xbs|.*svn.*|.*\.so|.*\.dll" \
		-exec sh -c "install -d \"$(DESTDIR)$(datarootdir)/xbmc/\`dirname '{}'\`\"" \; \
		-and \
		-exec install -m 0644 "{}" $(DESTDIR)$(datarootdir)/xbmc/"{}" \; \
		-exec printf " -- %-75.75s\r" "{}" \;
else
ifeq ($(findstring Darwin,$(shell uname -s)),Darwin)
	@find -E addons language media sounds userdata system -type f \
		-not -iregex ".*@ARCH@.*|.*\.vis|.*\.xbs|.*svn.*|.*\.so|.*\.dll" \
		-exec sh -c "install -d \"$(DESTDIR)$(datarootdir)/xbmc/\`dirname '{}'\`\"" \; \
		-and \
		-exec install -m 0644 "{}" $(DESTDIR)$(datarootdir)/xbmc/"{}" \; \
		-exec printf " -- %-75.75s\r" "{}" \;
else
	@find addons language media sounds userdata system -regextype posix-extended -type f -not -iregex ".*@ARCH@.*|.*\.vis|.*\.xbs|.*svn.*|.*\.so|.*\.dll|.*\.pvr" -exec install -D -m 0644 "{}" $(DESTDIR)$(datarootdir)/xbmc/"{}" \; -printf " -- %-75.75f\r"
endif
endif
	@# Icons and links
	@install -d $(DESTDIR)$(datarootdir)/applications
	@install tools/Linux/xbmc.desktop $(DESTDIR)$(datarootdir)/applications/xbmc.desktop
	@install -d $(DESTDIR)$(datadir)/icons/hicolor/48x48/apps
	@install -m 0644 tools/Linux/xbmc-48x48.png $(DESTDIR)$(datadir)/icons/hicolor/48x48/apps/xbmc.png
	@install -d $(DESTDIR)$(datadir)/icons/hicolor/256x256/apps
	@install -m 0644 media/icon.png $(DESTDIR)$(datadir)/icons/hicolor/256x256/apps/xbmc.png
	@test -z "$(DESTDIR)" && gtk-update-icon-cache -f -q -t $(datadir)/icons/hicolor || :

	@echo "Copying bindings to $(DESTDIR)$(includedir)/xbmc"
	@install -d $(DESTDIR)$(includedir)/xbmc
	@for f in $(BINDINGS); do \
	  install -m 0644 $$f $(DESTDIR)$(includedir)/xbmc ; \
	done

uninstall:
	@echo "Removing XBMC..."
	@rm -rf $(DESTDIR)$(libdir)/xbmc
	@rm -rf $(DESTDIR)$(datarootdir)/xbmc $(DESTDIR)$(bindir)/xbmc
	@rm -rf $(DESTDIR)$(bindir)/xbmc-standalone
	@rm -rf $(DESTDIR)$(datarootdir)/xsessions/XBMC.desktop
	@rm -rf $(libdir)/libXBMC_*
	@rm -rf $(prefix)/include/xbmc
	@echo "Done!"

clean-xbmc.bin:
	rm -f xbmc.bin
	for d in $(BIN_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-eventclients:
	for d in $(EC_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-xbmctex:
	for d in $(XBMCTEX_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-dvdpcodecs:
	for d in $(DVDPCODECS_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-papcodecs:
	for d in $(PAPCODECS_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-libs:
	for d in $(LIB_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-screensavers:
	for d in $(SS_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-visualisations:
	for d in $(VIS_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-libaddons:
	for d in $(LIBADDON_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d clean; fi; done
clean-pvraddons:
ifeq (@USE_PVR_ADDONS@,1)
	if test -f pvr-addons/Makefile; then $(MAKE) -C pvr-addons clean; fi;
endif

clean-codecs: clean-dvdpcodecs clean-papcodecs

clean-externals: clean-codecs clean-eventclients clean-xbmctex clean-libs \
	clean-screensavers clean-visualisations clean-libaddons clean-pvraddons

ifeq (1,@GTEST_CONFIGURED@)
check: testsuite
	for check_program in $(CHECK_PROGRAMS); do $(CURDIR)/$$check_program; done

testsuite: $(CHECK_PROGRAMS)

testframework: $(GTEST_LIBS)

$(GTEST_LIBS): $(GTEST_DIR)/Makefile

$(GTEST_DIR)/Makefile: force
	$(MAKE) -C $(GTEST_DIR)

$(CHECK_LIBS): force
	@$(MAKE) $(if $(V),,-s) -C $(@D)

xbmc-test: $(CHECK_LIBS) $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(GTEST_LIBS)
ifeq ($(findstring osx,@ARCH@), osx)
	$(SILENT_LD) $(CXX) $(LDFLAGS) $(GTEST_INCLUDES) -o $@ -Wl,-all_load,-ObjC $(CHECK_LIBS) $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(GTEST_LIBS) $(LIBS) -rdynamic
else
	$(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) $(GTEST_INCLUDES) -o $@ -Wl,--whole-archive $(CHECK_LIBS) $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(NWAOBJSXBMC) $(GTEST_LIBS) $(LIBS) -rdynamic
endif
else
# Give a message that the framework is not configured, but don't fail.
check testsuite testframework:
	@echo "Google Test Framework not configured, skipping testsuite check."
endif