Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler flag support check (fixes #77) #78

Merged
merged 1 commit into from
Sep 9, 2022
Merged
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
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,21 @@ EXTRA_CLEAN += \
h3/test/regression.diffs h3/test/regression.out h3/test/results \
h3-*.zip

# PGXS boilerplate
PG_CONFIG = pg_config
CUSTOM_COPT=-flto -mpc64

# additional flags
CFLAGS_ADD :=
PG_CC := $(shell $(PG_CONFIG) --cc)
CHECK_FLAG_CMD := echo 'int main() { return 0; }' | $(PG_CC) -x c - -o /dev/null {flag} 2>&1 1>/dev/null; echo $$?

# add -mpc64 flag is supported
CHECK_FLAG_MPC64 := $(shell $(subst {flag},-mpc64,$(CHECK_FLAG_CMD)))
ifeq ($(CHECK_FLAG_MPC64),0)
CFLAGS_ADD += -mpc64
endif

# PGXS boilerplate
CUSTOM_COPT=-flto $(CFLAGS_ADD)
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

Expand All @@ -85,7 +97,7 @@ $(LIBH3_BUILD): $(LIBH3_SOURCE)
mkdir -p $(LIBH3_BUILD)
cd $(LIBH3_BUILD) && cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-fPIC -fvisibility=hidden -flto -fwrapv -mpc64" \
-DCMAKE_C_FLAGS="-fPIC -fvisibility=hidden -flto -fwrapv $(CFLAGS_ADD)" \
-DBUILD_TESTING=OFF \
-DENABLE_COVERAGE=OFF \
-DENABLE_DOCS=OFF \
Expand Down