Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ ifeq ($(with_openssl), yes)
endif
ifeq ($(enable_pax), yes)
$(MAKE) -C contrib/pax_storage all
endif
ifeq ($(enable_ic_udp2),yes)
$(MAKE) -C contrib/udp2 all
endif
$(MAKE) -C gpMgmt all
$(MAKE) -C gpcontrib all
Expand Down Expand Up @@ -81,6 +84,9 @@ ifeq ($(enable_pax), yes)
endif
ifeq ($(with_openssl), yes)
$(MAKE) -C contrib/sslinfo $@
endif
ifeq ($(enable_ic_udp2),yes)
$(MAKE) -C contrib/udp2 $@
endif
$(MAKE) -C gpMgmt $@
$(MAKE) -C gpcontrib $@
Expand Down
35 changes: 35 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ PROTOBUF_LIBS
PROTOBUF_CFLAGS
enable_preload_ic_module
enable_ic_proxy
enable_ic_udp2
enable_external_fts
HAVE_CXX14
enable_gpcloud
Expand Down Expand Up @@ -909,6 +910,7 @@ enable_shared_postgres_backend
enable_link_postgres_with_shared
enable_gpcloud
enable_external_fts
enable_ic_udp2
enable_ic_proxy
enable_preload_ic_module
enable_pax
Expand Down Expand Up @@ -1629,6 +1631,7 @@ Optional Features:
libpostgres.so
--enable-gpcloud enable gpcloud support
--enable-external-fts enable external fts support
--enable-ic-udp2 enable interconnect udp2 implement
--enable-ic-proxy enable interconnect proxy mode (requires libuv
library)
--disable-preload-ic-module
Expand Down Expand Up @@ -9181,6 +9184,38 @@ $as_echo "#define USE_INTERNAL_FTS 1" >>confdefs.h
CFLAGS="$CFLAGS -DUSE_INTERNAL_FTS=1"
fi

#
# ic-udp2
#


# Check whether --enable-ic-udp2 was given.
if test "${enable_ic_udp2+set}" = set; then :
enableval=$enable_ic_udp2;
case $enableval in
yes)

$as_echo "#define ENABLE_IC_UDP2 1" >>confdefs.h

;;
no)
:
;;
*)
as_fn_error $? "no argument expected for --enable-ic-udp2 option" "$LINENO" 5
;;
esac

else
enable_ic_udp2=no

fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with interconnect udp2 support ... $enable_ic_udp2" >&5
$as_echo "checking whether to build with interconnect udp2 support ... $enable_ic_udp2" >&6; }


#
# ic-proxy
#
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,16 @@ if test "$enable_external_fts" = no; then
CFLAGS="$CFLAGS -DUSE_INTERNAL_FTS=1"
fi

#
# ic-udp2
#
PGAC_ARG_BOOL(enable, ic-udp2, no,
[enable interconnect udp2 implement],
[AC_DEFINE(ENABLE_IC_UDP2, 1,
[Define to 1 to build with interconnect udp2 support (--enable-ic-udp2)])])
AC_MSG_RESULT([checking whether to build with interconnect udp2 support ... $enable_ic_udp2])
AC_SUBST(enable_ic_udp2)

#
# ic-proxy
#
Expand Down
6 changes: 6 additions & 0 deletions contrib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ else
ALWAYS_SUBDIRS += pax_storage
endif

ifeq ($(enable_ic_udp2),yes)
SUBDIRS += udp2
else
ALWAYS_SUBDIRS += udp2
endif

# Missing:
# start-scripts \ (does not have a makefile)

Expand Down
111 changes: 111 additions & 0 deletions contrib/udp2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 3.11.0)
project(udp2)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Get the top-level project directory
set(TOP_DIR ${PROJECT_SOURCE_DIR}/../..)
set(CBDB_INCLUDE_DIR ${TOP_DIR}/src/include)

# CMAKE_INSTALL_PREFIX should be set by the calling Makefile
# If not set, we'll use a reasonable default but warn about it
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
message(WARNING "CMAKE_INSTALL_PREFIX not set by parent build system, using default")
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install prefix" FORCE)
endif()

# Check for debug/release configuration from main project
include(CheckSymbolExists)
set(PG_CONFIG_HEADER_FILE "${CBDB_INCLUDE_DIR}/pg_config.h")
if(EXISTS "${PG_CONFIG_HEADER_FILE}")
CHECK_SYMBOL_EXISTS(USE_ASSERT_CHECKING "${PG_CONFIG_HEADER_FILE}" UDP2_USE_DEBUG)
if(UDP2_USE_DEBUG)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Debug' based on main project configuration")
else()
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Release' based on main project configuration")
endif()
else()
# Fallback to Release if pg_config.h is not found
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
message(STATUS "Setting default CMAKE_BUILD_TYPE to 'Release'")
endif()
endif()

# First, build and install ic_common as a subdirectory
add_subdirectory(ic_common)

# Set up include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_INSTALL_PREFIX}/include/postgresql/)
include_directories(${CMAKE_INSTALL_PREFIX}/include/postgresql/udp2/)
include_directories(${CBDB_INCLUDE_DIR})
include_directories(${CBDB_INCLUDE_DIR}/server)

# Set up library directories
link_directories(${CMAKE_INSTALL_PREFIX}/lib/postgresql/)

# Source files for udp2 module
set(UDP2_SOURCES
ic_udp2.c
ic_modules.c
)

# Create the udp2 shared library
add_library(udp2 SHARED ${UDP2_SOURCES})

# Set compiler flags consistent with main project
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv")

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -ggdb")
message(STATUS "Building udp2 in Debug mode")
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -DNDEBUG")
message(STATUS "Building udp2 in Release mode")
endif()

# Link against ic_common library
target_link_libraries(udp2 ic_common)

# Make sure ic_common is built before udp2
add_dependencies(udp2 ic_common)

# Set output name and remove lib prefix
set_target_properties(udp2 PROPERTIES
OUTPUT_NAME "udp2"
PREFIX ""
)

# Install the udp2 library
install(TARGETS udp2
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/postgresql/"
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/postgresql/"
)

# Install udp2 headers
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/ic_udp2.h"
"${CMAKE_CURRENT_SOURCE_DIR}/ic_modules.h"
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/postgresql/"
)
70 changes: 70 additions & 0 deletions contrib/udp2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# contrib/udp2/Makefile

top_builddir = ../..

# Include the standard PostgreSQL build system to get variables like prefix, DESTDIR, etc.
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/udp2
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

# Use CMake for building this module
CMAKE_BUILD_DIR = build

# Default target
all: $(CMAKE_BUILD_DIR)/udp2.so

# Create build directory and configure with CMake
$(CMAKE_BUILD_DIR)/Makefile:
@echo "Configuring udp2 with CMake..."
@mkdir -p $(CMAKE_BUILD_DIR)
@cd $(CMAKE_BUILD_DIR) && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) ..

# Build the project using CMake
$(CMAKE_BUILD_DIR)/udp2.so: $(CMAKE_BUILD_DIR)/Makefile
@echo "Building udp2 with CMake..."
@cd $(CMAKE_BUILD_DIR) && $(MAKE)
@cp $(CMAKE_BUILD_DIR)/udp2.so udp2.so

# Install target
install: $(CMAKE_BUILD_DIR)/udp2.so
@echo "Installing udp2..."
@cd $(CMAKE_BUILD_DIR) && $(MAKE) install

# Clean target
clean:
@echo "Cleaning udp2..."
@rm -rf $(CMAKE_BUILD_DIR)
@rm -f udp2.so

# Ensure ic_common is built first
ic_common:
@echo "Building ic_common..."
@mkdir -p ic_common/build
@cd ic_common/build && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) .. && $(MAKE) && $(MAKE) install

# Make sure ic_common is built before udp2
$(CMAKE_BUILD_DIR)/udp2.so: ic_common

.PHONY: all install clean ic_common
Loading
Loading