Files
xmlada/Makefile.module.in
Emmanuel Briot ac93393f32 Use the same gnatmake command for the tests as we used to build the library.
Better support for cross builds


git-svn-id: svn+ssh://svn.eu.adacore.com/Dev/importfromcvs/trunk@11497 936e1b1b-40f2-da11-902a-00137254ae57
2001-12-05 14:57:30 +00:00

144 lines
3.9 KiB
Makefile

## General Makefile used to compile the modules
## This is included by all Makefiles, after they have defined the
## three variables
## DEPENDENCIES: list of modules we depend on
## MODULE: name of the module (to build libraires)
## WIN32: 'TRUE' if building on Windows, 'FALSE' otherwise
# Modify the line below to reflect the location where
# you want to install the library
PREFIX=@EXEC_PREFIX@
MAJOR=@XMLADA_MAJOR_VERSION@
MINOR=@XMLADA_MINOR_VERSION@
###########
## Five Makefile targets will be available from the command line:
##
## all: build objects and tests
## all_obj: build all objects, but not tests
## clean: remove all object and temporary files
## test: build the test programs found in the subdirectory test/
## lib: build the dynamic and static libraries for the module
##
## This makefile will not work with make other that GNU make
##
## You can also add special flags to the compiler (e.g -gnatf) by
## overriding the CFLAGS variable, as in
## > make CFLAGS="-gnatf"
###########
GNATMAKE=gnatmake
CC= @CC@
############
# Swap the two lines below if you are using a version of GNAT prior to 3.14
############
COMPILER=${GNATMAKE}
COMPILER=${GNATMAKE} -u -gnatwua -gnaty
RANLIB= @RANLIB@
ARFLAGS=cr
MKDIR=mkdir -p
CFLAGS=
BIND_FLAGS=-E
FPIC=
DEBUG=-g -gnata
CP=cp -p -f
CHMOD=chmod
LN=ln -f -s
libname=libxmlada_${MODULE}
soname=libxmlada_${MODULE}-${MAJOR}.${MINOR}
# Test programs to build
# These are all the programs in the test/ directory, whose name is test*.adb
TESTS=${wildcard test/test*.adb}
TEST_PROGS=${TESTS:%.adb=%}
DEP_SRC=${DEPENDENCIES:%=-aI../../%/}
DEP_OBJ=${DEPENDENCIES:%=-aO../../%/obj}
MKDIR=mkdir -p
SHELL=sh
GNATMAKE_FLAGS=-m ${DEBUG} $(CFLAGS) ${FPIC}
SRC=${wildcard *.ads}
OBJ=${sort ${SRC:%.ads=%.o}}
.PHONY: clean all all_obj test dirs
all:: dirs all_obj test
all_obj:: dirs ${OBJ}
test: ${TEST_PROGS}
dirs: force
@-${MKDIR} obj
@-${MKDIR} test
# This target is fairly complicated: it recompiles a single Ada file, if it
# wasn't up-to-date (gnatmake -u), and stops as soon as one of the files could
# not be compiled (thus the use of "MAKEsuccess", since grep would disturb
# the result)
# We also want to show the "gcc" command every time a file is actually compiled
# but hide the "gnatmake: object up to date" message when a file doesn't need
# to be compiled. The problem is that in the pipe A | B we want the output
# status of A, not of B, thus the fairly complicated shell command.
${OBJ}: force
ifeq (${WIN32}, TRUE)
@cd obj; ${COMPILER} ${DEP_SRC} ${DEP_OBJ} -I.. -I../.. ${@:%.o=%} ${GNATMAKE_FLAGS}
else
ifneq (${COMPILER}, ${GNATMAKE})
@cd obj; \
exec 3>&1; \
status=`((${COMPILER} ${DEP_SRC} ${DEP_OBJ} -I.. -I../..\
${@:%.o=%} $(GNATMAKE_FLAGS) 2>&1 1>&3 3>&- 4>&-; echo $$? >&4) |\
grep -v "gnatmake: object up to date." 1>&2 3>&- 4>&-) 4>&1`; \
exit $$status
else
@cd obj; ${COMPILER} ${DEP_SRC} ${DEP_OBJ} -I.. -I../.. ${@:%.o=%} ${GNATMAKE_FLAGS}
endif
endif
${TEST_PROGS}: force
cd test; ${GNATMAKE} ${DEP_SRC} ${DEP_OBJ} \
-aI.. -aI../.. -aO../obj ${@:test/%=%} ${GNATMAKE_FLAGS} \
-bargs ${BIND_FLAGS}
clean: force
-cd obj; ${RM} *.o
-cd obj; ${RM} *.ali
-cd test; ${RM} *.o
-cd test; ${RM} *.ali
-cd test; ${RM} b~*
-cd test; ${RM} *.exe
-${RM} ${TEST_PROGS}
@-rmdir obj
lib: ${OBJ}
cd obj; ${AR} ${ARFLAGS} ${libname}.a ${OBJ}
ifeq (${WIN32}, TRUE)
cd obj; ${RANLIB} ${libname}.a
else
@if [ -f /usr/bin/$(RANLIB) -o -f /bin/$(RANLIB) ]; then \
cd obj; ${RANLIB} ${libname}.a; \
fi
cd obj; ${CC} -shared -o ${soname}.so ${OBJ}
endif
install: lib
@${MKDIR} ${PREFIX}/lib
@${MKDIR} ${PREFIX}/include/xmlada
cd obj; ${CP} *.ali ${PREFIX}/include/xmlada
cd ${PREFIX}/include/xmlada; ${CHMOD} -w *.ali
${CP} *.ad[bs] ${PREFIX}/include/xmlada
cd obj; ${CP} ${libname}.a ${soname}.so ${PREFIX}/lib
cd ${PREFIX}/lib; ${LN} ${soname}.so ${libname}.so
force: