source: mainline/uspace/Makefile.common@ 46b60e6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 46b60e6 was 79ae36dd, checked in by Martin Decky <martin@…>, 14 years ago

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
  • Property mode set to 100644
File size: 9.3 KB
Line 
1#
2# Copyright (c) 2005 Martin Decky
3# Copyright (c) 2007 Jakub Jermar
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# - Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# - Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
15# - The name of the author may not be used to endorse or promote products
16# derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
30# Individual makefiles set:
31#
32# USPACE_PREFIX (*) relative path to uspace/ directory
33# SOURCES (*) list of source files
34# LIBS libraries to link with
35# DEFS compiler defines
36# EXTRA_CFLAGS additional flags to pass to C compiler
37# LINKER_SCRIPT linker script
38# PRE_DEPEND targets required for dependency check
39#
40# BINARY (/) binary output name (like appname)
41# LIBRARY (/) library output name (like libname)
42#
43# EXTRA_OUTPUT additional output targets
44# EXTRA_CLEAN additional cleanup targets
45#
46# Optionally, for a binary:
47# STATIC_NEEDED set to 'y' for init binaries, will build statically
48# linked version
49# STATIC_ONLY set to 'y' if binary cannot be linked dynamically
50# (e.g. uses thread-local variables)
51#
52# Optionally, for a libary:
53# SLIBRARY Name with full version, e.g. libfoo.so.0.0
54# LSONAME Soname / name with short version, e.g. libfoo.so.0
55#
56# (x) required variables
57# (/) exactly one of the variables must be defined
58#
59
60ROOT_PATH = $(USPACE_PREFIX)/..
61
62VERSION_DEF = $(ROOT_PATH)/version
63
64COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
65COMMON_HEADER = $(ROOT_PATH)/common.h
66
67CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
68CONFIG_HEADER = $(ROOT_PATH)/config.h
69
70-include $(VERSION_DEF)
71-include $(COMMON_MAKEFILE)
72-include $(CONFIG_MAKEFILE)
73
74ifneq ($(BINARY),)
75 JOB = $(BINARY).job
76 OUTPUT = $(BINARY)
77 EXTRA_OUTPUT += $(BINARY).disasm
78 EXTRA_CLEAN += $(BINARY).map
79endif
80
81ifneq ($(LIBRARY),)
82 JOB = $(LIBRARY).job
83 OUTPUT = $(LIBRARY).a
84endif
85
86ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
87 ifneq ($(SLIBRARY),)
88 LARCHIVE = $(LIBRARY).la
89 LOUTPUT = $(SLIBRARY)
90 EXTRA_OUTPUT += $(LOUTPUT).disasm $(LIBRARY).so $(LSONAME)
91 EXTRA_CLEAN += $(LOUTPUT).map $(LOUTPUT).ldisasm \
92 $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld \
93 $(LIBRARY).so $(LSONAME)
94 endif
95endif
96
97DEPEND = Makefile.depend
98DEPEND_PREV = $(DEPEND).prev
99
100LIB_PREFIX = $(USPACE_PREFIX)/lib
101
102LIBC_PREFIX = $(LIB_PREFIX)/c
103LIBSOFTFLOAT_PREFIX = $(LIB_PREFIX)/softfloat
104LIBSOFTINT_PREFIX = $(LIB_PREFIX)/softint
105
106LIBBLOCK_PREFIX = $(LIB_PREFIX)/block
107LIBFS_PREFIX = $(LIB_PREFIX)/fs
108LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
109
110LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2
111
112LIBUSB_PREFIX = $(LIB_PREFIX)/usb
113LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost
114LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev
115LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid
116LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt
117
118LIBDRV_PREFIX = $(LIB_PREFIX)/drv
119LIBPACKET_PREFIX = $(LIB_PREFIX)/packet
120LIBNET_PREFIX = $(LIB_PREFIX)/net
121
122ifeq ($(STATIC_NEEDED),y)
123 STATIC_BUILD = y
124else
125 ifeq ($(STATIC_ONLY),y)
126 STATIC_BUILD = y
127 else
128 ifeq ($(CONFIG_USE_SHARED_LIBS), y)
129 STATIC_BUILD = n
130 else
131 STATIC_BUILD = y
132 endif
133 endif
134endif
135
136# Build static whenever we use libusb because that library uses
137# thread local variables
138ifneq ($(findstring usb, $(LIBS)),)
139 STATIC_BUILD = y
140endif
141
142ifeq ($(STATIC_BUILD), y)
143BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
144LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
145else
146BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0
147LFLAGS = -Bdynamic
148LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
149endif
150
151ifeq ($(CONFIG_OPTIMIZE_FOR_SIZE),y)
152 OPTIMIZATION = s
153else
154 OPTIMIZATION = 3
155endif
156
157.PHONY: all clean
158
159all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT)
160 -[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
161
162clean:
163 rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(LARCHIVE) $(LOUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN)
164 find . -name '*.o' -follow -exec rm \{\} \;
165 find . -name '*.lo' -follow -exec rm \{\} \;
166
167GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
168 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
169 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
170 -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
171 -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
172 -pipe -g -D__$(ENDIANESS)__
173
174ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
175 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
176 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
177 -Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
178 -Werror-implicit-function-declaration -Wwrite-strings \
179 -pipe -g -D__$(ENDIANESS)__
180
181CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
182 -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
183 -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
184 -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
185 -Werror-implicit-function-declaration -Wwrite-strings \
186 -pipe -g -arch $(CLANG_ARCH) -D__$(ENDIANESS)__
187
188LIB_CFLAGS = $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
189LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive
190
191ifeq ($(CONFIG_DEBUG),y)
192 GCC_CFLAGS += -Werror
193 ICC_CFLAGS += -Werror
194endif
195
196ifeq ($(CONFIG_LINE_DEBUG),y)
197 GCC_CFLAGS += -g
198 ICC_CFLAGS += -g
199 SUNCC_CFLAGS += -g
200 CLANG_CFLAGS += -g
201endif
202
203## Setup platform configuration
204#
205
206-include $(LIBC_PREFIX)/arch/$(UARCH)/Makefile.common
207
208## Compilation options
209#
210
211JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
212
213ifeq ($(COMPILER),gcc_cross)
214 CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
215 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
216endif
217
218ifeq ($(COMPILER),gcc_native)
219 CFLAGS = $(GCC_CFLAGS) $(EXTRA_CFLAGS)
220 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
221endif
222
223ifeq ($(COMPILER),icc)
224 CFLAGS = $(ICC_CFLAGS) $(EXTRA_CFLAGS)
225 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
226endif
227
228ifeq ($(COMPILER),clang)
229 CFLAGS = $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
230 DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
231endif
232
233-include $(DEPEND)
234
235OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
236LOBJECTS := $(addsuffix .lo,$(basename $(SOURCES)))
237
238ifneq ($(BINARY),)
239%.disasm: $(BINARY)
240ifeq ($(CONFIG_LINE_DEBUG),y)
241 $(OBJDUMP) -d -S $< > $@
242else
243 $(OBJDUMP) -d $< > $@
244endif
245
246$(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBS) $(BASE_LIBS)
247 $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(BINARY).map -o $(BINARY) $(OBJECTS) $(LIBS) $(BASE_LIBS)
248ifeq ($(CONFIG_STRIP_BINARIES),y)
249 $(STRIP) $(BINARY)
250endif
251endif
252
253ifneq ($(SLIBRARY),)
254%.disasm: $(LOUTPUT)
255ifeq ($(CONFIG_LINE_DEBUG),y)
256 $(OBJDUMP) -d -S $< > $@
257else
258 $(OBJDUMP) -d $< > $@
259endif
260
261$(LOUTPUT): $(LARCHIVE) $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld
262 $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld $(LIB_LFLAGS) $(LARCHIVE) -o $@ -Map $(LOUTPUT).map
263
264$(LIBRARY).so:
265 ln -s $(SLIBRARY) $@
266
267$(LSONAME):
268 ln -s $(SLIBRARY) $@
269endif
270
271ifneq ($(LIBRARY),)
272%.a: $(OBJECTS)
273 $(AR) rc $@ $(OBJECTS)
274endif
275
276ifneq ($(SLIBRARY),)
277%.la: $(LOBJECTS)
278 $(AR) rc $@ $(LOBJECTS)
279endif
280
281%.o: %.S $(DEPEND)
282 $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
283ifeq ($(PRECHECK),y)
284 $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
285endif
286
287%.o: %.s $(DEPEND)
288 $(AS) $(AFLAGS) -o $@ $<
289ifeq ($(PRECHECK),y)
290 $(JOBFILE) $(JOB) $< $@ as asm
291endif
292
293%.o: %.c $(DEPEND)
294 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@
295ifeq ($(PRECHECK),y)
296 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
297endif
298
299%.lo: %.S $(DEPEND)
300 $(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
301ifeq ($(PRECHECK),y)
302 $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
303endif
304
305%.lo: %.s $(DEPEND)
306 $(AS) $(AFLAGS) -o $@ $<
307ifeq ($(PRECHECK),y)
308 $(JOBFILE) $(JOB) $< $@ as asm
309endif
310
311%.lo: %.c $(DEPEND)
312 $(CC) $(DEFS) $(LIB_CFLAGS) -c $< -o $@
313ifeq ($(PRECHECK),y)
314 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
315endif
316
317$(DEPEND): $(PRE_DEPEND)
318 makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
319 -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
320
321##
322# This explicit dependecy of the output binary on the object files seems to be
323# necessary to prevent parallel build failures (GNU make bug #26893 ???).
324$(OUTPUT): $(OBJECTS)
325
326$(LARCHIVE): $(LOBJECTS)
Note: See TracBrowser for help on using the repository browser.