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

Makefile: Fix for {Net,Free,Open}BSD and generic $CFLAGS in environ #36

Merged
merged 1 commit into from
Jan 24, 2024
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
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ calling_from_make:

UNAME := $(shell uname)

CFLAGS ?= -Wall -Werror -Wno-unused-parameter -pedantic -std=c99 -O2
CFLAGS ?= -Wall -Werror -Wextra -Wno-unused-parameter -pedantic -O2 -fPIC

ifeq ($(UNAME), Darwin)
TARGET_CFLAGS ?= -fPIC -undefined dynamic_lookup -dynamiclib -Wextra
endif

ifeq ($(UNAME), Linux)
TARGET_CFLAGS ?= -undefined dynamic_lookup -dynamiclib -Wextra
else ifeq (${UNAME}, NetBSD)
# c_src/spawner.c fails to compile on NetBSD and Darwin with -D_POSIX_C_SOURCE=200809L
# Should be fixed once NetBSD 10 get released:
# http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57871
TARGET_CFLAGS ?= -shared
else
# -D_POSIX_C_SOURCE=200809L needed on musl
CFLAGS += -D_POSIX_C_SOURCE=200809L
TARGET_CFLAGS ?= -fPIC -shared
TARGET_CFLAGS ?= -shared
endif

all: priv/exile.so priv/spawner
@echo > /dev/null

priv/exile.so: c_src/exile.c
mkdir -p priv
$(CC) -I$(ERL_INTERFACE_INCLUDE_DIR) $(TARGET_CFLAGS) $(CFLAGS) c_src/exile.c -o priv/exile.so
$(CC) -std=c99 -I$(ERL_INTERFACE_INCLUDE_DIR) $(TARGET_CFLAGS) $(CFLAGS) c_src/exile.c -o priv/exile.so

priv/spawner: c_src/spawner.c
mkdir -p priv
$(CC) $(CFLAGS) c_src/spawner.c -o priv/spawner
$(CC) -std=c99 $(CFLAGS) c_src/spawner.c -o priv/spawner

clean:
@rm -rf priv/exile.so priv/spawner