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.

148 lines
4.3 KiB

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