blob: b4c5cba18cbddb0944fe7476edd83e50162b246c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
ARCH_FLAGS =
STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation -fno-sized-deallocation
WARNING_FLAGS = -Werror -Wextra -Wall -Wno-nonnull-compare -Wno-deprecated-copy -Wno-address-of-packed-member -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-expansion-to-defined
FLAVOR_FLAGS = -fno-exceptions -fno-rtti -fstack-protector
OPTIMIZATION_FLAGS = -Os
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
SERENITY_BASE_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
INCLUDE_FLAGS += \
-I. \
-I$(SERENITY_BASE_DIR)/DevTools \
-I$(SERENITY_BASE_DIR) \
-I$(SERENITY_BASE_DIR)/Libraries \
-I$(SERENITY_BASE_DIR)/Servers
LDFLAGS += \
-L$(SERENITY_BASE_DIR)/Libraries/LibC \
-L$(SERENITY_BASE_DIR)/Libraries/LibPthread \
-L$(SERENITY_BASE_DIR)/Libraries/LibCore \
-L$(SERENITY_BASE_DIR)/Libraries/LibIPC \
-L$(SERENITY_BASE_DIR)/Libraries/LibM \
-L$(SERENITY_BASE_DIR)/Libraries/LibDraw \
-L$(SERENITY_BASE_DIR)/Libraries/LibGUI \
-L$(SERENITY_BASE_DIR)/Libraries/LibHTML \
-L$(SERENITY_BASE_DIR)/Libraries/LibMarkdown \
-L$(SERENITY_BASE_DIR)/Libraries/LibThread \
-L$(SERENITY_BASE_DIR)/Libraries/LibVT \
-L$(SERENITY_BASE_DIR)/Libraries/LibPCIDB \
-L$(SERENITY_BASE_DIR)/Libraries/LibProtocol \
-L$(SERENITY_BASE_DIR)/Libraries/LibAudio
VERBOSE = 0
ifneq ($(HOST_CXX),)
CXX = $(PRE_CXX) g++
AS = as
LINK = ld
OBJ_SUFFIX ?= .host
else
TOOLCHAIN_PATH = $(SERENITY_BASE_DIR)/Toolchain/Local/bin
CXX = $(PRE_CXX) $(TOOLCHAIN_PATH)/i686-pc-serenity-g++
AS = $(TOOLCHAIN_PATH)/i686-pc-serenity-as
LINK = $(TOOLCHAIN_PATH)/i686-pc-serenity-ld
DEFINES += -DDEBUG
INCLUDE_FLAGS += \
-I$(SERENITY_BASE_DIR)/Libraries/LibC \
-I$(SERENITY_BASE_DIR)/Libraries/LibM \
-I$(SERENITY_BASE_DIR)/Libraries/LibPthread
LDFLAGS += \
-L$(SERENITY_BASE_DIR)/Libraries/LibC
ifdef KERNEL
DEFINES += -DKERNEL
endif
OBJ_SUFFIX ?=
endif
#CXX = clang $(CLANG_FLAGS)
#CLANG_FLAGS = -Wconsumed -m32 -ffreestanding -march=i686
#SUGGEST_FLAGS = -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override #-Wsuggest-attribute=noreturn
CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) $(SUBPROJECT_CXXFLAGS)
DEFINES += -DSANITIZE_PTRS
IPCCOMPILER = $(SERENITY_BASE_DIR)/DevTools/IPCCompiler/IPCCompiler
SUFFIXED_OBJS = $(patsubst %.o,%$(OBJ_SUFFIX).o,$(OBJS))
ifeq ($(VERBOSE),1)
QUIET =
else
QUIET = @
endif
-include $(SUFFIXED_OBJS:%.o=%.d)
%$(OBJ_SUFFIX).o: %.cpp $(EXTRA_SOURCES)
@echo "CPP $@"
$(QUIET) $(CXX) $(CXXFLAGS) -o $@ -c $<
%.ao: %.S
@echo "AS $@"
$(QUIET) $(AS) -o $@ $<
$(PROGRAM): $(SUFFIXED_OBJS) $(EXTRA_OBJS)
@echo "LINK $(PROGRAM)"
$(QUIET) $(CXX) -o $(PROGRAM) $(EXTRA_OBJS) $(SUFFIXED_OBJS) $(LDFLAGS)
$(LIBRARY): $(SUFFIXED_OBJS) $(EXTRA_OBJS)
@echo "LIB $@"
$(QUIET) $(AR) rcs $@ $(OBJS) $(EXTRA_OBJS) $(LIBS)
.DEFAULT_GOAL := all
all: $(PROGRAM) $(LIBRARY)
EXTRA_CLEAN ?=
clean:
@echo "CLEAN"
$(QUIET) rm -f $(PROGRAM) $(LIBRARY) $(SUFFIXED_OBJS) $(EXTRA_OBJS) *.d $(EXTRA_CLEAN)
install:
.PHONY: all clean
|