2019-04-21 02:06:31 +00:00
|
|
|
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
SERENITY_BASE_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
|
|
|
|
|
2019-12-24 21:40:42 +00:00
|
|
|
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
|
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
INCLUDE_FLAGS += \
|
2019-07-18 08:15:00 +00:00
|
|
|
-I. \
|
2019-12-18 23:35:46 +00:00
|
|
|
-I$(SERENITY_BASE_DIR)/DevTools \
|
2019-07-18 08:15:00 +00:00
|
|
|
-I$(SERENITY_BASE_DIR) \
|
|
|
|
-I$(SERENITY_BASE_DIR)/Libraries \
|
2019-12-18 23:35:46 +00:00
|
|
|
-I$(SERENITY_BASE_DIR)/Servers
|
2019-07-18 08:15:00 +00:00
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
VERBOSE = 0
|
|
|
|
|
|
|
|
ifneq ($(HOST_CXX),)
|
2019-12-25 16:06:37 +00:00
|
|
|
ifeq '' '$(findstring clang++,$(CXX))'
|
|
|
|
C_WARNING_FLAGS += -Wno-unknown-warning-option
|
|
|
|
CXX_WARNING_FLAGS += -Wno-unknown-warning-option
|
|
|
|
endif
|
2019-12-20 19:11:20 +00:00
|
|
|
CXX = $(PRE_CXX) g++
|
2019-12-18 23:35:46 +00:00
|
|
|
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++
|
2019-12-24 21:40:42 +00:00
|
|
|
CC = $(PRE_CC) $(TOOLCHAIN_PATH)/i686-pc-serenity-gcc
|
2019-12-18 23:35:46 +00:00
|
|
|
AS = $(TOOLCHAIN_PATH)/i686-pc-serenity-as
|
|
|
|
LINK = $(TOOLCHAIN_PATH)/i686-pc-serenity-ld
|
2019-12-25 16:05:37 +00:00
|
|
|
RANLIB = $(TOOLCHAIN_PATH)/i686-pc-serenity-ranlib
|
|
|
|
AR = $(TOOLCHAIN_PATH)/i686-pc-serenity-ar
|
2019-12-28 03:53:57 +00:00
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
DEFINES += -DDEBUG
|
|
|
|
|
|
|
|
INCLUDE_FLAGS += \
|
|
|
|
-I$(SERENITY_BASE_DIR)/Libraries/LibC \
|
2019-12-20 20:06:26 +00:00
|
|
|
-I$(SERENITY_BASE_DIR)/Libraries/LibM \
|
|
|
|
-I$(SERENITY_BASE_DIR)/Libraries/LibPthread
|
2019-12-18 23:35:46 +00:00
|
|
|
|
|
|
|
ifdef KERNEL
|
|
|
|
DEFINES += -DKERNEL
|
2019-12-25 02:36:04 +00:00
|
|
|
else
|
|
|
|
# everything else gets -lc -lm
|
2019-12-28 03:53:57 +00:00
|
|
|
LIB_DEPS := C M $(LIB_DEPS)
|
2019-12-18 23:35:46 +00:00
|
|
|
endif
|
|
|
|
|
2019-12-25 02:36:04 +00:00
|
|
|
# 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)
|
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
OBJ_SUFFIX ?=
|
|
|
|
endif
|
|
|
|
|
|
|
|
#CXX = clang $(CLANG_FLAGS)
|
|
|
|
#CLANG_FLAGS = -Wconsumed -m32 -ffreestanding -march=i686
|
|
|
|
|
2019-12-25 02:36:04 +00:00
|
|
|
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)
|
2019-04-21 02:06:31 +00:00
|
|
|
|
2019-12-20 21:35:49 +00:00
|
|
|
DEFINES += -DSANITIZE_PTRS
|
2019-08-03 17:41:02 +00:00
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
SUFFIXED_OBJS = $(patsubst %.o,%$(OBJ_SUFFIX).o,$(OBJS))
|
|
|
|
|
|
|
|
ifeq ($(VERBOSE),1)
|
|
|
|
QUIET =
|
|
|
|
else
|
|
|
|
QUIET = @
|
|
|
|
endif
|
|
|
|
|
|
|
|
-include $(SUFFIXED_OBJS:%.o=%.d)
|
|
|
|
|
2020-01-01 19:20:30 +00:00
|
|
|
.SUFFIXES:
|
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
%$(OBJ_SUFFIX).o: %.cpp $(EXTRA_SOURCES)
|
2020-01-01 19:20:30 +00:00
|
|
|
@echo "$(notdir $(CURDIR)): C++ $@"
|
2019-12-18 23:35:46 +00:00
|
|
|
$(QUIET) $(CXX) $(CXXFLAGS) -o $@ -c $<
|
|
|
|
|
2019-12-24 21:40:42 +00:00
|
|
|
%$(OBJ_SUFFIX).o: %.c
|
2020-01-01 19:20:30 +00:00
|
|
|
@echo "$(notdir $(CURDIR)): C $@"
|
2019-12-24 21:40:42 +00:00
|
|
|
$(QUIET) $(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
%.ao: %.S
|
2020-01-01 19:20:30 +00:00
|
|
|
@echo "$(notdir $(CURDIR)): AS $@"
|
2019-12-18 23:35:46 +00:00
|
|
|
$(QUIET) $(AS) -o $@ $<
|
|
|
|
|
2019-12-25 12:34:20 +00:00
|
|
|
$(PROGRAM): $(STATIC_LIB_DEPS) $(SUFFIXED_OBJS) $(EXTRA_OBJS)
|
2020-01-01 19:20:30 +00:00
|
|
|
@echo "$(notdir $(CURDIR)): LINK $(PROGRAM)"
|
2019-12-18 23:35:46 +00:00
|
|
|
$(QUIET) $(CXX) -o $(PROGRAM) $(EXTRA_OBJS) $(SUFFIXED_OBJS) $(LDFLAGS)
|
|
|
|
|
|
|
|
$(LIBRARY): $(SUFFIXED_OBJS) $(EXTRA_OBJS)
|
2020-01-01 19:20:30 +00:00
|
|
|
@echo "$(notdir $(CURDIR)): LIB $@"
|
2019-12-18 23:35:46 +00:00
|
|
|
$(QUIET) $(AR) rcs $@ $(OBJS) $(EXTRA_OBJS) $(LIBS)
|
2019-12-28 05:50:39 +00:00
|
|
|
$(POST_LIBRARY_BUILD)
|
2019-12-18 23:35:46 +00:00
|
|
|
|
2019-12-28 05:50:39 +00:00
|
|
|
#.PHONY: $(STATIC_LIB_DEPS)
|
2019-12-25 02:36:04 +00:00
|
|
|
$(STATIC_LIB_DEPS):
|
2019-12-28 05:50:39 +00:00
|
|
|
@flock $(dir $(@)) $(MAKE) -C $(dir $(@))
|
2019-12-25 02:36:04 +00:00
|
|
|
|
|
|
|
IPCCOMPILER = $(SERENITY_BASE_DIR)/DevTools/IPCCompiler/IPCCompiler
|
|
|
|
IPCCOMPILER: $(IPCCOMPILER)
|
|
|
|
$(IPCCOMPILER):
|
2019-12-28 05:50:39 +00:00
|
|
|
@flock $(dir $(@)) $(MAKE) -C $(dir $(@))
|
2019-12-25 02:36:04 +00:00
|
|
|
|
|
|
|
FORMCOMPILER = $(SERENITY_BASE_DIR)/DevTools/FormCompiler/FormCompiler
|
|
|
|
FORMCOMPILER: $(FORMCOMPILER)
|
|
|
|
$(FORMCOMPILER):
|
2019-12-28 05:50:39 +00:00
|
|
|
@flock $(dir $(@)) $(MAKE) -C $(dir $(@))
|
2019-12-25 02:36:04 +00:00
|
|
|
|
2019-12-18 23:35:46 +00:00
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
|
|
|
|
all: $(PROGRAM) $(LIBRARY)
|
|
|
|
|
|
|
|
EXTRA_CLEAN ?=
|
|
|
|
|
|
|
|
clean:
|
2020-01-01 19:20:30 +00:00
|
|
|
@echo "$(notdir $(CURDIR)): CLEAN"
|
2019-12-18 23:35:46 +00:00
|
|
|
$(QUIET) rm -f $(PROGRAM) $(LIBRARY) $(SUFFIXED_OBJS) $(EXTRA_OBJS) *.d $(EXTRA_CLEAN)
|
|
|
|
|
|
|
|
install:
|
|
|
|
|
2019-12-25 02:36:04 +00:00
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
|
2019-12-23 12:23:37 +00:00
|
|
|
.PHONY: all clean install
|