skin parser: Allow the first character after conditional seperators to be \n
[maemo-rb.git] / rbutil / libtools.make
blobb3015015ed1b8ae9e6cc053452453f420f7b3bc1
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
8 # libtools.make
10 # Common Makefile for tools used by Rockbox Utility.
11 # Provides rules for building as library, universal library (OS X) and
12 # standalone binary.
14 # LIBSOURCES is a list of files to build the lib
15 # SOURCES is a list of files to build for the main binary
16 # EXTRADEPS is a list of make targets dependencies
18 ifndef V
19 SILENT = @
20 endif
22 # Get directory this Makefile is in for relative paths.
23 TOP := $(dir $(lastword $(MAKEFILE_LIST)))
25 # overwrite for releases
26 APPVERSION ?= $(shell $(TOP)/../tools/version.sh ../)
27 CFLAGS += -DVERSION=\"$(APPVERSION)\"
28 TARGET_DIR ?= $(shell pwd)/
30 BINARY = $(OUTPUT)
31 # when building a Windows binary add the correct file suffix
32 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
33 BINARY = $(OUTPUT).exe
34 CFLAGS+=-mno-cygwin
35 else
36 ifeq ($(findstring MINGW,$(shell uname)),MINGW)
37 BINARY = $(OUTPUT).exe
38 else
39 ifeq ($(findstring mingw,$(CROSS)$(CC)),mingw)
40 BINARY = $(OUTPUT).exe
41 endif
42 endif
43 endif
45 NATIVECC ?= gcc
46 CC ?= gcc
47 # OS X specifics. Needs to consider cross compiling for Windows.
48 ifeq ($(findstring Darwin,$(shell uname)),Darwin)
49 ifneq ($(findstring mingw,$(CROSS)$(CC)),mingw)
50 # when building libs for OS X build for both i386 and ppc at the same time.
51 # This creates fat objects, and ar can only create the archive but not operate
52 # on it. As a result the ar call must NOT use the u (update) flag.
53 CFLAGS += -arch ppc -arch i386
54 # building against SDK 10.4 is not compatible with gcc-4.2 (default on newer Xcode)
55 # might need adjustment for older Xcode.
56 CC ?= gcc-4.0
57 CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
58 NATIVECC ?= gcc-4.0
59 endif
60 endif
61 WINDRES = windres
63 BUILD_DIR ?= $(TARGET_DIR)build
64 OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/
66 ifdef RBARCH
67 CFLAGS += -arch $(RBARCH)
68 endif
70 all: $(BINARY)
72 OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(SOURCES))))
73 LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES))))
75 # additional link dependencies for the standalone executable
76 # extra dependencies: libucl
77 LIBUCL = libucl$(RBARCH).a
78 $(LIBUCL): $(OBJDIR)$(LIBUCL)
80 $(OBJDIR)$(LIBUCL):
81 $(SILENT)$(MAKE) -C $(TOP)/../tools/ucl/src TARGET_DIR=$(OBJDIR) $@
83 # building the standalone executable
84 $(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
85 @echo LD $@
86 # $(SILENT)mkdir -p $(dir $@)
87 # EXTRADEPS need to be built into OBJDIR.
88 $(SILENT)$(CROSS)$(CC) $(CFLAGS) $(LDOPTS) -o $(BINARY) \
89 $(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) \
90 $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
92 # common rules
93 $(OBJDIR)%.o: %.c
94 @echo CC $<
95 $(SILENT)mkdir -p $(dir $@)
96 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -c -o $@ $<
98 # lib rules
99 lib$(OUTPUT)$(RBARCH).a: $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a
100 lib$(OUTPUT)$(RBARCH): $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a
102 $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) \
103 $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
104 # rules to build a DLL. Only works for W32 as target (i.e. MinGW toolchain)
105 dll: $(OUTPUT).dll
106 $(OUTPUT).dll: $(TARGET_DIR)$(OUTPUT).dll
107 $(TARGET_DIR)$(OUTPUT).dll: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
108 @echo DLL $(notdir $@)
109 $(SILENT)mkdir -p $(dir $@)
110 $(SILENT)$(CROSS)$(CC) $(CFLAGS) -shared -o $@ $^ \
111 -Wl,--output-def,$(TARGET_DIR)$(OUTPUT).def
113 # create lib file from objects
114 $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
115 @echo AR $(notdir $@)
116 $(SILENT)mkdir -p $(dir $@)
117 $(SILENT)$(AR) rcs $@ $^
119 clean:
120 rm -f $(OBJS) $(OUTPUT) $(TARGET_DIR)lib$(OUTPUT)*.a $(OUTPUT).dmg
121 rm -rf $(OUTPUT)-* i386 ppc $(OBJDIR)
123 # OS X specifics
124 $(OUTPUT).dmg: $(OUTPUT)
125 @echo DMG $@
126 $(SILENT)mkdir -p $(OUTPUT)-dmg
127 $(SILENT)cp -p $(OUTPUT) $(OUTPUT)-dmg
128 $(SILENT)hdiutil create -srcfolder $(OUTPUT)-dmg $@