3 # Use `make` to build utility `otpcli`
4 # Use `make V=1` for verbose output
5 # Use `make test` (or `make V=1 test`) to run the tests
11 # Clean out the standard six single suffix inference rules
13 .SUFFIXES
: .c .sh .f .c˜ .sh˜ .f˜
21 # Since .c is part of a "cleaned out" single suffix rule, it must
22 # be LAST here otherwise some misguided implementations will choose
23 # the empty "cleaned out" do-nothing .c rule to turn a .c file into
24 # an executable instead of using the intended .o rule
41 Makefile Makefile
/phony
:
44 all clean depend targets utils
test : Makefile
/phony
47 $(Q
) rm -f Makefile.tmp
*.o
$(TARGETS
) $(UTILS
)
49 # For overriding from command line
50 # (default for CC is just "cc" in make_conf.sh)
66 CPPLINE
= $(CINCL
) $(CDEFS
)
67 CPPLINEXDEFS0
= $(CPPLINE
)
68 CPPLINEXDEFS
= $(CPPLINEXDEFS0
) $(CPPFLAGS
)
69 CCLINE0
= $(CWARN
) $(CPPLINE
) $(CFLGS
) $(COPTS
)
70 CCLINE
= $(CCLINE0
) $(CFLAGS
)
71 CCLINEXDEFS0
= $(CCLINE0
)
72 CCLINEXDEFS
= $(CCLINEXDEFS0
) $(CPPFLAGS
) $(CFLAGS
)
74 # make V=1 to show commands
80 QCC_0
= $(AT
)echo
"[CC] $@" &&
84 QLD_0
= $(AT
)echo
"[CCLD] $@" &&
90 $(QCC
) $(CC
) -o
"$@" -c
$(CCLINEXDEFS
) "$<"
93 $(QLD
) $(CC
) -o
"$@" $(LOPTS
) $(LDFLAGS
) "$<" $($(@F
)_libs
) $(LLIBS
) $(LIBS
)
116 $(Q
) for s in
$(DEPSRCS
); do
$(CC
) -E
$(CPPLINEXDEFS0
) "$$s.c" 2>/dev
/null | \
117 .
/awkdep.sh
"$$s.o" >>Makefile.tmp
; printf
"$$s : %s\n" "$$s.o" '$$('"$${s}_libs"')' >>Makefile.tmp
; done
118 $(Q
) for s in
$(UTILSOBJS
); do
$(CC
) -E
$(CPPLINEXDEFS0
) -D LT_NO_EMBED
"lt/$${s%.o}.c" 2>/dev
/null | \
119 .
/awkdep.sh
"$$s" >>Makefile.tmp
; printf
"lt/$${s%.o} : %s\n" "$$s" '$$('"$${s%.o}_libs"')' >>Makefile.tmp
; done
120 $(Q
) for s in
$(LIBLTOBJS
); do
$(CC
) -E
$(CPPLINEXDEFS0
) "lt/$${s%.o}.c" 2>/dev
/null | \
121 .
/awkdep.sh
"$$s" >>Makefile.tmp
; done
122 $(Q
) printf
'\043 %s\n' "autogenerated with make depend" >Makefile.dep
123 $(Q
) LC_ALL
=C
sort -u
<Makefile.tmp
>>Makefile.dep
&& rm -f Makefile.tmp
126 $(Q
) printf
'\043 %s\n' "autogenerated with make depend" >Makefile.dep
129 $(QCC
) $(CC
) -o
"$@" -c
$(CCLINEXDEFS
) "lt/$(@:.o=.c)"
132 $(QCC
) $(CC
) -o
"$@" -c
$(CCLINEXDEFS
) -D LT_NO_EMBED
"lt/$(@:.o=.c)"
135 $(QLD
) $(CC
) -o
"$@" $(LOPTS
) $(LDFLAGS
) ltsha1.o lt1.o
$(LLIBS
) $(LIBS
)
138 $(QLD
) $(CC
) -o
"$@" $(LOPTS
) $(LDFLAGS
) ltsha256.o lt256.o
$(LLIBS
) $(LIBS
)
141 $(QLD
) $(CC
) -o
"$@" $(LOPTS
) $(LDFLAGS
) ltsha512.o lt512.o
$(LLIBS
) $(LIBS
)
143 common_libs
= lt1.o lt256.o lt512.o
145 otpcli_libs
= $(common_libs
)
148 ltsha256_libs
= lt256.o
149 ltsha512_libs
= lt512.o
151 CHECKTAP
= awk
-v V
="$(V)" 'BEGIN{c=0} {if(V)print} /^ok [0-9]/{++c} END{if(NR!=c+1){print "Test failure";exit 1}}'
154 $(Q
) cd lt
&& echo
"Testing sha1" && .
/ltsha1-test.sh |
$(CHECKTAP
)
155 $(Q
) cd lt
&& echo
"Testing sha256" && .
/ltsha256-test.sh |
$(CHECKTAP
)
156 $(Q
) cd lt
&& echo
"Testing sha512" && .
/ltsha512-test.sh |
$(CHECKTAP
)
157 $(Q
) echo All hash tests pass
158 $(Q
) echo
"Testing otpcli" && .
/otpcli-test.sh |
$(CHECKTAP
)
159 $(Q
) echo All otpcli tests pass
161 # Must be after all ..._libs assignments above