Skip to content

Commit

Permalink
[fix] add support to build on darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
stef committed Dec 4, 2023
1 parent 9ab8ea8 commit 5160577
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ LIBS=-lsodium -loprf
DEFINES=
CFLAGS?=-march=native -Wall -O2 -g -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fasynchronous-unwind-tables -fpic \
-fstack-clash-protection -fcf-protection=full -Werror=format-security -Werror=implicit-function-declaration \
-Warray-bounds -fsanitize=bounds -fsanitize-undefined-trap-on-error \
-Wl,-z,defs -Wl,-z,relro -ftrapv -Wl,-z,noexecstack -std=c99 $(DEFINES)
-Warray-bounds -fsanitize=bounds -fsanitize-undefined-trap-on-error -ftrapv -std=c99 $(DEFINES)
#-fstrict-flex-arrays
LDFLAGS=-g $(LIBS)
CC=gcc
SOEXT=so
AEXT=a
SOVER=0

AR?=ar

UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
SOEXT=dylib
SOFLAGS=-Wl,-install_name,liboprf.$(SOEXT)
else
CFLAGS+=-Wl,-z,defs -Wl,-z,relro -Wl,-z,noexecstack -Wl,-z,now
SOEXT=so
SOFLAGS=-Wl,-soname,libopaque.so.$(SOVER)
endif

SODIUM_NEWER_THAN_1_0_18 := $(shell pkgconf --atleast-version=1.0.19 libsodium; echo $$?)
ifeq ($(SODIUM_NEWER_THAN_1_0_18),1)
CFLAGS+= -Iaux_
Expand Down Expand Up @@ -64,7 +72,7 @@ endif
tests: $(TESTS)

libopaque.$(SOEXT): common.o opaque.o $(EXTRA_OBJECTS)
$(CC) -shared $(CFLAGS) -Wl,-soname,libopaque.so.$(SOVER) -o libopaque.$(SOEXT) $^ $(LDFLAGS)
$(CC) -shared $(CFLAGS) $(SOFLAGS) -o libopaque.$(SOEXT) $^ $(LDFLAGS)
ln -fs libopaque.$(SOEXT) libopaque.so.$(SOVER)

libopaque.$(AEXT): common.o opaque.o $(EXTRA_OBJECTS)
Expand Down

0 comments on commit 5160577

Please sign in to comment.