Colour targets: Revert an optimisation from almost 18 months ago that actually turned...
[Rockbox.git] / apps / plugins / Makefile
blob4f518a2c1caec366aae4cee6b9ecac5ca4762cfc
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES = $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I$(FIRMDIR)/common \
11 -I$(FIRMDIR)/drivers -I$(APPSDIR) -Ilib -I$(BUILDDIR) \
12 -I$(BUILDDIR)/pluginbitmaps
13 CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \
14 -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
16 ifdef APPEXTRA
17 INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
18 endif
20 ifdef SOFTWARECODECS
21 CODECLIBS = -lmad -la52 -lffmpegFLAC -lTremor -lwavpack -lmusepack
22 endif
24 # Set up the bitmap libraries
25 BITMAPLIBS =
26 LINKBITMAPS =
27 ifneq ($(strip $(BMP2RB_MONO)),)
28 BITMAPLIBS += $(BUILDDIR)/libpluginbitmapsmono.a
29 LINKBITMAPS += -lpluginbitmapsmono
30 endif
31 ifneq ($(strip $(BMP2RB_NATIVE)),)
32 BITMAPLIBS += $(BUILDDIR)/libpluginbitmapsnative.a
33 LINKBITMAPS += -lpluginbitmapsnative
34 endif
35 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
36 BITMAPLIBS += $(BUILDDIR)/libpluginbitmapsremotemono.a
37 LINKBITMAPS += -lpluginbitmapsremotemono
38 endif
39 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
40 BITMAPLIBS += $(BUILDDIR)/libpluginbitmapsremotenative.a
41 LINKBITMAPS += -lpluginbitmapsremotenative
42 endif
44 LDS := plugin.lds
45 LINKFILE := $(OBJDIR)/pluginlink.lds
46 DEPFILE = $(OBJDIR)/dep-plugins
48 # This sets up 'SRC' based on the files mentioned in SOURCES
49 include $(TOOLSDIR)/makesrc.inc
51 # This sets up 'SUBDIRS' based on the directories mentioned in SUBDIRS
52 include $(TOOLSDIR)/makesubdirs.inc
54 ROCKS := $(SRC:%.c=$(OBJDIR)/%.rock)
55 SOURCES = $(SRC)
56 ELFS := $(SRC:%.c=$(OBJDIR)/%.elf)
57 OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
58 # as created by the cross-compiler for win32:
59 DEFS := $(SRC:%.c=$(OBJDIR)/%.def)
60 DIRS = .
62 .PHONY: $(SUBDIRS)
63 all: $(BUILDDIR)/libplugin.a $(ROCKS) $(SUBDIRS) $(DEPFILE)
65 $(DEPFILE): $(BITMAPLIBS)
67 dep: $(DEPFILE)
69 $(BUILDDIR)/credits.raw: $(DOCSDIR)/CREDITS
70 $(call PRINTS,create credits.raw)perl credits.pl < $< > $@
72 $(OBJDIR)/credits.o: credits.c $(BUILDDIR)/credits.raw
73 $(SILENT)mkdir -p $(dir $@)
74 $(call PRINTS,CC $(<F))$(CC) $(CFLAGS) -I$(OBJDIR) -c $< -o $@
76 build-bitmapsmono:
77 $(call PRINTS,MAKE in plugins/bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
79 build-bitmapsnative:
80 $(call PRINTS,MAKE in plugins/bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
82 build-bitmapsremotemono:
83 $(call PRINTS,MAKE in plugins/bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
85 build-bitmapsremotenative:
86 $(call PRINTS,MAKE in plugins/bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
88 $(BITMAPLIBS): $(BUILDDIR)/libplugin%.a: build-%
90 ifndef SIMVER
91 $(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
92 $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) -o $@ $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -lgcc \
93 -T$(LINKFILE) -Wl,--gc-sections -Wl,-Map,$(OBJDIR)/$*.map
95 $(OBJDIR)/%.rock : $(OBJDIR)/%.elf
96 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
97 else
99 ifeq ($(SIMVER), x11)
100 ###################################################
101 # This is the X11 simulator version
103 $(OBJDIR)/%.rock : $(OBJDIR)/%.o $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
104 $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -o $@
105 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
106 # 'x' must be kept or you'll have "Win32 error 5"
107 # $ fgrep 5 /usr/include/w32api/winerror.h | head -1
108 # #define ERROR_ACCESS_DENIED 5L
109 else
110 $(SILENT)chmod -x $@
111 endif
113 else # end of x11-simulator
114 ifeq ($(SIMVER), sdl)
115 ###################################################
116 # This is the SDL simulator version
118 $(OBJDIR)/%.rock : $(OBJDIR)/%.o $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
119 $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -o $@
120 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
121 # 'x' must be kept or you'll have "Win32 error 5"
122 # $ fgrep 5 /usr/include/w32api/winerror.h | head -1
123 # #define ERROR_ACCESS_DENIED 5L
124 else
125 $(SILENT)chmod -x $@
126 endif
128 else # end of sdl-simulator
129 ###################################################
130 # This is the win32 simulator version
131 DLLTOOLFLAGS = --export-all
132 DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
134 $(OBJDIR)/%.rock : $(OBJDIR)/%.o $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
135 $(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
136 $(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(BUILDDIR)/libplugin.a $(BITMAPLIBS) \
137 $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) -o $@
138 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
139 # 'x' must be kept or you'll have "Win32 error 5"
140 # $ fgrep 5 /usr/include/w32api/winerror.h | head -1
141 # #define ERROR_ACCESS_DENIED 5L
142 else
143 $(SILENT)chmod -x $@
144 endif
145 endif # end of win32-simulator
146 endif
148 endif # end of simulator section
150 include $(TOOLSDIR)/make.inc
152 $(BUILDDIR)/libplugin.a:
153 $(SILENT)mkdir -p $(OBJDIR)/lib
154 $(call PRINTS,MAKE in plugin/lib)$(MAKE) -C lib OBJDIR=$(OBJDIR)/lib
156 $(LINKFILE): $(LDS)
157 $(call PRINTS,build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P - >$@
159 $(SUBDIRS): $(BITMAPLIBS)
160 $(SILENT)mkdir -p $(OBJDIR)/$@
161 $(call PRINTS,MAKE in $@)$(MAKE) -C $@ OUTDIR=$(OBJDIR) OBJDIR=$(OBJDIR)/$@ \
162 LINKBITMAPS="$(LINKBITMAPS)" BITMAPLIBS="$(BITMAPLIBS)"
164 clean:
165 $(call PRINTS,cleaning plugins)rm -f $(ROCKS) $(LINKFILE) $(OBJDIR)/*.rock $(DEPFILE) $(ELFS) \
166 $(BUILDDIR)/credits.raw $(OBJS) $(DEFS)
167 $(SILENT)$(MAKE) -C lib clean OBJDIR=$(OBJDIR)/lib
168 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
169 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
170 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
171 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
172 $(SILENT)$(MAKE) -C rockboy clean OBJDIR=$(OBJDIR)/rockboy
173 $(SILENT)$(MAKE) -C searchengine clean OBJDIR=$(OBJDIR)/searchengine
174 @rm -rf $(BUILDDIR)/pluginbitmaps
176 -include $(DEPFILE)