Bump to 4.4
[platform/upstream/make.git] / Basic.mk
1 # Basic GNU -*-Makefile-*- to build GNU make
2 #
3 # NOTE:
4 # If you have no 'make' program at all to process this makefile:
5 #   * On Windows, run ".\buildw32.bat" to bootstrap one.
6 #   * On MS-DOS, run ".\builddos.bat" to bootstrap one.
7 #
8 # Once you have a GNU make program created, you can use it with this makefile
9 # to keep it up to date if you make changes, as:
10 #
11 #   make.exe -f Basic.mk
12 #
13 # Copyright (C) 2017-2022 Free Software Foundation, Inc.
14 # This file is part of GNU Make.
15 #
16 # GNU Make is free software; you can redistribute it and/or modify it under
17 # the terms of the GNU General Public License as published by the Free Software
18 # Foundation; either version 3 of the License, or (at your option) any later
19 # version.
20 #
21 # GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
24 # details.
25 #
26 # You should have received a copy of the GNU General Public License along with
27 # this program.  If not, see <https://www.gnu.org/licenses/>.
28
29 all:
30
31 src = src/
32 lib = lib/
33
34 make_SOURCES = $(src)ar.c $(src)arscan.c $(src)commands.c $(src)default.c $(src)dir.c $(src)expand.c $(src)file.c $(src)function.c $(src)getopt.c $(src)getopt1.c $(src)guile.c $(src)hash.c $(src)implicit.c $(src)job.c $(src)load.c $(src)loadapi.c $(src)main.c $(src)misc.c $(src)output.c $(src)read.c $(src)remake.c $(src)rule.c $(src)shuffle.c $(src)signame.c $(src)strcache.c $(src)variable.c $(src)version.c $(src)vpath.c
35 glob_SOURCES = $(lib)fnmatch.c $(lib)glob.c
36 loadavg_SOURCES = $(lib)getloadavg.c
37 alloca_SOURCES = $(lib)alloca.c
38 w32_SOURCES = $(src)w32/pathstuff.c $(src)w32/w32os.c $(src)w32/compat/dirent.c $(src)w32/compat/posixfcn.c $(src)w32/subproc/misc.c $(src)w32/subproc/sub_proc.c $(src)w32/subproc/w32err.c
39 vms_SOURCES = $(src)vms_exit.c $(src)vms_export_symbol.c $(src)vms_progname.c $(src)vmsfunctions.c $(src)vmsify.c
40 amiga_SOURCES = $(src)amiga.c
41
42 remote_SOURCES = $(src)remote-stub.c
43
44 OUTDIR =
45 SRCDIR = .
46
47 OBJEXT = o
48 EXEEXT =
49
50 PREFIX = /usr/local
51 INCLUDEDIR = $(PREFIX)/include
52 LIBDIR = $(PREFIX)/lib
53 LOCALEDIR = $(PREFIX)/share
54
55 PROG = $(OUTDIR)make$(EXEEXT)
56
57 prog_SOURCES = $(make_SOURCES) $(remote_SOURCES)
58
59 BUILT_SOURCES =
60
61 OBJECTS = $(patsubst %.c,$(OUTDIR)%.$(OBJEXT),$(prog_SOURCES))
62
63 OBJDIRS = $(addsuffix .,$(sort $(dir $(OBJECTS))))
64
65 # Use the default value of CC
66 LD = $(CC)
67
68 # Reserved for command-line override
69 CPPFLAGS =
70 CFLAGS = -g -O2
71 LDFLAGS =
72
73 extra_CPPFLAGS = -DHAVE_CONFIG_H -I$(OUTDIR)src -I$(SRCDIR)/src -I$(OUTDIR)lib -I$(SRCDIR)/lib \
74         -DLIBDIR=\"$(LIBDIR)\" -DINCLUDEDIR=\"$(INCLUDEDIR)\" -DLOCALEDIR=\"$(LOCALDIR)\"
75 extra_CFLAGS =
76 extra_LDFLAGS = $(extra_CFLAGS) $(CFLAGS)
77
78 C_SOURCE = -c
79 OUTPUT_OPTION = -o $@
80 LINK_OUTPUT = -o $@
81
82 # Command lines
83
84 # $(call COMPILE.cmd,<src>,<tgt>)
85 COMPILE.cmd = $(CC) $(extra_CFLAGS) $(CFLAGS) $(extra_CPPFLAGS) $(CPPFLAGS) $(TARGET_ARCH) $(OUTPUT_OPTION) $(C_SOURCE) $1
86
87 # $(call LINK.cmd,<objectlist>)
88 LINK.cmd = $(LD) $(extra_LDFLAGS) $(LDFLAGS) $(TARGET_ARCH) $1 $(LDLIBS) $(LINK_OUTPUT)
89
90 # $(CHECK.cmd) $(CHECK.args)
91 CHECK.cmd = cd $(SRCDIR)/tests && ./run_make_tests -make $(shell cd $(<D) && pwd)/$(<F)
92 CHECK.args ?=
93
94 # $(call MKDIR.cmd,<dirlist>)
95 MKDIR.cmd = mkdir -p $1
96
97 # $(call RM.cmd,<filelist>)
98 RM.cmd = rm -f $1
99
100 # $(call CP.cmd,<from>,<to>)
101 CP.cmd = cp $1 $2
102
103 CLEANSPACE = $(call RM.cmd,$(OBJECTS) $(PROG) $(BUILT_SOURCES))
104
105 # Load overrides for the above variables.
106 include $(firstword $(wildcard $(SRCDIR)/mk/$(lastword $(subst -, ,$(MAKE_HOST)).mk)))
107
108 VPATH = $(SRCDIR)
109
110 all: $(PROG)
111
112 $(PROG): $(OBJECTS)
113         $(call LINK.cmd,$^)
114
115 $(OBJECTS): $(OUTDIR)%.$(OBJEXT): %.c
116         $(call COMPILE.cmd,$<)
117
118 $(OBJECTS): | $(OBJDIRS) $(BUILT_SOURCES)
119
120 $(OBJDIRS):
121         $(call MKDIR.cmd,$@)
122
123 check:
124         $(CHECK.cmd) $(CHECK.args)
125
126 clean:
127         $(CLEANSPACE)
128
129 $(filter %.h,$(BUILT_SOURCES)): %.h : %.in.h
130         $(call RM.cmd,$@)
131         $(call CP.cmd,$<,$@)
132
133 .PHONY: all check clean
134
135 # --------------- DEPENDENCIES
136 #
137
138 $(OBJECTS): $(SRCDIR)/src/mkconfig.h
139
140 # src/.deps/amiga.Po
141 # dummy
142
143 # src/.deps/ar.Po
144 # dummy
145
146 # src/.deps/arscan.Po
147 # dummy
148
149 # src/.deps/commands.Po
150 # dummy
151
152 # src/.deps/default.Po
153 # dummy
154
155 # src/.deps/dir.Po
156 # dummy
157
158 # src/.deps/expand.Po
159 # dummy
160
161 # src/.deps/file.Po
162 # dummy
163
164 # src/.deps/function.Po
165 # dummy
166
167 # src/.deps/getopt.Po
168 # dummy
169
170 # src/.deps/getopt1.Po
171 # dummy
172
173 # src/.deps/guile.Po
174 # dummy
175
176 # src/.deps/hash.Po
177 # dummy
178
179 # src/.deps/implicit.Po
180 # dummy
181
182 # src/.deps/job.Po
183 # dummy
184
185 # src/.deps/load.Po
186 # dummy
187
188 # src/.deps/loadapi.Po
189 # dummy
190
191 # src/.deps/main.Po
192 # dummy
193
194 # src/.deps/misc.Po
195 # dummy
196
197 # src/.deps/output.Po
198 # dummy
199
200 # src/.deps/posixos.Po
201 # dummy
202
203 # src/.deps/read.Po
204 # dummy
205
206 # src/.deps/remake.Po
207 # dummy
208
209 # src/.deps/remote-cstms.Po
210 # dummy
211
212 # src/.deps/remote-stub.Po
213 # dummy
214
215 # src/.deps/rule.Po
216 # dummy
217
218 # src/.deps/shuffle.Po
219 # dummy
220
221 # src/.deps/signame.Po
222 # dummy
223
224 # src/.deps/strcache.Po
225 # dummy
226
227 # src/.deps/variable.Po
228 # dummy
229
230 # src/.deps/version.Po
231 # dummy
232
233 # src/.deps/vms_exit.Po
234 # dummy
235
236 # src/.deps/vms_export_symbol.Po
237 # dummy
238
239 # src/.deps/vms_progname.Po
240 # dummy
241
242 # src/.deps/vmsfunctions.Po
243 # dummy
244
245 # src/.deps/vmsify.Po
246 # dummy
247
248 # src/.deps/vpath.Po
249 # dummy