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.

135 lines
4.5 KiB

  1. diff --git a/Makefile b/Makefile
  2. index 6cb1176..6605879 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -1,85 +1,45 @@
  6. -T=openssl
  7. -
  8. -PREFIX ?=/usr/local
  9. -LIB_OPTION ?= -shared
  10. -
  11. -#Lua auto detect
  12. -LUA_VERSION ?= $(shell pkg-config luajit --print-provides)
  13. -ifeq ($(LUA_VERSION),) ############ Not use luajit
  14. -LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  15. -LUA_CFLAGS ?= -I$(PREFIX)/include/lua$(LUAV)
  16. -LUA_LIBS ?= -L$(PREFIX)/lib
  17. -LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
  18. -else
  19. -LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
  20. -LUA_CFLAGS ?= $(shell pkg-config luajit --cflags)
  21. -LUA_LIBS ?= $(shell pkg-config luajit --libs)
  22. -LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
  23. -endif
  24. -
  25. -#OS auto detect
  26. -SYS := $(shell gcc -dumpmachine)
  27. -
  28. -ifneq (, $(findstring linux, $(SYS)))
  29. -# Do linux things
  30. -LDFLAGS = -fPIC -lrt -ldl
  31. -OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
  32. -OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  33. -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  34. -endif
  35. -ifneq (, $(findstring apple, $(SYS)))
  36. -# Do darwin things
  37. -LDFLAGS = -fPIC -lrt -ldl
  38. -OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
  39. -OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  40. -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  41. -endif
  42. -ifneq (, $(findstring mingw, $(SYS)))
  43. -# Do mingw things
  44. -V = $(shell lua -e "v=string.gsub('$(LUAV)','%.','');print(v)")
  45. -LDFLAGS = -mwindows -lcrypt32 -lssl -lcrypto -lws2_32 $(PREFIX)/bin/lua$(V).dll
  46. -LUA_CFLAGS = -DLUA_LIB -DLUA_BUILD_AS_DLL -I$(PREFIX)/include/
  47. -CFLAGS = $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  48. -endif
  49. -ifneq (, $(findstring cygwin, $(SYS)))
  50. -# Do cygwin things
  51. -OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
  52. -OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
  53. -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  54. -endif
  55. -#custome config
  56. -ifeq (.config, $(wildcard .config))
  57. -include .config
  58. -endif
  59. -
  60. -LIBNAME= $T.so.$V
  61. -
  62. -#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
  63. -
  64. -# Compilation directives
  65. -WARN_MOST = -Wall -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
  66. -WARN = -Wall -Wno-unused-value
  67. -WARN_MIN =
  68. -CFLAGS += $(WARN_MIN) -DPTHREADS
  69. -CC= gcc -g $(CFLAGS) -Ideps
  70. -
  71. -
  72. -OBJS=src/asn1.o src/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 \
  73. -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 \
  74. -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
  75. -
  76. -.c.o:
  77. - $(CC) -c -o $@ $?
  78. -
  79. -all: $T.so
  80. - echo $(SYS)
  81. -
  82. -$T.so: $(OBJS)
  83. - MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(OPENSSL_LIBS) $(LUA_LIBS) $(LDFLAGS)
  84. -
  85. -install: all
  86. - mkdir -p $(LUA_LIBDIR)
  87. - cp $T.so $(LUA_LIBDIR)
  88. -
  89. -clean:
  90. - rm -f $T.so $(OBJS)
  91. +.PHONY: install clean
  92. +
  93. +PKGC ?= pkg-config
  94. +
  95. +LIBNAME = openssl.so
  96. +LIB_OPTION = -shared
  97. +
  98. +# lua's package config can be under various names
  99. +LUAPKGC := $(shell for pc in lua lua5.1 lua5.2 lua5.3; do \
  100. + $(PKGC) --exists $$pc && echo $$pc && break; \
  101. + done)
  102. +
  103. +BUILD_DIR = $(shell pwd)
  104. +
  105. +# LUA include/libraries build flags
  106. +LUA_LIBDIR := $(shell $(PKGC) --variable=libdir $(LUAPKGC))
  107. +LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
  108. +LUA_LIBS := $(shell $(PKGC) --libs-only-L $(LUAPKGC))
  109. +
  110. +# openssl include/libraries build flags
  111. +OPENSSL_LIBS = $(shell $(PKGC) openssl --libs)
  112. +OPENSSL_CFLAGS = $(shell $(PKGC) openssl --cflags)
  113. +
  114. +# openssl include/libraries build flags
  115. +LOCAL_INCLUDE = -I$(BUILD_DIR)/deps
  116. +
  117. +CFLAGS += -fPIC -DPTHREADS -g $(LOCAL_INCLUDE) $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
  118. +LDFLAGS += -lrt -ldl $(OPENSSL_LIBS) $(LUA_LIBS)
  119. +
  120. +OBJS = src/asn1.o src/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 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 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
  121. +
  122. +all: clean $(LIBNAME)
  123. +
  124. +$(LIBNAME): $(OBJS)
  125. + $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
  126. +
  127. +%.o: %.c
  128. + $(CC) $(CFLAGS) -c $< -o $@
  129. +
  130. +install: all
  131. + mkdir -p $(LUA_LIBDIR)
  132. + cp $(LIBNAME) $(LUA_LIBDIR)
  133. +
  134. +clean:
  135. + rm -f $(LIBNAME) $(OBJS)