diff options
| -rw-r--r-- | GNUmakefile | 205 | ||||
| -rw-r--r-- | src/GNUmakefile | 133 |
2 files changed, 210 insertions, 128 deletions
diff --git a/GNUmakefile b/GNUmakefile index c58686c..1893378 100644 --- a/GNUmakefile +++ b/GNUmakefile | |||
| @@ -9,6 +9,20 @@ GUARD_$(d) := 1 | |||
| 9 | 9 | ||
| 10 | all: # default target | 10 | all: # default target |
| 11 | 11 | ||
| 12 | # | ||
| 13 | # G N U M A K E F U N C T I O N S | ||
| 14 | # | ||
| 15 | KNOWN_APIS = 5.1 5.2 5.3 | ||
| 16 | |||
| 17 | # template for invoking luapath script | ||
| 18 | LUAPATH := $(d)/mk/luapath | ||
| 19 | LUAPATH_FN = $(shell env CC='$(subst ',\\',$(CC))' CPPFLAGS='$(subst ',\\',$(CPPFLAGS))' LDFLAGS='$(subst ',\\',$(LDFLAGS))' $(LUAPATH) -krxm3 -I '$(subst ',\\',$(DESTDIR)$(includedir))' -I/usr/include -I/usr/local/include -P '$(subst ',\\',$(DESTDIR)$(bindir))' -P '$(subst ',\\',$(bindir))' -L '$(subst ',\\',$(DESTDIR)$(libdir))' -L '$(subst ',\\',$(libdir))' -v$(1) $(2)) | ||
| 20 | |||
| 21 | # check whether luapath can locate Lua $(1) headers | ||
| 22 | HAVE_API_FN = $(and $(filter $(1),$(call LUAPATH_FN,$(1),version)),$(1)$(info enabling Lua $(1))) | ||
| 23 | |||
| 24 | # check whether $(1) in LUA_APIS or $(LUA$(1:.=)_CPPFLAGS) is non-empty | ||
| 25 | WITH_API_FN = $$(and $$(or $$(filter $(1),$$(LUA_APIS)),$$(LUA$(subst .,,$(1))_CPPFLAGS)),$(1)) | ||
| 12 | 26 | ||
| 13 | # | 27 | # |
| 14 | # E N V I R O N M E N T C O N F I G U R A T I O N | 28 | # E N V I R O N M E N T C O N F I G U R A T I O N |
| @@ -30,47 +44,43 @@ lua53path ?= $(datadir)/lua/5.3 | |||
| 30 | AR ?= ar | 44 | AR ?= ar |
| 31 | RANLIB ?= ranlib | 45 | RANLIB ?= ranlib |
| 32 | M4 ?= m4 | 46 | M4 ?= m4 |
| 47 | MV ?= mv | ||
| 33 | RM ?= rm | 48 | RM ?= rm |
| 34 | CP ?= cp | 49 | CP ?= cp |
| 35 | LN ?= ln | ||
| 36 | LN_S ?= $(LN) -s | ||
| 37 | RMDIR ?= rmdir | 50 | RMDIR ?= rmdir |
| 38 | MKDIR ?= mkdir | 51 | MKDIR ?= mkdir |
| 39 | CHMOD ?= chmod | 52 | CHMOD ?= chmod |
| 40 | INSTALL ?= install | 53 | INSTALL ?= install |
| 41 | INSTALL_DATA ?= $(INSTALL) -m 644 | 54 | INSTALL_DATA ?= $(INSTALL) -m 644 |
| 55 | TOUCH ?= touch | ||
| 56 | TEE ?= tee | ||
| 57 | TEE_A ?= $(TEE) -a | ||
| 58 | |||
| 59 | # see Lua Autodetection, below | ||
| 42 | 60 | ||
| 43 | .PHONY: $(d)/config | 61 | .PHONY: $(d)/config |
| 44 | 62 | ||
| 63 | PRINT_$(d) = printf "%s = %s\n" '$(1)' '$(subst ',\\',$(2))' | $(TEE_A) '$(3)' | ||
| 64 | |||
| 65 | LAZY_$(d) = \ | ||
| 66 | prefix includedir libdir datadir bindir \ | ||
| 67 | lua51cpath lua51path lua52cpath lua52path lua53cpath lua53path \ | ||
| 68 | CC ALL_CPPFLAGS CPPFLAGS ALL_CFLAGS CFLAGS ALL_LDFLAGS LDFLAGS \ | ||
| 69 | ALL_SOFLAGS SOFLAGS ALL_LIB LIBS \ | ||
| 70 | $(foreach API,$(KNOWN_APIS),ALL_LUA$(subst .,,$(API))_CPPFLAGS) \ | ||
| 71 | AR RANLIB M4 MV RM CP RMDIR MKDIR CHMOD INSTALL INSTALL_DATA TOUCH \ | ||
| 72 | TEE TEE_A | ||
| 73 | |||
| 74 | NONLAZY_$(d) = \ | ||
| 75 | LUA_APIS \ | ||
| 76 | $(foreach API,$(KNOWN_APIS),LUAC$(subst .,,$(API))) \ | ||
| 77 | $(foreach API,$(KNOWN_APIS),$(and $(call WITH_API_FN,$(API)),LUA$(subst .,,$(API))_CPPFLAGS)) | ||
| 78 | |||
| 45 | $(d)/config: | 79 | $(d)/config: |
| 46 | printf 'prefix ?= $(value prefix)'"\n" >| $(@D)/.config | 80 | $(TOUCH) $(@D)/.config.tmp |
| 47 | printf 'includedir ?= $(value includedir)'"\n" >> $(@D)/.config | 81 | @$(foreach V,$(LAZY_$(@D)), $(call PRINT_$(@D),$(V),$(value $(V)),$(@D)/.config.tmp);) |
| 48 | printf 'libdir ?= $(value libdir)'"\n" >> $(@D)/.config | 82 | @$(foreach V,$(NONLAZY_$(@D)), $(call PRINT_$(@D),$(V),$($(V)),$(@D)/.config.tmp);) |
| 49 | printf 'datadir ?= $(value datadir)'"\n" >> $(@D)/.config | 83 | $(MV) $(@D)/.config.tmp $(@D)/.config |
| 50 | printf 'bindir ?= $(value bindir)'"\n" >> $(@D)/.config | ||
| 51 | printf 'lua51cpath ?= $(value lua51cpath)'"\n" >> $(@D)/.config | ||
| 52 | printf 'lua51path ?= $(value lua51path)'"\n" >> $(@D)/.config | ||
| 53 | printf 'lua52cpath ?= $(value lua52cpath)'"\n" >> $(@D)/.config | ||
| 54 | printf 'lua52path ?= $(value lua52path)'"\n" >> $(@D)/.config | ||
| 55 | printf 'lua53cpath ?= $(value lua53cpath)'"\n" >> $(@D)/.config | ||
| 56 | printf 'lua53path ?= $(value lua53path)'"\n" >> $(@D)/.config | ||
| 57 | printf 'CC ?= $(CC)'"\n" >> $(@D)/.config | ||
| 58 | printf 'CPPFLAGS ?= $(value CPPFLAGS)'"\n" >> $(@D)/.config | ||
| 59 | printf 'CFLAGS ?= $(value CFLAGS)'"\n" >> $(@D)/.config | ||
| 60 | printf 'LDFLAGS ?= $(value LDFLAGS)'"\n" >> $(@D)/.config | ||
| 61 | printf 'SOFLAGS ?= $(value SOFLAGS)'"\n" >> $(@D)/.config | ||
| 62 | printf 'AR ?= $(value AR)'"\n" >> $(@D)/.config | ||
| 63 | printf 'RANLIB ?= $(value RANLIB)'"\n" >> $(@D)/.config | ||
| 64 | printf 'M4 ?= $(value M4)'"\n" >> $(@D)/.config | ||
| 65 | printf 'RM ?= $(value RM)'"\n" >> $(@D)/.config | ||
| 66 | printf 'CP ?= $(value CP)'"\n" >> $(@D)/.config | ||
| 67 | printf 'LN ?= $(value LN)'"\n" >> $(@D)/.config | ||
| 68 | printf 'LN_S ?= $(value LN_S)'"\n" >> $(@D)/.config | ||
| 69 | printf 'RMDIR ?= $(value RMDIR)'"\n" >> $(@D)/.config | ||
| 70 | printf 'MKDIR ?= $(value MKDIR)'"\n" >> $(@D)/.config | ||
| 71 | printf 'CHMOD ?= $(value CHMOD)'"\n" >> $(@D)/.config | ||
| 72 | printf 'INSTALL ?= $(value INSTALL)'"\n" >> $(@D)/.config | ||
| 73 | printf 'INSTALL_DATA ?= $(value INSTALL_DATA)'"\n" >> $(@D)/.config | ||
| 74 | 84 | ||
| 75 | # add local targets if building from inside project tree | 85 | # add local targets if building from inside project tree |
| 76 | ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" | 86 | ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" |
| @@ -81,7 +91,49 @@ endif | |||
| 81 | 91 | ||
| 82 | 92 | ||
| 83 | # | 93 | # |
| 84 | # S H A R E D C O M P I L A T I O N F L A G S | 94 | # L U A A U T O D E T E C T I O N |
| 95 | # | ||
| 96 | |||
| 97 | # set LUA_APIS if empty or "?" | ||
| 98 | ifeq ($(or $(strip $(LUA_APIS)),?),?) | ||
| 99 | override LUA_APIS := $(call HAVE_API_FN,5.1) $(call HAVE_API_FN,5.2) $(call HAVE_API_FN,5.3) | ||
| 100 | endif | ||
| 101 | |||
| 102 | define LUAXY_template | ||
| 103 | |||
| 104 | # set luaXYcpath if empty or "?" | ||
| 105 | ifeq ($$(or $$(strip $$(lua$(subst .,,$(1))cpath)),?),?) | ||
| 106 | override lua$(subst .,,$(1))cpath := $$(or $$(call LUAPATH_FN,$(1),cdir),$$(libdir)/lua/$(1)) | ||
| 107 | endif | ||
| 108 | |||
| 109 | # set luaXYpath if empty or "?" | ||
| 110 | ifeq ($$(or $$(strip $$(lua$(subst .,,$(1))path)),?),?) | ||
| 111 | override lua$(subst .,,$(1))path = $$(or $$(call LUAPATH_FN,$(1),ldir),$$(datadir)/lua/$(1)) | ||
| 112 | endif | ||
| 113 | |||
| 114 | # set LUAXY_CPPFLAGS if undefined or "?" (NB: can be empty if path already in $(CPPFLAGS)) | ||
| 115 | ifeq ($$(and $$(findstring undefined,$$(origin LUA$(subst .,,$(1))_CPPFLAGS)),?),?) | ||
| 116 | override LUA$(subst .,,$(1))_CPPFLAGS = $$(and $$(call WITH_API_FN,$(1)),$$(call LUAPATH_FN,$(1),cppflags)) | ||
| 117 | endif | ||
| 118 | |||
| 119 | # set ALL_LUAXY_CPPFLAGS if empty or "?" | ||
| 120 | ifeq ($$(or $$(strip $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS)),?),?) | ||
| 121 | override ALL_LUA$(subst .,,$(1))_CPPFLAGS = $$(LUA$(subst .,,$(1))_CPPFLAGS) | ||
| 122 | endif | ||
| 123 | |||
| 124 | # set LUAXYC if empty or "?" | ||
| 125 | ifeq ($$(or $$(strip $$(LUAC$(subst .,,$(1)))),?),?) | ||
| 126 | override LUAC$(subst .,,$(1)) = $$(or $$(call LUAPATH_FN,$(1),luac),true) | ||
| 127 | endif | ||
| 128 | |||
| 129 | endef # LUAXY_template | ||
| 130 | |||
| 131 | $(eval $(call LUAXY_template,5.1)) | ||
| 132 | $(eval $(call LUAXY_template,5.2)) | ||
| 133 | $(eval $(call LUAXY_template,5.3)) | ||
| 134 | |||
| 135 | # | ||
| 136 | # A U T O D E T E C T C O M P I L A T I O N F L A G S | ||
| 85 | # | 137 | # |
| 86 | cc-option ?= $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ | 138 | cc-option ?= $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ |
| 87 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi;) | 139 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi;) |
| @@ -89,44 +141,107 @@ cc-option ?= $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ | |||
| 89 | VENDOR_OS_$(d) := $(shell $(d)/mk/vendor.os) | 141 | VENDOR_OS_$(d) := $(shell $(d)/mk/vendor.os) |
| 90 | VENDOR_CC_$(d) := $(shell env CC="$(CC)" $(d)/mk/vendor.cc) | 142 | VENDOR_CC_$(d) := $(shell env CC="$(CC)" $(d)/mk/vendor.cc) |
| 91 | 143 | ||
| 144 | # | ||
| 145 | # ALL_CPPFLAGS | ||
| 146 | # | ||
| 147 | ifeq ($(origin ALL_CPPFLAGS), undefined) | ||
| 148 | |||
| 92 | ifneq ($(VENDOR_OS_$(d)), OpenBSD) | 149 | ifneq ($(VENDOR_OS_$(d)), OpenBSD) |
| 93 | CPPFLAGS_$(d) += -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE | 150 | ALL_CPPFLAGS += -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE |
| 94 | endif | 151 | endif |
| 95 | 152 | ||
| 96 | ifeq ($(VENDOR_OS_$(d)), SunOS) | 153 | ifeq ($(VENDOR_OS_$(d)), SunOS) |
| 97 | CPPFLAGS_$(d) += -Usun -D_XPG4_2 -D__EXTENSIONS__ | 154 | ALL_CPPFLAGS += -Usun -D_XPG4_2 -D__EXTENSIONS__ |
| 98 | endif | 155 | endif |
| 99 | 156 | ||
| 157 | ALL_CPPFLAGS += $(CPPFLAGS) | ||
| 158 | |||
| 159 | endif # ALL_CPPFLAGS | ||
| 160 | |||
| 161 | # | ||
| 162 | # ALL_CFLAGS | ||
| 163 | # | ||
| 164 | ifeq ($(origin ALL_CFLAGS), undefined) | ||
| 165 | |||
| 100 | ifeq ($(VENDOR_CC_$(d)), gcc) | 166 | ifeq ($(VENDOR_CC_$(d)), gcc) |
| 101 | CFLAGS_$(d) += -O2 -std=gnu99 -fPIC | 167 | ALL_CFLAGS += -O2 -std=gnu99 -fPIC |
| 102 | CFLAGS_$(d) += -g -Wall -Wextra $(call cc-option, -Wno-missing-field-initializers) $(call cc-option, -Wno-override-init) -Wno-unused | 168 | ALL_CFLAGS += -g -Wall -Wextra $(call cc-option, -Wno-missing-field-initializers) $(call cc-option, -Wno-override-init) -Wno-unused |
| 103 | endif | 169 | endif |
| 104 | 170 | ||
| 105 | ifeq ($(VENDOR_CC_$(d)), clang) | 171 | ifeq ($(VENDOR_CC_$(d)), clang) |
| 106 | CFLAGS_$(d) += -O2 -std=gnu99 -fPIC | 172 | ALL_CFLAGS += -O2 -std=gnu99 -fPIC |
| 107 | CFLAGS_$(d) += -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused | 173 | ALL_CFLAGS += -g -Wall -Wextra -Wno-missing-field-initializers -Wno-initializer-overrides -Wno-unused -Wno-dollar-in-identifier-extension |
| 108 | endif | 174 | endif |
| 109 | 175 | ||
| 110 | ifeq ($(VENDOR_CC_$(d)), sunpro) | 176 | ifeq ($(VENDOR_CC_$(d)), sunpro) |
| 111 | CFLAGS_$(d) += -xcode=pic13 | 177 | ALL_CFLAGS += -xcode=pic13 |
| 112 | CFLAGS_$(d) += -g | 178 | ALL_CFLAGS += -g |
| 113 | # | 179 | # |
| 114 | # Solaris Studio has a brain-dead function call analyzer which counts | 180 | # Solaris Studio supports anonymous unions just fine; but it complains |
| 115 | # arguments before preprocessor expansion. | 181 | # incessantly about them. |
| 116 | # | 182 | # |
| 117 | CFLAGS_$(d) += -erroff=E_ARGUEMENT_MISMATCH | 183 | ALL_CFLAGS += -erroff=E_ANONYMOUS_UNION_DECL |
| 118 | endif | 184 | endif |
| 119 | 185 | ||
| 120 | ifeq ($(VENDOR_OS_$(d)), Darwin) | 186 | ifeq ($(VENDOR_OS_$(d)), Darwin) |
| 121 | CFLAGS_$(d) += -Wno-deprecated-declarations | 187 | ALL_CFLAGS += -Wno-deprecated-declarations |
| 122 | endif | 188 | endif |
| 123 | 189 | ||
| 190 | ALL_CFLAGS += $(CFLAGS) | ||
| 191 | |||
| 192 | endif # ALL_CFLAGS | ||
| 193 | |||
| 194 | # | ||
| 195 | # ALL_SOFLAGS | ||
| 196 | # | ||
| 197 | ifeq ($(origin ALL_SOFLAGS), undefined) | ||
| 198 | |||
| 124 | ifeq ($(VENDOR_OS_$(d)), Darwin) | 199 | ifeq ($(VENDOR_OS_$(d)), Darwin) |
| 125 | SOFLAGS_$(d) += -bundle -undefined dynamic_lookup | 200 | ALL_SOFLAGS += -bundle -undefined dynamic_lookup |
| 126 | else | 201 | else |
| 127 | SOFLAGS_$(d) += -shared | 202 | ALL_SOFLAGS += -shared |
| 203 | endif | ||
| 204 | |||
| 205 | ALL_SOFLAGS += $(SOFLAGS) | ||
| 206 | |||
| 207 | endif # ALL_SOFLAGS | ||
| 208 | |||
| 209 | # | ||
| 210 | # ALL_LDFLAGS | ||
| 211 | # | ||
| 212 | ifeq ($(origin ALL_LDFLAGS), undefined) | ||
| 213 | |||
| 214 | ALL_LDFLAGS += -L$(DESTDIR)$(libdir) -L$(libdir) | ||
| 215 | ALL_LDFLAGS += $(LDFLAGS) | ||
| 216 | |||
| 217 | endif # ALL_LDFLAGS | ||
| 218 | |||
| 219 | # | ||
| 220 | # ALL_LIBS | ||
| 221 | # | ||
| 222 | ifeq ($(origin ALL_LIBS), undefined) | ||
| 223 | |||
| 224 | # put $(LIBS) first as they're more likely to be higher-level dependencies | ||
| 225 | ALL_LIBS += $(LIBS) | ||
| 226 | ALL_LIBS += -lssl -lcrypto -lpthread | ||
| 227 | |||
| 228 | # NetBSD, FreeBSD, OpenBSD (and presumably descendants) lack any libdl; | ||
| 229 | # dlopen, et al are part of libc. | ||
| 230 | ifneq ($(patsubst %BSD,BSD,$(VENDOR_OS_$(d))), BSD) | ||
| 231 | ALL_LIBS += -ldl | ||
| 128 | endif | 232 | endif |
| 129 | 233 | ||
| 234 | # This only seems to be necessary on Linux. Darwin and OpenBSD lack a librt. | ||
| 235 | # On OpenBSD clock_gettime is part of libc. Others have librt, but linking | ||
| 236 | # it in is unnecessary. | ||
| 237 | ifeq ($(VENDOR_OS_$(d)), Linux) | ||
| 238 | ALL_LIBS += -lrt | ||
| 239 | endif | ||
| 240 | |||
| 241 | ALL_LIBS += -lm | ||
| 242 | |||
| 243 | endif # ALL_LIBS | ||
| 244 | |||
| 130 | 245 | ||
| 131 | # | 246 | # |
| 132 | # P R O J E C T R U L E S | 247 | # P R O J E C T R U L E S |
diff --git a/src/GNUmakefile b/src/GNUmakefile index 8d645ea..4bf5f8d 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile | |||
| @@ -16,66 +16,46 @@ include $(d)/../GNUmakefile | |||
| 16 | # | 16 | # |
| 17 | # C O M P I L A T I O N F L A G S | 17 | # C O M P I L A T I O N F L A G S |
| 18 | # | 18 | # |
| 19 | OS_$(d) = $(shell $(d)/../mk/vendor.os) | 19 | CPPFLAGS_$(d) = $(ALL_CPPFLAGS) -DHAVE_CONFIG_H |
| 20 | CC_$(d) = $(shell env CC="$(CC) "$(d)/../mk/vendor.cc) | 20 | CFLAGS_$(d) = $(ALL_CFLAGS) |
| 21 | LUAPATH_$(d) = $(shell env CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(<D)/../mk/luapath -krxm3 -I$(DESTDIR)$(includedir) -I/usr/include -I/usr/local/include -P$(DESTDIR)$(bindir) -P$(bindir) -L$(DESTDIR)$(libdir) -L$(libdir) -v$(1) $(2)) | 21 | SOFLAGS_$(d) = $(ALL_SOFLAGS) |
| 22 | 22 | LDFLAGS_$(d) = $(ALL_LDFLAGS) | |
| 23 | CPPFLAGS_$(d) = $(CPPFLAGS_$(abspath $(@D)/../..)) -DHAVE_CONFIG_H | 23 | LIBS_$(d) = $(ALL_LIBS) |
| 24 | CFLAGS_$(d) = $(CFLAGS_$(abspath $(@D)/../..)) | ||
| 25 | LDFLAGS_$(d) = $(LDFLAGS_$(abspath $(@D)/../..)) | ||
| 26 | SOFLAGS_$(d) = $(SOFLAGS_$(abspath $(@D)/../..)) | ||
| 27 | |||
| 28 | ifeq ($(CC_$(d)), sunpro) | ||
| 29 | CPPFLAGS_$(d) += -DOPENSSL_NO_EC | ||
| 30 | endif | ||
| 31 | |||
| 32 | LDFLAGS_$(d) += -lssl -lcrypto -lpthread -lm | ||
| 33 | |||
| 34 | # NetBSD, FreeBSD, OpenBSD (and presumably descendants) lack any libdl; | ||
| 35 | # dlopen, et al are part of libc. | ||
| 36 | ifneq ($(patsubst %BSD,BSD,$(OS_$(d))), BSD) | ||
| 37 | LDFLAGS_$(d) += -ldl | ||
| 38 | endif | ||
| 39 | |||
| 40 | 24 | ||
| 41 | # | 25 | # |
| 42 | # C O M P I L A T I O N R U L E S | 26 | # C O M P I L A T I O N R U L E S |
| 43 | # | 27 | # |
| 28 | OBJS_$(d) = openssl.o | ||
| 29 | |||
| 44 | $(d)/config.h: $(abspath $(d)/..)/config.h | 30 | $(d)/config.h: $(abspath $(d)/..)/config.h |
| 45 | $(CP) $< $@ | 31 | $(CP) $< $@ |
| 46 | 32 | ||
| 47 | define BUILD_$(d) | 33 | define BUILD_$(d) |
| 48 | 34 | ||
| 49 | .SECONDARY: liblua$(1)-openssl openssl$(1) | 35 | $$(d)/$(1)/openssl.so: $$(addprefix $$(d)/$(1)/, $$(OBJS_$(d))) |
| 36 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LIBS_$$(abspath $$(@D)/..)) | ||
| 50 | 37 | ||
| 51 | $$(d)/$(1)/openssl.so: $$(d)/$(1)/openssl.o | 38 | $$(d)/$(1)/%.o: $$(d)/%.c $$(d)/compat52.h $$(d)/config.h |
| 52 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(SOFLAGS) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS) | ||
| 53 | |||
| 54 | $$(d)/$(1)/openssl.o: $$(d)/openssl.c $$(d)/compat52.h $$(d)/config.h | ||
| 55 | test "$$(notdir $$(@D))" = "$$(call LUAPATH_$$(<D), $$(notdir $$(@D)), version)" | ||
| 56 | $$(MKDIR) -p $$(@D) | 39 | $$(MKDIR) -p $$(@D) |
| 57 | $$(CC) $$(CFLAGS_$$(<D)) $$(CFLAGS) $$(call LUAPATH_$$(<D), $$(notdir $$(@D)), cppflags) $$(CPPFLAGS_$$(<D)) $$(CPPFLAGS) -c -o $$@ $$< | 40 | $$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$< |
| 41 | |||
| 42 | .SECONDARY: liblua$(1)-openssl openssl$(1) openssl | ||
| 58 | 43 | ||
| 59 | liblua$(1)-openssl openssl$(1): $$(d)/$(1)/openssl.so | 44 | liblua$(1)-openssl openssl$(1) openssl: $$(d)/$(1)/openssl.so |
| 60 | 45 | ||
| 61 | endef # BUILD_$(d) | 46 | endef # BUILD_$(d) |
| 62 | 47 | ||
| 63 | $(eval $(call BUILD_$(d),5.1)) | 48 | $(eval $(call BUILD_$(d),5.1)) |
| 64 | |||
| 65 | $(eval $(call BUILD_$(d),5.2)) | 49 | $(eval $(call BUILD_$(d),5.2)) |
| 66 | |||
| 67 | $(eval $(call BUILD_$(d),5.3)) | 50 | $(eval $(call BUILD_$(d),5.3)) |
| 68 | 51 | ||
| 69 | ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" | 52 | ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" |
| 70 | .SECONDARY: all5.1 all5.2 all | 53 | .SECONDARY: all all5.1 all5.2 all5.3 |
| 71 | 54 | ||
| 72 | all5.1: liblua5.1-openssl | 55 | all5.1: liblua5.1-openssl |
| 73 | |||
| 74 | all5.2: liblua5.2-openssl | 56 | all5.2: liblua5.2-openssl |
| 75 | |||
| 76 | all5.3: liblua5.3-openssl | 57 | all5.3: liblua5.3-openssl |
| 77 | 58 | all: $(foreach API,$(strip $(LUA_APIS)),all$(API)) | |
| 78 | all: all5.1 all5.2 | ||
| 79 | 59 | ||
| 80 | endif | 60 | endif |
| 81 | 61 | ||
| @@ -85,8 +65,6 @@ endif | |||
| 85 | # | 65 | # |
| 86 | define INSTALL_$(d) | 66 | define INSTALL_$(d) |
| 87 | 67 | ||
| 88 | LUAC$(1)_$(d) = $$(or $$(call LUAPATH_$(d), $(1), luac), true) | ||
| 89 | |||
| 90 | MODS$(1)_$(d) = \ | 68 | MODS$(1)_$(d) = \ |
| 91 | $$(DESTDIR)$(2)/_openssl.so \ | 69 | $$(DESTDIR)$(2)/_openssl.so \ |
| 92 | $$(DESTDIR)$(3)/openssl.lua \ | 70 | $$(DESTDIR)$(3)/openssl.lua \ |
| @@ -116,42 +94,34 @@ MODS$(1)_$(d) = \ | |||
| 116 | 94 | ||
| 117 | .SECONDARY: liblua$(1)-openssl-install openssl$(1)-install | 95 | .SECONDARY: liblua$(1)-openssl-install openssl$(1)-install |
| 118 | 96 | ||
| 119 | $$(DESTDIR)$(2)/_openssl.so: $$(d)/$(1)/openssl.so | 97 | liblua$(1)-openssl-install openssl$(1)-install: $$(MODS$(1)_$$(d)) |
| 120 | $$(MKDIR) -p $$(@D) | ||
| 121 | $$(CP) -fp $$< $$@ | ||
| 122 | 98 | ||
| 123 | $$(DESTDIR)$(3)/openssl.lua: $$(d)/openssl.lua | 99 | $$(DESTDIR)$(2)/_openssl.so: $$(d)/$(1)/openssl.so |
| 124 | $$(LUAC$(1)_$(d)) -p $$< | ||
| 125 | $$(MKDIR) -p $$(@D) | 100 | $$(MKDIR) -p $$(@D) |
| 126 | $$(CP) -p $$< $$@ | 101 | $$(CP) -p $$< $$@ |
| 127 | 102 | ||
| 128 | $$(DESTDIR)$(3)/openssl/%.lua: $$(d)/openssl.%.lua | 103 | $$(DESTDIR)$(3)/%.lua: $$(d)/%.lua |
| 129 | $$(LUAC$(1)_$(d)) -p $$< | 104 | $$(LUAC$(subst .,,$(1))) -p $$< |
| 130 | $$(MKDIR) -p $$(@D) | 105 | $$(MKDIR) -p $$(@D) |
| 131 | $$(CP) -p $$< $$@ | 106 | $$(CP) -p $$< $$@ |
| 132 | 107 | ||
| 133 | # pubkey.lua used to be symbolic link to pkey.lua, but that caused packaging | 108 | $$(DESTDIR)$(3)/openssl/%.lua: $$(d)/openssl.%.lua |
| 134 | # headaches. Now it's a stub, but the cp -p in the inference rule will copy | 109 | $$(LUAC$(subst .,,$(1))) -p $$< |
| 135 | # to the target of the symbolic link, so we need a special install rule to | ||
| 136 | # clean up the mess. | ||
| 137 | $$(DESTDIR)$(3)/openssl/pubkey.lua: $$(d)/openssl.pubkey.lua | ||
| 138 | $$(LUAC$(1)_$(d)) -p $$< | ||
| 139 | $$(MKDIR) -p $$(@D) | 110 | $$(MKDIR) -p $$(@D) |
| 140 | $$(RM) -f $$@ | ||
| 141 | $$(CP) -p $$< $$@ | 111 | $$(CP) -p $$< $$@ |
| 142 | 112 | ||
| 143 | $$(DESTDIR)$(3)/openssl/ocsp/%.lua: $$(d)/openssl.ocsp.%.lua | 113 | $$(DESTDIR)$(3)/openssl/ocsp/%.lua: $$(d)/ocsp.%.lua |
| 144 | $$(LUAC$(1)_$(d)) -p $$< | 114 | $$(LUAC$(subst .,,$(1))) -p $$< |
| 145 | $$(MKDIR) -p $$(@D) | 115 | $$(MKDIR) -p $$(@D) |
| 146 | $$(CP) -p $$< $$@ | 116 | $$(CP) -p $$< $$@ |
| 147 | 117 | ||
| 148 | $$(DESTDIR)$(3)/openssl/x509/%.lua: $$(d)/openssl.x509.%.lua | 118 | $$(DESTDIR)$(3)/openssl/x509/%.lua: $$(d)/x509.%.lua |
| 149 | $$(LUAC$(1)_$(d)) -p $$< | 119 | $$(LUAC$(subst .,,$(1))) -p $$< |
| 150 | $$(MKDIR) -p $$(@D) | 120 | $$(MKDIR) -p $$(@D) |
| 151 | $$(CP) -p $$< $$@ | 121 | $$(CP) -p $$< $$@ |
| 152 | 122 | ||
| 153 | $$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/openssl.ssl.%.lua | 123 | $$(DESTDIR)$(3)/openssl/ssl/%.lua: $$(d)/ssl.%.lua |
| 154 | $$(LUAC$(1)_$(d)) -p $$< | 124 | $$(LUAC$(subst .,,$(1))) -p $$< |
| 155 | $$(MKDIR) -p $$(@D) | 125 | $$(MKDIR) -p $$(@D) |
| 156 | $$(CP) -p $$< $$@ | 126 | $$(CP) -p $$< $$@ |
| 157 | 127 | ||
| @@ -169,31 +139,24 @@ liblua$(1)-openssl-uninstall openssl$(1)-uninstall: | |||
| 169 | endef # INSTALL_$(d) | 139 | endef # INSTALL_$(d) |
| 170 | 140 | ||
| 171 | $(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path))) | 141 | $(eval $(call INSTALL_$(d),5.1,$$(lua51cpath),$$(lua51path))) |
| 172 | |||
| 173 | $(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path))) | 142 | $(eval $(call INSTALL_$(d),5.2,$$(lua52cpath),$$(lua52path))) |
| 174 | |||
| 175 | $(eval $(call INSTALL_$(d),5.3,$$(lua53cpath),$$(lua53path))) | 143 | $(eval $(call INSTALL_$(d),5.3,$$(lua53cpath),$$(lua53path))) |
| 176 | 144 | ||
| 177 | ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" | 145 | ifneq "$(filter $(abspath $(d)/..)/%, $(abspath $(firstword $(MAKEFILE_LIST))))" "" |
| 146 | |||
| 178 | .SECONDARY: install5.1 install5.2 install5.3 install | 147 | .SECONDARY: install5.1 install5.2 install5.3 install |
| 179 | 148 | ||
| 180 | install5.1: liblua5.1-openssl-install | 149 | install5.1: liblua5.1-openssl-install |
| 181 | |||
| 182 | install5.2: liblua5.2-openssl-install | 150 | install5.2: liblua5.2-openssl-install |
| 183 | |||
| 184 | install5.3: liblua5.3-openssl-install | 151 | install5.3: liblua5.3-openssl-install |
| 185 | 152 | install: $(foreach API,$(strip $(LUA_APIS)),install$(API)) | |
| 186 | install: install5.1 install5.2 | ||
| 187 | 153 | ||
| 188 | .PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall | 154 | .PHONY: uninstall5.1 uninstall5.2 uninstall5.3 uninstall |
| 189 | 155 | ||
| 190 | uninstall5.1: liblua5.1-openssl-uninstall | 156 | uninstall5.1: liblua5.1-openssl-uninstall |
| 191 | |||
| 192 | uninstall5.2: liblua5.2-openssl-uninstall | 157 | uninstall5.2: liblua5.2-openssl-uninstall |
| 193 | |||
| 194 | uninstall5.3: liblua5.3-openssl-uninstall | 158 | uninstall5.3: liblua5.3-openssl-uninstall |
| 195 | 159 | uninstall: $(foreach API,$(strip $(LUA_APIS)),uninstall$(API)) | |
| 196 | uninstall: uninstall5.1 uninstall5.2 | ||
| 197 | 160 | ||
| 198 | endif | 161 | endif |
| 199 | 162 | ||
| @@ -204,7 +167,7 @@ endif | |||
| 204 | .PHONY: $(d)/clean $(d)/clean~ clean clean~ | 167 | .PHONY: $(d)/clean $(d)/clean~ clean clean~ |
| 205 | 168 | ||
| 206 | $(d)/clean: | 169 | $(d)/clean: |
| 207 | $(RM) -fr $(@D)/*.so $(@D)/*.o $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2 $(@D)/5.3 | 170 | $(RM) -fr $(@D)/config.h $(@D)/*.dSYM $(@D)/5.1 $(@D)/5.2 $(@D)/5.3 |
| 208 | 171 | ||
| 209 | $(d)/clean~: $(d)/clean | 172 | $(d)/clean~: $(d)/clean |
| 210 | $(RM) -f $(@D)/*~ | 173 | $(RM) -f $(@D)/*~ |
| @@ -221,27 +184,27 @@ clean~: $(d)/clean~ | |||
| 221 | 184 | ||
| 222 | $(d)/help: | 185 | $(d)/help: |
| 223 | @echo | 186 | @echo |
| 224 | @echo "ext/ targets:" | 187 | @echo "src/ targets:" |
| 225 | @echo "" | 188 | @echo "" |
| 226 | @echo " all - build all binary targets" | 189 | @echo " all - build all API targets" |
| 227 | @echo "openssl - invokes openssl5.1 and openssl5.2" | 190 | @echo " all5.1 - build 5.1/openssl.so" |
| 228 | @echo "openssl5.1 - build 5.1/openssl.so" | 191 | @echo " all5.2 - build 5.2/openssl.so" |
| 229 | @echo "openssl5.2 - build 5.2/openssl.so" | 192 | @echo " all5.3 - build 5.3/openssl.so" |
| 230 | @echo "openssl5.3 - build 5.3/openssl.so" | 193 | @echo " install - install all API targets" |
| 231 | @echo "install - invokes install5.1 and install5.2" | 194 | @echo " install5.1 - install openssl Lua 5.1 modules" |
| 232 | @echo "install5.1 - install openssl Lua 5.1 modules" | 195 | @echo " install5.2 - install openssl Lua 5.2 modules" |
| 233 | @echo "install5.2 - install openssl Lua 5.2 modules" | 196 | @echo " install5.3 - install openssl Lua 5.3 modules" |
| 234 | @echo "install5.3 - install openssl Lua 5.3 modules" | 197 | @echo " uninstall - uninstall all API targets" |
| 235 | @echo "uninstall - invokes uninstall5.1 and uninstall5.2" | ||
| 236 | @echo "uninstall5.1 - uninstall openssl Lua 5.1 modules" | 198 | @echo "uninstall5.1 - uninstall openssl Lua 5.1 modules" |
| 237 | @echo "uninstall5.2 - uninstall openssl Lua 5.2 modules" | 199 | @echo "uninstall5.2 - uninstall openssl Lua 5.2 modules" |
| 238 | @echo "uninstall5.3 - uninstall openssl Lua 5.3 modules" | 200 | @echo "uninstall5.3 - uninstall openssl Lua 5.3 modules" |
| 239 | @echo " clean - rm binary targets, object files, debugging symbols, etc" | 201 | @echo " clean - rm binary targets, object files, debugging symbols, etc" |
| 240 | @echo " clean~ - clean + rm *~" | 202 | @echo " clean~ - clean + rm *~" |
| 241 | @echo " help - echo this help message" | 203 | @echo " help - echo this help message" |
| 242 | @echo "" | 204 | @echo "" |
| 243 | @echo "Some important Make variables:" | 205 | @echo "Some important Make variables:" |
| 244 | @echo "" | 206 | @echo "" |
| 207 | @echo ' LUA_APIS - default Lua APIs to target ($(LUA_APIS))' | ||
| 245 | @echo " prefix - path to install root ($(value prefix))" | 208 | @echo " prefix - path to install root ($(value prefix))" |
| 246 | @echo ' lua51path - install path for Lua 5.1 modules ($(value lua51path))' | 209 | @echo ' lua51path - install path for Lua 5.1 modules ($(value lua51path))' |
| 247 | @echo 'lua51cpath - install path for Lua 5.1 C modules ($(value lua51cpath))' | 210 | @echo 'lua51cpath - install path for Lua 5.1 C modules ($(value lua51cpath))' |
| @@ -250,6 +213,10 @@ $(d)/help: | |||
| 250 | @echo ' lua53path - install path for Lua 5.3 modules ($(value lua53path))' | 213 | @echo ' lua53path - install path for Lua 5.3 modules ($(value lua53path))' |
| 251 | @echo 'lua53cpath - install path for Lua 5.3 C modules ($(value lua53cpath))' | 214 | @echo 'lua53cpath - install path for Lua 5.3 C modules ($(value lua53cpath))' |
| 252 | @echo "" | 215 | @echo "" |
| 216 | @echo 'LUA51_CPPFLAGS - cpp flags for Lua 5.1 headers ($(LUA51_CPPFLAGS))' | ||
| 217 | @echo 'LUA52_CPPFLAGS - cpp flags for Lua 5.2 headers ($(LUA52_CPPFLAGS))' | ||
| 218 | @echo 'LUA53_CPPFLAGS - cpp flags for Lua 5.3 headers ($(LUA53_CPPFLAGS))' | ||
| 219 | @echo "" | ||
| 253 | @echo "(NOTE: all the common GNU-style paths are supported, including" | 220 | @echo "(NOTE: all the common GNU-style paths are supported, including" |
| 254 | @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)" | 221 | @echo "prefix, bindir, libdir, datadir, includedir, and DESTDIR.)" |
| 255 | @echo "" | 222 | @echo "" |
