@@ -9,6 +9,9 @@ AC_PREFIX_DEFAULT(/usr)
if test "${CFLAGS+set}" != "set"; then
CFLAGS="-g -O2 -std=gnu11"
fi
+if test "${CXXFLAGS+set}" != "set"; then
+ CXXFLAGS="-g -O2 -std=gnu++11"
+fi
AC_PROG_INSTALL
LT_INIT
@@ -31,6 +34,9 @@ if test "${BUILD_CFLAGS+set}" != "set"; then
fi
fi
+AC_PROG_CXX
+# no C++ build tools yet
+
AC_ARG_ENABLE(shared,
[ --enable-shared=[yes/no] Enable use of shared libraries [default=yes]],,
enable_shared=yes)
@@ -14,6 +14,7 @@ MALLOCLIB = @malloc_lib@
LOADERFLAGS = @LDFLAGS@
LTLDFLAGS = @LDFLAGS@
CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wno-address-of-packed-member
+CXXFLAGS = @CXXFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wno-address-of-packed-member
BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
# make sure we don't pick up whacky LDFLAGS from the make environment and
@@ -63,6 +64,7 @@ XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_STAMP=$(PKG_STATE_DIR)/xfs_scrub_all_media.stamp
CC = @cc@
BUILD_CC = @BUILD_CC@
+CXX = @cxx@
AWK = @awk@
SED = @sed@
TAR = @tar@
@@ -161,9 +163,15 @@ ifeq ($(ENABLE_GETTEXT),yes)
GCFLAGS += -DENABLE_GETTEXT
endif
+# Override these if C++ needs other options
+SANITIZER_CXXFLAGS = $(SANITIZER_CFLAGS)
+GCXXFLAGS = $(GCFLAGS)
+PCXXFLAGS = $(PCFLAGS)
+
BUILD_CFLAGS += $(GCFLAGS) $(PCFLAGS)
# First, Sanitizer, Global, Platform, Local CFLAGS
CFLAGS += $(FCFLAGS) $(SANITIZER_CFLAGS) $(OPTIMIZER) $(GCFLAGS) $(PCFLAGS) $(LCFLAGS)
+CXXFLAGS += $(FCXXFLAGS) $(SANITIZER_CXXFLAGS) $(OPTIMIZER) $(GCXXFLAGS) $(PCXXFLAGS) $(LCXXFLAGS)
include $(TOPDIR)/include/buildmacros
@@ -125,6 +125,18 @@ CFILES = buf_mem.c \
xfs_trans_space.c \
xfs_types.c
+EXTRA_CFILES=\
+ ioctl_c_dummy.c
+
+EXTRA_CXXFILES=\
+ ioctl_cxx_dummy.cpp
+
+EXTRA_OBJECTS=\
+ $(patsubst %.c,%.o,$(EXTRA_CFILES)) \
+ $(patsubst %.cpp,%.o,$(EXTRA_CXXFILES))
+
+LDIRT += $(EXTRA_OBJECTS)
+
#
# Tracing flags:
# -DMEM_DEBUG all zone memory use
@@ -148,7 +160,23 @@ LTLIBS = $(LIBPTHREAD) $(LIBRT)
# don't try linking xfs_repair with a debug libxfs.
DEBUG = -DNDEBUG
-default: ltdepend $(LTLIBRARY)
+default: ltdepend $(LTLIBRARY) $(EXTRA_OBJECTS)
+
+%dummy.o: %dummy.cpp
+ @echo " [CXXD] $@"
+ $(Q)$(CXX) $(CXXFLAGS) -c $<
+
+%dummy.o: %dummy.c
+ @echo " [CCD] $@"
+ $(Q)$(CC) $(CFLAGS) -c $<
+
+MAKECXXDEP := $(MAKEDEPEND) $(CXXFLAGS)
+
+.PHONY: .extradep
+
+.extradep: $(EXTRA_CFILES) $(EXTRA_CXXFILES) $(HFILES)
+ $(Q)$(MAKEDEP) $(EXTRA_CFILES) > .extradep
+ $(Q)$(MAKECXXDEP) $(EXTRA_CXXFILES) >> .extradep
# set up include/xfs header directory
include $(BUILDRULES)
@@ -172,4 +200,5 @@ install-dev: install
# running the install-headers target.
ifndef NODEP
-include .ltdep
+-include .extradep
endif
new file mode 100644
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2024 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <djwong@kernel.org>
+ */
+
+/* Dummy program to test C compilation of user-exported xfs headers */
+
+#include "include/xfs.h"
+#include "include/handle.h"
+#include "include/jdm.h"
new file mode 100644
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2024 Oracle. All Rights Reserved.
+ * Author: Darrick J. Wong <djwong@kernel.org>
+ */
+
+/* Dummy program to test C++ compilation of user-exported xfs headers */
+
+extern "C" {
+#include "include/xfs.h"
+#include "include/handle.h"
+#include "include/jdm.h"
+};
@@ -42,6 +42,11 @@ AC_DEFUN([AC_PACKAGE_UTILITIES],
AC_SUBST(cc)
AC_PACKAGE_NEED_UTILITY($1, "$cc", cc, [C compiler])
+ AC_PROG_CXX
+ cxx="$CXX"
+ AC_SUBST(cxx)
+ AC_PACKAGE_NEED_UTILITY($1, "$cxx", cxx, [C++ compiler])
+
if test -z "$MAKE"; then
AC_PATH_PROG(MAKE, gmake,, $PATH)
fi