makefile.shared 2.3 KB

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