Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # The contents of this file are subject to the Initial
  2. # Developer's Public License Version 1.0 (the "License");
  3. # you may not use this file except in compliance with the
  4. # License. You may obtain a copy of the License at
  5. # https://www.firebirdsql.org/en/initial-developer-s-public-license-version-1-0/
  6. #
  7. # Software distributed under the License is distributed AS IS,
  8. # WITHOUT WARRANTY OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing rights
  10. # and limitations under the License.
  11. #
  12. # The Original Code was created by Alexander Peshkoff
  13. # for the Firebird Open Source RDBMS project.
  14. #
  15. # Copyright (c) 2020 Alexander Peshkoff <[email protected]>
  16. # and all contributors signed below.
  17. #
  18. # All Rights Reserved.
  19. # Contributor(s): ______________________________________.
  20. ifndef ROOT
  21. ROOT=../..
  22. endif
  23. #ROOT=$(shell cd ../..; pwd)
  24. PLUGINS=$(ROOT)/plugins
  25. BIN=$(ROOT)/bin
  26. LIB=$(ROOT)/lib
  27. LIB_PREFIX=lib
  28. SHRLIB_EXT=so
  29. ifndef INTERMED
  30. INTERMED=.
  31. endif
  32. ifdef OUT
  33. OUT_BIN=$(OUT)/bin
  34. OUT_PLUG=$(OUT)/plugins
  35. else
  36. OUT_BIN=.
  37. OUT_PLUG=.
  38. endif
  39. TOMCRYPT_COMPILE=-DLTC_PTHREAD -DUSE_LTM -DLTM_DESC
  40. OwnInclude=$(shell [ -d tomcrypt.include ] && echo Yes || echo No)
  41. ifeq ($(OwnInclude), Yes)
  42. TOMCRYPT_COMPILE += -Itomcrypt.include
  43. TOMCRYPT_LINK=-L$(LIB)/.tm
  44. endif
  45. SIMPLE_KEY_AUTH_NAME=$(LIB_PREFIX)fbSampleExtAuth.$(SHRLIB_EXT)
  46. BLD_SIMPLE_KEY_AUTH=$(OUT_PLUG)/$(SIMPLE_KEY_AUTH_NAME)
  47. SIMPLE_KEY_AUTH=$(PLUGINS)/$(SIMPLE_KEY_AUTH_NAME)
  48. KEYGEN_NAME=fbSampleExtAuthKeygen
  49. BLD_KEYGEN=$(OUT_BIN)/$(KEYGEN_NAME)
  50. KEYGEN=$(BIN)/$(KEYGEN_NAME)
  51. KEYGEN_objects=$(INTERMED)/keygen.o
  52. TCWRAP_objects=$(INTERMED)/TcWrapper.o
  53. KEY_AUTH_objects=$(INTERMED)/ExtAuth.o
  54. CXXFLAGS=-std=c++11 -pthread -I$(ROOT)/include -fPIC $(TOMCRYPT_COMPILE)
  55. LDFLAGS=-pthread -L$(LIB) -Wl,-rpath,'$$ORIGIN/../lib' $(TOMCRYPT_LINK)
  56. LINK_LIBS=-lfbclient -ltomcrypt -ltommath
  57. $(INTERMED)/%.o: ./%.cpp
  58. $(CXX) $(CXXFLAGS) -c $(firstword $<) -o $@
  59. .PHONY: all keygen plugin install
  60. all: keygen plugin
  61. keygen: $(BLD_KEYGEN)
  62. $(BLD_KEYGEN): $(KEYGEN_objects) $(TCWRAP_objects)
  63. $(CXX) $(LDFLAGS) $^ -o $@ $(LINK_LIBS)
  64. plugin: $(BLD_SIMPLE_KEY_AUTH)
  65. $(BLD_SIMPLE_KEY_AUTH): $(KEY_AUTH_objects) $(TCWRAP_objects)
  66. $(CXX) -shared $(LDFLAGS) $^ -o $@ $(LINK_LIBS)
  67. clean:
  68. rm -f $(INTERMED)/*.o* $(BLD_KEYGEN) $(BLD_SIMPLE_KEY_AUTH)
  69. install: $(SIMPLE_KEY_AUTH) $(KEYGEN)
  70. $(SIMPLE_KEY_AUTH): $(BLD_SIMPLE_KEY_AUTH)
  71. cp $^ $@
  72. $(KEYGEN): $(BLD_KEYGEN)
  73. cp $^ $@