valkey/deps/Makefile
Pieter Noordhuis 4b8a63941d Rebuild deps/ and src/ when ARCH changes
This change moves the build instructions for dependencies to a separate
Makefile in deps/. The ARCH environment variable is stored in a
.make-arch file in the same directory as the Makefile. The contents of
this file is read and compared to the current ARCH, and, on a mismatch
triggers rebuilding the entire source tree.

When file .make-arch exists and matches with ARCH from the environment,
the dependencies are assumed to already be built.

The new "clean" target only cleans the Redis source tree, not its
dependencies. To clear the dependencies as well, the "distclean" target
can be used.
2011-11-15 12:41:35 -08:00

60 lines
1.7 KiB
Makefile

# Redis dependency Makefile
UNAME_S:=$(shell sh -c 'uname -s 2> /dev/null || echo not')
LUA_CFLAGS=-O2 -Wall $(ARCH)
ifeq ($(UNAME_S),SunOS)
# Make isinf() available
LUA_CFLAGS+= -D__C99FEATURES__=1
endif
JEMALLOC_CFLAGS=
ifeq ($(ARCH),-m32)
JEMALLOC_CFLAGS+=CFLAGS="-std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -m32"
endif
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
default:
@echo "Explicit target required"
# Clean everything when ARCH is different
ifneq ($(shell sh -c '[ -f .make-arch ] && cat .make-arch'), $(ARCH))
.make-arch: distclean
else
.make-arch:
endif
.make-arch:
-(echo $(ARCH) > .make-arch)
distclean:
-(cd hiredis && $(MAKE) clean) > /dev/null || true
-(cd linenoise && $(MAKE) clean) > /dev/null || true
-(cd lua && $(MAKE) clean) > /dev/null || true
-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
-(rm -f .make-arch)
hiredis: .make-arch
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)hiredis$(ENDCOLOR)
cd hiredis && $(MAKE) static ARCH="$(ARCH)"
linenoise: .make-arch
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)linenoise$(ENDCOLOR)
cd linenoise && $(MAKE) ARCH="$(ARCH)"
lua: .make-arch
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)lua$(ENDCOLOR)
cd lua && $(MAKE) CFLAGS="$(LUA_CFLAGS)" MYLDFLAGS="$(ARCH)" ansi
jemalloc: .make-arch
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)jemalloc$(ENDCOLOR)
cd jemalloc && ./configure $(JEMALLOC_CFLAGS) --with-jemalloc-prefix=je_ --enable-cc-silence && $(MAKE) lib/libjemalloc.a
.PHONY: default conditional_clean hiredis linenoise lua jemalloc