makefile: support out of tree builds

This commit is contained in:
cathugger 2019-03-17 02:23:10 +02:00
parent 5c58f03805
commit c9d4f79b9f
No known key found for this signature in database
GPG key ID: 9BADDA2DAF6F01A8
3 changed files with 23 additions and 13 deletions

View file

@ -10,13 +10,13 @@ LDFLAGS= @NOPIE@ @LDFLAGS@
MV= mv
ED25519_DEFS= -DED25519_ref10 -DED25519_amd64_51_30k -DED25519_amd64_64_24k -DED25519_donna
ED25519_ref10= $(patsubst %.c,%.c.o,$(wildcard ed25519/ref10/*.c))
ED25519_ref10= $(patsubst @SRCDIR@/%.c,%.c.o,$(wildcard @SRCDIR@/ed25519/ref10/*.c))
ED25519_amd64_51_30k= \
$(patsubst %.c,%.c.o,$(wildcard ed25519/amd64-51-30k/*.c)) \
$(patsubst %.s,%.s.o,$(wildcard ed25519/amd64-51-30k/*.s))
$(patsubst @SRCDIR@/%.c,%.c.o,$(wildcard @SRCDIR@/ed25519/amd64-51-30k/*.c)) \
$(patsubst @SRCDIR@/%.s,%.s.o,$(wildcard @SRCDIR@/ed25519/amd64-51-30k/*.s))
ED25519_amd64_64_24k= \
$(patsubst %.c,%.c.o,$(wildcard ed25519/amd64-64-24k/*.c)) \
$(patsubst %.s,%.s.o,$(wildcard ed25519/amd64-64-24k/*.s))
$(patsubst @SRCDIR@/%.c,%.c.o,$(wildcard @SRCDIR@/ed25519/amd64-64-24k/*.c)) \
$(patsubst @SRCDIR@/%.s,%.s.o,$(wildcard @SRCDIR@/ed25519/amd64-64-24k/*.s))
ED25519_donna=
ED25519OBJ= $(ED25519_@ED25519IMPL@)
@ -64,6 +64,7 @@ ALLO= $(sort \
$(ED25519_ref10) \
$(ED25519_amd64_51_30k) \
$(ED25519_amd64_64_24k))
ALLC= $(patsubst %.c.o,%.c,$(filter %.c.o %.c,$(ALLO)))
CLEANO= $(filter %.o,$(ALLO))
@ -72,6 +73,8 @@ TEST_ED25519LIB= -lsodium
EXE= mkp224o test_base64 test_base32 test_base16 test_ed25519
.PHONY: default all clean distclean depend
default: mkp224o
all: $(EXE)
@ -91,12 +94,6 @@ test_base16: $(TEST_BASE16OBJ)
test_ed25519: $(TEST_ED25519OBJ)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@.tmp $^ $(TEST_ED25519LIB) && $(MV) $@.tmp $@
%.c.o: %.c
$(CC) $(CFLAGS) -c -o $@.tmp $< && $(MV) $@.tmp $@
%.s.o: %.s
$(CC) $(ASFLAGS) -c -o $@.tmp $< && $(MV) $@.tmp $@
clean:
$(RM) $(CLEANO)
$(RM) $(EXE)
@ -109,7 +106,15 @@ distclean:
$(RM) Makefile
depend:
makedepend -Y -fMakefile.in -o.c.o -- $(CSTD) $(ED25519_DEFS) -- $(ALLC)
(cd "@SRCDIR@" && makedepend -Y -fMakefile.in -o.c.o -- $(CSTD) $(ED25519_DEFS) -- $(ALLC))
VPATH=@SRCDIR@
%.c.o: %.c
$(CC) $(CFLAGS) -c -o $@.tmp $< && $(MV) $@.tmp $@
%.s.o: %.s
$(CC) $(ASFLAGS) -c -o $@.tmp $< && $(MV) $@.tmp $@
# DO NOT DELETE THIS LINE
@ -393,7 +398,7 @@ ed25519/ref10/sign.c.o: ed25519/ref10/ge.h ed25519/ref10/fe.h
ed25519/ref10/sign.c.o: ed25519/ref10/crypto_int32.h ed25519/ref10/sc.h
ioutil.c.o: types.h ioutil.h
keccak.c.o: types.h keccak.h
main.c.o: types.h vec.h cpucount.h keccak.h ioutil.h common.h yaml.h
main.c.o: types.h vec.h base32.h cpucount.h keccak.h ioutil.h common.h yaml.h
main.c.o: filters.h worker.h filters_main.inc.h filters_common.inc.h
test_base16.c.o: types.h base16.h
test_base32.c.o: types.h base32.h

View file

@ -293,9 +293,13 @@ yes|pcre2)
;;
esac
# recreate dir tree, because otherwise gcc will fuck up
(cd "$srcdir" && find ed25519 -type d) | xargs mkdir -p
AC_SUBST(CSTD,["$cstd"])
AC_SUBST(ED25519IMPL,["$ed25519impl"])
AC_SUBST(MYDEFS,["$MYDEFS"])
AC_SUBST(MAINLIB,["$MAINLIB"])
AC_SUBST(NOPIE,["$nopie"])
AC_SUBST(SRCDIR,["$srcdir"])
AC_OUTPUT(Makefile)

1
main.c
View file

@ -18,6 +18,7 @@
#include "types.h"
#include "vec.h"
#include "base32.h"
#include "cpucount.h"
#include "keccak.h"
#include "ioutil.h"