summaryrefslogtreecommitdiff
path: root/rbutil/libtools.make
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/libtools.make')
-rw-r--r--rbutil/libtools.make25
1 files changed, 9 insertions, 16 deletions
diff --git a/rbutil/libtools.make b/rbutil/libtools.make
index 7a125f98ea..c107e69bfd 100644
--- a/rbutil/libtools.make
+++ b/rbutil/libtools.make
@@ -37,8 +37,6 @@ TARGET_DIR ?= $(abspath .)/
37NATIVECC ?= gcc 37NATIVECC ?= gcc
38CC ?= gcc 38CC ?= gcc
39CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -) 39CPPDEFINES := $(shell echo foo | $(CROSS)$(CC) -dM -E -)
40# use POSIX/C99 printf on windows
41CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
42 40
43BINARY = $(OUTPUT) 41BINARY = $(OUTPUT)
44# when building a Windows binary add the correct file suffix 42# when building a Windows binary add the correct file suffix
@@ -50,6 +48,8 @@ else
50ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW) 48ifeq ($(findstring MINGW,$(CPPDEFINES)),MINGW)
51BINARY = $(OUTPUT).exe 49BINARY = $(OUTPUT).exe
52COMPILETARGET = mingw 50COMPILETARGET = mingw
51# use POSIX/C99 printf on windows
52CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
53else 53else
54ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE) 54ifeq ($(findstring APPLE,$(CPPDEFINES)),APPLE)
55COMPILETARGET = darwin 55COMPILETARGET = darwin
@@ -79,16 +79,9 @@ CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
79NATIVECC = gcc-4.0 79NATIVECC = gcc-4.0
80endif 80endif
81endif 81endif
82WINDRES = windres
83 82
84BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET) 83BUILD_DIR ?= $(TARGET_DIR)build$(COMPILETARGET)
85
86ifdef RBARCH
87ARCHFLAGS += -arch $(RBARCH)
88OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/
89else
90OBJDIR = $(abspath $(BUILD_DIR))/ 84OBJDIR = $(abspath $(BUILD_DIR))/
91endif
92 85
93all: $(BINARY) 86all: $(BINARY)
94 87
@@ -103,20 +96,20 @@ DEPS = $(addprefix $(OBJDIR),$(subst .c,.d,$(notdir $(SOURCES) $(LIBSOURCES))))
103 96
104# additional link dependencies for the standalone executable 97# additional link dependencies for the standalone executable
105# extra dependencies: libucl 98# extra dependencies: libucl
106LIBUCL = libucl$(RBARCH).a 99LIBUCL = libucl.a
107$(LIBUCL): $(OBJDIR)$(LIBUCL) 100$(LIBUCL): $(OBJDIR)$(LIBUCL)
108 101
109$(OBJDIR)$(LIBUCL): 102$(OBJDIR)$(LIBUCL):
110 $(SILENT)$(MAKE) -C $(TOP)/../tools/ucl/src TARGET_DIR=$(OBJDIR) $@ 103 $(SILENT)$(MAKE) -C $(TOP)/../tools/ucl/src TARGET_DIR=$(OBJDIR) $@
111 104
112# building the standalone executable 105# building the standalone executable
113$(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) 106$(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(TARGET_DIR)lib$(OUTPUT).a
114 @echo LD $@ 107 @echo LD $@
115 $(SILENT)$(call mkdir,$(dir $@)) 108 $(SILENT)$(call mkdir,$(dir $@))
116# EXTRADEPS need to be built into OBJDIR. 109# EXTRADEPS need to be built into OBJDIR.
117 $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -o $(BINARY) \ 110 $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -o $(BINARY) \
118 $(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) \ 111 $(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) \
119 $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) $(LDOPTS) 112 $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) lib$(OUTPUT).a $(addprefix $(OBJDIR),$(EXTRADEPS)) $(LDOPTS)
120 113
121# common rules 114# common rules
122$(OBJDIR)%.o: 115$(OBJDIR)%.o:
@@ -125,10 +118,10 @@ $(OBJDIR)%.o:
125 $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -c -o $@ $< 118 $(SILENT)$(CROSS)$(CC) $(ARCHFLAGS) $(CFLAGS) -c -o $@ $<
126 119
127# lib rules 120# lib rules
128lib$(OUTPUT)$(RBARCH).a: $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a 121lib$(OUTPUT).a: $(TARGET_DIR)lib$(OUTPUT).a
129lib$(OUTPUT)$(RBARCH): $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a 122lib$(OUTPUT): $(TARGET_DIR)lib$(OUTPUT).a
130 123
131$(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) \ 124$(TARGET_DIR)lib$(OUTPUT).a: $(LIBOBJS) \
132 $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) 125 $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
133# rules to build a DLL. Only works for W32 as target (i.e. MinGW toolchain) 126# rules to build a DLL. Only works for W32 as target (i.e. MinGW toolchain)
134dll: $(OUTPUT).dll 127dll: $(OUTPUT).dll
@@ -140,7 +133,7 @@ $(TARGET_DIR)$(OUTPUT).dll: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
140 -Wl,--output-def,$(TARGET_DIR)$(OUTPUT).def 133 -Wl,--output-def,$(TARGET_DIR)$(OUTPUT).def
141 134
142# create lib file from objects 135# create lib file from objects
143$(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) 136$(TARGET_DIR)lib$(OUTPUT).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS))
144 @echo AR $(notdir $@) 137 @echo AR $(notdir $@)
145 $(SILENT)$(call mkdir,$(dir $@)) 138 $(SILENT)$(call mkdir,$(dir $@))
146 $(SILENT)$(call rm,$@) 139 $(SILENT)$(call rm,$@)