properly handle install PREFIX etc.

This commit is contained in:
Steffen Jaeckel 2017-09-13 15:20:40 +02:00
parent 81530c207d
commit 8924d33424
3 changed files with 33 additions and 32 deletions

View File

@ -11,23 +11,6 @@ UNINSTALL_CMD = rm
include makefile_include.mk include makefile_include.mk
# Compiler and Linker Names
ifndef PREFIX
PREFIX=
endif
ifeq ($(CC),cc)
CC = $(PREFIX)gcc
endif
LD=$(PREFIX)ld
AR=$(PREFIX)ar
RANLIB=$(PREFIX)ranlib
ifndef MAKE
MAKE=make
endif
ifeq ($V,1) ifeq ($V,1)
silent= silent=
else else
@ -104,12 +87,12 @@ timing: $(LIBNAME) demo/timing.o
$(CC) $(CFLAGS) demo/timing.o $(LIBNAME) $(PROF) -o timing $(CC) $(CFLAGS) demo/timing.o $(LIBNAME) $(PROF) -o timing
profiled: profiled:
CC="$(CC)" PREFIX="${PREFIX} CFLAGS="${CFLAGS} -fprofile-generate" MAKE=${MAKE} ${MAKE} timing CC="$(CC)" CROSS_COMPILE="${CROSS_COMPILE} CFLAGS="${CFLAGS} -fprofile-generate" MAKE=${MAKE} ${MAKE} timing
./test ./test
rm -f `find . -type f -name "*.o" | xargs` rm -f `find . -type f -name "*.o" | xargs`
rm -f `find . -type f -name "*.a" | xargs` rm -f `find . -type f -name "*.a" | xargs`
rm -f test rm -f test
CC=$(CC) PREFIX="${PREFIX} CFLAGS="${CFLAGS} -fprofile-use" MAKE=${MAKE} ${MAKE} timing CC=$(CC) CROSS_COMPILE="${CROSS_COMPILE} CFLAGS="${CFLAGS} -fprofile-use" MAKE=${MAKE} ${MAKE} timing
# target that pre-processes all coverage data # target that pre-processes all coverage data
lcov-single-create: lcov-single-create:

View File

@ -60,12 +60,12 @@ $(LIBNAME): $(OBJECTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LIB) -export-symbols libtfm.symbols $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LIB) -export-symbols libtfm.symbols
install: .common_install install: .common_install
sed -e 's,^Version:.*,Version: $(VERSION),' tomsfastmath.pc.in > tomsfastmath.pc sed -e 's,^Version:.*,Version: $(VERSION_PC),' tomsfastmath.pc.in > tomsfastmath.pc
install -d $(LIBPATH)/pkgconfig install -d $(DESTDIR)$(LIBPATH)/pkgconfig
install -m 644 tomsfastmath.pc $(LIBPATH)/pkgconfig/ install -m 644 tomsfastmath.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
uninstall: .common_uninstall uninstall: .common_uninstall
rm $(LIBPATH)/pkgconfig/tomsfastmath.pc rm $(DESTDIR)$(LIBPATH)/pkgconfig/tomsfastmath.pc
mtest/mtest: mtest/mtest.c mtest/mtest: mtest/mtest.c
cd mtest ; make mtest cd mtest ; make mtest

View File

@ -14,6 +14,23 @@ endif
# #
VERSION=0.13.1-next VERSION=0.13.1-next
VERSION_LIB=1:0:0 VERSION_LIB=1:0:0
VERSION_PC=0.13.1
# Compiler and Linker Names
ifndef CROSS_COMPILE
CROSS_COMPILE:=
endif
ifeq ($(CC),cc)
CC := $(CROSS_COMPILE)gcc
endif
LD:=$(CROSS_COMPILE)ld
AR:=$(CROSS_COMPILE)ar
RANLIB=$(CROSS_COMPILE)ranlib
ifndef MAKE
MAKE=make
endif
# #
# Compilation flags # Compilation flags
@ -52,9 +69,10 @@ endif
# #
# (Un)Install related variables # (Un)Install related variables
# #
DESTDIR ?= /usr/local DESTDIR ?=
LIBPATH ?= $(DESTDIR)/lib PREFIX ?= /usr/local
INCPATH ?= $(DESTDIR)/include LIBPATH ?= $(PREFIX)/lib
INCPATH ?= $(PREFIX)/include
# #
@ -65,16 +83,16 @@ default: $(LIBNAME)
.common_install: $(LIBNAME) .common_install: $(LIBNAME)
install -d $(LIBPATH) install -d $(DESTDIR)$(LIBPATH)
$(INSTALL_CMD) $(LIBNAME) $(LIBPATH)/$(LIBNAME) $(INSTALL_CMD) $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
install -d $(INCPATH) install -d $(DESTDIR)$(INCPATH)
install $(HEADERS_PUB) $(INCPATH) install $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
HEADER_FILES=$(notdir $(HEADERS_PUB)) HEADER_FILES=$(notdir $(HEADERS_PUB))
.common_uninstall: .common_uninstall:
$(UNINSTALL_CMD) $(LIBPATH)/$(LIBNAME) $(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
rm $(HEADER_FILES:%=$(INCPATH)/%) rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
#This rule cleans the source tree of all compiled code, not including the pdf #This rule cleans the source tree of all compiled code, not including the pdf