diff options
| author | William Ahern <william@server.local> | 2013-09-09 13:59:31 -0700 |
|---|---|---|
| committer | William Ahern <william@server.local> | 2013-09-09 13:59:31 -0700 |
| commit | 6e6b301ceee052ffd4187d9024c09520e4378de3 (patch) | |
| tree | 4711d0e9a4868dda93a6168329e5ee9e4cc2781e | |
| parent | 709e7fde568d3808089d92114632e4f273ba924b (diff) | |
| download | luaossl-6e6b301ceee052ffd4187d9024c09520e4378de3.tar.gz luaossl-6e6b301ceee052ffd4187d9024c09520e4378de3.tar.bz2 luaossl-6e6b301ceee052ffd4187d9024c09520e4378de3.zip | |
-n
update openssl modules to new build
| -rw-r--r-- | GNUmakefile | 283 |
1 files changed, 133 insertions, 150 deletions
diff --git a/GNUmakefile b/GNUmakefile index d484ff5..c895dd1 100644 --- a/GNUmakefile +++ b/GNUmakefile | |||
| @@ -1,163 +1,146 @@ | |||
| 1 | prefix = /usr/local | 1 | # non-recursive prologue |
| 2 | bindir = $(prefix)/bin | 2 | sp := $(sp).x |
| 3 | libdir = $(prefix)/lib | 3 | dirstack_$(sp) := $(d) |
| 4 | datadir = $(prefix)/share | 4 | d := $(abspath $(lastword $(MAKEFILE_LIST))/..) |
| 5 | includedir = $(prefix)/include | ||
| 6 | luainclude = | ||
| 7 | luapath = | ||
| 8 | luacpath = | ||
| 9 | LUAC = | ||
| 10 | |||
| 11 | # backwards compatible install paths | ||
| 12 | ifneq ($(origin lua52include), undefined) | ||
| 13 | luainclude = $(lua52include) | ||
| 14 | endif | ||
| 15 | 5 | ||
| 16 | ifneq ($(origin lua52path), undefined) | 6 | ifeq ($(origin GUARD_$(d)), undefined) |
| 17 | luapath = $(lua52path) | 7 | GUARD_$(d) := 1 |
| 18 | endif | ||
| 19 | 8 | ||
| 20 | ifneq ($(origin lua52cpath), undefined) | ||
| 21 | luacpath = $(lua52cpath) | ||
| 22 | endif | ||
| 23 | 9 | ||
| 10 | # | ||
| 11 | # E N V I R O N M E N T C O N F I G U R A T I O N | ||
| 12 | # | ||
| 13 | include $(d)/../GNUmakefile | ||
| 24 | 14 | ||
| 25 | # call helper to derive our Lua paths | ||
| 26 | ENV = CC CPPFLAGS prefix bindir libdir datadir includedir \ | ||
| 27 | luainclude luapath luacpath LUAC | ||
| 28 | $(shell env $(foreach V, $(ENV), $(V)="$(call $(V))") ../mk/lua.path make > .config) | ||
| 29 | include .config | ||
| 30 | 15 | ||
| 16 | # | ||
| 17 | # C O M P I L A T I O N F L A G S | ||
| 18 | # | ||
| 19 | OS_$(d) = $(shell $(d)/../mk/vendor.os) | ||
| 20 | CC_$(d) = $(shell $(d)/../mk/vendor.cc) | ||
| 21 | LUAPATH_$(d) = $(shell env CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(<D)/../mk/lua.path -krxm3 -I$(DESTDIR)$(includedir) -I/usr/include -I/usr/local/include -P$(DESTDIR)$(bindir) -P$(bindir) -L$(DESTDIR)$(libdir) -L$(libdir) -v$(1) $(2)) | ||
| 31 | 22 | ||
| 32 | VENDOR.OS = $(shell ../mk/vendor.os) | 23 | CPPFLAGS_$(d) = $(CPPFLAGS_$(abspath $(@D)/../..)) |
| 33 | VENDOR.CC = $(shell env CC="${CC}" ../mk/vendor.cc) | 24 | CFLAGS_$(d) = $(CFLAGS_$(abspath $(@D)/../..)) |
| 25 | LDFLAGS_$(d) = $(LDFLAGS_$(abspath $(@D)/../..)) | ||
| 26 | SOFLAGS_$(d) = $(SOFLAGS_$(abspath $(@D)/../..)) | ||
| 34 | 27 | ||
| 35 | ifneq ($(luainclude),) | 28 | ifeq ($(CC_$(d)), sunpro) |
| 36 | CPPFLAGS = -I$(luainclude) | 29 | CPPFLAGS_$(d) += -DOPENSSL_NO_EC |
| 37 | endif | 30 | endif |
| 38 | 31 | ||
| 39 | ifeq ($(VENDOR.CC), sunpro) | 32 | LDFLAGS_$(d) += -lssl -lcrypto |
| 40 | DFLAGS = -g | ||
| 41 | CFLAGS = -xcode=pic13 $(DFLAGS) | ||
| 42 | CPPFLAGS += -DOPENSSL_NO_EC | ||
| 43 | else | ||
| 44 | DFLAGS = -g -Wall -Wextra -Wno-deprecated-declarations -Wno-unused | ||
| 45 | CFLAGS = -fPIC $(DFLAGS) | ||
| 46 | endif | ||
| 47 | 33 | ||
| 48 | LDFLAGS = -lssl -lcrypto | 34 | # |
| 35 | # C O M P I L A T I O N R U L E S | ||
| 36 | # | ||
| 37 | #all: $(d)/openssl.so | ||
| 38 | |||
| 39 | define BUILD_$(d) | ||
| 40 | |||
| 41 | .INTERMEDIATE: liblua$(1)-openssl | ||
| 42 | |||
| 43 | $$(d)/$(1)/openssl.so: $$(d)/$(1)/openssl.o | ||
| 44 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(SOFLAGS) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS) | ||
| 45 | |||
| 46 | $$(d)/$(1)/openssl.o: $$(d)/openssl.c $$(d)/compat52.h | ||
| 47 | test "$$(notdir $$(@D))" = "$$(call LUAPATH_$$(<D), $$(notdir $$(@D)), version)" | ||
| 48 | $$(MKDIR) -p $$(@D) | ||
| 49 | $$(CC) $$(CFLAGS_$$(<D)) $$(CFLAGS) $$(call LUAPATH_$$(<D), $$(notdir $$(@D)), cppflags) $$(CPPFLAGS_$$(<D)) $$(CPPFLAGS) -c -o $$@ $$< | ||
| 50 | |||
| 51 | liblua$(1)-openssl: $$(d)/$(1)/openssl.so | ||
| 52 | |||
| 53 | all: liblua$(1)-openssl | ||
| 54 | |||
| 55 | endef # BUILD_$(d) | ||
| 56 | |||
| 57 | $(eval $(call BUILD_$(d),5.1)) | ||
| 58 | |||
| 59 | $(eval $(call BUILD_$(d),5.2)) | ||
| 60 | |||
| 61 | |||
| 62 | # | ||
| 63 | # I N S T A L L & U N I N S T A L L R U L E S | ||
| 64 | # | ||
| 65 | define INSTALL_$(d) | ||
| 66 | |||
| 67 | LUAC$(1)_$(d) = $$(or $$(call LUAPATH_$(d), $(1), luac), true) | ||
| 68 | |||
| 69 | MODS$(1)_$(d) = \ | ||
| 70 | $$(DESTDIR)$(2)/_openssl.so \ | ||
| 71 | $$(DESTDIR)$(3)/openssl/bignum.lua \ | ||
| 72 | $$(DESTDIR)$(3)/openssl/pubkey.lua \ | ||
| 73 | $$(DESTDIR)$(3)/openssl/x509.lua \ | ||
| 74 | $$(DESTDIR)$(3)/openssl/x509/name.lua \ | ||
| 75 | $$(DESTDIR)$(3)/openssl/x509/altname.lua \ | ||
| 76 | $$(DESTDIR)$(3)/openssl/x509/chain.lua \ | ||
| 77 | $$(DESTDIR)$(3)/openssl/x509/store.lua \ | ||
| 78 | $$(DESTDIR)$(3)/openssl/ssl/context.lua \ | ||
| 79 | $$(DESTDIR)$(3)/openssl/ssl.lua \ | ||
| 80 | $$(DESTDIR)$(3)/openssl/digest.lua \ | ||
| 81 | $$(DESTDIR)$(3)/openssl/hmac.lua \ | ||
| 82 | $$(DESTDIR)$(3)/openssl/cipher.lua | ||
| 83 | |||
| 84 | .INTERMEDIATE: liblua$(1)-openssl-install | ||
| 85 | |||
| 86 | $$(DESTDIR)$(2)/_openssl.so: $$(d)/$(1)/openssl.so | ||
| 87 | $$(MKDIR) -p $$(@D) | ||
| 88 | $$(CP) -p $$< $$@ | ||
| 89 | |||
| 90 | $$(DESTDIR)$(3)/openssl/%.lua: $$(d)/openssl.%.lua | ||
| 91 | $$(MKDIR) -p $$(@D) | ||
| 92 | $$(CP) -p $$< $$@ | ||
| 93 | |||
| 94 | $$(DESTDIR)$(3)/openssl/x509/%.lua: $$(d)/openssl.x509.%.lua | ||
| 95 | $$(MKDIR) -p $$(@D) | ||
| 96 | $$(CP) -p $$< $$@ | ||
| 97 | |||
| 98 | $$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua | ||
| 99 | $$(MKDIR) -p $$(@D) | ||
| 100 | $$(CP) -p $$< $$@ | ||
| 101 | |||
| 102 | $$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua | ||
| 103 | $$(MKDIR) -p $$(@D) | ||
| 104 | $$(CP) -p $$< $$@ | ||
| 105 | |||
| 106 | liblua$(1)-openssl-install: $$(MODS$(1)_$$(d)) | ||
| 107 | |||
| 108 | .PHONY: liblua$(1)-openssl-uninstall uninstall | ||
| 109 | |||
| 110 | liblua$(1)-openssl-uninstall: | ||
| 111 | $$(RM) -f $$(MODS$(1)_$(d)) | ||
| 112 | -$$(RMDIR) $$(DESTDIR)$(3)/openssl/x509 | ||
| 113 | -$$(RMDIR) $$(DESTDIR)$(3)/openssl/ssl | ||
| 114 | -$$(RMDIR) $$(DESTDIR)$(3)/openssl | ||
| 115 | |||
| 116 | uninstall: liblua$(1)-openssl-uninstall | ||
| 117 | |||
| 118 | endef # INSTALL_$(d) | ||
| 119 | |||
| 120 | |||
| 121 | $(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path))) | ||
| 122 | |||
| 123 | $(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path))) | ||
| 124 | |||
| 125 | |||
| 126 | # | ||
| 127 | # C L E A N R U L E S | ||
| 128 | # | ||
| 129 | .PHONY: $(d)/clean $(d)/clean~ clean clean~ | ||
| 130 | |||
| 131 | $(d)/clean: | ||
| 132 | $(RM) -fr $(@D)/*.so $(@D)/*.o $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2 | ||
| 133 | |||
| 134 | $(d)/clean~: $(d)/clean | ||
| 135 | $(RM) -f $(@D)/*~ | ||
| 136 | |||
| 137 | clean: $(d)/clean | ||
| 138 | |||
| 139 | clean~: $(d)/clean~ | ||
| 49 | 140 | ||
| 50 | ifeq ($(VENDOR.OS), Darwin) | ||
| 51 | SOFLAGS = -bundle -undefined dynamic_lookup | ||
| 52 | else | ||
| 53 | SOFLAGS = -shared | ||
| 54 | endif | ||
| 55 | 141 | ||
| 142 | endif # include guard | ||
| 56 | 143 | ||
| 57 | all: openssl.so | 144 | # non-recursive epilogue |
| 58 | 145 | d := $(dirstack_$(sp)) | |
| 59 | openssl.so: openssl.o | 146 | sp := $(basename $(sp)) |
| 60 | $(CC) -o $@ $^ $(SOFLAGS) $(LDFLAGS) | ||
| 61 | |||
| 62 | openssl.o: openssl.c compat52.h | ||
| 63 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< | ||
| 64 | |||
| 65 | |||
| 66 | install: $(DESTDIR)$(luacpath)/_openssl.so \ | ||
| 67 | $(DESTDIR)$(luapath)/openssl/bignum.lua \ | ||
| 68 | $(DESTDIR)$(luapath)/openssl/pubkey.lua \ | ||
| 69 | $(DESTDIR)$(luapath)/openssl/x509.lua \ | ||
| 70 | $(DESTDIR)$(luapath)/openssl/x509/name.lua \ | ||
| 71 | $(DESTDIR)$(luapath)/openssl/x509/altname.lua \ | ||
| 72 | $(DESTDIR)$(luapath)/openssl/x509/chain.lua \ | ||
| 73 | $(DESTDIR)$(luapath)/openssl/x509/store.lua \ | ||
| 74 | $(DESTDIR)$(luapath)/openssl/ssl/context.lua \ | ||
| 75 | $(DESTDIR)$(luapath)/openssl/ssl.lua \ | ||
| 76 | $(DESTDIR)$(luapath)/openssl/digest.lua \ | ||
| 77 | $(DESTDIR)$(luapath)/openssl/hmac.lua \ | ||
| 78 | $(DESTDIR)$(luapath)/openssl/cipher.lua | ||
| 79 | |||
| 80 | $(DESTDIR)$(luacpath)/_openssl.so: openssl.so | ||
| 81 | mkdir -p $(@D) | ||
| 82 | cp -p $< $@ | ||
| 83 | |||
| 84 | $(DESTDIR)$(luapath)/openssl/bignum.lua: openssl.bignum.lua | ||
| 85 | mkdir -p $(@D) | ||
| 86 | cp -p $< $@ | ||
| 87 | |||
| 88 | $(DESTDIR)$(luapath)/openssl/pubkey.lua: openssl.pubkey.lua | ||
| 89 | mkdir -p $(@D) | ||
| 90 | cp -p $< $@ | ||
| 91 | |||
| 92 | $(DESTDIR)$(luapath)/openssl/x509.lua: openssl.x509.lua | ||
| 93 | mkdir -p $(@D) | ||
| 94 | cp -p $< $@ | ||
| 95 | |||
| 96 | $(DESTDIR)$(luapath)/openssl/x509/name.lua: openssl.x509.name.lua | ||
| 97 | mkdir -p $(@D) | ||
| 98 | cp -p $< $@ | ||
| 99 | |||
| 100 | $(DESTDIR)$(luapath)/openssl/x509/altname.lua: openssl.x509.altname.lua | ||
| 101 | mkdir -p $(@D) | ||
| 102 | cp -p $< $@ | ||
| 103 | |||
| 104 | $(DESTDIR)$(luapath)/openssl/x509/chain.lua: openssl.x509.chain.lua | ||
| 105 | mkdir -p $(@D) | ||
| 106 | cp -p $< $@ | ||
| 107 | |||
| 108 | $(DESTDIR)$(luapath)/openssl/x509/store.lua: openssl.x509.store.lua | ||
| 109 | mkdir -p $(@D) | ||
| 110 | cp -p $< $@ | ||
| 111 | |||
| 112 | $(DESTDIR)$(luapath)/openssl/ssl/context.lua: openssl.ssl.context.lua | ||
| 113 | mkdir -p $(@D) | ||
| 114 | cp -p $< $@ | ||
| 115 | |||
| 116 | $(DESTDIR)$(luapath)/openssl/ssl.lua: openssl.ssl.lua | ||
| 117 | mkdir -p $(@D) | ||
| 118 | cp -p $< $@ | ||
| 119 | |||
| 120 | $(DESTDIR)$(luapath)/openssl/digest.lua: openssl.digest.lua | ||
| 121 | mkdir -p $(@D) | ||
| 122 | cp -p $< $@ | ||
| 123 | |||
| 124 | $(DESTDIR)$(luapath)/openssl/hmac.lua: openssl.hmac.lua | ||
| 125 | mkdir -p $(@D) | ||
| 126 | cp -p $< $@ | ||
| 127 | |||
| 128 | $(DESTDIR)$(luapath)/openssl/cipher.lua: openssl.cipher.lua | ||
| 129 | mkdir -p $(@D) | ||
| 130 | cp -p $< $@ | ||
| 131 | |||
| 132 | |||
| 133 | .PHONY: clean clean~ help | ||
| 134 | |||
| 135 | clean: | ||
| 136 | rm -f *.so *.o | ||
| 137 | rm -f .config | ||
| 138 | |||
| 139 | clean~: clean | ||
| 140 | rm -f *~ | ||
| 141 | |||
| 142 | help: | ||
| 143 | @echo "Available targets:" | ||
| 144 | @echo "" | ||
| 145 | @echo " all - build all binary targets" | ||
| 146 | @echo "openssl.so - build openssl.so module" | ||
| 147 | @echo " install - install openssl modules" | ||
| 148 | @echo " clean - rm binary targets, object files, debugging symbols, etc" | ||
| 149 | @echo " clean~ - clean + rm *~" | ||
| 150 | @echo " help - echo this help message" | ||
| 151 | @echo "" | ||
| 152 | @echo "Some important Make variables:" | ||
| 153 | @echo "" | ||
| 154 | @echo " prefix - path to install root" | ||
| 155 | @echo 'luainclude - path to Lua headers ($$(prefix)/include/lua/5.2)' | ||
| 156 | @echo ' luapath - install path for Lua modules ($$(prefix)/share/lua/5.2)' | ||
| 157 | @echo ' luacpath - install path for Lua C modules ($$(prefix)/lib/lua/5.2)' | ||
| 158 | @echo ' LUAC - path to luac utility ($$(bindir)/luac)' | ||
| 159 | @echo "" | ||
| 160 | @echo "(NOTE: all the common GNU-style paths are supported, including" | ||
| 161 | @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)" | ||
| 162 | @echo "" | ||
| 163 | @echo "Report bugs to <william@25thandClement.com>" | ||
