summaryrefslogtreecommitdiff
path: root/cross/Makefile.in
blob: 575c6c4cb29569b41f6862464103d8e7c76c72e5 (plain)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
### @configure_input@

# Copyright (C) 2023-2024 Free Software Foundation, Inc.

# This file is part of GNU Emacs.

# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

top_srcdir = @top_srcdir@
srcdir = @srcdir@
top_builddir = @top_builddir@
builddir = @builddir@

FIND_DELETE = @FIND_DELETE@

-include $(top_builddir)/src/verbose.mk

# Cross-compiling Emacs for Android.

# The cross compiled binaries are built by having ``variant''
# Makefiles generated at configure-time.  First,
# $(top_builddir)/src/Makefile.android,
# $(top_builddir)/lib/Makefile.android,
# $(top_builddir)/lib/gnulib.mk.android and
# $(top_builddir)/lib-src/Makefile.android are copied to their usual
# locations in this directory.

# N.B. that LIB_SRCDIR is actually relative to builddir, because that
# is where the gnulib files get linked.

LIB_SRCDIR = $(realpath $(builddir)/lib)
LIB_TOP_SRCDIR = $(realpath $(top_srcdir))

SRC_SRCDIR = $(realpath $(top_srcdir)/src)
SRC_TOP_SRCDIR = $(realpath $(top_srcdir))

LIB_SRC_SRCDIR = $(realpath $(top_srcdir)/lib-src)
LIB_SRC_TOP_SRCDIR = $(realpath $(top_src))

# This is a list of binaries to build and install in lib-src.

LIBSRC_BINARIES = lib-src/etags lib-src/ctags lib-src/emacsclient \
		  lib-src/ebrowse lib-src/hexl lib-src/movemail

CLEAN_SUBDIRS = $(wildcard src lib-src lib etc)

.PHONY: all
all: lib/libgnu.a src/libemacs.so src/android-emacs $(LIBSRC_BINARIES)

# This Makefile relies on builddir and top_builddir being relative
# paths in *.android.

# This file is used to tell lib/gnulib.mk when
# $(top_builddir)/config.status changes.
config.status: $(top_builddir)/config.status
	$(AM_V_GEN) touch config.status

src/verbose.mk: $(srcdir)/verbose.mk.android
	$(AM_V_SILENT) cp -f $(srcdir)/verbose.mk.android \
	  src/verbose.mk

# Gnulib, make-fingerprint and make-docfile must be built before
# entering any of the rules below, or they will get the Android
# versions of many headers.

.PHONY: $(top_builddir)/lib/libgnu.a
$(top_builddir)/lib/libgnu.a:
	$(MAKE) -C $(top_builddir)/lib libgnu.a

.PHONY: $(top_builddir)/lib-src/make-fingerprint
$(top_builddir)/lib-src/make-fingerprint: $(top_builddir)/lib/libgnu.a
	$(MAKE) -C $(top_builddir)/lib-src make-fingerprint

.PHONY: $(top_builddir)/lib-src/make-docfile
$(top_builddir)/lib-src/make-docfile: $(top_builddir)/lib/libgnu.a
	$(MAKE) -C $(top_builddir)/lib-src make-docfile

PRE_BUILD_DEPS=$(top_builddir)/lib/libgnu.a		\
	       $(top_builddir)/lib-src/make-fingerprint	\
	       $(top_builddir)/lib-src/make-docfile

lib/config.h: $(top_builddir)/src/config.h.android
	$(AM_V_GEN) cp -f -p $(top_builddir)/src/config.h.android	\
	  lib/config.h

lib-src/config.h: $(top_builddir)/src/config.h.android
	$(AM_V_GEN) cp -f -p $(top_builddir)/src/config.h.android	\
	  lib-src/config.h

# Figure out where build-aux is.
# Then, replace the build-aux directory with its actual location,
# in case MKDIR_P points there.

relative_buildaux_dir := $(subst /,\/,$(top_srcdir)/build-aux)

lib/gnulib.mk: $(top_builddir)/lib/gnulib.mk.android
	$(AM_V_GEN) \
	  sed -e 's/^srcdir =.*$$/srcdir = $(subst /,\/,$(LIB_SRCDIR))/g' \
	      -e 's/$(relative_buildaux_dir)/$(subst /,\/,../$(top_builddir))\/build-aux/g' \
	    < $(top_builddir)/lib/gnulib.mk.android > $@

lib/Makefile: $(top_builddir)/lib/Makefile.android
	$(AM_V_GEN) \
	  sed -e 's/^top_srcdir =.*$$/top_srcdir = $(subst /,\/,$(LIB_TOP_SRCDIR))/g' \
	      -e 's/^srcdir =.*$$/srcdir = $(subst /,\/,$(LIB_SRCDIR))/g' \
	      -e 's/^VPATH =.*$$/VPATH = $(subst /,\/,$(LIB_SRCDIR))/g' \
		< $(top_builddir)/lib/Makefile.android > $@

# What is needed to build gnulib.
LIB_DEPS = lib/config.h lib/gnulib.mk lib/Makefile

.PHONY: lib/libgnu.a
lib/libgnu.a: src/verbose.mk config.status $(LIB_DEPS) $(PRE_BUILD_DEPS)
	$(MAKE) -C lib libgnu.a

# Edit srcdir and top_srcdir to the right locations.
# Edit references to ../admin/unidata to read ../../admin/unidata.
# Next, edit libsrc to the location at top_srcdir! It is important
# that src/Makefile uses the binaries there, instead of any
# cross-compiled binaries at ./lib-src.
# Edit out anything saying -I($(top_srcdir)/lib) into
# -I$../(srcdir)/lib; that should be covered by -I$(lib)

src/Makefile: $(top_builddir)/src/Makefile.android
	$(AM_V_GEN) \
	sed -e 's/^srcdir =.*$$/srcdir = $(subst /,\/,$(SRC_SRCDIR))/g' \
	    -e 's/^top_srcdir =.*$$/top_srcdir = $(subst /,\/,$(LIB_TOP_SRCDIR))/g' \
	    -e 's/\.\.\/admin\/unidata/..\/..\/admin\/unidata/g' \
	    -e 's/\.\.\/admin\/charsets/..\/..\/admin\/charsets/g' \
	    -e 's/^libsrc =.*$$/libsrc = \.\.\/\.\.\/lib-src/g' \
	    -e 's/libsrc =.*$$/libsrc = \.\.\/\.\.\/lib-src/g' \
	    -e 's/-I\$$(top_srcdir)\/lib//g' \
	    < $(top_builddir)/src/Makefile.android > $@

src/epaths.h: $(top_builddir)/src/epaths.h
	$(AM_V_GEN) cp -f -p $< $@

src/emacs-module.h: $(top_builddir)/src/emacs-module.h
	$(AM_V_GEN) cp -f -p $< $@

src/config.h: $(top_builddir)/src/config.h.android
	$(AM_V_GEN) cp -f -p $< $@

.PHONY: src/android-emacs src/libemacs.so

src/libemacs.so: src/Makefile src/config.h src/epaths.h \
  src/verbose.mk src/emacs-module.h lib/libgnu.a $(PRE_BUILD_DEPS)
	$(MAKE) -C src libemacs.so

src/android-emacs: src/Makefile src/config.h lib/libgnu.a \
  $(PRE_BUILD_DEPS)
	$(MAKE) -C src android-emacs

# Edit out SCRIPTS, it interferes with the build.
# Make BASE_CFLAGS also include cross/lib as well as ../lib.

lib-src/Makefile: $(top_builddir)/lib-src/Makefile.android
	$(AM_V_GEN) \
	sed -e 's/-I\$${srcdir}\/\.\.\/lib//g' \
	    -e 's/^srcdir=.*$$/srcdir = $(subst /,\/,$(LIB_SRC_SRCDIR))/g' \
	    -e 's/^top_srcdir=.*$$/top_srcdir = $(subst /,\/,$(LIB_SRC_TOP_SRCDIR))/g' \
	    -e 's/^SCRIPTS=.*$$/SCRIPTS=/g' \
	    -e 's/-I\.\.\/lib/-I..\/lib -I..\/$(subst /,\/,$(srcdir))\/lib/g' \
	  < $(top_builddir)/lib-src/Makefile.android > $@

.PHONY: $(LIBSRC_BINARIES)
$(LIBSRC_BINARIES) &: src/verbose.mk $(top_builddir)/$@ lib/libgnu.a \
  lib-src/config.h lib-src/Makefile $(PRE_BUILD_DEPS)
# Finally, go into lib-src and make everything being built
	$(MAKE) -C lib-src $(foreach bin,$(LIBSRC_BINARIES),$(notdir $(bin)))

.PHONY: clean maintainer-clean distclean
clean:
	for dir in $(CLEAN_SUBDIRS); do		\
	  find $$dir -type f $(FIND_DELETE);	\
	done
	rm -rf lib/config.h lib-src/config.h
# ndk-build won't have been generated in a non-Android build.
	if test -f ndk-build/Makefile; then	\
          $(MAKE) -C ndk-build clean;		\
	fi

maintainer-clean distclean bootstrap-clean: clean
# Remove links created by configure.
	for dir in $(CLEAN_SUBDIRS); do		\
	  find $$dir -type l $(FIND_DELETE);	\
	done
	rm -rf lib/Makefile lib/gnulib.mk ndk-build/Makefile
	rm -rf ndk-build/ndk-build.mk Makefile