]> git.codecow.com Git - Monocypher.git/commitdiff
moved SHA-512 source files to src/optional
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 8 Oct 2017 20:19:45 +0000 (22:19 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 8 Oct 2017 20:19:45 +0000 (22:19 +0200)
There are 2 reasons behind this change:

- The primary way to install Monocypher is to copy the source files
  into one's own project.  But it wasn't clear whether `sha512.c` and
  `sha512.h` are meant to be copied as well.

- Monocypher is advertised as a single source file library (or a 2
  files library if you count the header), and a casual glance may
  disagree.

Now things should be much clearer.

---

I made another slight change to the vector generation process: I
removed the optimisation options, which in conjunction with `-std=c99`
seem to trigger a bug in GCC 5.4.0 (it can't find a type definition).
Clang works.

Those optimisation options slowed down the whole process anyway, so no
loss there.

makefile
src/optional/sha512.c [moved from src/sha512.c with 100% similarity]
src/optional/sha512.h [moved from src/sha512.h with 100% similarity]
tests/gen/makefile

index 9e2194c349fd22c0f92e44e59cfbd23db4a13b45..8bdd273cfb9ee8b5115152182bb9f4ad45dcd5e4 100644 (file)
--- a/makefile
+++ b/makefile
@@ -69,23 +69,26 @@ lib/libmonocypher.a: lib/monocypher.o
 lib/libmonocypher.so: lib/monocypher.o
        @mkdir -p $(@D)
        $(CC) $(CFLAGS) -shared -o $@ $^
-lib/%.o: src/%.c src/%.h
+lib/sha512.o    : src/optional/sha512.c src/optional/sha512.o
+lib/monocypher.o: src/monocypher.c src/monocypher.h
+lib/monocypher.o lib/sha512.o:
        @mkdir -p $(@D)
-       $(CC) $(CFLAGS) -I src -fPIC -c -o $@ $<
+       $(CC) $(CFLAGS) -I src -I src/optional -fPIC -c -o $@ $<
 
 # Test & speed libraries
+$TEST_COMMON=tests/utils.h src/monocypher.h src/optional/sha512.h
 lib/utils.o: tests/utils.c tests/utils.h
-lib/test.o : tests/test.c  tests/utils.h src/monocypher.h src/sha512.h tests/vectors.h
-lib/speed.o: tests/speed.c tests/utils.h src/monocypher.h src/sha512.h
+lib/test.o : tests/test.c  $(TEST_COMMON) tests/vectors.h
+lib/speed.o: tests/speed.c $(TEST_COMMON)
 lib/utils.o lib/test.o lib/speed.o:
        @mkdir -p $(@D)
-       $(CC) $(CFLAGS) -I src -fPIC -c -o $@ $<
+       $(CC) $(CFLAGS) -I src -I src/optional -fPIC -c -o $@ $<
 
 # test & speed executables
 test.out : lib/test.o  lib/monocypher.o lib/sha512.o lib/utils.o
 speed.out: lib/speed.o lib/monocypher.o lib/sha512.o lib/utils.o
 test.out speed.out:
-       $(CC) $(CFLAGS) -I src -o $@ $^
+       $(CC) $(CFLAGS) -I src -I src/optional -o $@ $^
 
 tests/vectors.h:
        @echo ""
similarity index 100%
rename from src/sha512.c
rename to src/optional/sha512.c
similarity index 100%
rename from src/sha512.h
rename to src/optional/sha512.h
index e1bb1e46103ca5f3bbf113625ee93fea17d54d19..e1ad0e95be29975fc305ea99aed1d24063601310 100644 (file)
@@ -1,6 +1,6 @@
 CC=gcc -std=c99
 
-CFLAGS = -pedantic -Wall -Wextra -O3 -march=native
+CFLAGS = -pedantic -Wall -Wextra
 HASH   =
 #HASH=-DED25519_SHA512
 
@@ -12,7 +12,6 @@ VEC2    = $(patsubst %.vec, %.all.vec, $(VEC)) key_exchange.all.vec
 HEADERS = $(patsubst %.all.vec, %.h.vec, $(VEC2))
 VECTORS = ../vectors.h
 
-
 all: $(VECTORS)
 
 clean:
@@ -23,10 +22,11 @@ clean:
        ./$< > $@
 
 %.o: %.c ../utils.h ../ed25519-donna/ed25519.h
-       $(CC) $(CFLAGS) -c $<    \
-            -I ..                \
-            -I ../ed25519-donna  \
-            -I ../../src         \
+       $(CC) $(CFLAGS) -c $<     \
+            -I ..                 \
+            -I ../ed25519-donna   \
+            -I ../../src          \
+            -I ../../src/optional \
             $$(pkg-config --cflags libsodium)
 
 %.out: %.o monocypher.o utils.o ed25519.o
@@ -39,16 +39,17 @@ utils.o: ../utils.c ../utils.h
 ed25519.o: ../ed25519-donna/ed25519.c  $(wildcard ../ed25519-donna/*.h)
        $(CC) $(CFLAGS) -c $<       \
             -I ../../src            \
+            -I ../../src/optional   \
             $(HASH)                 \
             -DED25519_CUSTOMHASH    \
             -DED25519_TEST          \
             -DED25519_NO_INLINE_ASM \
             -DED25519_FORCE_32BIT
 
-monocypher.o: ../../src/monocypher.c ../../src/monocypher.h
-m_sha512.o  : ../../src/sha512.c     ../../src/sha512.h
+monocypher.o: ../../src/monocypher.c      ../../src/monocypher.h
+m_sha512.o  : ../../src/optional/sha512.c ../../src/optional/sha512.h
 monocypher.o m_sha512.o:
-       $(CC) $(CFLAGS) -c $< -I ../../src
+       $(CC) $(CFLAGS) -c $< -I ../../src -I ../../src/optional
 
 vector_to_header.out: ../vector_to_header.c
        $(CC) $(CFLAGS) $< -o $@