From 92485f3f6704744bbaf278fc967b3834a0393b18 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 9 May 2012 15:50:46 +0200 Subject: [PATCH] Add common.mk Adapt all the Makefiles to use it. Rename all the Makefile_atheros_openwrt-10.03 to Makefile_atheros_openwrt. --- Makefile | 4 +- Makefile_atheros_openwrt | 10 +- common.mk | 116 ++++++++++++++++++ libowlps-client/Makefile | 14 +-- ...openwrt-10.03 => Makefile_atheros_openwrt} | 15 +-- libowlps-resultreader/Makefile | 14 +-- libowlps/Makefile | 26 +--- ...openwrt-10.03 => Makefile_atheros_openwrt} | 27 +--- owlps-aggregator/Makefile | 25 +--- owlps-client/Makefile | 25 +--- ...openwrt-10.03 => Makefile_atheros_openwrt} | 26 +--- owlps-listener/Makefile | 25 +--- ...openwrt-10.03 => Makefile_atheros_openwrt} | 26 +--- owlps-positioner/Makefile | 24 +--- owlps-udp-to-http/Makefile | 24 +--- 15 files changed, 138 insertions(+), 263 deletions(-) create mode 100644 common.mk rename libowlps-client/{Makefile_atheros_openwrt-10.03 => Makefile_atheros_openwrt} (70%) rename libowlps/{Makefile_atheros_openwrt-10.03 => Makefile_atheros_openwrt} (79%) rename owlps-client/{Makefile_atheros_openwrt-10.03 => Makefile_atheros_openwrt} (71%) rename owlps-listener/{Makefile_atheros_openwrt-10.03 => Makefile_atheros_openwrt} (73%) diff --git a/Makefile b/Makefile index 7c51c7d..90a20a9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,4 @@ -ifndef MAKE - MAKE = make -endif +include common.mk .PHONY: \ all c clean purge help \ diff --git a/Makefile_atheros_openwrt b/Makefile_atheros_openwrt index 43a6f9e..c4685e8 100644 --- a/Makefile_atheros_openwrt +++ b/Makefile_atheros_openwrt @@ -1,11 +1,13 @@ ifndef MAKEFILE - MAKEFILE = Makefile_atheros_openwrt-10.03 + MAKEFILE := Makefile_atheros_openwrt endif -ifndef TARGET - TARGET = all +ifndef OPENWRT_VERSION + OPENWRT_VERSION := 10.03 endif +include common.mk + .PHONY: \ all help \ libowlps \ @@ -38,4 +40,6 @@ help : @echo "Compiles the supported modules for OpenWrt Atheros." @echo "Supported variables:" @echo " MAKEFILE: makefile to call (default: $(MAKEFILE))." + @echo " OPENWRT_VERSION: version of OpenWrt to build against \ +(default: $(OPENWRT_VERSION))." @echo " TARGET: target to call (default: all)." diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..697ae90 --- /dev/null +++ b/common.mk @@ -0,0 +1,116 @@ +# Export all variables by default +export + +### Versions ### + +# Current version of the libowlps +LIBOWLPS_VERSION := 3.0 + +# OwlPS source version +ifndef OWLPS_VERSION + OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') +endif + + +### make-related variables ### + +# Default make command +# Use MAKE=gmake on BSD systems. +ifndef MAKE + MAKE := make +endif + +# Default Makefile name +ifndef MAKEFILE + MAKEFILE := Makefile +endif + +# Default target to call, when calling a Makefile from another Makefile +ifndef TARGET + TARGET := all +endif + +# Target architecture +# This is unused for now. +ifndef ARCH + ARCH := native +endif + + +### Building tools ### + +# Misc tools +AR := ar +RANLIB := ranlib +STRIP := strip -s + +# Install/uninstall commands +CP := cp +MKDIR := mkdir -p +RM := rm -f +RM_RECURSIVE := \rm -fr +SYMLINK := ln -sf + +# C compiler +ifeq "$(origin CC)" "default" + COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) + ifeq "$(COLORGCC)" "0" + CC := colorgcc + endif +endif + +# C++ compiler +ifeq "$(origin CXX)" "default" + COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) + ifeq "$(COLORGCC)" "0" + CXX := colorgcc + endif +endif + + +### OpenWrt specifics ### +# +# To compile for OpenWrt, the OPENWRT_VERSION variable must be set. +# +# By default (i.e. if OPENWRT_VERSION is set to something else than a +# known version number, we assume compiling for trunk. For this to +# work we advise that you do something like that (assuming the OpenWrt +# builroot is installed in ~/openwrt/buildroot): +# mkdir -p ~/openwrt/atheros/trunk +# ln -s ../../buildroot/staging_dir +# ln -s \ +# ../../buildroot/staging_dir/target-mips_uClibc-0.9.33 \ +# target-mips_uClibc +# ln -s \ +# ../../buildroot/staging_dir/toolchain-mips_gcc-4.6-linaro_uClibc-0.9.33/ \ +# toolchain-mips_gcc_uClibc +# Of course, you have to update the symlinks when you compile a new +# version of the SDK. + +ifdef OPENWRT_VERSION + TOOLCHAIN_PREFIX := $$HOME/openwrt/atheros/trunk + STAGING_DIR := $(TOOLCHAIN_PREFIX)/staging_dir + TOOLCHAIN1 := $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc_uClibc + TOOLCHAIN_BIN := $(TOOLCHAIN1)/bin + TOOLCHAIN2 := $(TOOLCHAIN_PREFIX)/target-mips_uClibc + + ifeq "$(OPENWRT_VERSION)" "10.03" + TOOLCHAIN_PREFIX := $$HOME/openwrt/atheros/10.03/staging_dir + STAGING_DIR := $(TOOLCHAIN_PREFIX) + TOOLCHAIN1 := $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1 + TOOLCHAIN_BIN := $(TOOLCHAIN1)/usr/bin + TOOLCHAIN2 := $(TOOLCHAIN_PREFIX)/target-mips_uClibc-0.9.30.1 + endif + + CC := STAGING_DIR=$(STAGING_DIR) $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc + STRIP := STAGING_DIR=$(STAGING_DIR) $(TOOLCHAIN_BIN)/mips-openwrt-linux-strip -s +endif + + +### Installation directories ### + +PREFIX := /usr/local +INSTALL_DIR := $(PREFIX)/bin +INSTALL_LIB := $(PREFIX)/lib +INSTALL_INC := $(PREFIX)/include +INSTALL_MAN := $(PREFIX)/share/man diff --git a/libowlps-client/Makefile b/libowlps-client/Makefile index 1fa2642..f983e98 100644 --- a/libowlps-client/Makefile +++ b/libowlps-client/Makefile @@ -1,19 +1,7 @@ -# Compiler -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif - -# Other tools -AR = ar -RANLIB = ranlib -RM = rm -f +include ../common.mk # General variables LIB_CIBLE=libowlps-client -VERSION=1.0 # Targets to build STATIC=$(LIB_CIBLE).a diff --git a/libowlps-client/Makefile_atheros_openwrt-10.03 b/libowlps-client/Makefile_atheros_openwrt similarity index 70% rename from libowlps-client/Makefile_atheros_openwrt-10.03 rename to libowlps-client/Makefile_atheros_openwrt index 9a3ab29..72c8c59 100644 --- a/libowlps-client/Makefile_atheros_openwrt-10.03 +++ b/libowlps-client/Makefile_atheros_openwrt @@ -1,20 +1,7 @@ -# Cross-compilation toolchain directories -TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03/staging_dir -TOOLCHAIN1 = $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1 -TOOLCHAIN2 = $(TOOLCHAIN_PREFIX)/target-mips_uClibc-0.9.30.1 -TOOLCHAIN_BIN = $(TOOLCHAIN1)/usr/bin - -# Compiler -CC = $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc - -# Other tools -AR = ar -RANLIB = ranlib -RM = rm -f +include ../common.mk # General variables LIB_CIBLE=libowlps-client -VERSION=1.0 # Targets to build STATIC=$(LIB_CIBLE).a diff --git a/libowlps-resultreader/Makefile b/libowlps-resultreader/Makefile index 451eb68..7b812a0 100644 --- a/libowlps-resultreader/Makefile +++ b/libowlps-resultreader/Makefile @@ -1,19 +1,7 @@ -# Compiler -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif - -# Other tools -AR = ar -RANLIB = ranlib -RM = rm -f +include ../common.mk # General variables LIB_CIBLE = libowlps-resultreader -VERSION = 1.0 # Targets to build STATIC = $(LIB_CIBLE).a diff --git a/libowlps/Makefile b/libowlps/Makefile index 4dbf4fe..e6e0f7a 100644 --- a/libowlps/Makefile +++ b/libowlps/Makefile @@ -1,33 +1,11 @@ -# Installation directory -PREFIX=/usr/local -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compiler -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif - -# Other tools -AR = ar -RANLIB = ranlib - -# Install/uninstall commands -RM = rm -f -CP = cp -SYMLINK = ln -sf +include ../common.mk # General variables LIB_CIBLE=libowlps -VERSION = 3.0 # Targets to build STATIC=$(LIB_CIBLE).a -DYNAMIC=$(LIB_CIBLE).so.$(VERSION) +DYNAMIC=$(LIB_CIBLE).so.$(LIBOWLPS_VERSION) #PROGS= HEADER=owlps.h #HEADERS= diff --git a/libowlps/Makefile_atheros_openwrt-10.03 b/libowlps/Makefile_atheros_openwrt similarity index 79% rename from libowlps/Makefile_atheros_openwrt-10.03 rename to libowlps/Makefile_atheros_openwrt index c5d795c..72b73cc 100644 --- a/libowlps/Makefile_atheros_openwrt-10.03 +++ b/libowlps/Makefile_atheros_openwrt @@ -1,34 +1,11 @@ -# Cross-compilation toolchain directories -TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03/staging_dir -TOOLCHAIN1 = $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1 -TOOLCHAIN2 = $(TOOLCHAIN_PREFIX)/target-mips_uClibc-0.9.30.1 -TOOLCHAIN_BIN = $(TOOLCHAIN1)/usr/bin - -# Installation directory -PREFIX=/usr/local -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compiler -CC = $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc - -# Other tools -AR = ar -RANLIB = ranlib - -# Install/uninstall commands -RM = rm -f -CP = cp -SYMLINK = ln -sf +include ../common.mk # General variables LIB_CIBLE=libowlps -VERSION = 2.0 # Targets to build STATIC=$(LIB_CIBLE).a -DYNAMIC=$(LIB_CIBLE).so.$(VERSION) +DYNAMIC=$(LIB_CIBLE).so.$(LIBOWLPS_VERSION) #PROGS= HEADER=owlps.h #HEADERS= diff --git a/owlps-aggregator/Makefile b/owlps-aggregator/Makefile index 0191902..5ecd373 100644 --- a/owlps-aggregator/Makefile +++ b/owlps-aggregator/Makefile @@ -1,27 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif - -# Installation directory -PREFIX=/usr/local -INSTALL_DIR= $(PREFIX)/bin -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compilation tools -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif -STRIP = strip -s - -# Install/uninstall commands -RM = rm -f -CP = cp +include ../common.mk # Target TARGET=owlps-aggregatord diff --git a/owlps-client/Makefile b/owlps-client/Makefile index 3c0dcdc..5b1d849 100644 --- a/owlps-client/Makefile +++ b/owlps-client/Makefile @@ -1,27 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif - -# Installation directory -PREFIX=/usr/local -INSTALL_DIR= $(PREFIX)/bin -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compilation tools -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif -STRIP = strip -s - -# Install/uninstall commands -RM = rm -f -CP = cp +include ../common.mk # Target TARGET=owlps-client diff --git a/owlps-client/Makefile_atheros_openwrt-10.03 b/owlps-client/Makefile_atheros_openwrt similarity index 71% rename from owlps-client/Makefile_atheros_openwrt-10.03 rename to owlps-client/Makefile_atheros_openwrt index 7d4d5f7..b385fbd 100644 --- a/owlps-client/Makefile_atheros_openwrt-10.03 +++ b/owlps-client/Makefile_atheros_openwrt @@ -1,28 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif - -# Cross-compilation toolchain directories -TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03/staging_dir -TOOLCHAIN1 = $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1 -TOOLCHAIN2 = $(TOOLCHAIN_PREFIX)/target-mips_uClibc-0.9.30.1 -TOOLCHAIN_BIN = $(TOOLCHAIN1)/usr/bin - -# Installation directory -PREFIX=/usr/local -INSTALL_DIR= $(PREFIX)/bin -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compilation tools -CC = $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc -STRIP = $(TOOLCHAIN_BIN)/mips-openwrt-linux-strip -s - -# Install/uninstall commands -RM = rm -f -CP = cp +include ../common.mk # Target TARGET=owlps-client diff --git a/owlps-listener/Makefile b/owlps-listener/Makefile index 9abfebf..c0fad17 100644 --- a/owlps-listener/Makefile +++ b/owlps-listener/Makefile @@ -1,27 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif - -# Installation directory -PREFIX=/usr/local -INSTALL_DIR= $(PREFIX)/sbin -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compilation tools -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif -STRIP = strip -s - -# Install/uninstall commands -RM = rm -f -CP = cp +include ../common.mk # Target TARGET=owlps-listenerd diff --git a/owlps-listener/Makefile_atheros_openwrt-10.03 b/owlps-listener/Makefile_atheros_openwrt similarity index 73% rename from owlps-listener/Makefile_atheros_openwrt-10.03 rename to owlps-listener/Makefile_atheros_openwrt index 4998dbd..e048a05 100644 --- a/owlps-listener/Makefile_atheros_openwrt-10.03 +++ b/owlps-listener/Makefile_atheros_openwrt @@ -1,28 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif - -# Cross-compilation toolchain directories -TOOLCHAIN_PREFIX = $$HOME/openwrt/atheros/10.03/staging_dir -TOOLCHAIN1 = $(TOOLCHAIN_PREFIX)/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1 -TOOLCHAIN2 = $(TOOLCHAIN_PREFIX)/target-mips_uClibc-0.9.30.1 -TOOLCHAIN_BIN = $(TOOLCHAIN1)/usr/bin - -# Installation directory -PREFIX=/usr/local -INSTALL_DIR= $(PREFIX)/sbin -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compilation tools -CC = $(TOOLCHAIN_BIN)/mips-openwrt-linux-gcc -STRIP = $(TOOLCHAIN_BIN)/mips-openwrt-linux-strip -s - -# Install/uninstall commands -RM = rm -f -CP = cp +include ../common.mk # Target TARGET=owlps-listenerd diff --git a/owlps-positioner/Makefile b/owlps-positioner/Makefile index aabc48d..5b02054 100644 --- a/owlps-positioner/Makefile +++ b/owlps-positioner/Makefile @@ -1,7 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif +include ../common.mk # Directories & files SRC_DIR = src @@ -10,30 +7,11 @@ TESTS_DIR = tests DOXYGEN_DIR = doc DOXYFILE = Doxyfile -# Installation directory -PREFIX = /usr/local -INSTALL_DIR = $(PREFIX)/bin - -# System tools -RM = rm -f -RM_RECURSIVE = \rm -fr -CP = cp -MKDIR = mkdir -p - # Other tools STYLE = astyle --style=gnu --formatted CPPCHECK = cppcheck --quiet --enable=all DOXYGEN = OWLPS_VERSION=$(OWLPS_VERSION) doxygen >/dev/null -# Compilation tools -ifeq "$(origin CXX)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CXX = colorgcc - endif -endif -STRIP = strip -s - # Flags LIBOWLPS_DIR = ../libowlps TESTSGXXFLAGS = -I$(TESTS_DIR) -I$(SRC_DIR) -I. diff --git a/owlps-udp-to-http/Makefile b/owlps-udp-to-http/Makefile index ae1c5d1..fdc5f8c 100644 --- a/owlps-udp-to-http/Makefile +++ b/owlps-udp-to-http/Makefile @@ -1,26 +1,4 @@ -# Source version -ifndef OWLPS_VERSION - OWLPS_VERSION := $(shell git describe 2>/dev/null || echo 'UNKNOWN_VERSION') -endif - -# Installation directory -PREFIX=/usr/local -INSTALL_DIR= $(PREFIX)/bin -INSTALL_LIB= $(PREFIX)/lib -INSTALL_INC= $(PREFIX)/include -INSTALL_MAN= $(PREFIX)/share/man - -# Compiler -ifeq "$(origin CC)" "default" - COLORGCC := $(shell which colorgcc >/dev/null 2>&1 ; echo $$?) - ifeq "$(COLORGCC)" "0" - CC = colorgcc - endif -endif - -# Install/uninstall commands -RM = rm -f -CP = cp +include ../common.mk # Target TARGET = owlps-udp-to-http