makefile.shared 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # MAKEFILE for linux GCC
  2. #
  3. # This makefile produces a shared object and requires libtool to be installed.
  4. #
  5. # Thanks to Zed Shaw for helping debug this on BSD/OSX.
  6. # Tom St Denis
  7. #
  8. # (GNU make only)
  9. ### USAGE:
  10. #
  11. # CFLAGS="-DUSE_LTM -DLTM_DESC -I/path/to/libtommath" make -f makefile.shared all EXTRALIBS=/path/to/libtommath/libtommath.a
  12. # ./test
  13. # make -f makefile.shared PREFIX=/opt/libtom install
  14. #
  15. PLATFORM := $(shell uname | sed -e 's/_.*//')
  16. ifeq ($(LIBTOOL),rlibtool)
  17. TGTLIBTOOL:=slibtool-shared
  18. else
  19. ifndef LIBTOOL
  20. ifeq ($(PLATFORM), Darwin)
  21. TGTLIBTOOL:=glibtool
  22. else
  23. TGTLIBTOOL:=libtool
  24. endif
  25. else
  26. TGTLIBTOOL=$(LIBTOOL)
  27. endif
  28. endif
  29. ifeq ($(PLATFORM), CYGWIN)
  30. NO_UNDEFINED:=-no-undefined
  31. endif
  32. LTCOMPILE = $(TGTLIBTOOL) --mode=compile --tag=CC $(CC)
  33. INSTALL_CMD = $(TGTLIBTOOL) --mode=install install
  34. UNINSTALL_CMD = $(TGTLIBTOOL) --mode=uninstall rm
  35. #Output filenames for various targets.
  36. ifndef LIBNAME
  37. LIBNAME=libtomcrypt.la
  38. endif
  39. include makefile_include.mk
  40. #ciphers come in two flavours... enc+dec and enc
  41. src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
  42. $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
  43. .c.o:
  44. $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
  45. LOBJECTS = $(OBJECTS:.o=.lo)
  46. $(LIBNAME): $(OBJECTS)
  47. $(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
  48. test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
  49. $(TGTLIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
  50. # build the demos from a template
  51. define DEMO_template
  52. $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
  53. $$(TGTLIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
  54. endef
  55. $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
  56. install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
  57. sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
  58. install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
  59. install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
  60. install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
  61. uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
  62. rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
  63. # ref: $Format:%D$
  64. # git commit: $Format:%H$
  65. # commit time: $Format:%ai$