diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2023-07-26 00:41:55 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2023-07-26 00:56:47 +0200 |
commit | 066faa2d96f4ee4ec9351c3c8c0452639ba5f709 (patch) | |
tree | 5d89dd230c32f5fcb3870639be052b566199d52d | |
parent | 592ca59384dee2601deac54376405681b923a024 (diff) |
Improved local dep building.
* generate static libs with ar
* libcrt, libcxxrt, libusercrt
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | Makefile.deps | 96 | ||||
-rw-r--r-- | Makefile.inc | 45 | ||||
-rw-r--r-- | Makefile.native.inc | 12 |
5 files changed, 111 insertions, 51 deletions
@@ -1,9 +1,7 @@ /include /codesign-* +/CRT-build/ +/CRT-native-build/ /EASTL-build/ /EASTL-native-build/ /mingw-w64-sysroot/ -/*.o -/*.opp -/CRT/*.o -/CRT/*.opp @@ -44,6 +44,9 @@ deps-clean: $(MAKE) -C $(DPP_ROOT) -f Makefile.deps clean $(MAKE) -C $(DPP_ROOT) BUILD_NATIVE=1 -f Makefile.deps clean +package: + $(MAKE) -C $(DPP_ROOT) -f Makefile.deps package + help: $(MAKE) -C $(DPP_ROOT) -f Makefile.deps help diff --git a/Makefile.deps b/Makefile.deps index 0d08d6b..9f382a3 100644 --- a/Makefile.deps +++ b/Makefile.deps @@ -16,25 +16,58 @@ else include Makefile.native.inc endif +EASTL_DEPS := $(wildcard $(DPP_ROOT)/EASTL/source/*.cpp) $(wildcard $(DPP_ROOT)/EASTL/include/EASTL/*.h) +EASTL_STATIC_LIB := $(DPP_ROOT)/$(EASTL_BUILDDIR)/libEASTL.a + +LIBUSERCRT_OBJECTS := $(LIBCRT_BUILD_DIR)/ucrt$(NAME_SUFFIX).opp +LIBUSERCRT_STATIC_LIB := $(LIBCRT_BUILD_DIR)/libusercrt.a + all: deps -$(DPP_ROOT)/CRT/kcrt$(NAME_SUFFIX).o: $(CC) $(DPP_ROOT)/CRT/kcrt.c +$(LIBCRT_BUILD_DIR): + $(Q)mkdir -p '$(LIBCRT_BUILD_DIR)' + +$(LIBCRT_STATIC_LIB): $(LIBCRT_BUILD_DIR) $(LIBCRT_OBJECTS) +ifneq ($(Q),@) + $(Q)$(AR) -rsv '$@' $(LIBCRT_OBJECTS) +else + $(Q)$(AR) -rs '$@' $(LIBCRT_OBJECTS) 2>/dev/null >/dev/null +endif + @echo 'AR $@' + +$(LIBCXXRT_STATIC_LIB): $(LIBCRT_BUILD_DIR) $(LIBCXXRT_OBJECTS) +ifneq ($(Q),@) + $(Q)$(AR) -rsv '$@' $(LIBCXXRT_OBJECTS) +else + $(Q)$(AR) -rs '$@' $(LIBCXXRT_OBJECTS) 2>/dev/null >/dev/null +endif + @echo 'AR $@' + +$(LIBUSERCRT_STATIC_LIB): $(LIBCRT_BUILD_DIR) $(LIBUSERCRT_OBJECTS) +ifneq ($(Q),@) + $(Q)$(AR) -rsv '$@' $(LIBUSERCRT_OBJECTS) +else + $(Q)$(AR) -rs '$@' $(LIBUSERCRT_OBJECTS) 2>/dev/null >/dev/null +endif + @echo 'AR $@' + +$(LIBCRT_BUILD_DIR)/kcrt$(NAME_SUFFIX).o: $(CC) $(DPP_ROOT)/CRT/kcrt.c $(Q)$(CC) -std=c99 $(CFLAGS) -c CRT/kcrt.c -o $@ @echo 'CC $@' -$(DPP_ROOT)/CRT/ntdll_zw_functions$(NAME_SUFFIX).o: $(CC) $(DPP_ROOT)/CRT/ntdll_zw_functions.c +$(LIBCRT_BUILD_DIR)/ntdll_zw_functions$(NAME_SUFFIX).o: $(CC) $(DPP_ROOT)/CRT/ntdll_zw_functions.c $(Q)$(CC) -std=c99 $(CFLAGS) -c CRT/ntdll_zw_functions.c -o $@ @echo 'CC $@' -$(DPP_ROOT)/CRT/kcrt$(NAME_SUFFIX).opp: $(CXX) $(DPP_ROOT)/CRT/kcrt.cpp +$(LIBCRT_BUILD_DIR)/kcrt$(NAME_SUFFIX).opp: $(CXX) $(DPP_ROOT)/CRT/kcrt.cpp $(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) $(EASTL_CXXFLAGS) -c CRT/kcrt.cpp -o $@ @echo 'CXX $@' -$(DPP_ROOT)/CRT/ucrt$(NAME_SUFFIX).opp: $(CXX) $(DPP_ROOT)/CRT/ucrt.cpp +$(LIBCRT_BUILD_DIR)/ucrt$(NAME_SUFFIX).opp: $(CXX) $(DPP_ROOT)/CRT/ucrt.cpp $(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) $(EASTL_CXXFLAGS) -c CRT/ucrt.cpp -o $@ @echo 'CXX $@' -$(DPP_ROOT)/CRT/DriverThread$(NAME_SUFFIX).opp: $(CXX) $(DPP_ROOT)/CRT/DriverThread.cpp $(DPP_ROOT)/CRT/DriverThread.hpp +$(LIBCRT_BUILD_DIR)/DriverThread$(NAME_SUFFIX).opp: $(CXX) $(DPP_ROOT)/CRT/DriverThread.cpp $(DPP_ROOT)/CRT/DriverThread.hpp $(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) $(EASTL_CXXFLAGS) -c CRT/DriverThread.cpp -o $@ @echo 'CXX $@' @@ -100,10 +133,9 @@ deps-build: \ $(LOCAL_MINGW64_BUILD_SCRIPT) \ $(LOCAL_MINGW64_CC) \ $(EASTL_STATIC_LIB) \ - $(DRIVER_ADDITIONAL_OBJS) \ - $(DRIVER_CRT) \ - $(DRIVER_CRTPLUSPLUS) \ - $(USER_CRT) \ + $(LIBCRT_STATIC_LIB) \ + $(LIBCXXRT_STATIC_LIB) \ + $(LIBUSERCRT_STATIC_LIB) \ $(SIGNTOOL_PREFIX) deps: deps-print-local-notice deps-build @@ -124,21 +156,35 @@ $(SIGNTOOL_PREFIX)-code.p12: $(SIGNTOOL_PREFIX): $(SIGNTOOL_PREFIX)-code.p12 +package-mingw: deps + @echo 'Adding mingw build directories..' + tar --owner=0 --group=0 --no-same-owner --no-same-permissions \ + --no-acls --no-selinux --no-xattrs \ + --mtime ./Makefile.deps -rf mingw-w64-dpp.tar $(patsubst $(DPP_ROOT)/%,%,$(EASTL_STATIC_LIB)) \ + --transform 's,^,mingw-w64-dpp/,' + tar --owner=0 --group=0 --no-same-owner --no-same-permissions \ + --no-acls --no-selinux --no-xattrs \ + --mtime ./Makefile.deps -rf mingw-w64-dpp.tar $(patsubst $(DPP_ROOT)/%,%,$(LIBCRT_BUILD_DIR)) \ + --transform 's,^,mingw-w64-dpp/,' + tar --owner=0 --group=0 --no-same-owner --no-same-permissions \ + --no-acls --no-selinux --no-xattrs \ + --mtime ./Makefile.deps -rf mingw-w64-dpp.tar $(SYSROOT) \ + --transform 's,^,mingw-w64-dpp/,' + distclean: clean rm -f $(SIGNTOOL_PREFIX)-ca-* $(SIGNTOOL_PREFIX)-code* rm -rf $(LOCAL_MINGW64_BUILD_DIR) git submodule deinit --all clean: - rm -f $(DRIVER_CRT) $(DRIVER_CRTPLUSPLUS) $(USER_CRT) $(EASTL_STATIC_LIB) - rm -f $(DRIVER_ADDITIONAL_OBJS) - rm -rf $(EASTL_BUILDDIR) + rm -f $(LIBCRT_STATIC_LIB) $(LIBCXXRT_STATIC_LIB) $(LIBUSERCRT_STATIC_LIB) $(EASTL_STATIC_LIB) + rm -rf $(LIBCRT_BUILD_DIR) $(EASTL_BUILDDIR) else deps-build: \ $(EASTL_STATIC_LIB) \ - $(USER_CRT) + $(LIBUSERCRT_STATIC_LIB) deps: deps-build @@ -152,14 +198,32 @@ $(EASTL_STATIC_LIB): $(CXX) $(EASTL_DEPS) -DCMAKE_CXX_FLAGS='$(CFLAGS) $(CXXFLAGS) $(EASTL_CXXFLAGS)' && \ $(MAKE) $(CMAKE_Q) +package-native: deps + @echo 'Adding native build directories..' + tar --owner=0 --group=0 --no-same-owner --no-same-permissions \ + --no-acls --no-selinux --no-xattrs \ + --mtime ./Makefile.deps -rf mingw-w64-dpp.tar $(patsubst $(DPP_ROOT)/%,%,$(EASTL_STATIC_LIB)) \ + --transform 's,^,mingw-w64-dpp/,' + tar --owner=0 --group=0 --no-same-owner --no-same-permissions \ + --no-acls --no-selinux --no-xattrs \ + --mtime ./Makefile.deps -rf mingw-w64-dpp.tar $(patsubst $(DPP_ROOT)/%,%,$(LIBCRT_BUILD_DIR)) \ + --transform 's,^,mingw-w64-dpp/,' + distclean: clean clean: - rm -f $(USER_CRT) $(EASTL_STATIC_LIB) - rm -rf $(EASTL_BUILDDIR) + rm -f $(LIBUSERCRT_STATIC_LIB) $(EASTL_STATIC_LIB) + rm -rf $(LIBCRT_BUILD_DIR) $(EASTL_BUILDDIR) endif +package: + @echo 'Creating package containing repository sources and binary mingw64 toolchain..' + git archive --prefix 'mingw-w64-dpp/' -o mingw-w64-dpp.tar HEAD + $(MAKE) -C $(DPP_ROOT) -f Makefile.deps package-mingw + $(MAKE) -C $(DPP_ROOT) -f Makefile.deps BUILD_NATIVE=1 package-native + bzip2 -c mingw-w64-dpp.tar >mingw-w64-dpp.tar.bz2 + help: @echo '[Makefile.deps]' $(call HELP_MAKE_OPTIONS) @@ -167,5 +231,5 @@ help: @echo -e '\tWERROR = $(WERROR)' @echo -e '\tQ = $(Q)' -.PHONY: all deps-print-local-notice deps-build deps distclean clean help +.PHONY: all deps-print-local-notice deps-build deps package distclean clean help .DEFAULT_GOAL := all diff --git a/Makefile.inc b/Makefile.inc index c426576..d66de36 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -84,21 +84,17 @@ DRIVER_LIBS := -lntoskrnl -lhal USER_LDFLAGS := -Wl,--dynamicbase -Wl,--nxcompat -Wl,--gc-sections USER_LIBS := -DRIVER_ADDITIONAL_DEPS := $(DPP_ROOT)/CRT/DriverThread.cpp $(DPP_ROOT)/CRT/DriverThread.hpp -DRIVER_ADDITIONAL_OBJS := $(DPP_ROOT)/CRT/DriverThread$(NAME_SUFFIX).opp - -EASTL_DEPS := $(wildcard $(DPP_ROOT)/EASTL/source/*.cpp) $(wildcard $(DPP_ROOT)/EASTL/include/EASTL/*.h) EASTL_BUILDDIR := EASTL-build -EASTL_STATIC_LIB := $(DPP_ROOT)/$(EASTL_BUILDDIR)/libEASTL.a - -DRIVER_CRT_DEPS := $(DPP_ROOT)/CRT/kcrt.c $(DPP_ROOT)/CRT/ntdll_zw_functions.c -DRIVER_CRT := $(DPP_ROOT)/CRT/kcrt$(NAME_SUFFIX).o $(DPP_ROOT)/CRT/ntdll_zw_functions$(NAME_SUFFIX).o -DRIVER_CRTPLUSPLUS_DEPS := $(DPP_ROOT)/CRT/kcrt.cpp $(DPP_ROOT)/CRT/kcrt.c $(DPP_ROOT)/CRT/ntdll_zw_functions.c -DRIVER_CRTPLUSPLUS := $(DPP_ROOT)/CRT/kcrt$(NAME_SUFFIX).opp $(DPP_ROOT)/CRT/kcrt$(NAME_SUFFIX).o $(DPP_ROOT)/CRT/ntdll_zw_functions$(NAME_SUFFIX).o - -USER_CRT_DEPS := $(DPP_ROOT)/CRT/ucrt.cpp -USER_CRT := $(DPP_ROOT)/CRT/ucrt$(NAME_SUFFIX).opp +LIBCRT_BUILD_DIR := $(DPP_ROOT)/CRT-build +LIBCRT_OBJECTS := \ + $(LIBCRT_BUILD_DIR)/kcrt$(NAME_SUFFIX).o \ + $(LIBCRT_BUILD_DIR)/ntdll_zw_functions$(NAME_SUFFIX).o +LIBCXXRT_OBJECTS := \ + $(LIBCRT_BUILD_DIR)/kcrt$(NAME_SUFFIX).opp \ + $(LIBCRT_BUILD_DIR)/DriverThread$(NAME_SUFFIX).opp +LIBCRT_STATIC_LIB := $(LIBCRT_BUILD_DIR)/libcrt.a +LIBCXXRT_STATIC_LIB := $(LIBCRT_BUILD_DIR)/libcxxrt.a is_set = \ $(if $1,, \ @@ -113,11 +109,10 @@ define CHECK_REQUIRED_PATHS $(call path_exists,$(CXX)) $(call path_exists,$(RC)) $(call path_exists,$(DDK_INCLUDE_DIR)) - $(call path_exists,$(DRIVER_ADDITIONAL_OBJS)) $(call path_exists,$(EASTL_STATIC_LIB)) - $(call path_exists,$(DRIVER_CRT)) - $(call path_exists,$(DRIVER_CRTPLUSPLUS)) - $(call path_exists,$(USER_CRT)) + $(call path_exists,$(LIBCRT_STATIC_LIB)) + $(call path_exists,$(LIBCXXRT_STATIC_LIB)) + $(call path_exists,$(LIBUSERCRT_STATIC_LIB)) endef define BUILD_C_OBJECT @@ -146,7 +141,7 @@ define LINK_C_KERNEL_TARGET -Wl,-Map='$(2).map' \ -o '$(2)' \ $(1) \ - $(DRIVER_CRT) \ + $(LIBCRT_STATIC_LIB) \ $(DRIVER_LIBS) \ $(LDFLAGS_$(2)) @echo 'LD $(2)' @@ -161,7 +156,7 @@ define LINK_C_USER_TARGET -o '$(2)' \ $(1) \ $(EASTL_STATIC_LIB) \ - $(USER_LIBS) \ + $(LIBUSERCRT_STATIC_LIB) \ $(LDFLAGS_$(2)) @echo 'LD $(2)' endef @@ -178,9 +173,9 @@ define LINK_CPP_KERNEL_TARGET -Wl,-Map='$(2).map' \ -o '$(2)' \ $(1) \ - $(DRIVER_ADDITIONAL_OBJS) \ - $(DRIVER_CRTPLUSPLUS) \ $(EASTL_STATIC_LIB) \ + $(LIBCRT_STATIC_LIB) \ + $(LIBCXXRT_STATIC_LIB) \ $(DRIVER_LIBS) \ $(LDFLAGS_$(2)) @echo 'LD $(2)' @@ -197,8 +192,8 @@ define LINK_CPP_USER_TARGET $(USER_LDFLAGS) \ -o '$(2)' \ $(1) \ - $(USER_CRT) \ $(EASTL_STATIC_LIB) \ + $(LIBUSERCRT_STATIC_LIB) \ $(USER_LIBS) \ $(LDFLAGS_$(2)) @echo 'LD $(2)' @@ -245,7 +240,7 @@ define INSTALL_HEADERS done endef -ifneq ($(LOCAL_MINGW64_AR),) +ifneq ($(AR),) define PACKAGE $(call is_set,$(1),First argument: Library name missing) $(call is_set,$(2),Second argument: Object files missing) @@ -254,6 +249,10 @@ define PACKAGE $(AR) -rsv '$(3)/lib/lib$(1).a' $(2) tar --no-acls --no-selinux --no-xattrs --transform 's,^$(3),deps,' -cvjf '$(1).dpp' '$(3)' endef +else +define PACKAGE + $(error The tool AR is required for this operation.) +endef endif define HELP_MAKE_OPTIONS diff --git a/Makefile.native.inc b/Makefile.native.inc index 6c07789..39af860 100644 --- a/Makefile.native.inc +++ b/Makefile.native.inc @@ -36,12 +36,8 @@ EASTL_CXXFLAGS := -I$(DPP_ROOT)/EASTL/include -I$(DPP_ROOT)/EASTL/test/packages/ -Wno-deprecated-copy USER_LDFLAGS := -Wl,--gc-sections -EASTL_DEPS := $(wildcard $(DPP_ROOT)/EASTL/source/*.cpp) $(wildcard $(DPP_ROOT)/EASTL/include/EASTL/*.h) EASTL_BUILDDIR := EASTL-native-build -EASTL_STATIC_LIB := $(DPP_ROOT)/$(EASTL_BUILDDIR)/libEASTL.a - -USER_CRT_DEPS := $(DPP_ROOT)/CRT/ucrt.cpp -USER_CRT := $(DPP_ROOT)/CRT/ucrt$(NAME_SUFFIX).opp +LIBCRT_BUILD_DIR := $(DPP_ROOT)/CRT-native-build is_set = \ $(if $1,, \ @@ -55,7 +51,7 @@ define CHECK_REQUIRED_PATHS $(call path_exists,$(CC)) $(call path_exists,$(CXX)) $(call path_exists,$(EASTL_STATIC_LIB)) - $(call path_exists,$(USER_CRT)) + $(call path_exists,$(LIBUSERCRT_STATIC_LIB)) endef define BUILD_C_OBJECT @@ -105,8 +101,8 @@ define LINK_CPP_USER_TARGET $(USER_LDFLAGS) \ -o '$(2)' \ $(1) \ - $(USER_CRT) \ - $(EASTL_STATIC_LIB) + $(EASTL_STATIC_LIB) \ + $(LIBUSERCRT_STATIC_LIB) @echo 'LD $(2)' endef |