# MISC STRING TOOLS
empty :=
+esc := $(empty)\7f$(empty)
space := $(empty) $(empty)
comma := ,
-escspace = $(subst $(space),\$(space),$(subst \$(space),$(space),$1))
-hidspace = $(subst $(space),\7f,$(subst \$(space),\7f,$1))
-shwspace = $(subst \7f,\$(space),$1)
+slash := $(empty)/$(empty)
+backslash := $(empty)\$(empty)
+escspace = $(subst $(space),$(backslash)$(space),$(subst $(backslash)$(space),$(space),$(1)))
+hidspace = $(subst $(space),$(esc),$(subst $(backslash)$(space),$(esc),$(1)))
+shwspace = $(subst $(esc),$(backslash)$(space),$(1))
+unescp_all = $(subst $(esc),$(backslash),$(subst $(backslash),,$(subst $(backslash)$(backslash),$(esc),$(1))))
# PATH SEPARATOR STRING TOOLS
ifdef WINDOWS_HOST
endif
endif
ifdef WIN_PS_TOOLS
- fixps = $(subst \,/,$(1))
- psep = $(subst \\,/,$(subst /,\,$(1)))
- PS := $(strip \)
+ psep := $(backslash)
+ slash_path = $(subst $(backslash),$(slash),$(1))
+ sys_path = $(subst $(backslash)$(backslash),$(slash),$(subst $(slash),$(backslash),$(1)))
+ quote_path = "$(call sys_path,$(call unescp_all,$(1)))"
else
- fixps = $(1)
- PS := $(strip /)
- psep = $(1)
+ psep := $(slash)
+ slash_path = $(1)
+ sys_path = $(1)
+ quote_path = $(1)
endif
# PREFIXES AND EXTENSIONS
HOST_LP := $(if $(WINDOWS_HOST),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)
# VERSIONING
-VER := $(if $(VERSION),.$(VERSION),)
+VER := $(if $(LINUX_TARGET),$(if $(LINUX_HOST),$(if $(VERSION),.$(VERSION),),),)
# SUPER TOOLS
ifdef CCACHE
endif
ifdef WIN_SHELL_COMMANDS
echo = $(if $(1),echo $(1))
- cpq = $(if $(1),@cmd /c for %%I in ($(call psep,$(1))) do @copy /y %%I $(call psep,$(2)) > nul 2>&1)
- rmq = $(if $(1),-@del /f /q $(call psep,$(1)) > nul 2>&1)
- rmrq = $(if $(1),-@rmdir /q /s $(call psep,$(1)) > nul 2>&1)
- mkdirq = $(if $(1),-@mkdir $(call psep,$(1)) > nul 2>&1)
- rmdirq = $(if $(1),-@rmdir /q $(call psep,$(1)) > nul 2>&1)
+
+ WIN8 := $(shell ver | findstr "version 6.2")
+ifneq "$(WIN8)" ""
+ touch = $(if $(1),@cmd /c "for %I in ($(call sys_path,$(1))) do @(cd %~pI && type nul >> %~nxI && copy /by %~nxI+,, > nul 2>&1 && cd %cd%)")
+ cpq = $(if $(1),@cmd /c "for %I in ($(call sys_path,$(1))) do copy /by %I $(call sys_path,$(2))" > nul 2>&1)
+else
+ touch = $(if $(1),@cmd /c "for %%I in ($(call sys_path,$(1))) do @(cd %%~pI && type nul >> %%~nxI && copy /by %%~nxI+,, > nul 2>&1 && cd %%cd%%)")
+ cpq = $(if $(1),@cmd /c "for %%I in ($(call sys_path,$(1))) do copy /by %%I $(call sys_path,$(2))" > nul 2>&1)
+endif
+ rmq = $(if $(1),-del /f /q $(call sys_path,$(1)) > nul 2>&1)
+ rmrq = $(if $(1),-rmdir /q /s $(call sys_path,$(1)) > nul 2>&1)
+ mkdirq = $(if $(1),-mkdir $(call sys_path,$(1)) > nul 2>&1)
+ rmdirq = $(if $(1),-rmdir /q $(call sys_path,$(1)) > nul 2>&1)
else
echo = $(if $(1),echo "$(1)")
- cpq = $(if $(1),@cp $(1) $(2))
- rmq = $(if $(1),-@rm -f $(1))
- rmrq = $(if $(1),-@rm -f -r $(1))
- mkdirq = $(if $(1),-@mkdir -p $(1))
- rmdirq = $(if $(1),-@rmdir $(1))
+ touch = $(if $(1),touch $(1))
+ cpq = $(if $(1),cp $(1) $(2))
+ rmq = $(if $(1),-rm -f $(1))
+ rmrq = $(if $(1),-rm -f -r $(1))
+ mkdirq = $(if $(1),-mkdir -p $(1))
+ rmdirq = $(if $(1),-rmdir $(1))
endif
# COMPILER OPTIONS
# COMMON LIBRARIES DETECTION
ifdef WINDOWS_TARGET
ifdef OPENSSL_CONF
- _OPENSSL_CONF = $(call hidspace,$(call fixps,$(OPENSSL_CONF)))
+ _OPENSSL_CONF = $(call hidspace,$(call slash_path,$(OPENSSL_CONF)))
OPENSSL_INCLUDE_DIR = $(call shwspace,$(subst /bin/openssl.cfg,/include,$(_OPENSSL_CONF)))
OPENSSL_LIB_DIR = $(call shwspace,$(subst /bin/openssl.cfg,/lib,$(_OPENSSL_CONF)))
OPENSSL_BIN_DIR = $(call shwspace,$(subst /bin/openssl.cfg,/bin,$(_OPENSSL_CONF)))
OPENSSL_BIN_DIR = .
endif
endif
+
+# INSTALL_FLAGS
+ifdef BSD_HOST
+INSTALL_FLAGS :=
+else
+INSTALL_FLAGS := -D
+endif
+
+# DESTDIR
+ifdef WINDOWS_TARGET
+
+SOV := $(SO)
+
+ifndef DESTDIR
+
+ifeq "$(TARGET_ARCH)" "x86_64"
+ ifneq "$(wildcard $(SystemDrive)/Program\ Files )" ""
+ export DESTDIR=$(SystemDrive)/Program Files/Ecere SDK
+ else
+ export DESTDIR=$(SystemDrive)/Ecere SDK
+ endif
+else
+ ifdef ProgramFiles(x86)
+ export DESTDIR=${ProgramFiles(x86)}/Ecere SDK
+ else
+ ifdef ProgramFiles
+ export DESTDIR=$(ProgramFiles)/Ecere SDK
+ else
+ export DESTDIR=$(SystemDrive)/Ecere SDK
+ endif
+ endif
+endif
+
+endif # DESTDIR
+
+export prefix=
+
+ifndef BINDIR
+export BINDIR=$(DESTDIR)$(prefix)/bin
+endif
+
+ifndef LIBDIR
+export LIBDIR=$(BINDIR)
+endif
+export DESTLIBDIR=$(LIBDIR)
+
+ifndef SLIBDIR
+export SLIBDIR=$(DESTDIR)$(prefix)/lib
+endif
+export DESTSLIBDIR=$(SLIBDIR)
+
+else # WINDOWS_TARGET
+
+ifdef OSX_TARGET
+# TODO: OSX soname
+SOV := $(SO)
+else
+ifdef LIBVER
+SOV := $(SO)$(LIBVER)
+else
+ifdef VERSION
+SOV := $(SO).$(VERSION)
+else
+SOV := $(SO)
+endif
+endif
+endif
+
+ifndef DESTDIR
+export DESTDIR=
+endif
+
+ifndef prefix
+export prefix=/usr
+endif
+
+ifndef BINDIR
+export BINDIR=$(DESTDIR)$(prefix)/bin
+endif
+
+ifdef LIBDIR
+ export PREFIXLIBDIR=$(LIBDIR)
+else
+ export PREFIXLIBDIR=$(prefix)/lib/$(TARGET_ARCH)
+
+ ifeq "$(wildcard $(prefix)/lib/$(TARGET_ARCH) )" ""
+ export PREFIXLIBDIR=$(prefix)/lib
+
+ ifeq "$(TARGET_ARCH)" "i386-linux-gnu"
+ ifneq "$(wildcard $(prefix)/lib32 )" ""
+ export PREFIXLIBDIR=$(prefix)/lib32
+ endif
+ endif
+
+ endif
+endif
+
+DESTLIBDIR := $(DESTDIR)$(PREFIXLIBDIR)
+ifdef SLIBDIR
+DESTSLIBDIR := $(DESTDIR)$(SLIBDIR)
+else
+DESTSLIBDIR := $(DESTLIBDIR)
+endif
+
+endif # WINDOWS_TARGET