# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2004-2006 Silicon Graphics, Inc.
# All Rights Reserved.
#
# @configure_input@
#

ifndef _BUILDDEFS_INCLUDED_
_BUILDDEFS_INCLUDED_ = 1

DEBUG = @debug_build@
OPTIMIZER = @opt_build@
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
# only use what we calculate from the configured options above.
LDFLAGS =

LIBRT = @librt@
LIBUUID = @libuuid@
LIBURCU = @liburcu@
LIBPTHREAD = @libpthread@
LIBTERMCAP = @libtermcap@
LIBEDITLINE = @libeditline@
LIBBLKID = @libblkid@
LIBDEVMAPPER = @libdevmapper@
LIBINIH = @libinih@
LIBXFS = $(TOPDIR)/libxfs/libxfs.la
LIBFROG = $(TOPDIR)/libfrog/libfrog.la
LIBXCMD = $(TOPDIR)/libxcmd/libxcmd.la
LIBXLOG = $(TOPDIR)/libxlog/libxlog.la
LIBHANDLE = $(TOPDIR)/libhandle/libhandle.la

PKG_NAME	= @pkg_name@
PKG_USER	= @pkg_user@
PKG_GROUP	= @pkg_group@
PKG_RELEASE	= @pkg_release@
PKG_VERSION	= @pkg_version@
PKG_DISTRIBUTION= @pkg_distribution@
PKG_BUGREPORT	= @PACKAGE_BUGREPORT@

prefix		= @prefix@
exec_prefix	= @exec_prefix@
datarootdir	= @datarootdir@
top_builddir	= @top_builddir@

PKG_SBIN_DIR	= @sbindir@
PKG_LIB_DIR	= @libdir@@libdirsuffix@
PKG_LIBEXEC_DIR	= @libexecdir@/@pkg_name@
PKG_INC_DIR	= @includedir@/xfs
DK_INC_DIR	= @includedir@/disk
PKG_MAN_DIR	= @mandir@
PKG_DOC_DIR	= @datadir@/doc/@pkg_name@
PKG_LOCALE_DIR	= @datadir@/locale
PKG_DATA_DIR	= @datadir@/@pkg_name@
MKFS_CFG_DIR	= @datadir@/@pkg_name@/mkfs
PKG_STATE_DIR	= @localstatedir@/lib/@pkg_name@

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@
ZIP		= @zip@
MAKE		= @make@
ECHO		= @echo@
SORT		= @sort@
LN_S		= @LN_S@
SHELL		= @SHELL@
LIBTOOL		= @LIBTOOL@
MAKEDEPEND	= @makedepend@

MSGFMT		= @msgfmt@
MSGMERGE	= @msgmerge@
XGETTEXT	= @xgettext@
LOCALIZED_FILES	= @LOCALIZED_FILES@

RPM		= @rpm@
RPMBUILD	= @rpmbuild@
RPM_VERSION	= @rpm_version@

ENABLE_SHARED	= @enable_shared@
ENABLE_GETTEXT	= @enable_gettext@
ENABLE_EDITLINE	= @enable_editline@
ENABLE_SCRUB	= @enable_scrub@

HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@

HAVE_PWRITEV2 = @have_pwritev2@
HAVE_COPY_FILE_RANGE = @have_copy_file_range@
HAVE_CACHESTAT = @have_cachestat@
NEED_INTERNAL_FSXATTR = @need_internal_fsxattr@
NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG = @need_internal_fscrypt_add_key_arg@
NEED_INTERNAL_FSCRYPT_POLICY_V2 = @need_internal_fscrypt_policy_v2@
NEED_INTERNAL_STATX = @need_internal_statx@
HAVE_GETFSMAP = @have_getfsmap@
HAVE_MAP_SYNC = @have_map_sync@
HAVE_DEVMAPPER = @have_devmapper@
HAVE_MALLINFO = @have_mallinfo@
HAVE_MALLINFO2 = @have_mallinfo2@
HAVE_MEMFD_CREATE = @have_memfd_create@
HAVE_GETRANDOM_NONBLOCK = @have_getrandom_nonblock@
HAVE_LIBICU = @have_libicu@
HAVE_SYSTEMD = @have_systemd@
SYSTEMD_SYSTEM_UNIT_DIR = @systemd_system_unit_dir@
HAVE_CROND = @have_crond@
CROND_DIR = @crond_dir@
HAVE_UDEV = @have_udev@
UDEV_RULE_DIR = @udev_rule_dir@
HAVE_LIBURCU_ATOMIC64 = @have_liburcu_atomic64@

GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
#	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl

# _LGPL_SOURCE is for liburcu to work correctly with GPL/LGPL programs
PCFLAGS = -D_LGPL_SOURCE -D_GNU_SOURCE $(GCCFLAGS)
DEPENDFLAGS = -D__linux__
ifeq ($(HAVE_MNTENT),yes)
PCFLAGS+= -DHAVE_MNTENT
endif
ifeq ($(NEED_INTERNAL_FSXATTR),yes)
PCFLAGS+= -DOVERRIDE_SYSTEM_FSXATTR
endif
ifeq ($(NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG),yes)
PCFLAGS+= -DOVERRIDE_SYSTEM_FSCRYPT_ADD_KEY_ARG
endif
ifeq ($(NEED_INTERNAL_FSCRYPT_POLICY_V2),yes)
PCFLAGS+= -DOVERRIDE_SYSTEM_FSCRYPT_POLICY_V2
endif
ifeq ($(NEED_INTERNAL_STATX),yes)
PCFLAGS+= -DOVERRIDE_SYSTEM_STATX
endif
ifeq ($(HAVE_GETFSMAP),yes)
PCFLAGS+= -DHAVE_GETFSMAP
endif

LIBICU_LIBS = @libicu_LIBS@
LIBICU_CFLAGS = @libicu_CFLAGS@
ifeq ($(HAVE_LIBURCU_ATOMIC64),yes)
PCFLAGS += -DHAVE_LIBURCU_ATOMIC64
endif

SANITIZER_CFLAGS += @addrsan_cflags@ @threadsan_cflags@ @ubsan_cflags@ @autovar_init_cflags@
SANITIZER_LDFLAGS += @addrsan_ldflags@ @threadsan_ldflags@ @ubsan_ldflags@

# Use special ar/ranlib wrappers if we have lto
HAVE_LTO = @have_lto@
ifeq ($(HAVE_LTO),yes)
OPTIMIZER += @lto_cflags@
LOADERFLAGS += @lto_ldflags@
AR = @gcc_ar@
RANLIB = @gcc_ranlib@
endif

GCFLAGS = $(DEBUG) \
	  -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\"  \
	  -DPACKAGE=\"$(PKG_NAME)\" -I$(TOPDIR)/include -I$(TOPDIR)/libxfs \
	  -I$(TOPDIR)

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

endif

#
# For targets that should always be rebuilt,
# define a target that is never up-to-date.
# Targets needing this should depend on $(_FORCE)
_FORCE = __force_build
