| 1 |
|
| 2 |
include config.mak |
| 3 |
|
| 4 |
HEADERS = calc_sums.h hash_print.h common_func.h hash_update.h file.h file_mask.h file_set.h find_file.h hash_check.h output.h parse_cmdline.h rhash_main.h win_utils.h platform.h version.h |
| 5 |
SOURCES = calc_sums.c hash_print.c common_func.c hash_update.c file.c file_mask.c file_set.c find_file.c hash_check.c output.c parse_cmdline.c rhash_main.c win_utils.c |
| 6 |
OBJECTS = $(SOURCES:.c=.o) |
| 7 |
WIN_DIST_FILES = dist/MD5.bat dist/magnet.bat dist/rhashrc.sample |
| 8 |
OTHER_FILES = configure Makefile ChangeLog INSTALL.md COPYING README.md \ |
| 9 |
build/vc-2010/rhash.vcxproj dist/rhash.spec.in dist/rhash.1.in dist/rhash.1.win.sed \ |
| 10 |
docs/CONTRIBUTING.md docs/LIBRHASH.md librhash/Doxyfile po/rhash.pot \ |
| 11 |
tests/test_rhash.sh tests/test1K.data |
| 12 |
LIBRHASH_FILES = librhash/algorithms.c librhash/algorithms.h \ |
| 13 |
librhash/byte_order.c librhash/byte_order.h librhash/plug_openssl.c librhash/plug_openssl.h \ |
| 14 |
librhash/rhash.c librhash/rhash.h librhash/rhash_torrent.c librhash/rhash_torrent.h \ |
| 15 |
librhash/aich.c librhash/aich.h librhash/blake2b.c librhash/blake2b.h \ |
| 16 |
librhash/blake2s.c librhash/blake2s.h librhash/blake3.c librhash/blake3.h \ |
| 17 |
librhash/crc32.c librhash/crc32.h \ |
| 18 |
librhash/ed2k.c librhash/ed2k.h librhash/edonr.c librhash/edonr.h \ |
| 19 |
librhash/gost12.c librhash/gost12.h librhash/gost94.c librhash/gost94.h \ |
| 20 |
librhash/has160.c librhash/has160.h librhash/hex.c librhash/hex.h librhash/md4.c \ |
| 21 |
librhash/md4.h librhash/md5.c librhash/md5.h librhash/ripemd-160.c librhash/ripemd-160.h \ |
| 22 |
librhash/sha1.c librhash/sha1.h librhash/sha3.c librhash/sha3.h \ |
| 23 |
librhash/sha256.c librhash/sha256.h librhash/sha512.c librhash/sha512.h \ |
| 24 |
librhash/sha_ni.c librhash/sha_ni.h librhash/snefru.c librhash/snefru.h \ |
| 25 |
librhash/tiger.c librhash/tiger.h librhash/tiger_sbox.c \ |
| 26 |
librhash/torrent.h librhash/torrent.c librhash/tth.c librhash/tth.h \ |
| 27 |
librhash/whirlpool.c librhash/whirlpool.h librhash/whirlpool_sbox.c \ |
| 28 |
librhash/test_lib.c librhash/test_lib.h librhash/test_utils.c librhash/test_utils.h \ |
| 29 |
librhash/ustd.h librhash/util.c librhash/util.h librhash/Makefile |
| 30 |
I18N_FILES = po/ca.po po/de.po po/en_AU.po po/es.po po/fr.po po/gl.po po/it.po po/pt_BR.po po/ro.po po/ru.po po/uk.po |
| 31 |
ALL_FILES = $(SOURCES) $(HEADERS) $(LIBRHASH_FILES) $(OTHER_FILES) $(WIN_DIST_FILES) $(I18N_FILES) |
| 32 |
SPECFILE = dist/rhash.spec |
| 33 |
LIBRHASH_PC = dist/librhash.pc |
| 34 |
RPMTOP = rpms |
| 35 |
RPMDIRS = SOURCES SPECS BUILD SRPMS RPMS |
| 36 |
RHASH_NAME = rhash |
| 37 |
RHASH_BINARY = rhash$(EXEC_EXT) |
| 38 |
INSTALL_PROGRAM = $(INSTALL) -m 755 |
| 39 |
INSTALL_DATA = $(INSTALL) -m 644 |
| 40 |
|
| 41 |
all: $(BUILD_TARGETS) |
| 42 |
build: $(RHASH_BINARY) |
| 43 |
lib-shared: $(LIBRHASH_SHARED) |
| 44 |
lib-static: $(LIBRHASH_STATIC) |
| 45 |
install: build-install-binary install-data install-symlinks $(EXTRA_INSTALL) |
| 46 |
install-data: install-man install-conf |
| 47 |
uninstall: uninstall-binary uninstall-data uninstall-symlinks uninstall-lib uninstall-gmo uninstall-pkg-config |
| 48 |
|
| 49 |
config.mak: |
| 50 |
echo "Run the ./configure script first" && false |
| 51 |
|
| 52 |
# creating archives |
| 53 |
WIN_SUFFIX = win32 |
| 54 |
PACKAGE_NAME = $(RHASH_NAME)-$(VERSION) |
| 55 |
ARCHIVE_TARGZ = $(PACKAGE_NAME)-src.tar.gz |
| 56 |
ARCHIVE_TARGZ_CORE = $(RHASH_NAME)-core-$(VERSION)-src.tar.gz |
| 57 |
ARCHIVE_TARGZ_BINDINGS = $(RHASH_NAME)-bindings-$(VERSION)-src.tar.gz |
| 58 |
ARCHIVE_TARGZ_DEB = $(RHASH_NAME)_$(VERSION).orig.tar.gz |
| 59 |
ARCHIVE_XZ = $(PACKAGE_NAME)-src.tar.xz |
| 60 |
ARCHIVE_ZIP = $(PACKAGE_NAME)-$(WIN_SUFFIX).zip |
| 61 |
WIN_ZIP_DIR = RHash-$(VERSION)-$(WIN_SUFFIX) |
| 62 |
dist: tgz |
| 63 |
win-dist: zip |
| 64 |
zip: $(ARCHIVE_ZIP) |
| 65 |
dgz: check $(ARCHIVE_TARGZ_DEB) |
| 66 |
|
| 67 |
build-install-binary: $(BUILD_TARGETS) |
| 68 |
+$(MAKE) install-binary |
| 69 |
|
| 70 |
mkdir-bin: |
| 71 |
$(INSTALL) -d $(BINDIR) |
| 72 |
|
| 73 |
# install binary without (re-)compilation |
| 74 |
install-binary: mkdir-bin |
| 75 |
$(INSTALL_PROGRAM) $(RHASH_BINARY) $(BINDIR)/$(RHASH_BINARY) |
| 76 |
|
| 77 |
install-man: |
| 78 |
$(INSTALL) -d $(MANDIR)/man1 |
| 79 |
$(INSTALL_DATA) dist/rhash.1 $(MANDIR)/man1/rhash.1 |
| 80 |
|
| 81 |
install-conf: |
| 82 |
$(INSTALL) -d $(SYSCONFDIR) |
| 83 |
tr -d \\r < dist/rhashrc.sample > rc.tmp && $(INSTALL_DATA) rc.tmp $(SYSCONFDIR)/rhashrc |
| 84 |
rm -f rc.tmp |
| 85 |
|
| 86 |
# dependencies should be properly set, otherwise 'make -j<n>' can fail |
| 87 |
install-symlinks: mkdir-bin install-man install-binary |
| 88 |
cd $(BINDIR) && for f in $(SYMLINKS); do $(LN_S) $(RHASH_BINARY) $$f$(EXEC_EXT); done |
| 89 |
cd $(MANDIR)/man1 && for f in $(SYMLINKS); do $(LN_S) rhash.1 $$f.1; done |
| 90 |
|
| 91 |
install-pkg-config: |
| 92 |
$(INSTALL) -d $(PKGCONFIGDIR) |
| 93 |
$(INSTALL_DATA) $(LIBRHASH_PC) $(PKGCONFIGDIR)/ |
| 94 |
|
| 95 |
uninstall-binary: |
| 96 |
rm -f $(BINDIR)/$(RHASH_BINARY) |
| 97 |
|
| 98 |
uninstall-data: |
| 99 |
rm -f $(MANDIR)/man1/rhash.1 |
| 100 |
|
| 101 |
uninstall-symlinks: |
| 102 |
for f in $(SYMLINKS); do rm -f $(BINDIR)/$$f$(EXEC_EXT) $(MANDIR)/man1/$$f.1; done |
| 103 |
|
| 104 |
uninstall-pkg-config: |
| 105 |
rm -f $(PKGCONFIGDIR)/librhash.pc |
| 106 |
|
| 107 |
uninstall-lib: |
| 108 |
+cd librhash && $(MAKE) uninstall-lib |
| 109 |
|
| 110 |
install-lib-static: $(LIBRHASH_STATIC) install-lib-headers |
| 111 |
+cd librhash && $(MAKE) install-lib-static |
| 112 |
|
| 113 |
install-lib-shared: $(LIBRHASH_SHARED) |
| 114 |
+cd librhash && $(MAKE) install-lib-shared |
| 115 |
|
| 116 |
install-lib-headers: |
| 117 |
+cd librhash && $(MAKE) install-lib-headers |
| 118 |
|
| 119 |
install-lib-so-link: |
| 120 |
+cd librhash && $(MAKE) install-so-link |
| 121 |
|
| 122 |
$(LIBRHASH_SHARED): $(LIBRHASH_FILES) |
| 123 |
+cd librhash && $(MAKE) lib-shared |
| 124 |
|
| 125 |
$(LIBRHASH_STATIC): $(LIBRHASH_FILES) |
| 126 |
+cd librhash && $(MAKE) lib-static |
| 127 |
|
| 128 |
test-lib: test-lib-$(LIBRHASH_TYPE) |
| 129 |
|
| 130 |
test-lib-static: $(LIBRHASH_STATIC) |
| 131 |
+cd librhash && $(MAKE) test-static |
| 132 |
|
| 133 |
test-lib-shared: $(LIBRHASH_SHARED) |
| 134 |
+cd librhash && $(MAKE) test-shared |
| 135 |
|
| 136 |
test-libs: $(LIBRHASH_STATIC) $(LIBRHASH_SHARED) |
| 137 |
+cd librhash && $(MAKE) test-static test-shared |
| 138 |
|
| 139 |
test-full: $(RHASH_BINARY) |
| 140 |
/bin/sh tests/test_rhash.sh $(TEST_OPTIONS) --full ./$(RHASH_BINARY) |
| 141 |
|
| 142 |
test: $(RHASH_BINARY) |
| 143 |
/bin/sh tests/test_rhash.sh $(TEST_OPTIONS) ./$(RHASH_BINARY) |
| 144 |
|
| 145 |
print-info: lib-$(LIBRHASH_TYPE) |
| 146 |
+cd librhash && $(MAKE) print-info |
| 147 |
|
| 148 |
# check that source tree is consistent |
| 149 |
check: |
| 150 |
grep -q '\* === Version $(VERSION) ===' ChangeLog |
| 151 |
grep -q '^#define VERSION "$(VERSION)"' version.h |
| 152 |
test ! -f bindings/version.properties || grep -q '^version=$(VERSION)$$' bindings/version.properties |
| 153 |
|
| 154 |
$(RHASH_BINARY): $(OBJECTS) $(LIBRHASH_PATH) |
| 155 |
$(CC) $(OBJECTS) $(LIBRHASH_PATH) $(LDFLAGS) -o $@ |
| 156 |
|
| 157 |
# NOTE: dependences were generated by 'gcc -Ilibrhash -MM *.c' |
| 158 |
# we are using plain old makefile style to support BSD make |
| 159 |
calc_sums.o: calc_sums.c calc_sums.h common_func.h file.h hash_check.h \ |
| 160 |
file_set.h hash_print.h output.h parse_cmdline.h platform.h rhash_main.h \ |
| 161 |
win_utils.h librhash/rhash.h librhash/rhash_torrent.h |
| 162 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 163 |
|
| 164 |
common_func.o: common_func.c common_func.h output.h parse_cmdline.h \ |
| 165 |
version.h win_utils.h |
| 166 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 167 |
|
| 168 |
file.o: file.c file.h common_func.h parse_cmdline.h platform.h \ |
| 169 |
win_utils.h |
| 170 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 171 |
|
| 172 |
file_mask.o: file_mask.c file_mask.h common_func.h file.h |
| 173 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 174 |
|
| 175 |
file_set.o: file_set.c file_set.h common_func.h hash_print.h output.h \ |
| 176 |
parse_cmdline.h rhash_main.h file.h librhash/rhash.h |
| 177 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 178 |
|
| 179 |
find_file.o: find_file.c find_file.h common_func.h file.h output.h \ |
| 180 |
parse_cmdline.h platform.h win_utils.h |
| 181 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 182 |
|
| 183 |
hash_check.o: hash_check.c hash_check.h file.h file_set.h calc_sums.h \ |
| 184 |
common_func.h hash_print.h output.h parse_cmdline.h rhash_main.h \ |
| 185 |
librhash/rhash.h |
| 186 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 187 |
|
| 188 |
hash_print.o: hash_print.c hash_print.h calc_sums.h common_func.h file.h \ |
| 189 |
hash_check.h file_set.h output.h parse_cmdline.h rhash_main.h \ |
| 190 |
win_utils.h librhash/rhash.h |
| 191 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 192 |
|
| 193 |
hash_update.o: hash_update.c hash_update.h calc_sums.h common_func.h \ |
| 194 |
file.h hash_check.h file_set.h file_mask.h hash_print.h output.h \ |
| 195 |
parse_cmdline.h rhash_main.h win_utils.h |
| 196 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 197 |
|
| 198 |
output.o: output.c output.h calc_sums.h common_func.h file.h hash_check.h \ |
| 199 |
file_set.h parse_cmdline.h platform.h rhash_main.h win_utils.h \ |
| 200 |
librhash/rhash.h |
| 201 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 202 |
|
| 203 |
parse_cmdline.o: parse_cmdline.c parse_cmdline.h calc_sums.h \ |
| 204 |
common_func.h file.h hash_check.h file_set.h file_mask.h find_file.h \ |
| 205 |
hash_print.h output.h rhash_main.h win_utils.h librhash/rhash.h |
| 206 |
$(CC) -c $(CFLAGS) $(CONFCFLAGS) $< -o $@ |
| 207 |
|
| 208 |
rhash_main.o: rhash_main.c rhash_main.h file.h calc_sums.h common_func.h \ |
| 209 |
hash_check.h file_set.h file_mask.h find_file.h hash_print.h \ |
| 210 |
hash_update.h output.h parse_cmdline.h win_utils.h librhash/rhash.h |
| 211 |
$(CC) -c $(CFLAGS) $(LOCALECFLAGS) $< -o $@ |
| 212 |
|
| 213 |
win_utils.o: win_utils.c win_utils.h common_func.h file.h parse_cmdline.h |
| 214 |
$(CC) -c $(CFLAGS) $< -o $@ |
| 215 |
|
| 216 |
dist/rhash.1.win.html: dist/rhash.1 dist/rhash.1.win.sed |
| 217 |
sed -f dist/rhash.1.win.sed dist/rhash.1 | rman -fHTML -roff | \ |
| 218 |
sed -e '/<BODY/s/\(bgcolor=\)"[^"]*"/\1"white"/i' > dist/rhash.1.win.html |
| 219 |
# verify the result |
| 220 |
grep -q "utf8" dist/rhash.1.win.html |
| 221 |
grep -q "APPDATA" dist/rhash.1.win.html |
| 222 |
|
| 223 |
dist/rhash.1.html: dist/rhash.1 |
| 224 |
-rman --version 2>/dev/null && (rman -fHTML -roff dist/rhash.1 | sed -e '/<BODY/s/\(bgcolor=\)"[^"]*"/\1"white"/i' > $@) |
| 225 |
|
| 226 |
dist/rhash.1.txt: dist/rhash.1 |
| 227 |
-groff --version 2>/dev/null && (groff -t -e -mandoc -Tascii dist/rhash.1 | sed -e 's/.\[[0-9]*m//g' > $@) |
| 228 |
|
| 229 |
permissions: |
| 230 |
find . build dist docs librhash po tests -maxdepth 1 -type f -exec chmod -x '{}' \; |
| 231 |
chmod +x configure tests/test_rhash.sh |
| 232 |
|
| 233 |
copy-dist: $(ALL_FILES) permissions |
| 234 |
rm -rf $(PACKAGE_NAME) |
| 235 |
mkdir $(PACKAGE_NAME) |
| 236 |
cp -rl --parents $(ALL_FILES) $(PACKAGE_NAME)/ |
| 237 |
|
| 238 |
tgz-core: check |
| 239 |
+$(MAKE) copy-dist PACKAGE_NAME=$(PACKAGE_NAME)-core |
| 240 |
tar czf $(ARCHIVE_TARGZ_CORE) --owner=root --group=root $(PACKAGE_NAME)-core/ |
| 241 |
rm -rf $(PACKAGE_NAME)-core |
| 242 |
|
| 243 |
tgz-bindings: |
| 244 |
+cd bindings && $(MAKE) gzip ARCHIVE_GZIP=../$(ARCHIVE_TARGZ_BINDINGS) |
| 245 |
|
| 246 |
tgz: check clean-bindings |
| 247 |
+$(MAKE) copy-dist |
| 248 |
+cd bindings && $(MAKE) copy-dist COPYDIR=../$(PACKAGE_NAME)/bindings |
| 249 |
tar czf $(ARCHIVE_TARGZ) --owner=root:0 --group=root:0 $(PACKAGE_NAME)/ |
| 250 |
rm -rf $(PACKAGE_NAME) |
| 251 |
|
| 252 |
xz: check clean-bindings |
| 253 |
+$(MAKE) copy-dist |
| 254 |
+cd bindings && $(MAKE) copy-dist COPYDIR=../$(PACKAGE_NAME)/bindings |
| 255 |
tar cJf $(ARCHIVE_XZ) --owner=root:0 --group=root:0 $(PACKAGE_NAME)/ |
| 256 |
rm -rf $(PACKAGE_NAME) |
| 257 |
|
| 258 |
win-dir: $(WIN_DIST_FILES) dist/rhash.1.win.html |
| 259 |
test -s dist/rhash.1.win.html && test -x $(RHASH_BINARY) |
| 260 |
-rm -rf $(WIN_ZIP_DIR) |
| 261 |
mkdir $(WIN_ZIP_DIR) |
| 262 |
cp $(RHASH_BINARY) ChangeLog $(WIN_DIST_FILES) $(WIN_ZIP_DIR)/ |
| 263 |
cp dist/rhash.1.win.html $(WIN_ZIP_DIR)/rhash-doc.html |
| 264 |
|
| 265 |
$(ARCHIVE_ZIP): $(WIN_DIST_FILES) dist/rhash.1.win.html |
| 266 |
+$(MAKE) win-dir |
| 267 |
zip -9r $(ARCHIVE_ZIP) $(WIN_ZIP_DIR) |
| 268 |
rm -rf $(WIN_ZIP_DIR) |
| 269 |
|
| 270 |
$(ARCHIVE_TARGZ_DEB) : $(ALL_FILES) |
| 271 |
+$(MAKE) tgz |
| 272 |
mv -f $(ARCHIVE_TARGZ) $(ARCHIVE_TARGZ_DEB) |
| 273 |
|
| 274 |
# rpm packaging |
| 275 |
$(SPECFILE): $(SPECFILE).in config.mak |
| 276 |
sed -e 's/@VERSION@/$(VERSION)/' $(SPECFILE).in > $(SPECFILE) |
| 277 |
|
| 278 |
rpm: tgz |
| 279 |
-for i in $(RPMDIRS); do mkdir -p $(RPMTOP)/$$i; done |
| 280 |
cp -f $(ARCHIVE_TARGZ) $(RPMTOP)/SOURCES |
| 281 |
rpmbuild -ba --clean --define "_topdir `pwd`/$(RPMTOP)" $(SPECFILE) |
| 282 |
mv -f `find $(RPMTOP) -name "*rhash*-$(VERSION)*.rpm"` . |
| 283 |
rm -rf $(RPMTOP) |
| 284 |
|
| 285 |
clean-bindings: |
| 286 |
+cd bindings && $(MAKE) clean |
| 287 |
|
| 288 |
clean-local: |
| 289 |
rm -f *.o $(RHASH_BINARY) |
| 290 |
rm -f po/*.gmo po/*.po~ po/compile-gmo.tag |
| 291 |
|
| 292 |
distclean: clean-local |
| 293 |
rm -f config.log config.mak dist/rhash.1 $(SPECFILE) $(LIBRHASH_PC) |
| 294 |
+cd librhash && $(MAKE) distclean |
| 295 |
|
| 296 |
clean: clean-local |
| 297 |
+cd librhash && $(MAKE) clean |
| 298 |
|
| 299 |
update-po: |
| 300 |
xgettext *.c -k_ -cTRANSLATORS -o po/rhash.pot \ |
| 301 |
--msgid-bugs-address='Aleksey <[email protected]>' --package-name='RHash' |
| 302 |
for f in $(I18N_FILES); do \ |
| 303 |
msgmerge -U $$f po/rhash.pot; \ |
| 304 |
done |
| 305 |
|
| 306 |
po/compile-gmo.tag: $(I18N_FILES) |
| 307 |
for f in $(I18N_FILES); do \ |
| 308 |
g=`basename $$f .po`; \ |
| 309 |
msgfmt -o po/$$g.gmo $$f; \ |
| 310 |
done |
| 311 |
touch $@ |
| 312 |
|
| 313 |
compile-gmo: po/compile-gmo.tag |
| 314 |
|
| 315 |
install-gmo: compile-gmo |
| 316 |
for f in $(I18N_FILES); do \ |
| 317 |
l=`basename $$f .po`; \ |
| 318 |
$(INSTALL) -d $(LOCALEDIR)/$$l/LC_MESSAGES; \ |
| 319 |
$(INSTALL_DATA) po/$$l.gmo $(LOCALEDIR)/$$l/LC_MESSAGES/rhash.mo; \ |
| 320 |
done |
| 321 |
|
| 322 |
uninstall-gmo: |
| 323 |
for f in $(I18N_FILES); do \ |
| 324 |
rm -f $(LOCALEDIR)/`basename $$f .po`/LC_MESSAGES/rhash.mo; \ |
| 325 |
done |
| 326 |
|
| 327 |
.PHONY: all build lib-shared lib-static clean clean-bindings distclean clean-local \ |
| 328 |
test test-shared test-static test-full test-lib test-libs test-lib-shared test-lib-static \ |
| 329 |
install build-install-binary install-binary install-lib-shared install-lib-static \ |
| 330 |
install-lib-headers install-lib-so-link install-conf install-data install-gmo install-man \ |
| 331 |
install-symlinks install-pkg-config uninstall-gmo uninstall-pkg-config \ |
| 332 |
uninstall uninstall-binary uninstall-data uninstall-lib uninstall-symlinks \ |
| 333 |
print-info check copy-dist update-po compile-gmo mkdir-bin permissions \ |
| 334 |
dgz dist tgz tgz-bindings tgz-core rpm win-dist win-dir xz zip |