|
| 1 | +# Minimal build steps that produce libdcsctp.a |
| 2 | +# Copyright (C) 2025 |
| 3 | +# Author: Thomas Fitzsimmons <fitzsim@fitzsim.org> |
| 4 | +# Version: 1 |
| 5 | +# SPDX-License-Identifier: Apache-2.0 |
| 6 | +# "gn" has no support for ppc64le. This Makefile can be used in place of "gn" |
| 7 | +# and "ninja" to build libdcsctp.a on non-"gn" architectures. The Makefile was |
| 8 | +# written from scratch starting from the assumption that all non-test net/dcsctp |
| 9 | +# .cc files were needed by libdcsctp4j.so. Runtime testing of Jitsi confirms |
| 10 | +# that the resulting libdcsctp.a satisfies libdcsctp4j.so's needs on ppc64le. |
| 11 | +S := $(VPATH) |
| 12 | +DEBUG ?= -O2 |
| 13 | +# Add GCC-compatible flags extracted from "ninja -v" output for x86-64 target. |
| 14 | +CXXFLAGS += -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 |
| 15 | +CXXFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 |
| 16 | +CXXFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE |
| 17 | +CXXFLAGS += -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE |
| 18 | +CXXFLAGS += -D_GLIBCXX_ASSERTIONS=1 |
| 19 | +CXXFLAGS += -DNDEBUG -DNVALGRIND |
| 20 | +CXXFLAGS += -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DWEBRTC_ENABLE_PROTOBUF=1 |
| 21 | +CXXFLAGS += -DWEBRTC_STRICT_FIELD_TRIALS=0 |
| 22 | +CXXFLAGS += -DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE -DRTC_ENABLE_VP9 |
| 23 | +CXXFLAGS += -DRTC_DAV1D_IN_INTERNAL_DECODER_FACTORY -DWEBRTC_HAVE_SCTP |
| 24 | +CXXFLAGS += -DWEBRTC_ENABLE_LIBEVENT -DWEBRTC_LIBRARY_IMPL -DWEBRTC_ENABLE_AVX2 |
| 25 | +CXXFLAGS += -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1 -DWEBRTC_POSIX |
| 26 | +CXXFLAGS += -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -Wall -Wextra |
| 27 | +CXXFLAGS += -Wimplicit-fallthrough -Wextra-semi -Wno-missing-field-initializers |
| 28 | +CXXFLAGS += -Wno-unused-parameter -Wno-psabi -Wno-cast-function-type |
| 29 | +CXXFLAGS += -Wno-invalid-offsetof -Wshadow -Werror |
| 30 | +CXXFLAGS += -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing |
| 31 | +CXXFLAGS += -fstack-protector -funwind-tables -fPIC -pthread |
| 32 | +CXXFLAGS += -fmerge-all-constants -ffp-contract=off -m64 |
| 33 | +CXXFLAGS += -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= |
| 34 | +CXXFLAGS += -D__TIMESTAMP__= -no-canonical-prefixes |
| 35 | +CXXFLAGS += $(DEBUG) -fdata-sections |
| 36 | +CXXFLAGS += -ffunction-sections -fno-math-errno -fno-omit-frame-pointer |
| 37 | +CXXFLAGS += -gdwarf-4 -g2 -ggnu-pubnames -fvisibility=hidden -Wno-shadow |
| 38 | +CXXFLAGS += -Wundef -std=c++17 -Wno-trigraphs |
| 39 | +CXXFLAGS += -fno-exceptions -fno-rtti |
| 40 | +CXXFLAGS += -fvisibility-inlines-hidden -Wnon-virtual-dtor -Woverloaded-virtual |
| 41 | +# Silence GCC 12 warnings. |
| 42 | +CXXFLAGS += -Wno-return-type -Wno-overloaded-virtual -Wno-comment -Wno-undef |
| 43 | +CXXFLAGS += -Wno-redundant-move |
| 44 | +# Add include paths to fix compilation errors due to missing headers. |
| 45 | +CXXFLAGS += -I$(S) |
| 46 | +CXXFLAGS += -I$(S)/third_party/abseil-cpp |
| 47 | +CXXFLAGS += -I$(S)/third_party/crc32c/config |
| 48 | +CXXFLAGS += -I$(S)/third_party/crc32c/src/include |
| 49 | +# Assume all non-test .cc files under net/dcsctp are needed by libdcsctp4j.so. |
| 50 | +# "gn/ninja" includes 37 extra objects but they are not needed by |
| 51 | +# libdcsctp4j.so. |
| 52 | +TESTS = $(shell find $(S)/net/dcsctp -name "*_test*.cc") |
| 53 | +SOURCES = $(shell find $(S)/net/dcsctp -name "*.cc") |
| 54 | +OBJECTS = $(patsubst %.cc,%.o,$(filter-out $(TESTS),$(SOURCES))) |
| 55 | +# Assume all source files are in subdirectories and subsubdirectories of |
| 56 | +# net/dcsctp. |
| 57 | +DIRS = $(shell find $(S) -maxdepth 5 -type d -print) |
| 58 | +# Add other objects required to fix libdcsctp4j.so errors; first compilation |
| 59 | +# errors, then undefined symbol errors reported at runtime by the dynamic |
| 60 | +# linker. |
| 61 | +OBJECTS += $(S)/api/units/time_delta.o |
| 62 | +OBJECTS += $(S)/rtc_base/checks.o |
| 63 | +OBJECTS += $(S)/rtc_base/logging.o |
| 64 | +OBJECTS += $(S)/rtc_base/platform_thread_types.o |
| 65 | +OBJECTS += $(S)/rtc_base/string_encode.o |
| 66 | +OBJECTS += $(S)/rtc_base/string_utils.o |
| 67 | +OBJECTS += $(S)/rtc_base/strings/string_builder.o |
| 68 | +OBJECTS += $(S)/rtc_base/strings/string_format.o |
| 69 | +OBJECTS += $(S)/rtc_base/system_time.o |
| 70 | +OBJECTS += $(S)/rtc_base/time_utils.o |
| 71 | +OBJECTS += $(S)/third_party/abseil-cpp/absl/base/internal/raw_logging.o |
| 72 | +OBJECTS += $(S)/third_party/abseil-cpp/absl/types/bad_variant_access.o |
| 73 | +OBJECTS += $(S)/third_party/crc32c/src/src/crc32c.o |
| 74 | +OBJECTS += $(S)/third_party/crc32c/src/src/crc32c_portable.o |
| 75 | +# Keep built object paths separate from source code paths. |
| 76 | +ifeq ($(strip $(OBJDIR)),) |
| 77 | +$(error "Set OBJDIR to absolute path in which to store output objects") |
| 78 | +endif |
| 79 | +OBJECTS := $(addprefix $(OBJDIR)/,$(OBJECTS)) |
| 80 | +OBJDIRS := $(addprefix $(OBJDIR)/,$(DIRS)) |
| 81 | +ifneq ($(strip $(VERBOSE)),1) |
| 82 | +SILENT := @ |
| 83 | +endif |
| 84 | +$(OBJDIR)/%.o: %.cc |
| 85 | + @echo CXX $@ |
| 86 | + $(SILENT)$(CXX) $(CXXFLAGS) -c $< -o $@ |
| 87 | +$(OBJDIR)/libdcsctp.a: $(OBJECTS) |
| 88 | + @echo AR $@ |
| 89 | + $(SILENT)$(AR) $(ARFLAGS) $@ $^ |
| 90 | +$(OBJECTS): | $(OBJDIRS) |
| 91 | +$(OBJDIRS): |
| 92 | + @mkdir -p $@ |
0 commit comments