mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
0b501335f5
Lock each directory before entering it so when using -j, the same dependency isn't built more than once at a time. This doesn't get full -j parallelism though, since one make child will be sitting idle waiting for flock to receive its lock and continue making (which should then do nothing since it will have been built already). Unfortunately there's not much that can be done to fix that since it can't proceed until its dependency is built by another make process.
136 lines
4.1 KiB
Text
136 lines
4.1 KiB
Text
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
SERENITY_BASE_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
|
|
|
|
CXX_STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation -fno-sized-deallocation
|
|
CXX_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
|
|
CXX_FLAVOR_FLAGS = -fno-exceptions -fno-rtti -fstack-protector
|
|
#CXX_SUGGEST_FLAGS = -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override #-Wsuggest-attribute=noreturn
|
|
|
|
C_STANDARD_FLAGS =
|
|
C_WARNING_FLAGS = -Werror -Wextra -Wall -Wno-nonnull-compare -Wno-address-of-packed-member -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-expansion-to-defined
|
|
C_FLAVOR_FLAGS = -fstack-protector
|
|
|
|
ARCH_FLAGS =
|
|
OPTIMIZATION_FLAGS = -Os
|
|
|
|
INCLUDE_FLAGS += \
|
|
-I. \
|
|
-I$(SERENITY_BASE_DIR)/DevTools \
|
|
-I$(SERENITY_BASE_DIR) \
|
|
-I$(SERENITY_BASE_DIR)/Libraries \
|
|
-I$(SERENITY_BASE_DIR)/Servers
|
|
|
|
VERBOSE = 0
|
|
|
|
ifneq ($(HOST_CXX),)
|
|
ifeq '' '$(findstring clang++,$(CXX))'
|
|
C_WARNING_FLAGS += -Wno-unknown-warning-option
|
|
CXX_WARNING_FLAGS += -Wno-unknown-warning-option
|
|
endif
|
|
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++
|
|
CC = $(PRE_CC) $(TOOLCHAIN_PATH)/i686-pc-serenity-gcc
|
|
AS = $(TOOLCHAIN_PATH)/i686-pc-serenity-as
|
|
LINK = $(TOOLCHAIN_PATH)/i686-pc-serenity-ld
|
|
RANLIB = $(TOOLCHAIN_PATH)/i686-pc-serenity-ranlib
|
|
AR = $(TOOLCHAIN_PATH)/i686-pc-serenity-ar
|
|
|
|
DEFINES += -DDEBUG
|
|
|
|
INCLUDE_FLAGS += \
|
|
-I$(SERENITY_BASE_DIR)/Libraries/LibC \
|
|
-I$(SERENITY_BASE_DIR)/Libraries/LibM \
|
|
-I$(SERENITY_BASE_DIR)/Libraries/LibPthread
|
|
|
|
ifdef KERNEL
|
|
DEFINES += -DKERNEL
|
|
else
|
|
# everything else gets -lc -lm
|
|
LIB_DEPS := C M $(LIB_DEPS)
|
|
endif
|
|
|
|
# turn "LIB_DEPS=C Core Thread" into "-lc -lcore -lthread -L.../LibC ..."
|
|
LDFLAGS += $(foreach lib,$(LIB_DEPS),\
|
|
-l$(shell echo $(lib) | tr A-Z a-z))
|
|
LDFLAGS += $(foreach lib,$(LIB_DEPS),\
|
|
-L$(SERENITY_BASE_DIR)/Libraries/Lib$(lib))
|
|
|
|
STATIC_LIB_DEPS = $(foreach lib,$(LIB_DEPS),\
|
|
$(SERENITY_BASE_DIR)/Libraries/Lib$(lib)/lib$(shell echo $(lib) | tr A-Z a-z).a)
|
|
|
|
OBJ_SUFFIX ?=
|
|
endif
|
|
|
|
#CXX = clang $(CLANG_FLAGS)
|
|
#CLANG_FLAGS = -Wconsumed -m32 -ffreestanding -march=i686
|
|
|
|
CXXFLAGS = -MMD -MP $(CXX_WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(CXX_FLAVOR_FLAGS) $(ARCH_FLAGS) $(CXX_STANDARD_FLAGS) $(CXX_SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) $(SUBPROJECT_CXXFLAGS)
|
|
CFLAGS = -MMD -MP $(C_FLAVOR_FLAGS) $(ARCH_FLAGS) $(C_STANDARD_FLAGS) $(C_SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) $(SUBPROJECT_CXXFLAGS)
|
|
|
|
DEFINES += -DSANITIZE_PTRS
|
|
|
|
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 "C++ $@"
|
|
$(QUIET) $(CXX) $(CXXFLAGS) -o $@ -c $<
|
|
|
|
%$(OBJ_SUFFIX).o: %.c
|
|
@echo "C $@"
|
|
$(QUIET) $(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
%.ao: %.S
|
|
@echo "AS $@"
|
|
$(QUIET) $(AS) -o $@ $<
|
|
|
|
$(PROGRAM): $(STATIC_LIB_DEPS) $(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)
|
|
$(POST_LIBRARY_BUILD)
|
|
|
|
#.PHONY: $(STATIC_LIB_DEPS)
|
|
$(STATIC_LIB_DEPS):
|
|
@flock $(dir $(@)) $(MAKE) -C $(dir $(@))
|
|
|
|
IPCCOMPILER = $(SERENITY_BASE_DIR)/DevTools/IPCCompiler/IPCCompiler
|
|
IPCCOMPILER: $(IPCCOMPILER)
|
|
$(IPCCOMPILER):
|
|
@flock $(dir $(@)) $(MAKE) -C $(dir $(@))
|
|
|
|
FORMCOMPILER = $(SERENITY_BASE_DIR)/DevTools/FormCompiler/FormCompiler
|
|
FORMCOMPILER: $(FORMCOMPILER)
|
|
$(FORMCOMPILER):
|
|
@flock $(dir $(@)) $(MAKE) -C $(dir $(@))
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
all: $(PROGRAM) $(LIBRARY)
|
|
|
|
EXTRA_CLEAN ?=
|
|
|
|
clean:
|
|
@echo "CLEAN"
|
|
$(QUIET) rm -f $(PROGRAM) $(LIBRARY) $(SUFFIXED_OBJS) $(EXTRA_OBJS) *.d $(EXTRA_CLEAN)
|
|
|
|
install:
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
.PHONY: all clean install
|