make: Fix MinGW build machinery machinery

This commit makes it possible to successfully run "make all" against ytools'
again, with TARGET_TUPLE set to i686-ms-w64-mingw. Lots of minor and major
tweaks here and there.

The biggest diff is a move of the architecture-related definitions into
platform.mk. The are needed pretty early on, so that seems reasonable.

Making this work again is part of the larger effort to support cross
buildchains in a more concise way, i.e. without so many if ($(TARGET),mingw))
all over the place. TARGET's relevance should dwindle, until it's finally taken
over by the TARGET_XXX variables extracted from TARGET_TUPLE or TARGET_TRIPLET.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-03-02 17:21:48 +00:00
commit f9d398d219
7 changed files with 140 additions and 139 deletions

View file

@ -7,12 +7,18 @@ JW_BUILD_DEF_MK_INCLUDED = true
MAKEFLAGS += -r
ifneq ($(wildcard $(MODDIR)/make/.cache.mk),)
include $(MODDIR)/make/.cache.mk
endif
ifneq ($(wildcard $(TOPDIR)/make/.cache.mk),)
include $(TOPDIR)/make/.cache.mk
endif
# "-include" tries search path, we don't want that
define try_include
ifneq ($$(wildcard $(1)),)
include $(1)
endif
endef
$(eval $(call try_include,$(MODDIR)/make/.cache.mk))
$(eval $(call try_include,$(TOPDIR)/make/.cache.mk))
$(eval $(call try_include,$(MODDIR)/make/pre-local.mk))
$(eval $(call try_include,$(TOPDIR)/make/pre-local.mk))
$(eval $(call try_include,pre-local.mk))
include $(MODDIR)/make/platform.mk
include $(MODDIR)/make/projects.mk
@ -23,12 +29,6 @@ else
export SHELL := /bin/bash
endif
# ----- pre-local.mk
-include $(MODDIR)/make/pre-local.mk
-include $(TOPDIR)/make/pre-local.mk
-include pre-local.mk
# ----- executables
ifndef WHICH
WHICH := $(firstword $(wildcard /usr/bin/which) $(shell which which))
@ -64,9 +64,6 @@ endif
ifndef MY_SHELL
MY_SHELL := /bin/bash
endif
ifndef GET_OS_SH
GET_OS_SH := $(SHELL) $(MOD_SCRIPT_DIR)/get-os.sh
endif
ifndef ID
ID := $(shell $(WHICH) id)
endif
@ -197,98 +194,6 @@ PUBLIC_PATH_DEVEL_DOC = /doc/devel
UPLOAD_URL_DEVEL_DOC = rsync_ssh://$(JANWARE_USER)@janware.com:/srv/dav/pub/clients/$(JANWARE_CLIENT)/$(PUBLIC_PATH_DEVEL_DOC)
PKG_VENDOR ?= janware GmbH
# ----- host and target variables
ifeq ($(OS_TUPLE),)
OS_TUPLE := $(shell $(GET_OS_SH) tuple)
endif
ifneq ($(TARGET_TUPLE),)
TARGET_TUPLE_WORDS := $(subst -, ,$(TARGET_TUPLE))
TARGET_ARCH := $(word 1,$(TARGET_TUPLE_WORDS))
TARGET_VENDOR := $(word 2,$(TARGET_TUPLE_WORDS))
TARGET_OS := $(word 3,$(TARGET_TUPLE_WORDS))
TARGET_ABI := $(word 4,$(TARGET_TUPLE_WORDS))
TARGET_TRIPLET := $(TARGET_ARCH)-$(TARGET_OS)-$(TARGET_ABI)
else ifneq ($(TARGET_TRIPLET),)
TARGET_TRIPLET_WORDS := $(subst -, ,$(TARGET_TRIPLET))
TARGET_ARCH := $(word 1,$(TARGET_TRIPLET_WORDS))
TARGET_VENDOR := unknown
TARGET_OS := $(word 2,$(TARGET_TRIPLET_WORDS))
TARGET_ABI := $(word 3,$(TARGET_TRIPLET_WORDS))
TARGET_TUPLE := $(TARGET_ARCH)-$(TARGET_VENDOR)-$(TARGET_OS)-$(TARGET_ABI)
else
TARGET_TUPLE := $(OS_TUPLE)
TARGET_TUPLE_WORDS := $(subst -, ,$(TARGET_TUPLE))
TARGET_ARCH := $(word 1,$(TARGET_TUPLE_WORDS))
TARGET_VENDOR := $(word 2,$(TARGET_TUPLE_WORDS))
TARGET_OS := $(word 3,$(TARGET_TUPLE_WORDS))
TARGET_ABI := $(word 4,$(TARGET_TUPLE_WORDS))
TARGET_TRIPLET := $(TARGET_ARCH)-$(TARGET_OS)-$(TARGET_ABI)
endif
ifeq ($(TARGET_TUPLE),)
$(error TARGET_TUPLE is empty)
endif
# - support legacy jw-build target variables
ifeq ($(TARGET_ABI),mingw32)
TARGET ?= mingw
else ifeq ($(TARGET_ABI),mingw64)
TARGET ?= mingw
else
TARGET ?= $(TARGET_OS)
endif
ifeq ($(OS_NAME_VERSION),)
OS_NAME_VERSION := $(shell $(GET_OS_SH))
endif
ifeq ($(OS_NAME),)
OS_NAME := $(shell $(GET_OS_SH) name)
endif
ARCH ?= $(TARGET_ARCH)
ARCH_32 = i586
ifndef ARCH
# TODO unreached code, test and fix this
ifeq ($(shell uname -m),armv7l)
ARCH = armv7hl
SYSTEM_LIBDIR_NAME = lib
else ifeq ($(shell uname -m),armv6l)
ARCH = armv6hl
SYSTEM_LIBDIR_NAME = lib
else ifeq ($(shell uname -m),aarch64)
ARCH = aarch64
SYSTEM_LIBDIR_NAME = lib
else ifeq ($(shell uname -m),x86_64)
ARCH = x86_64
SYSTEM_LIBDIR_NAME = lib64
else
ARCH = $(ARCH_32)
SYSTEM_LIBDIR_NAME = lib
endif
SYSTEM_LIBDIR = /usr/$(SYSTEM_LIBDIR_NAME)
endif
ifneq ($(TARGET_TUPLE),$(OS_TUPLE))
ifeq ($(TARGET),mingw)
FLAVOUR_PREFIX ?= win32-
FLAVOUR_SUFFIX ?= -win32
FLAVOUR_PATH_PREFIX ?= win32/
FLAVOUR_PATH_SUFFIX ?= /win32
ifneq ($(wildcard /usr/bin/i686-w64-mingw32-gcc),)
MINGW_SYS_ROOT ?= /usr/i686-w64-mingw32/sys-root/mingw
endif
else
FLAVOUR_PREFIX ?= $(TARGET_TRIPLET)-
FLAVOUR_SUFFIX ?= -$(TARGET_TRIPLET)
FLAVOUR_PATH_PREFIX ?= $(TARGET_TRIPLET)/
FLAVOUR_PATH_SUFFIX ?= /$(TARGET_TRIPLET)
endif
endif
# ----- packaging variables
ifneq ($(filter debian%,$(OS_NAME_VERSION)),)
@ -525,8 +430,8 @@ INSTALL_JAVADIR ?= $(JAVADIR)
INSTALLED_JAVA ?= $(addprefix $(INSTALL_JAVADIR)/,$(JAVA_JARS))
# -- LD_CONF
INSTALLATION_FILE_TYPES += LD_CONF
ifneq ($(TARGET),mingw)
ifneq ($(findstring $(TARGET_OS),linux),)
INSTALLATION_FILE_TYPES += LD_CONF
LD_CONF += $(filter-out $(DONT_INSTALL),ld-$(PROJECT).conf)
BUILD_LD_CONFDIR = $(TOPDIR)/lib/ld.so.conf.d
INSTALL_LD_CONFDIR = $(LD_CONF_DIR)
@ -534,7 +439,7 @@ ifneq ($(TARGET),mingw)
endif
# -- LOGROT
ifneq ($(TARGET),mingw)
ifneq ($(findstring $(TARGET_OS),linux),)
INSTALLATION_FILE_TYPES += LOGROT
LOGROT += $(basename $(filter-out $(DONT_INSTALL),$(wildcard *.logrotate)))
BUILD_LOGROTDIR = $(TOPDIR)/bin/logrotate.d
@ -543,7 +448,7 @@ ifneq ($(TARGET),mingw)
endif
# -- APACHE_CONF
ifneq ($(TARGET),mingw)
ifneq ($(findstring $(TARGET_OS),linux),)
INSTALLATION_FILE_TYPES += APACHE_CONF
APACHE_CONF += $(filter-out $(DONT_INSTALL),$(wildcard *.apache-conf))
BUILD_APACHE_CONFDIR = $(TOPDIR)/bin/apache/conf.d
@ -552,7 +457,7 @@ ifneq ($(TARGET),mingw)
endif
# -- RSYSLOG
ifneq ($(TARGET),mingw)
ifneq ($(findstring $(TARGET_OS),linux),)
INSTALLATION_FILE_TYPES += RSYSLOG
RSYSLOG += $(filter-out $(DONT_INSTALL),$(wildcard *.rsyslog rsyslog-*.bprof))
BUILD_RSYSLOGDIR = $(TOPDIR)/bin/rsyslog.d
@ -562,7 +467,7 @@ ifneq ($(TARGET),mingw)
endif
# -- CRONTAB
ifneq ($(TARGET),mingw)
ifneq ($(findstring $(TARGET_OS),linux),)
INSTALLATION_FILE_TYPES += CRONTAB
CRONTAB += $(filter-out $(DONT_INSTALL),$(wildcard *.crontab))
BUILD_CRONTABDIR = $(TOPDIR)/cron.d
@ -570,7 +475,7 @@ ifneq ($(TARGET),mingw)
endif
# -- PKG_CONFIG
ifneq ($(TARGET),mingw)
ifneq ($(findstring $(TARGET_OS),linux),)
INSTALLATION_FILE_TYPES += PKG_CONFIG
PKG_CONFIG += $(sort $(filter-out $(DONT_INSTALL),$(wildcard *.pc) $(LOCAL_PKG_CONFIG)))
ifeq ($(DEVELOPMENT),true)
@ -588,9 +493,11 @@ INSTALL_DIR ?= $(INSTALL)
# ----- local.mk
-include $(MODDIR)/make/local.mk
-include $(TOPDIR)/make/local.mk
-include local.mk
$(eval $(call try_include,$(MODDIR)/make/local.mk))
#-include $(MODDIR)/make/local.mk
$(eval $(call try_include,$(TOPDIR)/make/local.mk))
$(eval $(call try_include,local.mk))
BTOOLS_DIR ?= $(call proj_dir, dspider-btools)
#DSPCD_DIR ?= $(call proj_dir, dspcd)