Makefile: avoid redefining BUILDDIR, so we can remove its directory in clean target

This commit is contained in:
Nguyen Anh Quynh 2014-04-29 16:29:55 +08:00
parent 5519a68812
commit 6ae472fe36

View File

@ -32,10 +32,11 @@ endif
PREFIX ?= /usr PREFIX ?= /usr
DESTDIR ?= DESTDIR ?=
ifndef BUILDDIR ifndef BUILDDIR
BUILDDIR = . BLDIR = .
OBJDIR = . OBJDIR = .
else else
OBJDIR = $(BUILDDIR)/obj BLDIR = $(BUILDDIR)
OBJDIR = $(BLDIR)/obj
endif endif
INCDIR = $(DESTDIR)$(PREFIX)/include INCDIR = $(DESTDIR)$(PREFIX)/include
@ -246,15 +247,15 @@ endif
endif endif
endif endif
LIBRARY = $(BUILDDIR)/lib$(LIBNAME).$(EXT) LIBRARY = $(BLDIR)/lib$(LIBNAME).$(EXT)
ARCHIVE = $(BUILDDIR)/lib$(LIBNAME).$(AR_EXT) ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT)
PKGCFGF = $(BUILDDIR)/$(LIBNAME).pc PKGCFGF = $(BLDIR)/$(LIBNAME).pc
.PHONY: all clean install uninstall dist .PHONY: all clean install uninstall dist
all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF) all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF)
$(MAKE) -C tests $(MAKE) -C tests
$(INSTALL_DATA) $(BUILDDIR)/lib$(LIBNAME).$(EXT) $(BUILDDIR)/tests/ $(INSTALL_DATA) $(BLDIR)/lib$(LIBNAME).$(EXT) $(BLDIR)/tests/
$(LIBRARY): $(LIBOBJ) $(LIBRARY): $(LIBOBJ)
$(CC) $(LDFLAGS) $(LIBOBJ) -o $(LIBRARY) $(CC) $(LDFLAGS) $(LIBOBJ) -o $(LIBRARY)
@ -314,7 +315,11 @@ clean:
rm -f $(LIBRARY) $(ARCHIVE) rm -f $(LIBRARY) $(ARCHIVE)
rm -f $(PKGCFGF) rm -f $(PKGCFGF)
$(MAKE) -C tests clean $(MAKE) -C tests clean
rm -f $(BUILDDIR)/tests/lib$(LIBNAME).$(EXT) rm -f $(BLDIR)/tests/lib$(LIBNAME).$(EXT)
ifdef BUILDDIR
rm -rf $(BUILDDIR)
endif
$(MAKE) -C bindings/python clean $(MAKE) -C bindings/python clean
$(MAKE) -C bindings/java clean $(MAKE) -C bindings/java clean