summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile488
1 files changed, 10 insertions, 478 deletions
diff --git a/Makefile b/Makefile
index d8e3b1664..ac38b50ea 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,7 @@
#
# Look at Makefile.config for configuration options.
#
-# Tested on unix platforms (building for GTK and cross-compiling for RO) and
-# on RO (building for RO).
+# Best results obtained building on unix platforms cross compiling for others
#
# To clean, invoke as above, with the 'clean' target
#
@@ -26,100 +25,8 @@
all: all-program
-# Determine host type
-# NOTE: HOST determination on RISC OS could fail because of missing bug fixes
-# in UnixLib which only got addressed in UnixLib 5 / GCCSDK 4.
-# When you don't have 'uname' available, you will see:
-# File 'uname' not found
-# When you do and using a 'uname' compiled with a buggy UnixLib, you
-# will see the following printed on screen:
-# RISC OS
-# In both cases HOST make variable is empty and we recover from that by
-# assuming we're building on RISC OS.
-# In case you don't see anything printed (including the warning), you
-# have an up-to-date RISC OS build system. ;-)
-HOST := $(shell uname -s)
-
-# Sanitise host
-# TODO: Ideally, we want the equivalent of s/[^A-Za-z0-9]/_/g here
-HOST := $(subst .,_,$(subst -,_,$(subst /,_,$(HOST))))
-
-ifeq ($(HOST),)
- HOST := riscos
- $(warning Build platform determination failed but that's a known problem for RISC OS so we're assuming a native RISC OS build.)
-else
- ifeq ($(HOST),RISC OS)
- # Fixup uname -s returning "RISC OS"
- HOST := riscos
- endif
-endif
-ifeq ($(HOST),riscos)
- # Build happening on RO platform, default target is RO backend
- ifeq ($(TARGET),)
- TARGET := riscos
- endif
-endif
-
-ifeq ($(HOST),BeOS)
- HOST := beos
-endif
-ifeq ($(HOST),Haiku)
- # Haiku implements the BeOS API
- HOST := beos
-endif
-ifeq ($(HOST),beos)
- # Build happening on BeOS platform, default target is BeOS backend
- ifeq ($(TARGET),)
- TARGET := beos
- endif
- ifeq ($(TARGET),haiku)
- override TARGET := beos
- endif
-endif
-
-ifeq ($(HOST),AmigaOS)
- HOST := amiga
- ifeq ($(TARGET),)
- TARGET := amiga
- endif
-endif
-
-ifeq ($(HOST),FreeMiNT)
- HOST := mint
-endif
-ifeq ($(HOST),mint)
- ifeq ($(TARGET),)
- TARGET := atari
- endif
-endif
-
-ifeq ($(findstring MINGW,$(HOST)),MINGW)
- # MSYS' uname reports the likes of "MINGW32_NT-6.0"
- HOST := windows
-endif
-ifeq ($(HOST),windows)
- ifeq ($(TARGET),)
- TARGET := windows
- endif
-endif
-
-# Default target is GTK backend
-ifeq ($(TARGET),)
- TARGET := gtk3
-endif
-
-# valid values for the TARGET
-VLDTARGET := riscos gtk2 gtk3 beos amiga amigaos3 framebuffer windows atari monkey
+# default values for base variables
-# Check for valid TARGET
-ifeq ($(filter $(VLDTARGET),$(TARGET)),)
- $(error Unknown TARGET "$(TARGET)", Must be one of $(VLDTARGET))
-endif
-
-# ensure empty values for base variables
-
-# Sub target for build
-SUBTARGET=
# Resources executable target depends upon
RESOURCES=
# Messages executable target depends on
@@ -153,169 +60,11 @@ BUILD_CFLAGS = -g -W -Wall -Wundef -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wmissing-declarations -Wuninitialized \
-Wno-unused-parameter
-ifeq ($(TARGET),riscos)
- ifeq ($(HOST),riscos)
- # Build for RO on RO
- GCCSDK_INSTALL_ENV := <NSLibs$$Dir>
- CCRES := ccres
- TPLEXT :=
- MAKERUN := makerun
- SQUEEZE := squeeze
- RUNEXT :=
- CC := gcc
- CXX := g++
- EXEEXT :=
- PKG_CONFIG :=
- else
- # Cross-build for RO (either using GCCSDK 3.4.6 - AOF,
- # either using GCCSDK 4 - ELF)
- ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
- ifneq ($(realpath /opt/netsurf/arm-unknown-riscos/env),)
- GCCSDK_INSTALL_ENV := /opt/netsurf/arm-unknown-riscos/env
- else
- GCCSDK_INSTALL_ENV := /home/riscos/env
- endif
- endif
-
- ifeq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
- ifneq ($(realpath /opt/netsurf/arm-unknown-riscos/cross/bin),)
- GCCSDK_INSTALL_CROSSBIN := /opt/netsurf/arm-unknown-riscos/cross/bin
- else
- GCCSDK_INSTALL_CROSSBIN := /home/riscos/cross/bin
- endif
- endif
-
- CCRES := $(GCCSDK_INSTALL_CROSSBIN)/ccres
- TPLEXT := ,fec
- MAKERUN := $(GCCSDK_INSTALL_CROSSBIN)/makerun
- SQUEEZE := $(GCCSDK_INSTALL_CROSSBIN)/squeeze
- RUNEXT := ,feb
- CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
- ifneq (,$(findstring arm-unknown-riscos-gcc,$(CC)))
- SUBTARGET := -elf
- EXEEXT := ,e1f
- ELF2AIF := $(GCCSDK_INSTALL_CROSSBIN)/elf2aif
- else
- SUBTARGET := -aof
- EXEEXT := ,ff8
- endif
- CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
- PKG_CONFIG := $(GCCSDK_INSTALL_ENV)/ro-pkg-config
- endif
-else
- ifeq ($(TARGET),beos)
- # Building for BeOS/Haiku
- #ifeq ($(HOST),beos)
- # Build for BeOS on BeOS
- GCCSDK_INSTALL_ENV := /boot/develop
- CC := gcc
- CXX := g++
- EXEEXT :=
- PKG_CONFIG := pkg-config
- #endif
- else
- ifeq ($(TARGET),windows)
- ifneq ($(HOST),windows)
- # Set Mingw defaults
- GCCSDK_INSTALL_ENV ?= /opt/netsurf/i686-w64-mingw32/env
- GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/i686-w64-mingw32/cross/bin
-
- CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
- WINDRES := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*windres)
-
- PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
- else
- # Building on Windows
- CC := gcc
- PKG_CONFIG :=
- endif
- else
- ifeq ($(findstring amiga,$(TARGET)),amiga)
- ifeq ($(findstring amiga,$(HOST)),amiga)
- PKG_CONFIG := pkg-config
- else
- ifeq ($(TARGET),amigaos3)
- GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-unknown-amigaos/env
- GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-unknown-amigaos/cross/bin
-
- SUBTARGET = os3
- else
- GCCSDK_INSTALL_ENV ?= /opt/netsurf/ppc-amigaos/env
- GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/ppc-amigaos/cross/bin
- endif
-
- override TARGET := amiga
-
- CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
-
- PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
- endif
- else
- ifeq ($(TARGET),atari)
- ifeq ($(HOST),atari)
- PKG_CONFIG := pkg-config
- else
- ifeq ($(HOST),mint)
- PKG_CONFIG := pkg-config
- else
- GCCSDK_INSTALL_ENV ?= /opt/netsurf/m68k-atari-mint/env
- GCCSDK_INSTALL_CROSSBIN ?= /opt/netsurf/m68k-atari-mint/cross/bin
-
- CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
-
- PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
- endif
- endif
- else
- ifeq ($(TARGET),monkey)
- ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
- PKG_CONFIG := pkg-config
- else
- PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
- endif
-
- ifneq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
- CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
- CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
- endif
- else
- ifeq ($(TARGET),framebuffer)
- ifeq ($(origin GCCSDK_INSTALL_ENV),undefined)
- PKG_CONFIG := pkg-config
- else
- PKG_CONFIG := PKG_CONFIG_LIBDIR="$(GCCSDK_INSTALL_ENV)/lib/pkgconfig" pkg-config
- endif
-
- ifneq ($(origin GCCSDK_INSTALL_CROSSBIN),undefined)
- CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
- CXX := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*g++)
- endif
-
- else
- # All native targets
-
- # use native package config
- PKG_CONFIG := pkg-config
-
- # gtk target processing
- ifeq ($(TARGET),gtk3)
- override TARGET := gtk
- override NETSURF_GTK_MAJOR := 3
- SUBTARGET = $(NETSURF_GTK_MAJOR)
- else
- ifeq ($(TARGET),gtk2)
- override TARGET := gtk
- override NETSURF_GTK_MAJOR := 2
- SUBTARGET = $(NETSURF_GTK_MAJOR)
- endif
- endif
- endif
- endif
- endif
- endif
- endif
- endif
-endif
+# compute HOST, TARGET and SUBTARGET
+include frontends/Makefile.hts
+
+# target specific tool overrides
+include frontends/$(TARGET)/Makefile.tools
# compiler versioning to adjust warning flags
CC_VERSION := $(shell $(CC) -dumpfullversion -dumpversion)
@@ -340,138 +89,8 @@ TOOLROOT := $(OBJROOT)/tools
CFLAGS_ENV := $(CFLAGS)
CXXFLAGS_ENV := $(CXXFLAGS)
-# A macro that conditionaly adds flags to the build when a feature is enabled.
-#
-# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
-# 2: Parameters to add to CFLAGS
-# 3: Parameters to add to LDFLAGS
-# 4: Human-readable name for the feature
-define feature_enabled
- ifeq ($$(NETSURF_USE_$(1)),YES)
- CFLAGS += $(2)
- CXXFLAGS += $(2)
- LDFLAGS += $(3)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(4) enabled (NETSURF_USE_$(1) := YES))
- endif
- else ifeq ($$(NETSURF_USE_$(1)),NO)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(4) disabled (NETSURF_USE_$(1) := NO))
- endif
- else
- $$(info M.CONFIG: $(4) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
- $$(error NETSURF_USE_$(1) must be YES or NO)
- endif
-endef
-
-# A macro that conditionaly adds flags to the build with a uniform display.
-#
-# 1: Feature name (ie, NETSURF_USE_BMP -> BMP)
-# 2: Human-readable name for the feature
-# 3: Parameters to add to CFLAGS when enabled
-# 4: Parameters to add to LDFLAGS when enabled
-# 5: Parameters to add to CFLAGS when disabled
-# 6: Parameters to add to LDFLAGS when disabled
-define feature_switch
- ifeq ($$(NETSURF_USE_$(1)),YES)
- CFLAGS += $(3)
- CXXFLAGS += $(3)
- LDFLAGS += $(4)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(2) enabled (NETSURF_USE_$(1) := YES))
- endif
- else ifeq ($$(NETSURF_USE_$(1)),NO)
- CFLAGS += $(5)
- CXXFLAGS += $(5)
- LDFLAGS += $(6)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(2) disabled (NETSURF_USE_$(1) := NO))
- endif
- else
- $$(info M.CONFIG: $(4) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
- $$(error NETSURF_USE_$(1) must be YES or NO)
- endif
-endef
-
-# Extend flags with appropriate values from pkg-config for enabled features
-#
-# 1: pkg-config required modules for feature
-# 2: Human-readable name for the feature
-define pkg_config_find_and_add
- ifeq ($$(PKG_CONFIG),)
- $$(error pkg-config is required to auto-detect feature availability)
- endif
-
- PKG_CONFIG_$(1)_EXISTS := $$(shell $$(PKG_CONFIG) --exists $(1) && echo yes)
-
- ifeq ($$(PKG_CONFIG_$(1)_EXISTS),yes)
- CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
- CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(1))
- LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(1))
- ifneq ($(MAKECMDGOALS),clean)
- $$(info PKG.CNFG: $(2) ($(1)) enabled)
- endif
- else
- ifneq ($(MAKECMDGOALS),clean)
- $$(info PKG.CNFG: $(2) ($(1)) failed)
- $$(error Unable to find library for: $(2) ($(1)))
- endif
- endif
-endef
-
-# Extend flags with appropriate values from pkg-config for enabled features
-#
-# 1: Feature name (ie, NETSURF_USE_RSVG -> RSVG)
-# 2: pkg-config required modules for feature
-# 3: Human-readable name for the feature
-define pkg_config_find_and_add_enabled
- ifeq ($$(PKG_CONFIG),)
- $$(error pkg-config is required to auto-detect feature availability)
- endif
-
- NETSURF_FEATURE_$(1)_AVAILABLE := $$(shell $$(PKG_CONFIG) --exists $(2) && echo yes)
- NETSURF_FEATURE_$(1)_CFLAGS ?= -DWITH_$(1)
-
- ifeq ($$(NETSURF_USE_$(1)),YES)
- ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
- CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
- CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
- LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(3) ($(2)) enabled (NETSURF_USE_$(1) := YES))
- endif
- else
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(3) ($(2)) failed (NETSURF_USE_$(1) := YES))
- $$(error Unable to find library for: $(3) ($(2)))
- endif
- endif
- else ifeq ($$(NETSURF_USE_$(1)),AUTO)
- ifeq ($$(NETSURF_FEATURE_$(1)_AVAILABLE),yes)
- CFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
- CXXFLAGS += $$(shell $$(PKG_CONFIG) --cflags $(2)) $$(NETSURF_FEATURE_$(1)_CFLAGS)
- LDFLAGS += $$(shell $$(PKG_CONFIG) --libs $(2)) $$(NETSURF_FEATURE_$(1)_LDFLAGS)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(3) ($(2)) auto-enabled (NETSURF_USE_$(1) := AUTO))
- NETSURF_USE_$(1) := YES
- endif
- else
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(3) ($(2)) auto-disabled (NETSURF_USE_$(1) := AUTO))
- NETSURF_USE_$(1) := NO
- endif
- endif
- else ifeq ($$(NETSURF_USE_$(1)),NO)
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(3) ($(2)) disabled (NETSURF_USE_$(1) := NO))
- endif
- else
- ifneq ($(MAKECMDGOALS),clean)
- $$(info M.CONFIG: $(3) ($(2)) error (NETSURF_USE_$(1) := $$(NETSURF_USE_$(1))))
- $$(error NETSURF_USE_$(1) must be YES, NO, or AUTO)
- endif
- endif
-endef
+# library and feature building macros
+include Makefile.macros
# ----------------------------------------------------------------------------
# General flag setup
@@ -681,20 +300,6 @@ S_COMMON := \
# Message targets
# ----------------------------------------------------------------------------
-# Message splitting rule generation macro
-# 1 = Language
-define split_messages
-
-$$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessages $$(TOOLROOT)/split-messages
- $$(VQ)echo "MSGSPLIT: Language: $(1) Filter: $$(MESSAGES_FILTER)"
- $$(Q)$$(MKDIR) -p $$(MESSAGES_TARGET)/$(1)
- $$(Q)$$(RM) $$@
- $$(Q)$$(TOOLROOT)/split-messages -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$<
-
-CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
-MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages
-
-endef
# generate the message file rules
$(eval $(foreach LANG,$(MESSAGES_LANGUAGES), \
@@ -745,7 +350,7 @@ ifeq ($(TARGET),beos)
$(Q)$(BEOS_SETVER) $(EXETARGET) \
-app $(VERSION_MAJ) $(VERSION_MIN) 0 d 0 \
-short "NetSurf $(VERSION_FULL)" \
- -long "NetSurf $(VERSION_FULL) © 2003 - 2016 The NetSurf Developers"
+ -long "NetSurf $(VERSION_FULL) © 2003 - 2021 The NetSurf Developers"
$(VQ)echo " MIMESET: $(EXETARGET)"
$(Q)$(BEOS_MIMESET) $(EXETARGET)
endif
@@ -769,79 +374,6 @@ all-program: $(EXETARGET) $(POSTEXES)
.SUFFIXES:
DEPFILES :=
-# Now some macros which build the make system
-
-# 1 = Source file
-# 2 = dep filename, no prefix
-# 3 = obj filename, no prefix
-define dependency_generate_c
-DEPFILES += $(2)
-
-endef
-
-# 1 = Source file
-# 2 = dep filename, no prefix
-# 3 = obj filename, no prefix
-define dependency_generate_s
-DEPFILES += $(2)
-
-endef
-
-# 1 = Source file
-# 2 = obj filename, no prefix
-# 3 = dep filename, no prefix
-ifeq ($(CC_MAJOR),2)
-# simpler deps tracking for gcc2...
-define compile_target_c
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(IFLAGS) $$(CFLAGS) -MM \
- $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
- > $$(DEPROOT)/$(3)
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-else
-define compile_target_c
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(COMMON_WARNFLAGS) $$(CWARNFLAGS) $$(IFLAGS) $$(CFLAGS) $(CFLAGS_ENV) \
- -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
- -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-endif
-
-define compile_target_cpp
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo " DEP: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(CC) $$(IFLAGS) $$(CXXFLAGS) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) -MM \
- $(1) | sed 's,^.*:,$$(DEPROOT)/$(3) $$(OBJROOT)/$(2):,' \
- > $$(DEPROOT)/$(3)
- $$(VQ)echo " COMPILE: $(1)"
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CXX) $$(COMMON_WARNFLAGS) $$(CXXWARNFLAGS) $$(IFLAGS) $$(CXXFLAGS) $(CXXFLAGS_ENV) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
-
-# 1 = Source file
-# 2 = obj filename, no prefix
-# 3 = dep filename, no prefix
-define compile_target_s
-$$(OBJROOT)/$(2): $(1) $$(OBJROOT)/created $$(DEPROOT)/created
- $$(VQ)echo "ASSEMBLE: $(1)"
- $$(Q)$$(RM) $$(DEPROOT)/$(3)
- $$(Q)$$(RM) $$(OBJROOT)/$(2)
- $$(Q)$$(CC) $$(ASFLAGS) -MMD -MT '$$(DEPROOT)/$(3) $$(OBJROOT)/$(2)' \
- -MF $$(DEPROOT)/$(3) -o $$(OBJROOT)/$(2) -c $(1)
-
-endef
# Rules to construct dep lines for each object...
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \