Implement recursive mutex
[helenos.git] / boot / Makefile.build
blob653331657c9f109775e436d2393ff5ecec66e1da
2 # Copyright (c) 2006 Martin Decky
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
9 # - Redistributions of source code must retain the above copyright
10 #   notice, this list of conditions and the following disclaimer.
11 # - Redistributions in binary form must reproduce the above copyright
12 #   notice, this list of conditions and the following disclaimer in the
13 #   documentation and/or other materials provided with the distribution.
14 # - The name of the author may not be used to endorse or promote products
15 #   derived from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 .PHONY: all clean depend
31 include Makefile.common
33 INCLUDES = -Igeneric/include -Iarch/$(KARCH)/include -Igenarch/include -I$(ROOT_PATH)/abi/include
34 OPTIMIZATION = 3
36 DEFS = -DBOOT -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
38 AFLAGS =
39 LFLAGS = --fatal-warnings --warn-common
41 # FIXME: This condition is a workaround for issue #693.
42 ifneq ($(BARCH),mips32)
43         AFLAGS += --fatal-warnings
44 endif
46 COMMON_CFLAGS = $(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
47         -ffreestanding -fno-builtin -nostdlib -nostdinc \
48         -fexec-charset=UTF-8 -finput-charset=UTF-8 -fno-common \
49         -fdebug-prefix-map=$(realpath $(ROOT_PATH))=.
51 GCC_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
52         -std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
53         -pipe
55 CLANG_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
56         -Werror-implicit-function-declaration -Wwrite-strings \
57         -pipe  -fno-stack-protector -fno-PIC
59 ifeq ($(CONFIG_DEBUG),y)
60         COMMON_CFLAGS += -Werror
61 endif
63 ifeq ($(CONFIG_LINE_DEBUG),y)
64         COMMON_CFLAGS += -g
65 endif
67 ifeq ($(COMPILER),clang)
68         CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
69 else
70         CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS) $(EXTRA_CFLAGS)
71 endif
73 OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
74 DEPENDS := $(addsuffix .d,$(basename $(SOURCES)))
76 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BOOT_OUTPUT)
78 clean:
79         rm -f $(RAW) $(MAP)
81 -include $(DEPENDS)
83 AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS))
85 $(BOOT_OUTPUT): $(RAW)
86         $(OBJCOPY) -O $(BFD_OUTPUT) $< $@
88 $(RAW): $(OBJECTS) $(LINK)
89         $(LD) -n $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@ $(OBJECTS)
91 $(LINK): | depend
92         $(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $(LINK).in | grep -v "^\#" > $(LINK)
94 %.o: %.S | depend
95         $(CC) -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
96 ifeq ($(PRECHECK),y)
97         $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
98 endif
100 %.o: %.c | depend
101         $(CC) -MD $(DEFS) $(CFLAGS) -c $< -o $@
102 ifeq ($(PRECHECK),y)
103         $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
104 endif
106 %.o: %.s | depend
107         $(CC) -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@
108 ifeq ($(PRECHECK),y)
109         $(JOBFILE) $(JOB) $< $@ as asm
110 endif
112 depend: $(PRE_DEPEND)
114 $(COMPS).s: $(COMPS).zip
115         unzip -p $< $@ > $@
117 $(COMPS).h: $(COMPS).zip
118         unzip -p $< $@ > $@
120 $(COMPS)_desc.c: $(COMPS).zip
121         unzip -p $< $@ > $@
123 $(COMPONENTS_DEFLATE): $(COMPS).zip
124         unzip -p $< $@ > $@
126 $(COMPS).zip: $(COMPONENTS)
127         $(MKARRAY) --deflate $(COMPS) $(COMP) "$(AS_PROLOG)" ".section .components, \"a\"" $^
129 include Makefile.initrd