Makefile.adalib   [plain text]


# This is the Unix/NT makefile used to build an alternate GNAT run-time.
# Note that no files in the original GNAT library dirctory will be
# modified by this procedure
#
# This Makefile requires Gnu make.
# Here is how to use this Makefile
#
# 1. Create a new directory (say adalib)
#    e.g.  $ mkdir adalib
#          $ cd adalib           
#
# 2. Copy this Makefile from the standard Adalib directory, e.g.
#    $ cp /usr/local/gnat/lib/gcc-lib/<target>/2.8.1/adalib/Makefile.adalib .
#
# 3. If needed (e.g for pragma Normalize_Scalars), create a gnat.adc
#    containing the configuration pragmas you want to use to build the library
#    e.g. $ echo pragma Normalize_Scalars; > gnat.adc
#    Note that this step is usually not needed, and most pragmas are not
#    relevant to the GNAT run time. 
#          
# 4. Determine the values of the following MACROS
#      ROOT   (location of GNAT installation, e.g /usr/local)
#    and optionnally
#      CFLAGS (back end compilation flags such as -g -O2)
#      ADAFLAGS (front end compilation flags such as -gnatpgn)
#                *beware* the minimum value for this MACRO is -gnatpg 
#                for proper compilation of the GNAT library
# 5a. If you are using a native compile, call make
#   e.g.  $ make -f Makefile.adalib ROOT=/usr/local CFLAGS="-g -O0"
#
# 5b. If you are using a cross compiler, you need to define two additional
#     MACROS:
#       CC    (name of the cross compiler)
#       AR    (name of the cross ar)
#
#   e.g.  $ make -f Makefile.adalib ROOT=/opt/gnu/gnat \
#     CFLAGS="-O2 -g -I/usr/wind/target/h" CC=powerpc-wrs-vxworks-gcc \
#     AR=arppc
#
# 6. put this new library on your Object PATH where you want to use it
# in place of the original one. This can be achieved for instance by
# updating the value of the environment variable ADA_OBJECTS_PATH

SHELL=sh
PWD=$${PWDCMD-pwd}

CC = gcc
AR = ar
GNAT_ROOT = $(shell cd $(ROOT);${PWD})/
target = $(shell $(CC) -dumpmachine)
version = $(shell $(CC) -dumpversion)
ADA_INCLUDE_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adainclude/
ADA_OBJECTS_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adalib/

vpath %.adb $(ADA_INCLUDE_PATH)
vpath %.ads $(ADA_INCLUDE_PATH)
vpath %.c $(ADA_INCLUDE_PATH)
vpath %.h $(ADA_INCLUDE_PATH)

CFLAGS = -O2
ADAFLAGS = -gnatpgn
ALL_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS) -I. 
FORCE_DEBUG_ADAFLAGS = -g
INCLUDES = -I$(ADA_INCLUDE_PATH)

# Say how to compile Ada programs.
.SUFFIXES: .ada .adb .ads

.c.o:
	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(INCLUDES) $<
.adb.o:
	$(CC) -c $(ALL_ADAFLAGS) $<
.ads.o:
	$(CC) -c $(ALL_ADAFLAGS) $<

GNAT_OBJS :=$(filter-out prefix.o __%,$(shell $(AR) t $(ADA_OBJECTS_PATH)libgnat.a))
GNARL_OBJS:=$(filter-out __%,$(shell $(AR) t $(ADA_OBJECTS_PATH)libgnarl.a))
OBJS := $(GNAT_OBJS) $(GNARL_OBJS)

all: libgnat.a libgnarl.a
	chmod 0444 *.ali *.a
	rm *.o

libgnat.a: $(GNAT_OBJS)
	$(AR) r libgnat.a $(GNAT_OBJS)

libgnarl.a: $(GNARL_OBJS)
	$(AR) r libgnarl.a $(GNARL_OBJS)

a-except.o: a-except.adb a-except.ads
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) -O0 -fno-inline $<

s-assert.o: s-assert.adb s-assert.ads a-except.ads
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) $<

s-tasdeb.o: s-tasdeb.adb
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) $(ALL_ADAFLAGS) $<

s-vaflop.o: s-vaflop.adb
	$(CC) -c $(FORCE_DEBUG_ADAFLAGS) -O $(ALL_ADAFLAGS) $<

s-memory.o: s-memory.adb s-memory.ads
	$(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) $<

a-init.o: a-init.c a-ada.h a-types.h a-raise.h
	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) \
		$(ALL_CPPFLAGS) $(INCLUDES) -fexceptions $<

a-traceb.o: a-traceb.c
	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) \
		$(ALL_CPPFLAGS) $(INCLUDES) -fno-omit-frame-pointer $<

prefix.o: prefix.c gansidecl.h
	$(CC) -c $(CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
		-DPREFIX=\"$(GNAT_ROOT)\" $<