-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (132 loc) · 5.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/make
#
# NetSurf Source makefile for libraries and browser
#
# The TARGET variable changes what toolkit is built for valid values are:
# gtk2 (default if unset)
# gtk3
# riscos
# framebuffer
# amiga
# cocoa
# atari
#
# The HOST variable controls the targetted ABI and not all toolkits build with
# all ABI e.g TARGET=riscos must be paired with HOST=arm-unknown-riscos
# The default is to use the BUILD variable contents which in turn defaults to
# the current cc default ABI target
# Component settings
COMPONENT := netsurf-all
COMPONENT_VERSION := 3.11
# Targets
# Netsurf target
NETSURF_TARG := netsurf
# nsgenbind host tool
NSGENBIND_TARG := nsgenbind
# Library targets
NSLIB_ALL_TARG := buildsystem libnslog libwapcaplet libparserutils libcss libhubbub libdom libnsbmp libnsgif librosprite libnsutils libutf8proc libnspsl
NSLIB_SVGTINY_TARG := libsvgtiny
NSLIB_FB_TARG := libnsfb
NSLIB_RO_TARG := librufl libpencil
# Build Environment
export TARGET ?= gtk2
TMP_PREFIX := $(CURDIR)/inst-$(TARGET)
export PKG_CONFIG_PATH := $(TMP_PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
export PATH := $(PATH):$(TMP_PREFIX)/bin/
TMP_NSSHARED := $(CURDIR)/buildsystem
# The system actually doing the build
BUILD ?= $(shell $(CC) -dumpmachine)
# The host we are targetting
HOST ?= $(BUILD)
# build verbosity.
# NetSurf uses the kernel style quiet Q variable but we also need to cope with thr GNU V=1 style
ifeq ($(V),1)
Q:=
else
Q=@
endif
# only build what we require for the target
ifeq ($(TARGET),riscos)
NSLIB_TARG := $(NSLIB_ALL_TARG) $(NSLIB_SVGTINY_TARG) $(NSLIB_RO_TARG)
NSBUILD_TARG := $(NSGENBIND_TARG)
else
ifeq ($(TARGET),framebuffer)
NSLIB_TARG := $(NSLIB_ALL_TARG) $(NSLIB_SVGTINY_TARG) $(NSLIB_FB_TARG)
NSBUILD_TARG := $(NSGENBIND_TARG)
else
ifeq ($(TARGET),amiga)
NSLIB_TARG := $(NSLIB_ALL_TARG) $(NSLIB_SVGTINY_TARG)
NSBUILD_TARG := $(NSGENBIND_TARG)
else
ifeq ($(TARGET),cocoa)
NSLIB_TARG := $(NSLIB_ALL_TARG) $(NSLIB_SVGTINY_TARG)
NSBUILD_TARG := $(NSGENBIND_TARG)
else
ifeq ($(TARGET),atari)
NSLIB_TARG := $(NSLIB_ALL_TARG)
NSBUILD_TARG := $(NSGENBIND_TARG)
else
NSLIB_TARG := $(NSLIB_ALL_TARG) $(NSLIB_SVGTINY_TARG)
NSBUILD_TARG := $(NSGENBIND_TARG)
endif
endif
endif
endif
endif
.PHONY: build install clean checkout-release checkout-head dist dist-head
# clean macro for each sub target
define do_clean
$(MAKE) distclean --directory=$1 HOST=$(HOST) NSSHARED=$(TMP_NSSHARED) Q=$(Q)
endef
# clean macro for each host sub target
define do_build_clean
$(MAKE) distclean --directory=$1 HOST=$(HOST) NSSHARED=$(TMP_NSSHARED) Q=$(Q)
endef
# prefixed install macro for each sub target
define do_prefix_install
$(MAKE) install --directory=$1 HOST=$(HOST) PREFIX=$(TMP_PREFIX) Q=$(Q) WARNFLAGS='-Wall -W -Wno-error' DESTDIR=
endef
# prefixed install macro for each host sub target
define do_build_prefix_install
$(MAKE) install --directory=$1 HOST=$(BUILD) PREFIX=$(TMP_PREFIX) Q=$(Q) DESTDIR=
endef
build: $(TMP_PREFIX)/build-stamp
$(TMP_PREFIX)/build-stamp:
mkdir -p $(TMP_PREFIX)/include
mkdir -p $(TMP_PREFIX)/lib
mkdir -p $(TMP_PREFIX)/bin
$(foreach L,$(NSLIB_TARG),$(call do_prefix_install,$(L)))
$(foreach L,$(NSBUILD_TARG),$(call do_build_prefix_install,$(L)))
$(MAKE) --directory=$(NETSURF_TARG) PREFIX=$(PREFIX) TARGET=$(TARGET) USER_DEFINES=$(USER_DEFINES) $(NETSURF_CONFIG)
touch $@
package: $(TMP_PREFIX)/build-stamp
$(MAKE) --directory=$(NETSURF_TARG) PREFIX=$(PREFIX) TARGET=$(TARGET) package $(NETSURF_CONFIG)
install: $(TMP_PREFIX)/build-stamp
$(MAKE) install --directory=$(NETSURF_TARG) TARGET=$(TARGET) PREFIX=$(PREFIX) DESTDIR=$(DESTDIR) $(NETSURF_CONFIG)
clean:
$(RM) -r $(TMP_PREFIX)
$(foreach L,$(NSLIB_TARG),$(call do_clean,$(L)))
$(foreach L,$(NSBUILD_TARG),$(call do_build_clean,$(L)))
$(MAKE) clean --directory=$(NETSURF_TARG) TARGET=$(TARGET)
# check out last release tag on each submodule
checkout-release: $(NSLIB_TARG) $(NETSURF_TARG) $(NSGENBIND_TARG) $(NSLIB_FB_TARG) $(NSLIB_SVGTINY_TARG) $(NSLIB_RO_TARG)
git fetch --recurse-submodules
for x in $^; do cd $$x; (git checkout origin/HEAD && git checkout $$(git describe --abbrev=0 --match="release/*" )); cd ..; done
# check out head on each submodule
checkout-head: $(NSLIB_TARG) $(NETSURF_TARG) $(NSGENBIND_TARG) $(NSLIB_FB_TARG) $(NSLIB_SVGTINY_TARG) $(NSLIB_RO_TARG)
git submodule init
git submodule update
git fetch --recurse-submodules
for x in $^; do cd $$x; git checkout origin/HEAD ; cd ..; done
# Generate a dist tarball from the head of all submodules
dist-head: checkout-head
$(eval DIST_FILE := $(COMPONENT)-${COMPONENT_VERSION}~$$$${BUILD_NUMBER:-1})
$(Q)git-archive-all --prefix=$(DIST_FILE)/ $(DIST_FILE).tgz
$(Q)mv $(DIST_FILE).tgz $(DIST_FILE).tar.gz
dist:
$(eval GIT_TAG := $(shell git describe --abbrev=0 --match "release/*"))
$(eval GIT_VER := $(shell x="$(GIT_TAG)"; echo "$${x#release/}"))
$(if $(subst $(GIT_VER),,$(COMPONENT_VERSION)), $(error Component Version "$(COMPONENT_VERSION)" and GIT tag version "$(GIT_VER)" do not match))
$(eval DIST_FILE := $(COMPONENT)-${GIT_VER})
$(Q)git-archive-all --force-submodules --prefix=$(DIST_FILE)/ $(DIST_FILE).tgz
$(Q)mv $(DIST_FILE).tgz $(DIST_FILE).tar.gz