mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
Merge pull request #9742 from obsidiansystems/mingw-makefiles
More makefile preparations for Windows
This commit is contained in:
commit
1acb1e0ca3
5 changed files with 76 additions and 42 deletions
37
Makefile
37
Makefile
|
@ -1,8 +1,12 @@
|
||||||
|
# External build directory support
|
||||||
|
|
||||||
include mk/build-dir.mk
|
include mk/build-dir.mk
|
||||||
|
|
||||||
-include $(buildprefix)Makefile.config
|
-include $(buildprefix)Makefile.config
|
||||||
clean-files += $(buildprefix)Makefile.config
|
clean-files += $(buildprefix)Makefile.config
|
||||||
|
|
||||||
|
# List makefiles
|
||||||
|
|
||||||
ifeq ($(ENABLE_BUILD), yes)
|
ifeq ($(ENABLE_BUILD), yes)
|
||||||
makefiles = \
|
makefiles = \
|
||||||
mk/precompiled-headers.mk \
|
mk/precompiled-headers.mk \
|
||||||
|
@ -43,6 +47,8 @@ makefiles += \
|
||||||
tests/functional/plugins/local.mk
|
tests/functional/plugins/local.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Miscellaneous global Flags
|
||||||
|
|
||||||
OPTIMIZE = 1
|
OPTIMIZE = 1
|
||||||
|
|
||||||
ifeq ($(OPTIMIZE), 1)
|
ifeq ($(OPTIMIZE), 1)
|
||||||
|
@ -52,9 +58,29 @@ else
|
||||||
GLOBAL_CXXFLAGS += -O0 -U_FORTIFY_SOURCE
|
GLOBAL_CXXFLAGS += -O0 -U_FORTIFY_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include mk/platform.mk
|
||||||
|
|
||||||
|
ifdef HOST_WINDOWS
|
||||||
|
# Windows DLLs are stricter about symbol visibility than Unix shared
|
||||||
|
# objects --- see https://gcc.gnu.org/wiki/Visibility for details.
|
||||||
|
# This is a temporary sledgehammer to export everything like on Unix,
|
||||||
|
# and not detail with this yet.
|
||||||
|
#
|
||||||
|
# TODO do not do this, and instead do fine-grained export annotations.
|
||||||
|
GLOBAL_LDFLAGS += -Wl,--export-all-symbols
|
||||||
|
endif
|
||||||
|
|
||||||
|
GLOBAL_CXXFLAGS += -g -Wall -include $(buildprefix)config.h -std=c++2a -I src
|
||||||
|
|
||||||
|
# Include the main lib, causing rules to be defined
|
||||||
|
|
||||||
include mk/lib.mk
|
include mk/lib.mk
|
||||||
|
|
||||||
# Must be included after `mk/lib.mk` so isn't the default target.
|
# Fallback stub rules for better UX when things are disabled
|
||||||
|
#
|
||||||
|
# These must be defined after `mk/lib.mk`. Otherwise the first rule
|
||||||
|
# incorrectly becomes the default target.
|
||||||
|
|
||||||
ifneq ($(ENABLE_UNIT_TESTS), yes)
|
ifneq ($(ENABLE_UNIT_TESTS), yes)
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
check:
|
check:
|
||||||
|
@ -69,8 +95,11 @@ installcheck:
|
||||||
@exit 1
|
@exit 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Must be included after `mk/lib.mk` so rules refer to variables defined
|
# Documentation or else fallback stub rules.
|
||||||
# by the library. Rules are not "lazy" like variables, unfortunately.
|
#
|
||||||
|
# The documentation makefiles be included after `mk/lib.mk` so rules
|
||||||
|
# refer to variables defined by `mk/lib.mk`. Rules are not "lazy" like
|
||||||
|
# variables, unfortunately.
|
||||||
|
|
||||||
ifeq ($(ENABLE_DOC_GEN), yes)
|
ifeq ($(ENABLE_DOC_GEN), yes)
|
||||||
$(eval $(call include-sub-makefile, doc/manual/local.mk))
|
$(eval $(call include-sub-makefile, doc/manual/local.mk))
|
||||||
|
@ -89,5 +118,3 @@ internal-api-html:
|
||||||
@echo "Internal API docs are disabled. Configure with '--enable-internal-api-docs', or avoid calling 'make internal-api-html'."
|
@echo "Internal API docs are disabled. Configure with '--enable-internal-api-docs', or avoid calling 'make internal-api-html'."
|
||||||
@exit 1
|
@exit 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GLOBAL_CXXFLAGS += -g -Wall -include $(buildprefix)config.h -std=c++2a -I src
|
|
||||||
|
|
33
mk/lib.mk
33
mk/lib.mk
|
@ -12,38 +12,7 @@ man-pages :=
|
||||||
install-tests :=
|
install-tests :=
|
||||||
install-tests-groups :=
|
install-tests-groups :=
|
||||||
|
|
||||||
ifdef HOST_OS
|
include mk/platform.mk
|
||||||
HOST_KERNEL = $(firstword $(subst -, ,$(HOST_OS)))
|
|
||||||
ifeq ($(patsubst mingw%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_MINGW = 1
|
|
||||||
HOST_WINDOWS = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(HOST_KERNEL), cygwin)
|
|
||||||
HOST_CYGWIN = 1
|
|
||||||
HOST_WINDOWS = 1
|
|
||||||
HOST_UNIX = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst darwin%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_DARWIN = 1
|
|
||||||
HOST_UNIX = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst freebsd%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_FREEBSD = 1
|
|
||||||
HOST_UNIX = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst netbsd%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_NETBSD = 1
|
|
||||||
HOST_UNIX = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(HOST_KERNEL), linux)
|
|
||||||
HOST_LINUX = 1
|
|
||||||
HOST_UNIX = 1
|
|
||||||
endif
|
|
||||||
ifeq ($(patsubst solaris%,,$(HOST_KERNEL)),)
|
|
||||||
HOST_SOLARIS = 1
|
|
||||||
HOST_UNIX = 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Hack to define a literal space.
|
# Hack to define a literal space.
|
||||||
space :=
|
space :=
|
||||||
|
|
|
@ -3,7 +3,7 @@ libs-list :=
|
||||||
ifdef HOST_DARWIN
|
ifdef HOST_DARWIN
|
||||||
SO_EXT = dylib
|
SO_EXT = dylib
|
||||||
else
|
else
|
||||||
ifdef HOST_CYGWIN
|
ifdef HOST_WINDOWS
|
||||||
SO_EXT = dll
|
SO_EXT = dll
|
||||||
else
|
else
|
||||||
SO_EXT = so
|
SO_EXT = so
|
||||||
|
@ -65,7 +65,7 @@ define build-library
|
||||||
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
|
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
|
||||||
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
|
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
|
||||||
|
|
||||||
ifdef HOST_CYGWIN
|
ifdef HOST_WINDOWS
|
||||||
$(1)_INSTALL_DIR ?= $$(bindir)
|
$(1)_INSTALL_DIR ?= $$(bindir)
|
||||||
else
|
else
|
||||||
$(1)_INSTALL_DIR ?= $$(libdir)
|
$(1)_INSTALL_DIR ?= $$(libdir)
|
||||||
|
@ -85,7 +85,7 @@ define build-library
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
ifndef HOST_DARWIN
|
ifndef HOST_DARWIN
|
||||||
ifndef HOST_CYGWIN
|
ifndef HOST_WINDOWS
|
||||||
$(1)_LDFLAGS += -Wl,-z,defs
|
$(1)_LDFLAGS += -Wl,-z,defs
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
32
mk/platform.mk
Normal file
32
mk/platform.mk
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
ifdef HOST_OS
|
||||||
|
HOST_KERNEL = $(firstword $(subst -, ,$(HOST_OS)))
|
||||||
|
ifeq ($(patsubst mingw%,,$(HOST_KERNEL)),)
|
||||||
|
HOST_MINGW = 1
|
||||||
|
HOST_WINDOWS = 1
|
||||||
|
endif
|
||||||
|
ifeq ($(HOST_KERNEL), cygwin)
|
||||||
|
HOST_CYGWIN = 1
|
||||||
|
HOST_WINDOWS = 1
|
||||||
|
HOST_UNIX = 1
|
||||||
|
endif
|
||||||
|
ifeq ($(patsubst darwin%,,$(HOST_KERNEL)),)
|
||||||
|
HOST_DARWIN = 1
|
||||||
|
HOST_UNIX = 1
|
||||||
|
endif
|
||||||
|
ifeq ($(patsubst freebsd%,,$(HOST_KERNEL)),)
|
||||||
|
HOST_FREEBSD = 1
|
||||||
|
HOST_UNIX = 1
|
||||||
|
endif
|
||||||
|
ifeq ($(patsubst netbsd%,,$(HOST_KERNEL)),)
|
||||||
|
HOST_NETBSD = 1
|
||||||
|
HOST_UNIX = 1
|
||||||
|
endif
|
||||||
|
ifeq ($(HOST_KERNEL), linux)
|
||||||
|
HOST_LINUX = 1
|
||||||
|
HOST_UNIX = 1
|
||||||
|
endif
|
||||||
|
ifeq ($(patsubst solaris%,,$(HOST_KERNEL)),)
|
||||||
|
HOST_SOLARIS = 1
|
||||||
|
HOST_UNIX = 1
|
||||||
|
endif
|
||||||
|
endif
|
|
@ -1,5 +1,11 @@
|
||||||
programs-list :=
|
programs-list :=
|
||||||
|
|
||||||
|
ifdef HOST_WINDOWS
|
||||||
|
EXE_EXT = .exe
|
||||||
|
else
|
||||||
|
EXE_EXT =
|
||||||
|
endif
|
||||||
|
|
||||||
# Build a program with symbolic name $(1). The program is defined by
|
# Build a program with symbolic name $(1). The program is defined by
|
||||||
# various variables prefixed by ‘$(1)_’:
|
# various variables prefixed by ‘$(1)_’:
|
||||||
#
|
#
|
||||||
|
@ -31,7 +37,7 @@ define build-program
|
||||||
_srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src)))
|
_srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src)))
|
||||||
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
|
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
|
||||||
_libs := $$(foreach lib, $$($(1)_LIBS), $$(foreach lib2, $$($$(lib)_LIB_CLOSURE), $$($$(lib2)_PATH)))
|
_libs := $$(foreach lib, $$($(1)_LIBS), $$(foreach lib2, $$($$(lib)_LIB_CLOSURE), $$($$(lib2)_PATH)))
|
||||||
$(1)_PATH := $$(_d)/$$($(1)_NAME)
|
$(1)_PATH := $$(_d)/$$($(1)_NAME)$(EXE_EXT)
|
||||||
|
|
||||||
$$(eval $$(call create-dir, $$(_d)))
|
$$(eval $$(call create-dir, $$(_d)))
|
||||||
|
|
||||||
|
@ -42,7 +48,7 @@ define build-program
|
||||||
|
|
||||||
ifdef $(1)_INSTALL_DIR
|
ifdef $(1)_INSTALL_DIR
|
||||||
|
|
||||||
$(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME)
|
$(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME)$(EXE_EXT)
|
||||||
|
|
||||||
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue