2 ## Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow (danshu@microsoft.com)
3 ## Distributed under the MIT Software License.
4 ## See accompanying file LICENSE.txt or copy at
5 ## https://opensource.org/licenses/MIT
8 # dynamic library compatibility
9 # 1. If the library source code has changed at all since the last update,
10 # then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
11 # 2. If any interfaces have been added, removed, or changed since the last update,
12 # increment current, and set revision to 0.
13 # 3. If any interfaces have been added since the last public release, then increment age.
14 # 4. If any interfaces have been removed or changed since the last public release,
21 INCLUDEDIR
=$(PREFIX
)/include/sha1dc
27 ifeq ($(shell uname
),Darwin
)
36 CFLAGS
=-O2
-Wall
-Werror
-Wextra
-pedantic
-std
=c90
-Ilib
39 LT_CC
:=$(LIBTOOL
) --tag
=CC
--mode
=compile
$(CC
)
41 LT_LD
:=$(LIBTOOL
) --tag
=CC
--mode
=link
$(CC
)
42 LT_INSTALL
:=$(LIBTOOL
) --tag
=CC
--mode
=install $(INSTALL
)
46 ifneq (, $(shell which
$(LIBTOOL
) 2>/dev
/null
))
55 LT_INSTALL
:=$(INSTALL
)
58 CFLAGS
+=$(TARGETCFLAGS
)
59 LDFLAGS
+=$(TARGETLDFLAGS
)
69 H_DEP
:=$(shell find .
-type f
-name
"*.h")
70 FS_LIB
=$(wildcard $(LIB_DIR
)/*.c
)
71 FS_SRC
=$(wildcard $(SRC_DIR
)/*.c
)
72 FS_OBJ_LIB
=$(FS_LIB
:$(LIB_DIR
)/%.c
=$(LIB_OBJ_DIR
)/%.lo
)
73 FS_OBJ_SRC
=$(FS_SRC
:$(SRC_DIR
)/%.c
=$(SRC_OBJ_DIR
)/%.lo
)
74 FS_OBJ
=$(FS_OBJ_SRC
) $(FS_OBJ_LIB
)
75 FS_DEP_LIB
=$(FS_LIB
:$(LIB_DIR
)/%.c
=$(LIB_DEP_DIR
)/%.d
)
76 FS_DEP_SRC
=$(FS_SRC
:$(SRC_DIR
)/%.c
=$(SRC_DEP_DIR
)/%.d
)
77 FS_DEP
=$(FS_DEP_SRC
) $(FS_DEP_LIB
)
86 $(LT_INSTALL
) -d
$(LIBDIR
) $(BINDIR
) $(INCLUDEDIR
)
87 $(LT_INSTALL
) bin
/libsha1detectcoll.
$(LIB_EXT
) $(LIBDIR
)/libsha1detectcoll.
$(LIB_EXT
)
88 $(LT_INSTALL
) lib
/sha1.h
$(INCLUDEDIR
)/sha1.h
89 $(LT_INSTALL
) bin
/sha1dcsum
$(BINDIR
)/sha1dcsum
90 $(LT_INSTALL
) bin
/sha1dcsum_partialcoll
$(BINDIR
)/sha1dcsum_partialcoll
94 -$(RM
) $(BINDIR
)/sha1dcsum
95 -$(RM
) $(BINDIR
)/sha1dcsum_partialcoll
96 -$(RM
) $(INCLUDEDIR
)/sha1.h
97 -$(RM
) $(LIBDIR
)/libsha1detectcoll.
$(LIB_EXT
)
101 -find .
-type f
-name
'*.a' -print -delete
102 -find .
-type f
-name
'*.d' -print -delete
103 -find .
-type f
-name
'*.o' -print -delete
104 -find .
-type f
-name
'*.la' -print -delete
105 -find .
-type f
-name
'*.lo' -print -delete
106 -find .
-type f
-name
'*.so' -print -delete
107 -find .
-type d
-name
'.libs' -print | xargs
rm -rv
112 test e98a60b463a6868a6ce351ab0166c0af0c8c4721
!= `bin/sha1dcsum test/sha1_reducedsha_coll.bin | cut -d' ' -f1` ||
(echo
"\nError: Compiled for incorrect endianness" && false
)
113 test a56374e1cf4c3746499bc7c0acb39498ad2ee185
= `bin/sha1dcsum test/sha1_reducedsha_coll.bin | cut -d' ' -f1`
114 test 16e96b70000dd1e7c85b8368ee197754400e58ec
= `bin/sha1dcsum test/shattered-1.pdf | cut -d' ' -f1`
115 test e1761773e6a35916d99f891b77663e6405313587
= `bin/sha1dcsum test/shattered-2.pdf | cut -d' ' -f1`
116 test dd39885a2a5d8f59030b451e00cb45da9f9d3828
= `bin/sha1dcsum_partialcoll test/sha1_reducedsha_coll.bin | cut -d' ' -f1`
117 test d3a1d09969c3b57113fd17b23e01dd3de74a99bb
= `bin/sha1dcsum_partialcoll test/shattered-1.pdf | cut -d' ' -f1`
118 test 92246b0b718f4c704d37bb025717cbc66babf102
= `bin/sha1dcsum_partialcoll test/shattered-2.pdf | cut -d' ' -f1`
120 bin
/sha1dcsum_partialcoll
test/*
126 tools
: sha1dcsum sha1dcsum_partialcoll
129 sha1dcsum
: bin
/sha1dcsum
131 .PHONY
: sha1dcsum_partialcoll
132 sha1dcsum_partialcoll
: bin
/sha1dcsum_partialcoll
136 library
: bin
/libsha1detectcoll.
$(LIB_EXT
)
138 bin
/libsha1detectcoll.la
: $(FS_OBJ_LIB
)
139 $(MKDIR
) $(shell dirname
$@
) && $(LDLIB
) $(LDFLAGS
) $(FS_OBJ_LIB
) -rpath
$(LIBDIR
) -version-info
$(LIBCOMPAT
) -o bin
/libsha1detectcoll.la
141 bin
/libsha1detectcoll.a
: $(FS_OBJ_LIB
)
142 $(MKDIR
) $(shell dirname
$@
) && $(AR
) cru bin
/libsha1detectcoll.a
$(FS_OBJ_LIB
)
144 bin
/sha1dcsum
: $(FS_OBJ_SRC
) bin
/libsha1detectcoll.
$(LIB_EXT
)
145 $(LD
) $(LDFLAGS
) $(FS_OBJ_SRC
) -Lbin
-lsha1detectcoll
-o bin
/sha1dcsum
147 bin
/sha1dcsum_partialcoll
: $(FS_OBJ_SRC
) bin
/libsha1detectcoll.
$(LIB_EXT
)
148 $(LD
) $(LDFLAGS
) $(FS_OBJ_SRC
) -Lbin
-lsha1detectcoll
-o bin
/sha1dcsum_partialcoll
151 $(SRC_DEP_DIR
)/%.d
: $(SRC_DIR
)/%.c
152 $(MKDIR
) $(shell dirname
$@
) && $(CC_DEP
) $(CFLAGS
) -M
-MF
$@
$<
154 $(SRC_OBJ_DIR
)/%.lo
${SRC_OBJ_DIR}/%.o
: ${SRC_DIR}/%.c
${SRC_DEP_DIR}/%.d
$(H_DEP
)
155 $(MKDIR
) $(shell dirname
$@
) && $(CC
) $(CFLAGS
) -o
$@
-c
$<
158 $(LIB_DEP_DIR
)/%.d
: $(LIB_DIR
)/%.c
159 $(MKDIR
) $(shell dirname
$@
) && $(CC_DEP
) $(CFLAGS
) -M
-MF
$@
$<
161 $(LIB_OBJ_DIR
)/%.lo
$(LIB_OBJ_DIR
)/%.o
: $(LIB_DIR
)/%.c
$(LIB_DEP_DIR
)/%.d
$(H_DEP
)
162 $(MKDIR
) $(shell dirname
$@
) && $(CC
) $(CFLAGS
) -o
$@
-c
$<