diff --git a/Makefile b/Makefile index 62e24f7..5a9ca7b 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,13 @@ LD = gfortran FFLAGS += -J$(OBJDIR) -I$(INCDIR) -ffree-line-length-none -fPIC CPPFLAGS += -DREVISION=\"$(GIT_REV)$(GIT_DIRTY)\" -DPREFIX=\"$(PREFIX)\" +ifndef DETERMINISTIC +ifdef AR_DEFAULT_DETERMINISTIC +# Write timestamps to allow partial updates +ARFLAGS = crU +endif +endif + # Static build options ifdef STATIC LIBRARIES := $(LIBRARIES:so=a) @@ -109,7 +116,7 @@ install: $(BINARIES) $(LIBRARIES) $(SHAREDIR)/doc $(SHAREDIR)/gray.1 $(OBJDIR)/%.o: $(OBJDIR)/%.d # GRAY binary -$(GRAY): $(shell ./depend $(OBJDIR)/main.o) | $(BINDIR) +$(GRAY): $(OBJDIR)/main.o $(LIBGRAY).a | $(BINDIR) $(LD) $(LDFLAGS) -o '$@' $^ # GRAY shared library diff --git a/configure b/configure index 91b9416..05f68d4 100755 --- a/configure +++ b/configure @@ -15,6 +15,7 @@ Options: --prefix=PREFIX install files in PREFIX [/usr/local] --enable-static statically link programs and libraries [no] --disable-static dynamically link programs and libraries [yes] + --enable-deterministic try to make a bit-for-bit deterministic build [no] --with-katex=PATH specify path to the KaTeX library [automatically downloaded] EOF } @@ -40,6 +41,7 @@ for arg in "$@"; do ;; --enable-static) printf 'STATIC=1\n' >> configure.mk ;; --disable-static) ;; + --enable-deterministic) printf 'DETERMINISTIC=1\n' >> configure.mk ;; --with-katex=*) printf 'KATEX_URL==file://%s/\n' "${arg#*=}" >> configure.mk ;; *=*) printf '%s\n' "${arg?}" >> configure.mk @@ -79,3 +81,8 @@ if [ $? -ne 0 ]; then fi printf 'using %s as Fortran compiler\n' "$FC" printf '%s=%s\n' FC "$FC" >> configure.mk + +# Check whether ar is deterministic by default +if ar h | grep -q '\[D\].*(default)' 2>/dev/null; then + printf 'AR_DEFAULT_DETERMINISTIC=1\n' >> configure.mk +fi diff --git a/default.nix b/default.nix index b02ae79..858f68a 100644 --- a/default.nix +++ b/default.nix @@ -59,6 +59,7 @@ in configureFlags = [ (lib.enableFeature static "static") "--with-katex=${katex}" + "--enable-deterministic" "GIT_REV=${version}" "GIT_DIRTY=" ];