Add common.mk

Adapt all the Makefiles to use it.
Rename all the Makefile_atheros_openwrt-10.03 to
Makefile_atheros_openwrt.
This commit is contained in:
Matteo Cypriani 2012-05-09 15:50:46 +02:00
parent b0c9905ecc
commit 92485f3f67
15 changed files with 138 additions and 263 deletions

View File

@ -1,6 +1,4 @@
ifndef MAKE
MAKE = make
endif
include common.mk
.PHONY: \
all c clean purge help \

View File

@ -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)."

116
common.mk Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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=

View File

@ -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=

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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