aboutsummaryrefslogblamecommitdiffstats
path: root/Makefile
blob: e0415b164232e93d5006b30747c374c16fcad1fa (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13

       
                           
 








                      

                          

             
             




                                       



                      
                                 
                                               
                                             
                                              





                                            

                                            






                                             
                                      

















                                             





                                          


                                         

             

                                    


                     




                             

       

































                        

                    
                      



                    


                          







                                              
                                                    

      
                                                          

     
                                                                              

     
                                                   











                                                  

                                     



                                             


                                                            





                                                                                               


                                                                 






                                                                     



                                                                              

      


                                                                                    




                                         
.POSIX:

include mk/before-config.mk

CONFIGFILE = config.mk
include $(CONFIGFILE)

OS = linux
# Linux:   linux
# Mac OS:  macos
# Windows: windows
include mk/$(OS).mk

include mk/after-config.mk


LIB_MAJOR = 1
LIB_MINOR = 1
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
LIB_NAME = hashsum


OBJ =\
	$(OBJ_PUBLIC)\
	$(OBJ_HIDDEN)

OBJ_PUBLIC =\
	libhashsum_init_hasher.o\
	libhashsum_get_algorithm_from_string.o\
	libhashsum_init_hasher_from_string.o\
	libhashsum_get_relative_performance.o\
	libhashsum_init_md2_hasher.o\
	libhashsum_init_md4_hasher.o\
	libhashsum_init_md5_hasher.o\
	libhashsum_init_ripemd_128_hasher.o\
	libhashsum_init_ripemd_160_hasher.o\
	libhashsum_init_ripemd_256_hasher.o\
	libhashsum_init_ripemd_320_hasher.o\
	libhashsum_init_sha0_hasher.o\
	libhashsum_init_sha1_hasher.o\
	libhashsum_init_sha_224_hasher.o\
	libhashsum_init_sha_256_hasher.o\
	libhashsum_init_sha_384_hasher.o\
	libhashsum_init_sha_512_hasher.o\
	libhashsum_init_sha_512_224_hasher.o\
	libhashsum_init_sha_512_256_hasher.o\
	libhashsum_init_sha2_hasher.o\
	libhashsum_init_keccak_224_hasher.o\
	libhashsum_init_keccak_256_hasher.o\
	libhashsum_init_keccak_384_hasher.o\
	libhashsum_init_keccak_512_hasher.o\
	libhashsum_init_keccak_hasher.o\
	libhashsum_init_sha3_224_hasher.o\
	libhashsum_init_sha3_256_hasher.o\
	libhashsum_init_sha3_384_hasher.o\
	libhashsum_init_sha3_512_hasher.o\
	libhashsum_init_sha3_hasher.o\
	libhashsum_init_shake128_hasher.o\
	libhashsum_init_shake256_hasher.o\
	libhashsum_init_shake512_hasher.o\
	libhashsum_init_shake_hasher.o\
	libhashsum_init_rawshake128_hasher.o\
	libhashsum_init_rawshake256_hasher.o\
	libhashsum_init_rawshake512_hasher.o\
	libhashsum_init_rawshake_hasher.o\
	libhashsum_init_blake224_hasher.o\
	libhashsum_init_blake256_hasher.o\
	libhashsum_init_blakes_hasher.o\
	libhashsum_init_blake384_hasher.o\
	libhashsum_init_blake512_hasher.o\
	libhashsum_init_blakeb_hasher.o\
	libhashsum_init_blake_hasher.o\
	libhashsum_init_blake2s_hasher.o\
	libhashsum_init_blake2b_hasher.o

OBJ_HIDDEN =\
	libhashsum_reverse_byte__.o\
	libhashsum_init_keccak__.o

HDR =\
	libhashsum.h\
	common.h\
	$(SUBHDR)

SUBHDR =\
	libhashsum/internal.h

TEST =\
	t/md2.t\
	t/md4.t\
	t/md5.t\
	t/ripemd-128.t\
	t/ripemd-160.t\
	t/ripemd-256.t\
	t/ripemd-320.t\
	t/sha0.t\
	t/sha1.t\
	t/sha_224.t\
	t/sha_256.t\
	t/sha_384.t\
	t/sha_512.t\
	t/sha_512_224.t\
	t/sha_512_256.t\
	t/keccak_224.t\
	t/keccak_256.t\
	t/keccak_384.t\
	t/keccak_512.t\
	t/keccak.t\
	t/sha3_224.t\
	t/sha3_256.t\
	t/sha3_384.t\
	t/sha3_512.t\
	t/shake128.t\
	t/shake256.t\
	t/shake512.t\
	t/rawshake128.t\
	t/rawshake256.t\
	t/rawshake512.t\
	t/blake224.t\
	t/blake256.t\
	t/blake384.t\
	t/blake512.t\
	t/blake2s.t\
	t/blake2b.t\
	t/misc-tests.t

LOBJ = $(OBJ:.o=.lo)
TOBJ = $(TEST:.t=.o)

MAN3 = $(OBJ_PUBLIC:.o=.3)
MAN7 = libhashsum.7


all: libhashsum.a libhashsum.$(LIBEXT) $(TEST)
$(OBJ): $(HDR)
$(LOBJ): $(HDR)
$(TOBJ): $(HDR)
$(TEST): libhashsum.a

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS_FULL)

.c.lo:
	$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS_FULL)

.c.t:
	$(CC) -o $@ $< libhashsum.a $(CFLAGS) $(CPPFLAGS_FULL) $(LDFLAGS_FULL)

.o.t:
	$(CC) -o $@ $< libhashsum.a $(LDFLAGS_FULL)

libhashsum.a: $(OBJ)
	@rm -f -- $@
	$(AR) rc $@ $(OBJ)
	$(AR) ts $@ > /dev/null

libhashsum.$(LIBEXT): $(LOBJ)
	$(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)

check: $(TEST)
	@set -e;\
	for t in $(TEST); do\
		printf '%s\n' $$t;\
		$(CHECK_PREFIX) $$t;\
	done

install: libhashsum.a libhashsum.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include/libhashsum"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
	cp -- libhashsum.a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- libhashsum.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBMINOREXT)"
	$(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBMINOREXT)"
	ln -sf -- libhashsum.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBMAJOREXT)"
	ln -sf -- libhashsum.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBEXT)"
	cp -- libhashsum.h "$(DESTDIR)$(PREFIX)/include/"
	cp -- $(SUBHDR) "$(DESTDIR)$(PREFIX)/include/libhashsum/"
	cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3/"
	cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7/"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libhashsum.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libhashsum.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libhashsum.h"
	-cd -- "$(DESTDIR)$(PREFIX)/include/libhashsum/" && rm -f -- $(SUBHDR)
	-rmdir -- "$(DESTDIR)$(PREFIX)/include/libhashsum"
	-cd -- "$(DESTDIR)$(MANPREFIX)/man3/" && rm -f -- $(MAN3)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man7/" && rm -f -- $(MAN7)

clean:
	-rm -f -- *.o *.a *.lo *.su *.t *.gch *.gcov *.gcno *.gcda
	-rm -f -- t/*.o t/*.a t/*.lo t/*.su t/*.t t/*.gch t/*.gcov t/*.gcno t/*.gcda
	-rm -f -- *.so *.so.* *.dll *.dylib *.$(LIBEXT)

.SUFFIXES:
.SUFFIXES: .lo .o .c .t

.PHONY: all check install uninstall clean