Makefile overhaul. All generated bitmaps are now explicitly in OBJDIR/bitmaps and...
[kugel-rb.git] / apps / plugins / Makefile
blobc9405a49b947094aa7126e479e28073377d1790b
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)
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 += pluginbitmapsmono
29 LINKBITMAPS += -lpluginbitmapsmono
30 endif
31 ifneq ($(strip $(BMP2RB_NATIVE)),)
32 BITMAPLIBS += pluginbitmapsnative
33 LINKBITMAPS += -lpluginbitmapsnative
34 endif
35 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
36 BITMAPLIBS += pluginbitmapsremotemono
37 LINKBITMAPS += -lpluginbitmapsremotemono
38 endif
39 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
40 BITMAPLIBS += pluginbitmapsremotenative
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: build
65 dep: $(DEPFILE)
67 build: $(DEPFILE) $(BITMAPLIBS)
68 $(call PRINTS,MAKE rocks)$(MAKE) rocks
69 $(call PRINTS,MAKE subdirs)$(MAKE) subdirs
71 rocks: $(ROCKS)
73 subdirs: $(SUBDIRS)
75 $(BUILDDIR)/credits.raw: $(DOCSDIR)/CREDITS
76 $(call PRINTS,create credits.raw)perl credits.pl < $< > $@
78 $(OBJDIR)/credits.o: credits.c $(BUILDDIR)/credits.raw
79 $(SILENT)mkdir -p $(dir $@)
80 $(call PRINTS,CC $(<F))$(CC) $(CFLAGS) -I$(OBJDIR) -c $< -o $@
82 pluginbitmapsmono:
83 $(call PRINTS,MAKE in plugins/bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
85 pluginbitmapsnative:
86 $(call PRINTS,MAKE in plugins/bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
88 pluginbitmapsremotemono:
89 $(call PRINTS,MAKE in plugins/bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
91 pluginbitmapsremotenative:
92 $(call PRINTS,MAKE in plugins/bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
94 ifndef SIMVER
95 $(OBJDIR)/%.rock: $(OBJDIR)/%.o $(LINKFILE)
96 $(SILENT)$(CC) $(CFLAGS) -o $(OBJDIR)/$*.elf $< -L$(BUILDDIR) \
97 $(CODECLIBS) -lplugin $(LINKBITMAPS) -lgcc \
98 -T$(LINKFILE) -Wl,--gc-sections -Wl,-Map,$(OBJDIR)/$*.map
99 $(call PRINTS,LINK $(@F))$(OC) -O binary $(OBJDIR)/$*.elf $(OBJDIR)/$*.rock
101 else
103 ifeq ($(SIMVER), x11)
104 ###################################################
105 # This is the X11 simulator version
107 $(OBJDIR)/%.rock : $(OBJDIR)/%.o
108 $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -o $@
109 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
110 # 'x' must be kept or you'll have "Win32 error 5"
111 # $ fgrep 5 /usr/include/w32api/winerror.h | head -1
112 # #define ERROR_ACCESS_DENIED 5L
113 else
114 $(SILENT)chmod -x $@
115 endif
117 else # end of x11-simulator
118 ifeq ($(SIMVER), sdl)
119 ###################################################
120 # This is the SDL simulator version
122 $(OBJDIR)/%.rock : $(OBJDIR)/%.o
123 $(call PRINTS,LD $(@F))$(CC) $(CFLAGS) $(SHARED_FLAG) $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -o $@
124 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
125 # 'x' must be kept or you'll have "Win32 error 5"
126 # $ fgrep 5 /usr/include/w32api/winerror.h | head -1
127 # #define ERROR_ACCESS_DENIED 5L
128 else
129 $(SILENT)chmod -x $@
130 endif
132 else # end of sdl-simulator
133 ###################################################
134 # This is the win32 simulator version
135 DLLTOOLFLAGS = --export-all
136 DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin
138 $(OBJDIR)/%.rock : $(OBJDIR)/%.o
139 $(call PRINTS,DLL $(@F))$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
140 $(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(BUILDDIR)/libplugin.a $(BITMAPLIBS) \
141 $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) -o $@
142 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
143 # 'x' must be kept or you'll have "Win32 error 5"
144 # $ fgrep 5 /usr/include/w32api/winerror.h | head -1
145 # #define ERROR_ACCESS_DENIED 5L
146 else
147 $(SILENT)chmod -x $@
148 endif
149 endif # end of win32-simulator
150 endif
152 endif # end of simulator section
154 include $(TOOLSDIR)/make.inc
156 pluginlib:
157 $(SILENT)mkdir -p $(OBJDIR)/lib
158 $(call PRINTS,MAKE in plugin/lib)$(MAKE) -C lib OBJDIR=$(OBJDIR)/lib
160 $(LINKFILE): $(LDS)
161 $(call PRINTS,build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P - >$@
163 $(SUBDIRS):
164 $(SILENT)mkdir -p $(OBJDIR)/$@
165 $(call PRINTS,MAKE in $@)$(MAKE) -C $@ OUTDIR=$(OBJDIR) OBJDIR=$(OBJDIR)/$@ \
166 LINKBITMAPS="$(LINKBITMAPS)"
168 clean:
169 $(call PRINTS,cleaning plugins)rm -f $(ROCKS) $(LINKFILE) $(OBJDIR)/*.rock $(DEPFILE) $(ELFS) \
170 $(BUILDDIR)/credits.raw $(OBJS) $(DEFS)
171 $(SILENT)$(MAKE) -C lib clean OBJDIR=$(OBJDIR)/lib
172 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
173 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
174 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
175 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
176 $(SILENT)$(MAKE) -C rockboy clean OBJDIR=$(OBJDIR)/rockboy
177 $(SILENT)$(MAKE) -C searchengine clean OBJDIR=$(OBJDIR)/searchengine
178 @rm -rf $(BUILDDIR)/pluginbitmaps
180 -include $(DEPFILE)