improve VERBOSE handling
[olsrd.git] / lib / pud / wireformat / Makefile
index 3cbdc7a..c7c7752 100644 (file)
@@ -12,22 +12,19 @@ include $(TOPDIR)/Makefile.inc
 #
 ######################
 
-MACHINE=$(shell uname -m)
-ifeq ($(strip $(MACHINE)),x86_64)
-LIBDIR_INSTALL = usr/lib64
-else
-LIBDIR_INSTALL = usr/lib
-endif
-
+DESTDIR ?=
+USRDIR ?= $(DESTDIR)/usr
+INCLUDEDIR ?= $(DESTDIR)/usr/include
+LIBDIR ?= $(USRDIR)/lib
 
 BUILD_DIR = build
+LIBDIR_BUILD = lib
 
-INC_DIR_BASE_C = include
+
+INC_DIR_BASE_C = ./include
 INC_DIR_C = $(INC_DIR_BASE_C)/$(PROJECT)
 INC_DIR_OLSRD = ../../../src
 
-LIBDIR_BUILD = lib
-
 MODULES = nodeIdConversion wireFormat
 
 SRC_DIR_C = src
@@ -36,16 +33,8 @@ OBJECTS_C = $(MODULES:%=$(BUILD_DIR)/%.o)
 INCLUDES = -I "$(INC_DIR_BASE_C)" -I "$(INC_DIR_OLSRD)"
 LIBRARIES = -lm
 
-DESTDIR ?=
-INC_DIR_INSTALL = usr/$(INC_DIR_C)
-
-
-ifneq ($(OS),linux)
 
-default_target install clean all:
-       @echo "*** only supported on Linux"
-
-else
+.PHONY: all default_target prepare clean doc doc-clean install install-headers uninstall uninstall-headers
 
 #
 # Targets
@@ -56,54 +45,64 @@ all: default_target
 default_target: prepare $(LIBDIR_BUILD)/$(SONAME)
 
 $(LIBDIR_BUILD)/$(SONAME): $(OBJECTS_C)
+ifeq ($(VERBOSE),0)
        @echo "[LD] $@"
-       @$(CC) -shared -Wl,-soname=$(SONAME) $(LIBRARIES) -o "$@" $(OBJECTS_C)
+endif
+       $(MAKECMDPREFIX)$(CC) -shared -Wl,-soname=$(SONAME) $(LIBRARIES) -o "$@" $(OBJECTS_C)
 
 $(BUILD_DIR)/%.o: $(SRC_DIR_C)/%.c $(INC_DIR_C)/compiler.h
+ifeq ($(VERBOSE),0)
        @echo "[CC] $<"
-       @$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c -o "$@" "$<"
+endif
+       $(MAKECMDPREFIX)$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c -o "$@" "$<"
+
+.gitignore:
+ifeq ($(VERBOSE),0)
+       @echo "[$@]"
+endif
+       $(MAKECMDPREFIX)echo "/$(BUILD_DIR)/" > $@
+       $(MAKECMDPREFIX)echo "/$(LIBDIR_BUILD)/" >> $@
+       $(MAKECMDPREFIX)$(MAKE) -C doc $@
 
 
 #
 # Phony Targets
 #
 
-.PHONY: .gitignore prepare clean doc doc-clean install uninstall java-clean java-doc java-install java-uninstall
-
-.gitignore:
-       @echo "[$@]"
-       @echo "/$(BUILD_DIR)/" > $@
-       @echo "/$(LIBDIR_BUILD)/" >> $@
-       @$(MAKE) -C doc $@
-
 prepare:
-       @mkdir -p "$(BUILD_DIR)" "$(LIBDIR_BUILD)"
+       $(MAKECMDPREFIX)mkdir -p "$(BUILD_DIR)" "$(LIBDIR_BUILD)"
 
 clean: doc-clean
+ifeq ($(VERBOSE),0)
        @echo "[$@]"
-       @rm -fr "$(BUILD_DIR)" "$(LIBDIR_BUILD)" "$(SRC_DIR_C)/"*.d
+endif
+       $(MAKECMDPREFIX)rm -fr "$(BUILD_DIR)" "$(LIBDIR_BUILD)" "$(SRC_DIR_C)/"*.d
 
 doc:
-       @$(MAKE) -C doc all
+       $(MAKECMDPREFIX)$(MAKE) -C doc all
 
 doc-clean:
-       @$(MAKE) -C doc clean
+       $(MAKECMDPREFIX)$(MAKE) -C doc clean
 
 install: all
-       rm -fr "$(DESTDIR)/$(INC_DIR_INSTALL)"
-       mkdir -v -p "$(DESTDIR)/$(LIBDIR_INSTALL)" "$(DESTDIR)/$(INC_DIR_INSTALL)"
-       cp "$(LIBDIR_BUILD)/$(SONAME)" "$(DESTDIR)/$(LIBDIR_INSTALL)/$(SONAME).$(PLUGIN_VER)"
-       $(STRIP) "$(DESTDIR)/$(LIBDIR_INSTALL)/$(SONAME).$(PLUGIN_VER)"
-       ldconfig -n "$(DESTDIR)/$(LIBDIR_INSTALL)"
-       cp -t "$(DESTDIR)/$(INC_DIR_INSTALL)" $(INC_DIR_C)/*.h
+       mkdir -v -p "$(LIBDIR)"
+       cp "$(LIBDIR_BUILD)/$(SONAME)" "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
+       $(STRIP) "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
+       /sbin/ldconfig -n "$(LIBDIR)"
+
+install-headers:
+       rm -fr "$(INCLUDEDIR)/$(PROJECT)"
+       mkdir -v -p "$(INCLUDEDIR)/$(PROJECT)"
+       cp -t "$(INCLUDEDIR)/$(PROJECT)" $(INC_DIR_C)/*.h
 
 uninstall:
-       rm -fr "$(DESTDIR)/$(INC_DIR_INSTALL)/"*.h
-       rm -f "$(DESTDIR)/$(LIBDIR_INSTALL)/$(SONAME)" \
-             "$(DESTDIR)/$(LIBDIR_INSTALL)/$(SONAME).$(PLUGIN_VER)"
-       ldconfig -n "$(DESTDIR)/$(LIBDIR_INSTALL)"
+       rm -f "$(LIBDIR)/$(SONAME)" \
+             "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
+       /sbin/ldconfig -n "$(LIBDIR)"
        rmdir -v -p --ignore-fail-on-non-empty \
-         "$(DESTDIR)/$(LIBDIR_INSTALL)" \
-         "$(DESTDIR)/$(INC_DIR_INSTALL)"
+         "$(LIBDIR)"
 
-endif
+uninstall-headers:
+       rm -fr "$(INCLUDEDIR)/$(PROJECT)/"*.h
+       rmdir -v -p --ignore-fail-on-non-empty \
+         "$(INCLUDEDIR)/$(PROJECT)"