makefile.shared 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. ifndef LIBTOOL
  17. ifeq ($(PLATFORM), Darwin)
  18. LIBTOOL:=glibtool
  19. else
  20. LIBTOOL:=libtool
  21. endif
  22. endif
  23. ifeq ($(PLATFORM), CYGWIN)
  24. NO_UNDEFINED:=-no-undefined
  25. endif
  26. LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC)
  27. INSTALL_CMD = $(LIBTOOL) --mode=install install
  28. UNINSTALL_CMD = $(LIBTOOL) --mode=uninstall rm
  29. #Output filenames for various targets.
  30. ifndef LIBNAME
  31. LIBNAME=libtomcrypt.la
  32. endif
  33. include makefile_include.mk
  34. #ciphers come in two flavours... enc+dec and enc
  35. src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
  36. $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
  37. .c.o:
  38. $(LTCOMPILE) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $@ -c $<
  39. LOBJECTS = $(OBJECTS:.o=.lo)
  40. $(LIBNAME): $(OBJECTS)
  41. $(LIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
  42. test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
  43. $(LIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
  44. # build the demos from a template
  45. define DEMO_template
  46. $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
  47. $$(LIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
  48. endef
  49. $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
  50. install: $(call print-help,install,Installs the library + headers + pkg-config file) .common_install
  51. sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
  52. install -p -d $(DESTDIR)$(LIBPATH)/pkgconfig
  53. install -p -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
  54. install_bins: $(call print-help,install_bins,Installs the useful demos ($(USEFUL_DEMOS))) .common_install_bins
  55. uninstall: $(call print-help,uninstall,Uninstalls the library + headers + pkg-config file) .common_uninstall
  56. rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
  57. # ref: $Format:%D$
  58. # git commit: $Format:%H$
  59. # commit time: $Format:%ai$