~ubuntu-branches/debian/stretch/adabrowse/stretch

« back to all changes in this revision

Viewing changes to Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2004-02-14 13:22:40 UTC
  • Revision ID: james.westby@ubuntu.com-20040214132240-cqumhiq1677pkvzo
Tags: upstream-4.0.2
ImportĀ upstreamĀ versionĀ 4.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#------------------------------------------------------------------------------
 
2
# Makefile for GNAT for adabrowse
 
3
#
 
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
 
8
# uncommented ones.
 
9
#
 
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
#------------------------------------------------------------------------------
 
19
 
 
20
# It is assumed that the pathes to your ASIS installation are in your
 
21
# ADA_INCLUDE_PATH and ADA_OBJECTS_PATH!
 
22
 
 
23
# This makefile has become pretty complicated, mainly because of things
 
24
# which we figure out when the makefile is run:
 
25
#
 
26
# 1. We determine the compiler name used by gnatmake by default, and
 
27
#    generate a package spec AD.Setup containing this name.
 
28
#
 
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.
 
32
#
 
33
#    To get the compiler's name and to create AD.Setup, we build a small
 
34
#    utility program called get_gcc.
 
35
#
 
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.
 
41
#
 
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.
 
48
#
 
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.
 
55
#
 
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.
 
63
#
 
64
# Only after these two configuration steps building of AdaBrowse proper
 
65
# begins.
 
66
#
 
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).
 
69
 
 
70
GCC_OPTIONS = -O2
 
71
LD_OPTIONS  = -lasis
 
72
 
 
73
host := $(shell gcc -dumpmachine)
 
74
 
 
75
RM        := rm -f
 
76
CP        := cp
 
77
ADABROWSE := adabrowse
 
78
NASTY     := nasty
 
79
GET_GCC   := get_gcc
 
80
EXE       :=
 
81
CONFIGURE := adconf
 
82
PATH_SEP  := :
 
83
 
 
84
ifeq "$(findstring mingw32, $(host))" "mingw32"
 
85
   # Assume we're on Windows
 
86
   RM        := cmd.exe /c del
 
87
   CP        := cmd.exe /c copy
 
88
   ADABROWSE := adabrowse.exe
 
89
   NASTY     := nasty.exe
 
90
   GET_GCC   := get_gcc.exe
 
91
   CONFIGURE := adconf.exe
 
92
   EXE       := .exe
 
93
   PATH_SEP  := ;
 
94
endif
 
95
 
 
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.
 
101
 
 
102
GNAT_OPTIONS := -gnatwa -gnaty3abefhiklmprt
 
103
 
 
104
GET_GCC_GEN  = get_gcc.o get_gcc.ali
 
105
GET_GCC_FULL = $(GET_GCC_GEN) get_gcc.txt get_gcc.use
 
106
 
 
107
ifdef GNATSRC
 
108
 
 
109
INTERNAL_GNAT_SRC  := $(subst \,/,$(subst \\,/,$(GNATSRC)))
 
110
INTERNAL_GNAT_SRC2 := $(INTERNAL_GNAT_SRC)
 
111
 
 
112
# Check that this GNAT source directory is correct:
 
113
ifeq "$(strip $(wildcard $(INTERNAL_GNAT_SRC)/prj-env.ads))" ""
 
114
 
 
115
INTERNAL_GNAT_SRC := $(INTERNAL_GNAT_SRC2)/ada
 
116
 
 
117
ifeq "$(strip $(wildcard $(INTERNAL_GNAT_SRC)/prj-env.ads))" ""
 
118
 
 
119
INTERNAL_GNAT_SRC := $(INTERNAL_GNAT_SRC2)/src/ada
 
120
 
 
121
ifeq "$(strip $(wildcard $(INTERNAL_GNAT_SRC)/prj-env.ads))" ""
 
122
 
 
123
$(error GNAT sources not found)
 
124
#
 
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.)
 
128
#
 
129
# Hence we deliberately use a non-existing dependency to make make stop
 
130
# with a halfway sensible message.
 
131
 
 
132
adabrowse : Cannot_Find_GNAT_Sources
 
133
 
 
134
endif
 
135
 
 
136
endif
 
137
 
 
138
endif
 
139
 
 
140
endif
 
141
 
 
142
# Figure out where the ASIS installation is.
 
143
 
 
144
Include_Dirs := $(subst \,/, $(subst $(PATH_SEP), ,$(ADA_INCLUDE_PATH)))
 
145
A4G_DIR := $(foreach dir,$(Include_Dirs),$(wildcard $(dir)/a4g.ali))
 
146
 
 
147
ifeq "$(strip $(A4G_DIR))" ""
 
148
 
 
149
# ADA_INCLUDE_PATH had better contain the asis directory.
 
150
$(error ADA_INCLUDE_PATH must contain the ASIS installation!)
 
151
 
 
152
adabrowse : ASIS_Not_On_ADA_INCLUDE_PATH
 
153
 
 
154
endif
 
155
 
 
156
ASIS_DIR := $(strip $(dir $(word 1, $(A4G_DIR))))
 
157
 
 
158
ifeq "$(ASIS_DIR)" ""
 
159
 
 
160
# Something went wrong.
 
161
$(error Cannot figure out the ASIS installation directory!)
 
162
 
 
163
adabrowse : ASIS_Not_Found
 
164
 
 
165
endif
 
166
 
 
167
ifdef ADABROWSE_GNATSRC
 
168
 
 
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!
 
174
 
 
175
# But don't do this only the variable comes from the comamnd line, and if
 
176
# ADABROWSE_GCC_LIB also is defined!
 
177
 
 
178
ifneq "$(findstring command,$(origin ADABROWSE_GNATSRC))" ""
 
179
 
 
180
ifdef ADABROWSE_GCC_LIB
 
181
 
 
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)
 
184
 
 
185
endif
 
186
 
 
187
endif
 
188
 
 
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.
 
192
 
 
193
GNAT_OPTIONS += -gnatwIL
 
194
 
 
195
endif
 
196
 
 
197
# MAIN TARGET: (first in this makefile)
 
198
 
 
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)
 
203
 
 
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.
 
207
 
 
208
./config/$(CONFIGURE): get_gcc.use ./config/adconf.adb
 
209
        cd ./config; gnatmake -q -I.. adconf
 
210
 
 
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.
 
213
#
 
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.
 
220
 
 
221
run-conf:
 
222
        cd ./config; \
 
223
        ./$(CONFIGURE) $(shell get_gcc -gcc get_gcc.use) \
 
224
                       $(ASIS_DIR) \
 
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 ..
 
229
 
 
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"!
 
233
 
 
234
get_gcc.o :
 
235
        gnatmake -q -c -f get_gcc.adb
 
236
 
 
237
get_gcc.ali:
 
238
        gnatmake -q -c -f get_gcc.adb
 
239
 
 
240
$(GET_GCC): get_gcc.o get_gcc.ali get_gcc.adb
 
241
        gnatmake -q get_gcc
 
242
 
 
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.)
 
251
 
 
252
get_gcc.use: $(GET_GCC)
 
253
        $(RM) $(GET_GCC) $(GET_GCC_GEN)
 
254
        gnatmake get_gcc 2>get_gcc.use
 
255
 
 
256
# Ok, finally we can build adabrowse! The first dependency handles the
 
257
# C file in the distribution. All the others may be regenerated.
 
258
 
 
259
ifneq "$(EXE)" ""
 
260
 
 
261
# On Windows, add a target "adabrowse"
 
262
 
 
263
adabrowse: $(ADABROWSE)
 
264
        -$(warning AdaBrowse built without reconfiguration)
 
265
 
 
266
endif
 
267
 
 
268
$(ADABROWSE): util-nl.o \
 
269
              ad-setup.ads \
 
270
              ad-projects-impl.ads ad-projects-impl_yes-get_parent.adb
 
271
        gnatmake $(GCC_OPTIONS) adabrowse -cargs $(GNAT_OPTIONS) \
 
272
                                          -largs $(LD_OPTIONS)
 
273
        strip $(ADABROWSE)
 
274
 
 
275
$(NASTY): nasty.adb
 
276
        gnatmake nasty -cargs $(GCC_OPTIONS)
 
277
 
 
278
ad-setup.ads: get_gcc.use
 
279
        $(shell get_gcc -setup get_gcc.use)
 
280
 
 
281
util-nl.o: get_gcc.use util-nl.c
 
282
        $(shell get_gcc -gcc get_gcc.use) -c $(GCC_OPTIONS) util-nl.c
 
283
 
 
284
clean:
 
285
        $(RM) $(ADABROWSE) $(NASTY) $(GET_GCC) *.o *.ali
 
286