diff --git a/makefile b/makefile index a917931..e46d5ed 100644 --- a/makefile +++ b/makefile @@ -21,6 +21,8 @@ else RANLIB:=$(PREFIX)ranlib endif endif +INSTALL_CMD = install + #Output filenames for various targets. ifndef LIBNAME @@ -281,29 +283,11 @@ endif #This rule installs the library and the header files. This must be run #as root in order to have a high enough permission to write to the correct #directories and to set the owner and group to root. -ifndef NODOCS -install: library docs -else -install: library -endif - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 $(LIBNAME) $(LIBPATH) - install -m 644 $(HEADERS) $(INCPATH) -ifndef NODOCS - install -d $(DATAPATH) - install -m 644 doc/crypt.pdf $(DATAPATH) -endif +install: .common_install -install_bins: $(USEFUL_DEMOS) - install -d $(BINPATH) - install -m 775 $(USEFUL_DEMOS) $(BINPATH) +install_bins: .common_install_bins -install_test: $(LIBTEST) - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 $(LIBTEST) $(LIBPATH) - install -m 644 testprof/tomcrypt_test.h $(INCPATH) +install_test: .common_install_test profile: CFLAGS="$(CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov" diff --git a/makefile.common b/makefile.common index 95a4d19..c550cc2 100644 --- a/makefile.common +++ b/makefile.common @@ -1,5 +1,9 @@ #common make targets shared over multiple makefiles +ifndef INSTALL_CMD +$(error your makefile must define INSTALL_CMD) +endif + bins: $(USEFUL_DEMOS) all_test: test tv_gen $(DEMOS) @@ -14,6 +18,30 @@ doxy: docs: $(MAKE) -C doc/ crypt.pdf V=$(V) + +install_all: install install_bins install_docs install_test + + +.common_install: $(LIBNAME) + install -d $(INCPATH) + install -d $(LIBPATH) + $(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME) + install -m 644 $(HEADERS) $(INCPATH) + +.common_install_bins: $(USEFUL_DEMOS) + install -d $(BINPATH) + $(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH) + +.common_install_test: $(LIBTEST) + install -d $(LIBPATH) + install -d $(INCPATH) + install -m 644 testprof/tomcrypt_test.h $(INCPATH) + $(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH) + +install_docs: docs + install -d $(DATAPATH) + install -m 644 doc/crypt.pdf $(DATAPATH) + install_hooks: for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done diff --git a/makefile.shared b/makefile.shared index 43b2efa..ccc5a31 100644 --- a/makefile.shared +++ b/makefile.shared @@ -16,7 +16,7 @@ ifndef LT endif endif LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) - +INSTALL_CMD = $(LT) --mode=install install #Output filenames for various targets. ifndef LIBTEST_S @@ -239,23 +239,14 @@ $(LIBNAME): $(OBJECTS) $(LIBTEST): $(TOBJECTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./testprof -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) -install: $(LIBNAME) - install -d $(LIBPATH)/pkgconfig - install -d $(INCPATH) - $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME) - install -m 644 $(HEADERS) $(INCPATH) +install: .common_install sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > libtomcrypt.pc - install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc + install -d $(LIBPATH)/pkgconfig + install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/ -install_bins: $(USEFUL_DEMOS) - install -d $(BINPATH) - $(LT) --mode=install install -c $(USEFUL_DEMOS) $(BINPATH) +install_bins: .common_install_bins -install_test: $(LIBTEST) - install -d $(LIBPATH) - install -d $(INCPATH) - install -m 644 testprof/tomcrypt_test.h $(INCPATH) - $(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST) +install_test: .common_install_test test: $(LIBNAME) $(LIBTEST) $(TESTS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS)