1
#------------------------------------------------------------------------------
2
# Makefile for GNAT for adabrowse
4
# This makefile assumes that the ASIS libraries are in
5
# ADA_INCLUDE_PATH and ADA_OBJECTS_PATH. If this is not
6
# the case, uncomment and edit the alternate definitions
7
# of GCC_OPTIONS and LD_OPTIONS below, and comment the now
10
# 05-APR-2002 TW Initial version
11
# 02-MAY-2002 TW Added 'nasty', changed the targets so they are macro refs.
12
# 08-MAY-2002 TW Changed the makefile so that it uses 'get_gcc' to figure
13
# out the name of the gcc used by GNAT.
14
# 08-JUN-2003 TW Added the automatic configuration stuff (with or without
15
# the project manager support).
16
# 20-NOV-2003 TW Correction for splitting path lists: Unix has ':' as the
17
# path separator, whereas Windows uses ';'!
18
#------------------------------------------------------------------------------
20
# It is assumed that the pathes to your ASIS installation are in your
21
# ADA_INCLUDE_PATH and ADA_OBJECTS_PATH!
23
# This makefile has become pretty complicated, mainly because of things
24
# which we figure out when the makefile is run:
26
# 1. We determine the compiler name used by gnatmake by default, and
27
# generate a package spec AD.Setup containing this name.
29
# This is so because on some Linux installations, the compiler to
30
# use for GNAT is not called "gcc" but "gnatgcc", and I want AdaBrowse
31
# to default to this name.
33
# To get the compiler's name and to create AD.Setup, we build a small
34
# utility program called get_gcc.
36
# 2. We figure out whether the GNAT sources are available. This is indicated
37
# by variable GNATSRC being set to the directory where the GNAT sources
38
# are. If this variable is set, and the directory actually contains the
39
# GNAT sources, then we try to configure AdaBrowse such that it uses the
40
# GNAT project manager.
42
# This is so because I don't want to distribute parts of the GNAT sources
43
# with AdaBrowse. The reason is that the project manager and some files
44
# it depends on differ between different GNAT versions, and furthermore
45
# I think ACT wouldn't like my distributing extracts from the 3.15p and
46
# 3.16a sources. Also, I'd have to add more and more extracts as new
47
# compiler versions appeared.
49
# So the way chosen here is actually simpler: the GNAT sources, which
50
# contain the project manager, are available from ACT, and users who
51
# want project manager support in AdaBrowse can get them and then just
52
# tell this makefile where they are. It isn't even necessary to try to
53
# build GNAT. The only requiremnet is that the sources are consistent
54
# with the GNAT and ASIS version used.
56
# To configure AdaBrowse, we build a utility program in subdirectory
57
# ./config and run it. The program then tries to build (using gnatmake)
58
# a dummy application using the project manager. If that succeeds, it
59
# configures AdaBrowse by generating two files ad-projects-impl.ads
60
# and ad-projects-impl-get_parent.adb. if building the dummy application
61
# failes, these files are set up such that AdaBrowse doesn't use the
62
# GNAT project manager.
64
# Only after these two configuration steps building of AdaBrowse proper
67
# And finally, this makefile is being complicated by the fact that the
68
# it has to work with the ancient GNU make 3.77 (distributed with GNAT 3.15p).
73
host := $(shell gcc -dumpmachine)
77
ADABROWSE := adabrowse
84
ifeq "$(findstring mingw32, $(host))" "mingw32"
85
# Assume we're on Windows
88
ADABROWSE := adabrowse.exe
90
GET_GCC := get_gcc.exe
91
CONFIGURE := adconf.exe
96
# GNAT-specific gcc options: enable all warnings, and style checking.
97
# The style checking flags are nearly as plain "-gnaty", but do not
98
# check comment format, and do not require explicit specs for all
99
# subprograms. I chose this setting because these two things do not
100
# correspond at all to *my* style.
102
GNAT_OPTIONS := -gnatwa -gnaty3abefhiklmprt
104
GET_GCC_GEN = get_gcc.o get_gcc.ali
105
GET_GCC_FULL = $(GET_GCC_GEN) get_gcc.txt get_gcc.use
109
INTERNAL_GNAT_SRC := $(subst \,/,$(subst \\,/,$(GNATSRC)))
110
INTERNAL_GNAT_SRC2 := $(INTERNAL_GNAT_SRC)
112
# Check that this GNAT source directory is correct:
113
ifeq "$(strip $(wildcard $(INTERNAL_GNAT_SRC)/prj-env.ads))" ""
115
INTERNAL_GNAT_SRC := $(INTERNAL_GNAT_SRC2)/ada
117
ifeq "$(strip $(wildcard $(INTERNAL_GNAT_SRC)/prj-env.ads))" ""
119
INTERNAL_GNAT_SRC := $(INTERNAL_GNAT_SRC2)/src/ada
121
ifeq "$(strip $(wildcard $(INTERNAL_GNAT_SRC)/prj-env.ads))" ""
123
$(error GNAT sources not found)
125
# Unfortunately, the error function doesn't work with GNU make 3.77,
126
# which is being distributed with GNAT 3.15p. (The GNAT 3.16a distribution
127
# contains the current GNU make 3.79.1.)
129
# Hence we deliberately use a non-existing dependency to make make stop
130
# with a halfway sensible message.
132
adabrowse : Cannot_Find_GNAT_Sources
142
# Figure out where the ASIS installation is.
144
Include_Dirs := $(subst \,/, $(subst $(PATH_SEP), ,$(ADA_INCLUDE_PATH)))
145
A4G_DIR := $(foreach dir,$(Include_Dirs),$(wildcard $(dir)/a4g.ali))
147
ifeq "$(strip $(A4G_DIR))" ""
149
# ADA_INCLUDE_PATH had better contain the asis directory.
150
$(error ADA_INCLUDE_PATH must contain the ASIS installation!)
152
adabrowse : ASIS_Not_On_ADA_INCLUDE_PATH
156
ASIS_DIR := $(strip $(dir $(word 1, $(A4G_DIR))))
158
ifeq "$(ASIS_DIR)" ""
160
# Something went wrong.
161
$(error Cannot figure out the ASIS installation directory!)
163
adabrowse : ASIS_Not_Found
167
ifdef ADABROWSE_GNATSRC
169
# Set the pathes so that we can compile files from the GNAT source
170
# distribution without problems. If we don't do that, we will not be
171
# able to link, because the GNAT compiler sources also contain
172
# the library sources. We must therefore make sure that the installed
173
# library always comes first!
175
# But don't do this only the variable comes from the comamnd line, and if
176
# ADABROWSE_GCC_LIB also is defined!
178
ifneq "$(findstring command,$(origin ADABROWSE_GNATSRC))" ""
180
ifdef ADABROWSE_GCC_LIB
182
export ADA_INCLUDE_PATH:=$(ASIS_DIR)$(PATH_SEP)$(ADABROWSE_GCC_LIB)$(PATH_SEP)$(ADABROWSE_GNATSRC)$(PATH_SEP)$(ADA_INCLUDE_PATH)
183
export ADA_OBJECTS_PATH:=$(ASIS_DIR)$(PATH_SEP)$(subst adainclude,adalib,$(ADABROWSE_GCC_LIB))$(PATH_SEP)$(ADA_OBJECTS_PATH)
189
# The GNAT sources may of course use internal GNAT units, so we don't
190
# want that warning. Also, we get spurious warnings on elaboration issues,
191
# all in GNAT sources. Suppress this warning, too.
193
GNAT_OPTIONS += -gnatwIL
197
# MAIN TARGET: (first in this makefile)
199
all: ./config/$(CONFIGURE) run-conf
200
$(MAKE) $(ADABROWSE) \
201
ADABROWSE_GCC_LIB=$(dir $(subst \,/,$(shell $(shell get_gcc -gcc get_gcc.use) -print-libgcc-file-name)))adainclude \
202
ADABROWSE_GNATSRC=$(INTERNAL_GNAT_SRC)
204
# Configuration stuff. We build an executable adconf, which then figures out
205
# from its parameters and by trying to compile a certain file whether or not
206
# we do have project manager support.
208
./config/$(CONFIGURE): get_gcc.use ./config/adconf.adb
209
cd ./config; gnatmake -q -I.. adconf
211
# If adconf is called with two argument only (i.e., GNATSRC is not set), it
212
# configures AdaBrowse not to use the project manager.
214
# If adconf is called with four arguments, it configures AdaBrowse such that
215
# it *does* use the project manager, and then tries to compile the file
216
# ad-projects-impl_yes.adb. If that fails, it retries again after having
217
# made one single change to account for a difference between GNAT 3.15p and
218
# 3.16a. If compilation still fails, it reverts to the configuration not
219
# using the project manager.
223
./$(CONFIGURE) $(shell get_gcc -gcc get_gcc.use) \
225
$(INTERNAL_GNAT_SRC) \
226
$(dir $(subst \,/,$(shell $(shell get_gcc -gcc get_gcc.use) -print-libgcc-file-name)))adainclude
227
-cd ./config; $(CP) ad-projects-impl.ads ..
228
-cd ./config; $(CP) ad-projects-impl_yes-get_parent.adb ..
230
# All this 'get_gcc' stuff here is GNAT specific: we try to dynamically
231
# figure out the name of the gcc used by GNAT. On some systems, it
232
# appears that this name is "gnatgcc", not "gcc"!
235
gnatmake -q -c -f get_gcc.adb
238
gnatmake -q -c -f get_gcc.adb
240
$(GET_GCC): get_gcc.o get_gcc.ali get_gcc.adb
243
# Note: the dependency below first ensures that all the files we're
244
# going to delete in the rm command actually exist. This is a work-
245
# around for Win 2k, where make stops because cmd.exe /c del returns
246
# a failure exit code because some files may not exist. However, they
247
# must not exist when we run gnatmake, or we won't have the desired
248
# output in get_gcc.err. (The trick is that the first line in that
249
# file will be the compile command gnatmake uses for get_gcc.adb,
250
# which will start with the compiler name.)
252
get_gcc.use: $(GET_GCC)
253
$(RM) $(GET_GCC) $(GET_GCC_GEN)
254
gnatmake get_gcc 2>get_gcc.use
256
# Ok, finally we can build adabrowse! The first dependency handles the
257
# C file in the distribution. All the others may be regenerated.
261
# On Windows, add a target "adabrowse"
263
adabrowse: $(ADABROWSE)
264
-$(warning AdaBrowse built without reconfiguration)
268
$(ADABROWSE): util-nl.o \
270
ad-projects-impl.ads ad-projects-impl_yes-get_parent.adb
271
gnatmake $(GCC_OPTIONS) adabrowse -cargs $(GNAT_OPTIONS) \
276
gnatmake nasty -cargs $(GCC_OPTIONS)
278
ad-setup.ads: get_gcc.use
279
$(shell get_gcc -setup get_gcc.use)
281
util-nl.o: get_gcc.use util-nl.c
282
$(shell get_gcc -gcc get_gcc.use) -c $(GCC_OPTIONS) util-nl.c
285
$(RM) $(ADABROWSE) $(NASTY) $(GET_GCC) *.o *.ali