totp

Simple cli tool for storing TOTP secrets and generating tokens
git clone https://git.inz.fi/totp/
Log | Files | Refs | Submodules

Makefile (2883B)


      1 .POSIX:
      2 AFLCC = afl-clang-fast
      3 AFLFUZZ = afl-fuzz
      4 CFLAGS = -W -Wall -Wextra -pedantic -std=c99 -Os
      5 AES_CFLAGS += -DECB=0 -DCBC=1 -DCTR=0 -DAES256=1
      6 SOURCES = sha1.c sha256.c sha512.c tiny-AES-c/aes.c main.c util.c db.c token.c
      7 HEADERS = sha1.h sha256.h sha512.h tiny-AES-c/aes.h util.h db.h token.h
      8 OBJS = ${SOURCES:.c=.o}
      9 TEST_SOURCES = sha1.c sha256.c sha512.c util.c algotest.c
     10 TEST_OBJS = ${TEST_SOURCES:.c=.o}
     11 
     12 VERSION = 0.1
     13 PREFIX = /usr/local
     14 BINDIR = ${PREFIX}/bin
     15 MANDIR = ${PREFIX}/share/man/man1
     16 
     17 NAME=totp
     18 
     19 all: ${NAME}
     20 
     21 debug: clean
     22 	${MAKE} CFLAGS="-W -Wall -Wextra -pedantic -std=c99 -fsanitize=undefined,address,pointer-compare -O2 -g" NAME=${NAME}-dbg ${NAME}-dbg test
     23 	${MAKE} clean
     24 
     25 ${NAME}: ${OBJS}
     26 	${CC} ${CFLAGS} -o $@ ${OBJS} ${LDFLAGS}
     27 
     28 unity.c: Makefile
     29 	for i in ${SOURCES}; do echo "#include \"$$i\""; done > unity.c
     30 
     31 unity: ${NAME}-unity
     32 
     33 ${NAME}-unity: unity.c ${SOURCES} ${HEADERS}
     34 	${CC} ${CFLAGS} -o ${NAME}-unity $< ${LDFLAGS}
     35 
     36 algotest: ${TEST_OBJS};
     37 	${CC} ${CFLAGS} -o $@ ${TEST_OBJS} ${LDFLAGS}
     38 
     39 test: algotest ${NAME}
     40 	./algotest
     41 	cd tests; ./test.sh ../${NAME}
     42 
     43 fuzzdb: fuzzdb.c
     44 	${AFLCC} fuzzdb.c -o fuzzdb -fsanitize=undefined,address
     45 
     46 fuzzdbraw: fuzzdb.c
     47 	${AFLCC} fuzzdb.c -o fuzzdbraw -fsanitize=undefined,address -DRAW_DB
     48 
     49 test/fuzz-crashes:
     50 	mkdir tests/fuzz-crashes
     51 
     52 db-fuzz: fuzzdb tests/fuzz-crashes
     53 	${AFLFUZZ} -i tests/dbs -o tests/fuzz-crashes ./fuzzdb
     54 
     55 dbraw-fuzz: fuzzdbraw tests/fuzz-crashes
     56 	${AFLFUZZ} -i tests/rawdbs -o tests/fuzz-crashes ./fuzzdbraw
     57 
     58 fuzzuri: fuzzuri.c
     59 	${AFLCC} fuzzuri.c -o fuzzuri -fsanitize=undefined,address
     60 
     61 uri-fuzz: fuzzuri tests/fuzz-crashes
     62 	${AFLFUZZ} -i tests/uris -o tests/fuzz-crashes ./fuzzuri
     63 
     64 .c.o:
     65 	${CC} -c $< -o $@ ${CFLAGS} ${AES_CFLAGS}
     66 
     67 clean:
     68 	rm -f ${OBJS} ${TEST_OBJS} unity.c
     69 
     70 install: all
     71 	mkdir -p "${DESTDIR}${BINDIR}"
     72 	cp -f "${NAME}" "${DESTDIR}${BINDIR}"
     73 	chmod 755 "${DESTDIR}${BINDIR}/${NAME}"
     74 	mkdir -p "${DESTDIR}${MANDIR}"
     75 	cp -f "${NAME}.1" "${DESTDIR}${MANDIR}"
     76 	chmod 644 "${DESTDIR}${MANDIR}/${NAME}.1"
     77 
     78 depend:
     79 	for i in ${HEADERS} ${SOURCES} ${TEST_SOURCES}; do echo "$$i"; done | sort | uniq | while read i; do \
     80 		sed -ne 's!^# *include *"\([^"]*\)".*!'"$$(echo "$$i" | sed -e 's/\.c$$/\.o/')"': '"$$(dirname "$$i" | sed -ne 's!^[^.].*!&/!; T; p; ')"'\1!; T; p' <"$$i"; \
     81 	done | sort
     82 
     83 algotest.o: sha1.h
     84 algotest.o: sha256.h
     85 algotest.o: sha512.h
     86 algotest.o: util.h
     87 db.h: token.h
     88 db.o: db.h
     89 db.o: tiny-AES-c/aes.h
     90 db.o: token.h
     91 db.o: util.h
     92 main.o: arg.h
     93 main.o: db.h
     94 main.o: sha1.h
     95 main.o: sha256.h
     96 main.o: sha512.h
     97 main.o: tiny-AES-c/aes.h
     98 main.o: token.h
     99 main.o: util.h
    100 sha1.o: sha1.h
    101 sha1.o: util.h
    102 sha256.o: sha256.h
    103 sha256.o: util.h
    104 sha512.o: sha512.h
    105 sha512.o: util.h
    106 tiny-AES-c/aes.o: tiny-AES-c/aes.h
    107 token.h: util.h
    108 token.o: token.h
    109 token.o: util.h
    110 util.o: util.h
    111 
    112 ${OBJS} ${TEST_OBJS}: Makefile
    113 
    114 .PHONY: test depend all debug unity db-fuzz uri-fuzz