You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
4.3 KiB

  1. --- a/Makefile
  2. +++ b/Makefile
  3. @@ -1,121 +1,52 @@
  4. T=openssl
  5. +.PHONY: install clean
  6. -PREFIX ?=/usr/local
  7. -CC := $(CROSS)$(CC)
  8. -AR := $(CROSS)$(AR)
  9. -LD := $(CROSS)$(LD)
  10. -
  11. -#OS auto detect
  12. -ifneq (,$(TARGET_SYS))
  13. - SYS := $(TARGET_SYS)
  14. -else
  15. - SYS := $(shell gcc -dumpmachine)
  16. -endif
  17. -
  18. -#Lua auto detect
  19. -LUA_VERSION := $(shell pkg-config luajit --print-provides)
  20. -ifeq ($(LUA_VERSION),)
  21. - # Not found luajit package, try lua
  22. - LUA_VERSION := $(shell pkg-config lua --print-provides)
  23. - ifeq ($(LUA_VERSION),)
  24. - # Not found lua package, try from prefix
  25. - LUA_VERSION := $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  26. - LUA_CFLAGS ?= -I$(PREFIX)/include/lua$(LUA_VERSION)
  27. - LUA_LIBS ?= -L$(PREFIX)/lib -llua
  28. - LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
  29. - else
  30. - # Found lua package
  31. - LUA_VERSION := $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  32. - LUA_CFLAGS ?= $(shell pkg-config lua --cflags)
  33. - LUA_LIBS ?= $(shell pkg-config lua --libs)
  34. - LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
  35. - endif
  36. -else
  37. - # Found luajit package
  38. - LUA_VERSION := $(shell luajit -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  39. - LUA_CFLAGS ?= $(shell pkg-config luajit --cflags)
  40. - LUA_LIBS ?= $(shell pkg-config luajit --libs)
  41. - LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
  42. -endif
  43. -
  44. -#OpenSSL auto detect
  45. -OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  46. -OPENSSL_LIBS ?= $(shell pkg-config openssl --static --libs)
  47. -
  48. -ifneq (, $(findstring linux, $(SYS)))
  49. - # Do linux things
  50. - CFLAGS = -fpic
  51. - LDFLAGS = -Wl,--no-undefined -fpic -lrt -ldl -lm
  52. -endif
  53. -
  54. -ifneq (, $(findstring apple, $(SYS)))
  55. - # Do darwin things
  56. - CFLAGS = -fPIC
  57. - LDFLAGS = -fPIC -undefined dynamic_lookup -ldl
  58. - #MACOSX_DEPLOYMENT_TARGET="10.3"
  59. - CC := MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(CC)
  60. -endif
  61. +PKGC ?= pkg-config
  62. -ifneq (, $(findstring mingw, $(SYS)))
  63. - # Do mingw things
  64. - CFLAGS = -DLUA_LIB -DLUA_BUILD_AS_DLL -DWIN32_LEAN_AND_MEAN
  65. -endif
  66. +LIB_OPTION = -shared
  67. +LUAPKGC = lua
  68. -ifneq (, $(findstring cygwin, $(SYS)))
  69. - # Do cygwin things
  70. - CFLAGS = -fPIC
  71. -endif
  72. +# LUA include/libraries build flags
  73. +LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
  74. +LUA_LIBS_DIR := $(shell $(PKGC) --libs $(LUAPKGC))
  75. -ifneq (, $(findstring iOS, $(SYS)))
  76. - # Do iOS things
  77. - CFLAGS = -fPIC
  78. - LDFLAGS = -fPIC -ldl
  79. -endif
  80. +# openssl include/libraries build flags
  81. +OPENSSL_CFLAGS ?= $(shell $(PKGC) openssl --cflags)
  82. +OPENSSL_LIBS_DIR ?= $(shell $(PKGC) openssl --libs)
  83. -#custom config
  84. +LDFLAGS = -Wl,--no-undefined -fpic -lrt -ldl -lm $(OPENSSL_LIBS_DIR) $(LUA_LIBS_DIR)
  85. +CFLAGS += -fPIC -DPTHREADS $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  86. ifeq (.config, $(wildcard .config))
  87. - include .config
  88. +include .config
  89. endif
  90. -LIBNAME= $T.so.$V
  91. +LIBNAME= $T.so
  92. -CFLAGS += $(OPENSSL_CFLAGS) $(LUA_CFLAGS) $(TARGET_FLAGS)
  93. -LDFLAGS += -shared $(OPENSSL_LIBS) $(LUA_LIBS)
  94. # Compilation directives
  95. WARN_MIN = -Wall -Wno-unused-value
  96. WARN = -Wall
  97. WARN_MOST = $(WARN) -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
  98. CFLAGS += -g $(WARN_MIN) -DPTHREADS -Ideps -Ideps/lua-compat -Ideps/auxiliar
  99. -
  100. OBJS=src/asn1.o deps/auxiliar/auxiliar.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o \
  101. src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o \
  102. src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o \
  103. src/xalgor.o src/callback.o src/srp.o deps/auxiliar/subsidiar.o
  104. -.c.o:
  105. - $(CC) $(CFLAGS) -c -o $@ $?
  106. +%.o: %.c
  107. + $(CC) $(CFLAGS) -c $< -o $@
  108. all: $T.so
  109. - @echo "Target system: "$(SYS)
  110. + echo $(SYS)
  111. + $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
  112. -$T.so: lib$T.a
  113. - $(CC) -o $@ src/openssl.o -L. -l$T $(LDFLAGS)
  114. -
  115. -lib$T.a: $(OBJS)
  116. - $(AR) rcs $@ $?
  117. +$T.so: $(OBJS)
  118. + echo "LUA LIBS_DIR: " $(LUA_LIBS_DIR)
  119. + $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(LDFLAGS)
  120. install: all
  121. mkdir -p $(LUA_LIBDIR)
  122. cp $T.so $(LUA_LIBDIR)
  123. -info:
  124. - @echo "Target system: "$(SYS)
  125. - @echo "CC:" $(CC)
  126. - @echo "AR:" $(AR)
  127. - @echo "PREFIX:" $(PREFIX)
  128. -
  129. clean:
  130. - rm -f $T.so lib$T.a $(OBJS)
  131. -
  132. -# vim: ts=8 sw=8 noet
  133. + rm -f $T.so $(OBJS)