makefile.shared 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #Output filenames for various targets.
  26. ifndef LIBNAME
  27. LIBNAME=libtomcrypt.la
  28. endif
  29. include makefile_include.mk
  30. #ciphers come in two flavours... enc+dec and enc
  31. src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
  32. $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
  33. .c.o:
  34. $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $<
  35. $(LIBNAME): $(OBJECTS)
  36. $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo" | LC_ALL=C sort` $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT)
  37. install: .common_install
  38. sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' libtomcrypt.pc.in > libtomcrypt.pc
  39. install -d $(DESTDIR)$(LIBPATH)/pkgconfig
  40. install -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
  41. install_bins: .common_install_bins
  42. test: $(LIBNAME) $(TOBJECTS)
  43. $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
  44. timing: $(TIMINGS) $(LIBNAME)
  45. $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $^ $(EXTRALIBS)
  46. # build the demos from a template
  47. define DEMO_template
  48. $(1): demos/$(1).o $$(LIBNAME)
  49. ifneq ($V,1)
  50. @echo " * $${CC} $$@"
  51. endif
  52. $$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
  53. endef
  54. $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
  55. # ref: $Format:%D$
  56. # git commit: $Format:%H$
  57. # commit time: $Format:%ai$