ladybird/Makefile.common

159 lines
4.6 KiB
Text
Raw Normal View History

MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
SERENITY_BASE_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
CXX_STANDARD_FLAGS = -std=c++2a
2019-12-24 21:40:42 +00:00
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)/Services
VERBOSE = 0
UNAME_S := $(shell uname -s)
ifneq ($(USE_HOST_CXX),)
ifeq ($(UNAME_S),OpenBSD)
HOST_CXX ?= clang++
endif
ifeq '' '$(findstring clang++,$(CXX))'
C_WARNING_FLAGS += -Wno-unknown-warning-option
CXX_WARNING_FLAGS += -Wno-unknown-warning-option
endif
ifeq ($(HOST_CXX),)
2020-04-13 19:22:06 +00:00
CXX = $(PRE_CXX) c++
else
CXX = $(HOST_CXX)
endif
AS = as
LINK = ld
OBJ_SUFFIX ?= .host
ARCH = $(shell arch -s)
else
ifeq ($(UNAME_S),SerenityOS)
TOOLCHAIN_PREFIX =
else
TOOLCHAIN_PATH = $(SERENITY_BASE_DIR)/Toolchain/Local/bin
TOOLCHAIN_PREFIX = $(TOOLCHAIN_PATH)/i686-pc-serenity-
endif
CXX = $(PRE_CXX) $(TOOLCHAIN_PREFIX)g++
CC = $(PRE_CC) $(TOOLCHAIN_PREFIX)gcc
AS = $(TOOLCHAIN_PREFIX)as
LINK = $(TOOLCHAIN_PREFIX)ld
RANLIB = $(TOOLCHAIN_PREFIX)ranlib
AR = $(TOOLCHAIN_PREFIX)ar
ARCH = i386
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 ifdef BOOTSTRAPPER
DEFINES += -DBOOTSTRAPPER
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)
2019-12-24 21:40:42 +00:00
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)
.SUFFIXES:
%$(OBJ_SUFFIX).o: %.cpp $(EXTRA_SOURCES)
@echo "$(notdir $(CURDIR)): C++ $@"
$(QUIET) $(CXX) $(CXXFLAGS) -o $@ -c $<
2019-12-24 21:40:42 +00:00
%$(OBJ_SUFFIX).o: %.c
@echo "$(notdir $(CURDIR)): C $@"
2019-12-24 21:40:42 +00:00
$(QUIET) $(CC) $(CFLAGS) -o $@ -c $<
%.ao: %.S
@echo "$(notdir $(CURDIR)): AS $@"
$(QUIET) $(AS) -o $@ $<
$(PROGRAM): $(STATIC_LIB_DEPS) $(SUFFIXED_OBJS) $(EXTRA_OBJS)
@echo "$(notdir $(CURDIR)): LINK $(PROGRAM)"
$(QUIET) $(CXX) -o $(PROGRAM) $(EXTRA_OBJS) $(SUFFIXED_OBJS) $(LDFLAGS)
$(LIBRARY): $(SUFFIXED_OBJS) $(EXTRA_OBJS)
@echo "$(notdir $(CURDIR)): 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 "$(notdir $(CURDIR)): CLEAN"
$(QUIET) rm -f $(PROGRAM) $(LIBRARY) $(SUFFIXED_OBJS) $(EXTRA_OBJS) $(patsubst %.o,%.d,$(SUFFIXED_OBJS) $(EXTRA_OBJS)) $(EXTRA_CLEAN)
install:
.DELETE_ON_ERROR:
.PHONY: all clean install