CC ?= gcc
CFLAGS ?= -Wall -Wextra -std=c99 -O2
AR ?= ar

OBJS = libotppad.o
LIB  = libotppad.a

all: $(LIB)

$(LIB): $(OBJS)
	$(AR) rcs $@ $(OBJS)

libotppad.o: libotppad.c libotppad.h
	$(CC) $(CFLAGS) -c libotppad.c -o libotppad.o

test: test_libotppad
	./test_libotppad

test_libotppad: test_libotppad.c $(LIB)
	$(CC) $(CFLAGS) -I. test_libotppad.c -L. -lotppad -o test_libotppad

clean:
	rm -f $(OBJS) $(LIB) test_libotppad

.PHONY: all test clean
