Minor changes to get it working on macOS
This commit is contained in:
67
software/Makefile.macos
Normal file
67
software/Makefile.macos
Normal file
@@ -0,0 +1,67 @@
|
||||
GIT_VERSION := $(shell git --no-pager describe --tags --always)
|
||||
GIT_COMMIT := $(shell git rev-parse --verify HEAD)
|
||||
GIT_DATE := $(firstword $(shell git --no-pager show --date=iso-strict --format="%ad" --name-only))
|
||||
|
||||
PREFIX = $(DESTDIR)/usr/local
|
||||
FTDILOC = /usr/local/Cellar/libftdi/1.4/include/libftdi1/
|
||||
|
||||
CFLAGS = -Wall -Wextra -Werror -std=c99 -O3 -fPIC -I Keccak -I $(FTDILOC) \
|
||||
-DGIT_VERSION=\"$(GIT_VERSION)\"\
|
||||
-DGIT_COMMIT=\"$(GIT_COMMIT)\"\
|
||||
-DGIT_DATE=\"$(GIT_DATE)\"\
|
||||
-DMACOS
|
||||
|
||||
FOUND = $(shell /sbin/ldconfig -p | grep --silent libftdi.so && echo found)
|
||||
ifeq ($(FOUND), found)
|
||||
FTDI= -lftdi
|
||||
else
|
||||
FTDI= -lftdi1
|
||||
endif
|
||||
|
||||
all: libinfnoise.a libinfnoise.so infnoise
|
||||
|
||||
infnoise: libinfnoise.a infnoise.o daemon.o
|
||||
$(CC) $(CFLAGS) -o infnoise infnoise.o daemon.o libinfnoise.a $(FTDI) -lm -L. -linfnoise
|
||||
|
||||
%.o: %.c infnoise.h libinfnoise.h
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
KeccakF-1600-reference.o: Keccak/KeccakF-1600-reference.c Keccak/KeccakF-1600-interface.h Keccak/brg_endian.h
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
# static lib compiled into infnoise binary
|
||||
libinfnoise.o: libinfnoise.c libinfnoise.h libinfnoise_private.h healthcheck.c
|
||||
$(CC) $(CFLAGS) -c libinfnoise.c
|
||||
|
||||
libinfnoise.a: libinfnoise.o healthcheck.o KeccakF-1600-reference.o
|
||||
|
||||
ar rcs libinfnoise.a libinfnoise.o healthcheck.o KeccakF-1600-reference.o
|
||||
ranlib libinfnoise.a
|
||||
|
||||
# shared lib
|
||||
libinfnoise.so: libinfnoise.o healthcheck.o KeccakF-1600-reference.o
|
||||
$(CC) $(CFLAGS) -fvisibility=hidden -o libinfnoise.so libinfnoise.o healthcheck.o KeccakF-1600-reference.o -Wl $(FTDI) -lm -shared
|
||||
|
||||
libs: libinfnoise.a
|
||||
|
||||
clean:
|
||||
$(RM) infnoise *.o *.a *.gch *.so libinfnoise-example
|
||||
|
||||
install-lib: libinfnoise.so
|
||||
install -d $(PREFIX)/include
|
||||
install -m 0644 libinfnoise.h $(PREFIX)/include
|
||||
install -d $(PREFIX)/lib
|
||||
install -m 0644 libinfnoise.so $(PREFIX)/lib
|
||||
ldconfig $(PREFIX)/lib
|
||||
|
||||
install: infnoise
|
||||
install -d $(PREFIX)/sbin
|
||||
install -m 0755 infnoise $(PREFIX)/sbin/
|
||||
install -d $(PREFIX)/lib/udev/rules.d/
|
||||
install -m 0644 init_scripts/75-infnoise.rules $(PREFIX)/lib/udev/rules.d/
|
||||
install -d $(PREFIX)/lib/systemd/system
|
||||
install -m 0644 init_scripts/infnoise.service $(PREFIX)/lib/systemd/system
|
||||
|
||||
postinstall:
|
||||
systemctl restart systemd-udevd
|
||||
systemctl enable infnoise
|
||||
@@ -160,8 +160,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (opts.devRandom) {
|
||||
#ifdef LINUX
|
||||
inmWriteEntropyStart(BUFLEN/8u, opts.debug); // todo: create method in libinfnoise.h for this?
|
||||
// also todo: check superUser in this mode (it will fail silently if not :-/)
|
||||
#endif
|
||||
#ifdef MACOS
|
||||
message = "dev/random not supported on macOS";
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Optionally run in the background and optionally write a PID-file
|
||||
|
||||
@@ -113,8 +113,15 @@ bool outputBytes(uint8_t *bytes, uint32_t length, uint32_t entropy, bool writeD
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
#ifdef MACOS
|
||||
*message = "macOS doesn't support writes to entropy pool";
|
||||
entropy = 0; // suppress warning
|
||||
return false;
|
||||
#endif
|
||||
#ifdef LINUX
|
||||
inmWaitForPoolToHaveRoom();
|
||||
inmWriteEntropyToPool(bytes, length, entropy);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user