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

CHESSBOX_SRCDIR = $(APPSDIR)/plugins/chessbox
CHESSBOX_OBJDIR = $(BUILDDIR)/apps/plugins/chessbox

CHESSBOX_SRC := $(call preprocess, $(CHESSBOX_SRCDIR)/SOURCES)
CHESSBOX_OBJ := $(call c2obj, $(CHESSBOX_SRC))

OTHER_SRC += $(CHESSBOX_SRC)

ifeq ($(findstring YES, $(call preprocess, $(APPSDIR)/plugins/BUILD_OVERLAY)), YES)
    ### lowmem targets
    ROCKS += $(CHESSBOX_OBJDIR)/chessbox.ovl
    CHESSBOX_OUTLDS = $(CHESSBOX_OBJDIR)/chessbox.link
    CHESSBOX_OVLFLAGS = -T$(CHESSBOX_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map
else
    ROCKS += $(CHESSBOX_OBJDIR)/chessbox.rock
endif

CHESSBOXFLAGS = $(filter-out -O%,$(PLUGINFLAGS)) -O2

$(CHESSBOX_OBJDIR)/chessbox.rock: $(CHESSBOX_OBJ)

$(CHESSBOX_OBJDIR)/chessbox.refmap: $(CHESSBOX_OBJ)

$(CHESSBOX_OUTLDS): $(PLUGIN_LDS) $(CHESSBOX_OBJDIR)/chessbox.refmap
	$(call PRINTS,PP $(@F))$(call preprocess2file,$<,$@,-DOVERLAY_OFFSET=$(shell \
		$(TOOLSDIR)/ovl_offset.pl $(CHESSBOX_OBJDIR)/chessbox.refmap))

$(CHESSBOX_OBJDIR)/chessbox.ovl: $(CHESSBOX_OBJ) $(CHESSBOX_OUTLDS)
	$(SILENT)$(CC) $(PLUGINFLAGS) -o $(basename $@).elf \
		$(filter %.o, $^) \
		$(filter %.a, $+) \
		-lgcc $(CHESSBOX_OVLFLAGS)
	$(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)

# special pattern rule for compiling chessbox with extra flags
$(CHESSBOX_OBJDIR)/%.o: $(CHESSBOX_SRCDIR)/%.c $(CHESSBOX_SRCDIR)/chessbox.make
	$(SILENT)mkdir -p $(dir $@)
	$(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(CHESSBOXFLAGS) -c $< -o $@