summaryrefslogtreecommitdiffstats
path: root/apps/plugins/imageviewer/imageviewer.make
blob: d06bbfd5715a0bca93a29b55c70b01ce11319ec1 (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
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#

IMGVSRCDIR := $(APPSDIR)/plugins/imageviewer
IMGVBUILDDIR := $(BUILDDIR)/apps/plugins/imageviewer

ROCKS += $(IMGVBUILDDIR)/imageviewer.rock

IMGV_SRC := $(call preprocess, $(IMGVSRCDIR)/SOURCES)
IMGV_OBJ := $(call c2obj, $(IMGV_SRC))

# add source files to OTHER_SRC to get automatic dependencies
OTHER_SRC += $(IMGV_SRC)

$(IMGVBUILDDIR)/imageviewer.rock: $(IMGV_OBJ)

IMGDECFLAGS = $(PLUGINFLAGS) -DIMGDEC

# include decoder's make from each subdir
IMGVSUBDIRS := $(call preprocess, $(IMGVSRCDIR)/SUBDIRS)
$(foreach dir,$(IMGVSUBDIRS),$(eval include $(dir)/$(notdir $(dir)).make))

IMGDECLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$(IMGVBUILDDIR)/$*.refmap

ifndef APP_TYPE
    IMGDEC_OUTLDS = $(IMGVBUILDDIR)/%.link
    IMGDEC_OVLFLAGS = -T$(IMGVBUILDDIR)/$*.link -Wl,--gc-sections -Wl,-Map,$(IMGVBUILDDIR)/$*.map
else
    IMGDEC_OVLFLAGS = $(PLUGINLDFLAGS)
endif

$(IMGVBUILDDIR)/%.ovl: $(IMGDEC_OUTLDS)
	$(call PRINTS,LD $(@F))$(CC) $(IMGDECFLAGS) -o $(IMGVBUILDDIR)/$*.elf \
		$(filter-out $(PLUGIN_CRT0),$(filter %.o, $^)) \
		$(filter %.a, $+) \
		-lgcc $(IMGDEC_OVLFLAGS)
ifdef APP_TYPE
	$(SILENT)cp $(IMGVBUILDDIR)/$*.elf $@
else
	$(SILENT)$(OC) -O binary $(IMGVBUILDDIR)/$*.elf $@
endif

# rule to create reference map for image decoder
$(IMGVBUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(IMGVSRCDIR)/imageviewer.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
	$(call PRINTS,LD $(@F))$(CC) $(IMGDECFLAGS) -o /dev/null \
		$(filter %.o, $^) \
		$(filter %.a, $+) \
		-lgcc $(IMGDECLDFLAGS)

$(IMGVBUILDDIR)/%.link: $(PLUGIN_LDS) $(IMGVBUILDDIR)/%.refmap
	$(call PRINTS,PP $(@F))$(call preprocess2file,$<,$@,-DIMGVDECODER_OFFSET=$(shell \
		$(TOOLSDIR)/ovl_offset.pl $(IMGVBUILDDIR)/$*.refmap))