1# Makefile for gnattools 2# Copyright 2003, 2004, 2009, 2010 Free Software Foundation, Inc. 3# 4# This file is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 3 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program; see the file COPYING3. If not see 16# <http://www.gnu.org/licenses/>. 17 18# Default target; must be first. 19all: gnattools 20 21# Standard autoconf-set variables. 22SHELL = @SHELL@ 23srcdir = @srcdir@ 24libdir = @libdir@ 25build = @build@ 26target = @target@ 27host = @host@ 28host_alias = @host_alias@ 29prefix = @prefix@ 30INSTALL = @INSTALL@ 31INSTALL_DATA = @INSTALL_DATA@ 32INSTALL_PROGRAM = @INSTALL_PROGRAM@ 33 34# Nonstandard autoconf-set variables. 35LN_S=@LN_S@ 36target_noncanonical=@target_noncanonical@ 37 38# Variables for the user (or the top level) to override. 39exeext = @EXEEXT@ 40objext=.o 41TRACE=no 42ADA_FOR_BUILD= 43ADA_FOR_TARGET= 44LDFLAGS= 45PWD_COMMAND = $${PWDCMD-pwd} 46 47# The tedious process of getting CFLAGS right. 48CFLAGS=-g 49GCC_WARN_CFLAGS = -W -Wall 50WARN_CFLAGS = @warn_cflags@ 51 52ADA_CFLAGS=@ADA_CFLAGS@ 53 54# Variables for gnattools. 55ADAFLAGS= -gnatpg -gnata 56 57# For finding the GCC build dir, which is used far too much 58GCC_DIR=../gcc 59 60# Absolute srcdir for gcc (why do we want absolute? I dunno) 61fsrcdir := $(shell cd $(srcdir)/../gcc/; ${PWD_COMMAND}) 62 63# Useful "subroutines" for the excess includes 64INCLUDES_FOR_SUBDIR = -I. -I.. -I../.. -I$(fsrcdir)/ada -I$(fsrcdir)/config \ 65 -I$(fsrcdir)/../include -I$(fsrcdir) 66ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada 67 68CXX_LFLAGS = \ 69 -B../../../$(target_noncanonical)/libstdc++-v3/src/.libs \ 70 -B../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \ 71 -L../../../$(target_noncanonical)/libstdc++-v3/src/.libs \ 72 -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs 73 74# Variables for gnattools, native 75TOOLS_FLAGS_TO_PASS_NATIVE= \ 76 "CC=../../xgcc -B../../" \ 77 "CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \ 78 "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \ 79 "LDFLAGS=$(LDFLAGS)" \ 80 "ADAFLAGS=$(ADAFLAGS)" \ 81 "ADA_CFLAGS=$(ADA_CFLAGS)" \ 82 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \ 83 "ADA_INCLUDES=-I- -I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\ 84 "exeext=$(exeext)" \ 85 "fsrcdir=$(fsrcdir)" \ 86 "srcdir=$(fsrcdir)" \ 87 "GNATMAKE=../../gnatmake" \ 88 "GNATLINK=../../gnatlink" \ 89 "GNATBIND=../../gnatbind" \ 90 "TOOLSCASE=native" 91 92# Variables for regnattools 93TOOLS_FLAGS_TO_PASS_RE= \ 94 "CC=../../xgcc -B../../" \ 95 "CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \ 96 "CFLAGS=$(CFLAGS)" \ 97 "LDFLAGS=$(LDFLAGS)" \ 98 "ADAFLAGS=$(ADAFLAGS)" \ 99 "ADA_CFLAGS=$(ADA_CFLAGS)" \ 100 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \ 101 "ADA_INCLUDES=-I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\ 102 "exeext=$(exeext)" \ 103 "fsrcdir=$(fsrcdir)" \ 104 "srcdir=$(fsrcdir)" \ 105 "GNATMAKE=../../gnatmake" \ 106 "GNATLINK=../../gnatlink" \ 107 "GNATBIND=../../gnatbind" \ 108 "TOOLSCASE=cross" 109 110# Variables for gnattools, cross 111ifeq ($(build), $(host)) 112 GNATMAKE_FOR_HOST=gnatmake 113 GNATLINK_FOR_HOST=gnatlink 114 GNATBIND_FOR_HOST=gnatbind 115 GNATLS_FOR_HOST=gnatls 116else 117 GNATMAKE_FOR_HOST=$(host_alias)-gnatmake 118 GNATLINK_FOR_HOST=$(host_alias)-gnatlink 119 GNATBIND_FOR_HOST=$(host_alias)-gnatbind 120 GNATLS_FOR_HOST=$(host_alias)-gnatls 121endif 122 123# Put the host RTS dir first in the PATH to hide the default runtime 124# files that are among the sources 125RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib ))) 126 127TOOLS_FLAGS_TO_PASS_CROSS= \ 128 "CC=$(CC)" \ 129 "CXX=$(CXX)" \ 130 "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \ 131 "LDFLAGS=$(LDFLAGS)" \ 132 "ADAFLAGS=$(ADAFLAGS)" \ 133 "ADA_CFLAGS=$(ADA_CFLAGS)" \ 134 "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \ 135 "ADA_INCLUDES=-I$(RTS_DIR)/../adainclude -I$(RTS_DIR) $(ADA_INCLUDES_FOR_SUBDIR)" \ 136 "exeext=$(exeext)" \ 137 "fsrcdir=$(fsrcdir)" \ 138 "srcdir=$(fsrcdir)" \ 139 "GNATMAKE=$(GNATMAKE_FOR_HOST)" \ 140 "GNATLINK=$(GNATLINK_FOR_HOST)" \ 141 "GNATBIND=$(GNATBIND_FOR_HOST)" \ 142 "TOOLSCASE=cross" \ 143 "LIBGNAT=" 144 145# File lists 146# ---------- 147 148# File associations set by configure 149EXTRA_GNATTOOLS = @EXTRA_GNATTOOLS@ 150TOOLS_TARGET_PAIRS = @TOOLS_TARGET_PAIRS@ 151 152# Makefile targets 153# ---------------- 154 155.PHONY: gnattools gnattools-native gnattools-cross regnattools 156gnattools: @default_gnattools_target@ 157 158# Sanity check 159$(GCC_DIR)/stamp-gnatlib-rts: 160 @if [ ! -f $(GCC_DIR)/stamp-gnatlib-rts ] ; \ 161 then \ 162 echo "Cannot build gnattools while gnatlib is out of date or unbuilt" ; \ 163 false; \ 164 else \ 165 true; \ 166 fi 167 168 169# Build directory for the tools. Let's copy the target-dependent 170# sources using the same mechanism as for gnatlib. The other sources are 171# accessed using the vpath directive in ada/Makefile.in 172 173$(GCC_DIR)/stamp-tools: 174 -rm -rf $(GCC_DIR)/ada/tools 175 -mkdir -p $(GCC_DIR)/ada/tools 176 -(cd $(GCC_DIR)/ada/tools; $(LN_S) ../sdefault.adb ../snames.ads ../snames.adb .) 177 -$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \ 178 rm -f $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));\ 179 $(LN_S) $(fsrcdir)/ada/$(word 2,$(subst <, ,$(PAIR))) \ 180 $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));) 181 touch $(GCC_DIR)/stamp-tools 182 183# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap 184# reasons: gnatmake should be built with a recent compiler, a recent compiler 185# may not generate ALI files compatible with an old gnatmake so it is important 186# to be able to build gnatmake without a version of gnatmake around. Once 187# everything has been compiled once, gnatmake can be recompiled with itself 188# (see target regnattools) 189gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts 190 # gnattools1 191 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ 192 $(TOOLS_FLAGS_TO_PASS_NATIVE) \ 193 ../../gnatmake$(exeext) ../../gnatlink$(exeext) 194 # gnattools2 195 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ 196 $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools 197 198# gnatmake/link can be built with recent gnatmake/link if they are available. 199# This is especially convenient for building cross tools or for rebuilding 200# the tools when the original bootstrap has already be done. 201regnattools: $(GCC_DIR)/stamp-gnatlib-rts 202 # gnattools1-re 203 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ 204 $(TOOLS_FLAGS_TO_PASS_RE) INCLUDES="" \ 205 gnatmake-re gnatlink-re 206 # gnattools2 207 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ 208 $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools 209 210gnattools-cross: $(GCC_DIR)/stamp-tools 211 # gnattools1-re 212 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ 213 $(TOOLS_FLAGS_TO_PASS_CROSS) INCLUDES="" \ 214 gnatmake-re gnatlink-re 215 # gnattools2 216 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ 217 $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools 218 # Rename cross tools to where the GCC makefile wants them when 219 # installing. FIXME: installation should be done elsewhere. 220 if [ -f $(GCC_DIR)/gnatbind$(exeext) ] ; then \ 221 mv $(GCC_DIR)/gnatbind$(exeext) $(GCC_DIR)/gnatbind-cross$(exeext); \ 222 fi 223 if [ -f $(GCC_DIR)/gnatchop$(exeext) ] ; then \ 224 mv $(GCC_DIR)/gnatchop$(exeext) $(GCC_DIR)/gnatchop-cross$(exeext); \ 225 fi 226 if [ -f $(GCC_DIR)/gnat$(exeext) ] ; then \ 227 mv $(GCC_DIR)/gnat$(exeext) $(GCC_DIR)/gnat-cross$(exeext); \ 228 fi 229 if [ -f $(GCC_DIR)/gnatkr$(exeext) ] ; then \ 230 mv $(GCC_DIR)/gnatkr$(exeext) $(GCC_DIR)/gnatkr-cross$(exeext); \ 231 fi 232 if [ -f $(GCC_DIR)/gnatlink$(exeext) ] ; then \ 233 mv $(GCC_DIR)/gnatlink$(exeext) $(GCC_DIR)/gnatlink-cross$(exeext); \ 234 fi 235 if [ -f $(GCC_DIR)/gnatls$(exeext) ] ; then \ 236 mv $(GCC_DIR)/gnatls$(exeext) $(GCC_DIR)/gnatls-cross$(exeext); \ 237 fi 238 if [ -f $(GCC_DIR)/gnatmake$(exeext) ] ; then \ 239 mv $(GCC_DIR)/gnatmake$(exeext) $(GCC_DIR)/gnatmake-cross$(exeext); \ 240 fi 241 if [ -f $(GCC_DIR)/gnatmem$(exeext) ] ; then \ 242 mv $(GCC_DIR)/gnatmem$(exeext) $(GCC_DIR)/gnatmem-cross$(exeext); \ 243 fi 244 if [ -f $(GCC_DIR)/gnatname$(exeext) ] ; then \ 245 mv $(GCC_DIR)/gnatname$(exeext) $(GCC_DIR)/gnatname-cross$(exeext); \ 246 fi 247 if [ -f $(GCC_DIR)/gnatprep$(exeext) ] ; then \ 248 mv $(GCC_DIR)/gnatprep$(exeext) $(GCC_DIR)/gnatprep-cross$(exeext); \ 249 fi 250 if [ -f $(GCC_DIR)/gnatxref$(exeext) ] ; then \ 251 mv $(GCC_DIR)/gnatxref$(exeext) $(GCC_DIR)/gnatxref-cross$(exeext); \ 252 fi 253 if [ -f $(GCC_DIR)/gnatfind$(exeext) ] ; then \ 254 mv $(GCC_DIR)/gnatfind$(exeext) $(GCC_DIR)/gnatfind-cross$(exeext); \ 255 fi 256 if [ -f $(GCC_DIR)/gnatclean$(exeext) ] ; then \ 257 mv $(GCC_DIR)/gnatclean$(exeext) $(GCC_DIR)/gnatclean-cross$(exeext); \ 258 fi 259 if [ -f $(GCC_DIR)/gnatsym$(exeext) ] ; then \ 260 mv $(GCC_DIR)/gnatsym$(exeext) $(GCC_DIR)/gnatsym-cross$(exeext); \ 261 fi 262 263# Other 264# ----- 265 266# Check uninstalled version. 267check: 268 269# Check installed version. 270installcheck: 271 272# Build info (none here). 273info: 274 275# Build DVI (none here). 276dvi: 277 278# Build PDF (none here). 279pdf: 280 281# Build HTML (none here). 282html: 283 284.PHONY: check installcheck info dvi pdf html 285 286# Build TAGS (none here). 287TAGS: 288 289# Installation rules. 290install: 291 292install-strip: install 293 294install-info: 295 296install-pdf: 297 298install-html: 299 300.PHONY: install install-strip install-info install-pdf install-html 301 302# Cleaning rules. 303mostlyclean: 304 305clean: 306 307distclean: 308 $(RM) Makefile config.status config.log 309 310maintainer-clean: 311 312.PHONY: mostlyclean clean distclean maintainer-clean 313 314# Rules for rebuilding this Makefile. 315Makefile: $(srcdir)/Makefile.in config.status 316 CONFIG_FILES=$@ ; \ 317 CONFIG_HEADERS= ; \ 318 $(SHELL) ./config.status 319 320config.status: $(srcdir)/configure 321 $(SHELL) ./config.status --recheck 322 323AUTOCONF = autoconf 324configure_deps = \ 325 $(srcdir)/configure.ac \ 326 $(srcdir)/../config/acx.m4 \ 327 $(srcdir)/../config/override.m4 328 329$(srcdir)/configure: @MAINT@ $(configure_deps) 330 cd $(srcdir) && $(AUTOCONF) 331 332# Don't export variables to the environment, in order to not confuse 333# configure. 334.NOEXPORT: 335 336