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.

98 lines
3.5 KiB

  1. --- a/Makefile
  2. +++ b/Makefile
  3. @@ -1,58 +1,36 @@
  4. T=openssl
  5. +.PHONY: install clean
  6. -PREFIX ?=/usr/local
  7. -LIB_OPTION ?= -shared
  8. +PKGC ?= pkg-config
  9. -#Lua auto detect
  10. -LUA_VERSION ?= $(shell pkg-config luajit --print-provides)
  11. -ifeq ($(LUA_VERSION),) ############ Not use luajit
  12. -LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  13. -LUA_CFLAGS ?= -I$(PREFIX)/include/lua$(LUAV)
  14. -LUA_LIBS ?= -L$(PREFIX)/lib
  15. -LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
  16. -else
  17. -LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  18. -LUA_CFLAGS ?= $(shell pkg-config luajit --cflags)
  19. -LUA_LIBS ?= $(shell pkg-config luajit --libs)
  20. -LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
  21. -endif
  22. +LIB_OPTION = -shared
  23. -#OS auto detect
  24. -SYS := $(shell gcc -dumpmachine)
  25. +# lua's package config can be under various names
  26. +LUAPKGC := $(shell for pc in lua lua5.1 lua5.2 lua5.3; do \
  27. + $(PKGC) --exists $$pc && echo $$pc && break; \
  28. + done)
  29. -ifneq (, $(findstring linux, $(SYS)))
  30. -# Do linux things
  31. -LDFLAGS = -fPIC -lrt -ldl
  32. -OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
  33. -OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  34. -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  35. -endif
  36. -ifneq (, $(findstring apple, $(SYS)))
  37. -# Do darwin things
  38. -LDFLAGS = -fPIC -lrt -ldl
  39. +BUILD_DIR = $(shell pwd)
  40. +
  41. +# LUA include/libraries build flags
  42. +#LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  43. +LUA_LIBDIR := $(shell $(PKGC) --variable=libdir $(LUAPKGC))
  44. +LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
  45. +LUA_LIBS := $(shell $(PKGC) --libs-only-L $(LUAPKGC))
  46. +#LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
  47. +
  48. +# openssl include/libraries build flags
  49. +LDFLAGS += -lrt -ldl $(OPENSSL_LIBS) $(LUA_LIBS)
  50. OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
  51. OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  52. -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  53. -endif
  54. -ifneq (, $(findstring mingw, $(SYS)))
  55. -# Do mingw things
  56. -V = $(shell lua -e "v=string.gsub('$(LUAV)','%.','');print(v)")
  57. -LDFLAGS = -mwindows -lcrypt32 -lssl -lcrypto -lws2_32 $(PREFIX)/bin/lua$(V).dll
  58. -LUA_CFLAGS = -DLUA_LIB -DLUA_BUILD_AS_DLL -I$(PREFIX)/include/
  59. -CFLAGS = $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  60. -endif
  61. -ifneq (, $(findstring cygwin, $(SYS)))
  62. -# Do cygwin things
  63. -OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
  64. -OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  65. -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  66. -endif
  67. -#custome config
  68. +# openssl include/libraries build flags
  69. +LOCAL_INCLUDE = -I$(BUILD_DIR)/deps
  70. +CFLAGS += -fPIC -DPTHREADS $(LOCAL_INCLUDE) $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  71. ifeq (.config, $(wildcard .config))
  72. include .config
  73. endif
  74. -LIBNAME= $T.so.$V
  75. +LIBNAME= $T.so
  76. #LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
  77. @@ -68,11 +46,12 @@ OBJS=src/asn1.o src/auxiliar.o src/bio.o
  78. 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 \
  79. 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 src/xalgor.o src/callback.o
  80. -.c.o:
  81. - $(CC) -c -o $@ $?
  82. +%.o: %.c
  83. + $(CC) $(CFLAGS) -c $< -o $@
  84. all: $T.so
  85. echo $(SYS)
  86. + $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
  87. $T.so: $(OBJS)
  88. MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(OPENSSL_LIBS) $(LUA_LIBS) $(LDFLAGS)