diff --git a/CHANGES b/CHANGES index 6a4c976..27ffbc5 100755 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ _____________________________________ +Version 0.1.6 +???, 2006 +_____________________________________ + +_____________________________________ + Version 0.1.5 June 19, 2006 _____________________________________ diff --git a/Makefile b/Makefile index 777bdee..e9206e9 100755 --- a/Makefile +++ b/Makefile @@ -1,8 +1,4 @@ -export VERSION = 0.1.5 -export OS ?= $(shell uname -s) - -export CXXWARNFLAGS = -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic -export CXXFLAGS = $(CXXWARNFLAGS) -g -O2 +include Makefile.common .PHONY: all build-static build-shared check clean distclean all: build-static build-shared check @@ -12,7 +8,7 @@ build-static: build-shared: $(MAKE) -C src build-shared -check: build-shared +check: build-static build-shared $(MAKE) -C test clean: @@ -23,8 +19,6 @@ distclean: clean $(MAKE) -C src distclean ifneq ($(OS),Windows) -export prefix ?= /usr - .PHONY: install install-static install: $(MAKE) -C src install-static diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..89c4376 --- /dev/null +++ b/Makefile.common @@ -0,0 +1,7 @@ +VERSION := 0.1.6 +OS ?= $(shell uname -s) + +CXXWARNFLAGS := -Wall -Wold-style-cast -Wundef -Wsign-compare -Wconversion -Wpointer-arith -pedantic +CXXFLAGS := $(CXXWARNFLAGS) -g -O2 + +prefix := /usr diff --git a/Makefile.deps b/Makefile.deps new file mode 100644 index 0000000..93db288 --- /dev/null +++ b/Makefile.deps @@ -0,0 +1,26 @@ +.PHONY: cleandeps + +ifneq ($(OS),Windows) + +.static-dep/%.dep: %.cpp + @mkdir -p $(dir $@) + $(CXX) -MM -MT $(patsubst %.cpp,%.o,$<) $(CPPFLAGS) $< > $@ + +.shared-dep/%.dep: %.cpp + @mkdir -p $(dir $@) + $(CXX) -MM -MT $(patsubst %.cpp,%.lo,$<) $(CPPFLAGS) $< > $@ + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),distclean) +-include $(addprefix .static-dep/,$(SRC:.cpp=.dep)) +-include $(addprefix .shared-dep/,$(SRC:.cpp=.dep)) +endif +endif + +cleandeps: + $(RM) -R .static-dep + $(RM) -R .shared-dep + +else +cleandeps: +endif diff --git a/include/Makefile b/include/Makefile index 4210a3f..26a8139 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,3 +1,5 @@ +include ../Makefile.common + .PHONY: install install: mkdir -p $(prefix)/include/loki diff --git a/src/Makefile b/src/Makefile index 85942b5..85cb0f4 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,29 +1,31 @@ -SRC = $(wildcard *.cpp) -STATIC_OBJ = $(SRC:.cpp=.o) -SHARED_OBJ = $(SRC:.cpp=.lo) +include ../Makefile.common + +SRC := $(wildcard *.cpp) +STATIC_OBJ := $(SRC:.cpp=.o) +SHARED_OBJ := $(SRC:.cpp=.lo) override CPPFLAGS += -I../include -DNDEBUG -STATIC_LIB = libloki.a +STATIC_LIB := libloki.a ifeq ($(OS), Darwin) - SHARED_LIB_BASE = libloki.dylib - SHARED_LIB_VERSIONED = libloki.$(VERSION).dylib + SHARED_LIB_BASE := libloki.dylib + SHARED_LIB_VERSIONED := libloki.$(VERSION).dylib override LDFLAGS += -dynamiclib -single_module -install_name $(SHARED_LIB_VERSIONED) -fPIC - LDLIBS = -lpthread - RESULT_DIR = ../lib/ + LDLIBS := -lpthread + RESULT_DIR := ../lib/ else ifeq ($(OS), Linux) - SHARED_LIB_BASE = libloki.so - SHARED_LIB_VERSIONED = libloki.so.$(VERSION) + SHARED_LIB_BASE := libloki.so + SHARED_LIB_VERSIONED := libloki.so.$(VERSION) override LDFLAGS += --shared -Wl,-soname=$(SHARED_LIB_VERSIONED) -fPIC - LDLIBS = -lpthread - RESULT_DIR = ../lib/ + LDLIBS := -lpthread + RESULT_DIR := ../lib/ else - SHARED_LIB_BASE = libloki.dll + SHARED_LIB_BASE := libloki.dll override LDFLAGS += --shared - LDLIBS = - RESULT_DIR = ../lib/ + LDLIBS := + RESULT_DIR := ../lib/ endif endif @@ -38,14 +40,14 @@ ifneq ($(OS), Windows) $(RM) $(SHARED_OBJ) endif -distclean: clean +distclean: clean cleandeps $(RM) $(RESULT_DIR)$(STATIC_LIB) $(RM) $(RESULT_DIR)$(SHARED_LIB_BASE) ifneq ($(OS),Windows) $(RM) $(RESULT_DIR)$(SHARED_LIB_VERSIONED) -INSTALL = install -INSTALL_DATA = $(INSTALL) -m 644 +INSTALL := install +INSTALL_DATA := $(INSTALL) -m 644 .PHONY: install install-static install-shared install: install-static install-shared @@ -73,3 +75,5 @@ endif $(RESULT_DIR)$(STATIC_LIB): $(STATIC_OBJ) $(AR) $(ARFLAGS) $@ $^ + +include ../Makefile.deps diff --git a/test/DeletableSingleton/Makefile b/test/DeletableSingleton/Makefile index 72d4be9..353a78f 100755 --- a/test/DeletableSingleton/Makefile +++ b/test/DeletableSingleton/Makefile @@ -1,12 +1,16 @@ -BIN = DeletableSingleton$(BIN_SUFFIX) -SRC = DeletableSingleton.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := DeletableSingleton$(BIN_SUFFIX) +SRC := DeletableSingleton.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Factory/Makefile b/test/Factory/Makefile index a338efc..5dfbdb9 100755 --- a/test/Factory/Makefile +++ b/test/Factory/Makefile @@ -1,12 +1,16 @@ -BIN = Factory$(BIN_SUFFIX) -SRC = Factory.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := Factory$(BIN_SUFFIX) +SRC := Factory.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Function/Makefile b/test/Function/Makefile index 68181ae..581e86f 100644 --- a/test/Function/Makefile +++ b/test/Function/Makefile @@ -1,12 +1,16 @@ -BIN = FunctionTest$(BIN_SUFFIX) -SRC = FunctionTest.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := FunctionTest$(BIN_SUFFIX) +SRC := FunctionTest.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/LockingPtr/Makefile b/test/LockingPtr/Makefile index 4c75a8b..6fad8a5 100755 --- a/test/LockingPtr/Makefile +++ b/test/LockingPtr/Makefile @@ -1,12 +1,17 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) +LDLIBS += -lpthread .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Longevity/Makefile b/test/Longevity/Makefile index a73f477..ae22023 100755 --- a/test/Longevity/Makefile +++ b/test/Longevity/Makefile @@ -1,14 +1,16 @@ -BIN1 = main$(BIN_SUFFIX) -SRC1 = main.cpp -OBJ1 = $(SRC1:.cpp=.o) -BIN2 = main2$(BIN_SUFFIX) -SRC2 = main2.cpp -OBJ2 = $(SRC2:.cpp=.o) -override CXXFLAGS = $(CXXWARNFLAGS) -g -fexpensive-optimizations -O3 +include ../Makefile.common + +BIN1 := main$(BIN_SUFFIX) +SRC1 := main.cpp +OBJ1 := $(SRC1:.cpp=.o) +BIN2 := main2$(BIN_SUFFIX) +SRC2 := main2.cpp +OBJ2 := $(SRC2:.cpp=.o) +CXXFLAGS := $(CXXWARNFLAGS) -g -fexpensive-optimizations -O3 .PHONY: all clean all: $(BIN1) $(BIN2) -clean: +clean: cleandeps $(RM) $(BIN1) $(RM) $(OBJ1) $(RM) $(BIN2) @@ -19,3 +21,5 @@ $(BIN1): $(OBJ1) $(BIN2): $(OBJ2) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Makefile b/test/Makefile index 7d03302..f67d981 100755 --- a/test/Makefile +++ b/test/Makefile @@ -1,13 +1,3 @@ -export CPPFLAGS = -I../../include -DNDEBUG -export LDFLAGS = -L../../lib -export LDLIBS = -lloki - -ifeq ($(OS),Windows) -export BIN_SUFFIX = .exe -else -export BIN_SUFFIX = -endif - SUBTARGETS_ORIG := $(patsubst %/,%,$(dir $(wildcard */Makefile))) SUBTARGETS := $(filter-out $(SUBTARGETS_FILTER_OUT),$(SUBTARGETS_ORIG)) diff --git a/test/Makefile.common b/test/Makefile.common new file mode 100644 index 0000000..3834719 --- /dev/null +++ b/test/Makefile.common @@ -0,0 +1,11 @@ +include ../../Makefile.common + +override CPPFLAGS += -I../../include -DNDEBUG +override LDFLAGS += -L../../lib -static +LDLIBS := -lloki + +ifeq ($(OS),Windows) +BIN_SUFFIX := .exe +else +BIN_SUFFIX := +endif diff --git a/test/OrderedStatic/Makefile b/test/OrderedStatic/Makefile index 4c75a8b..d15cc73 100755 --- a/test/OrderedStatic/Makefile +++ b/test/OrderedStatic/Makefile @@ -1,12 +1,16 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Pimpl/Makefile b/test/Pimpl/Makefile index 4c75a8b..d15cc73 100755 --- a/test/Pimpl/Makefile +++ b/test/Pimpl/Makefile @@ -1,12 +1,16 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Register/Makefile b/test/Register/Makefile index f61098a..7b17b0c 100755 --- a/test/Register/Makefile +++ b/test/Register/Makefile @@ -1,10 +1,12 @@ -BIN1 = main$(BIN_SUFFIX) -SRC1 = main.cpp -OBJ1 = $(SRC1:.cpp=.o) -LIB1 = libfoo.a -SRC2 = foo.cpp -OBJ2 = $(SRC2:.cpp=.o) -override CPPFLAGS += -DLOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT +include ../Makefile.common + +BIN1 := main$(BIN_SUFFIX) +SRC1 := main.cpp +OBJ1 := $(SRC1:.cpp=.o) +LIB1 := libfoo.a +SRC2 := foo.cpp +OBJ2 := $(SRC2:.cpp=.o) +CPPFLAGS += -DLOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT .PHONY: all clean all: $(BIN1) @@ -15,8 +17,10 @@ $(BIN1): $(OBJ1) $(LIB1) $(LIB1): $(OBJ2) $(AR) $(ARFLAGS) $@ $^ -clean: +clean: cleandeps $(RM) $(BIN1) $(RM) $(OBJ1) $(RM) $(LIB1) $(RM) $(OBJ2) + +include ../../Makefile.deps diff --git a/test/RegressionTest/Makefile b/test/RegressionTest/Makefile index 10c9754..f6df1ce 100755 --- a/test/RegressionTest/Makefile +++ b/test/RegressionTest/Makefile @@ -1,12 +1,16 @@ -BIN = Test$(BIN_SUFFIX) -SRC = Test.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := Test$(BIN_SUFFIX) +SRC := Test.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/SafeFormat/Makefile b/test/SafeFormat/Makefile index 3855976..668990e 100755 --- a/test/SafeFormat/Makefile +++ b/test/SafeFormat/Makefile @@ -1,13 +1,17 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) -override CXXFLAGS = $(CXXWARNFLAGS) -g -fexpensive-optimizations -O3 +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) +CXXFLAGS := $(CXXWARNFLAGS) -g -fexpensive-optimizations -O3 .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/ScopeGuard/Makefile b/test/ScopeGuard/Makefile index 4c75a8b..d15cc73 100755 --- a/test/ScopeGuard/Makefile +++ b/test/ScopeGuard/Makefile @@ -1,12 +1,16 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Singleton/Makefile b/test/Singleton/Makefile index 4e07d3c..9e5344c 100644 --- a/test/Singleton/Makefile +++ b/test/Singleton/Makefile @@ -1,13 +1,15 @@ -BIN1 = Dependencies$(BIN_SUFFIX) -SRC1 = Dependencies.cpp -OBJ1 = $(SRC1:.cpp=.o) -BIN2 = Phoenix$(BIN_SUFFIX) -SRC2 = Phoenix.cpp -OBJ2 = $(SRC2:.cpp=.o) +include ../Makefile.common + +BIN1 := Dependencies$(BIN_SUFFIX) +SRC1 := Dependencies.cpp +OBJ1 := $(SRC1:.cpp=.o) +BIN2 := Phoenix$(BIN_SUFFIX) +SRC2 := Phoenix.cpp +OBJ2 := $(SRC2:.cpp=.o) .PHONY: all clean all: $(BIN1) $(BIN2) -clean: +clean: cleandeps $(RM) $(BIN1) $(RM) $(OBJ1) $(RM) $(BIN2) @@ -18,3 +20,5 @@ $(BIN1): $(OBJ1) $(BIN2): $(OBJ2) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/SingletonDll/Makefile b/test/SingletonDll/Makefile index 1bb67dd..84e5e47 100755 --- a/test/SingletonDll/Makefile +++ b/test/SingletonDll/Makefile @@ -1,26 +1,29 @@ +include ../Makefile.common + ifeq ($(OS),Darwin) - LIB1 = libfoo.dylib - LIB2 = libsingletondll.dylib - SHARED_LIB_FLAG = -dynamiclib + LIB1 := libfoo.dylib + LIB2 := libsingletondll.dylib + SHARED_LIB_FLAG := -dynamiclib else ifeq ($(OS),Linux) - LIB1 = libfoo.so - LIB2 = libsingletondll.so - SHARED_LIB_FLAG = --shared + LIB1 := libfoo.so + LIB2 := libsingletondll.so + SHARED_LIB_FLAG := --shared else - LIB1 = foo.dll - LIB2 = singletondll.dll - SHARED_LIB_FLAG = --shared + LIB1 := foo.dll + LIB2 := singletondll.dll + SHARED_LIB_FLAG := --shared endif endif -BIN1 = client$(BIN_SUFFIX) -SRC1 = client.cpp -OBJ1 = $(SRC1:.cpp=.o) -SRC2 = foo.cpp -OBJ2 = $(SRC2:.cpp=.o) -SRC3 = singletondll.cpp -OBJ3 = $(SRC3:.cpp=.o) +BIN1 := client$(BIN_SUFFIX) +SRC1 := client.cpp +OBJ1 := $(SRC1:.cpp=.o) +SRC2 := foo.cpp +OBJ2 := $(SRC2:.cpp=.o) +SRC3 := singletondll.cpp +OBJ3 := $(SRC3:.cpp=.o) +override LDFLAGS := -L../../lib .PHONY: all clean all: $(BIN1) @@ -34,10 +37,12 @@ $(LIB1): $(OBJ2) $(LIB2): $(OBJ3) $(CXX) $(SHARED_LIB_FLAG) $(LDFLAGS) -L. -o $@ $^ -lfoo $(LDLIBS) -clean: +clean: cleandeps $(RM) $(BIN1) $(RM) $(OBJ1) $(RM) $(LIB1) $(RM) $(OBJ2) $(RM) $(LIB2) $(RM) $(OBJ3) + +include ../../Makefile.deps diff --git a/test/SmallObj/Makefile b/test/SmallObj/Makefile index d8364fe..80d903b 100755 --- a/test/SmallObj/Makefile +++ b/test/SmallObj/Makefile @@ -1,14 +1,16 @@ -BIN1 = SmallObjBench$(BIN_SUFFIX) -SRC1 = SmallObjBench.cpp -OBJ1 = $(SRC1:.cpp=.o) -BIN2 = SmallObjSingleton$(BIN_SUFFIX) -SRC2 = SmallObjSingleton.cpp -OBJ2 = $(SRC2:.cpp=.o) -override CXXFLAGS = $(CXXWARNFLAGS) -g -fexpensive-optimizations -O3 +include ../Makefile.common + +BIN1 := SmallObjBench$(BIN_SUFFIX) +SRC1 := SmallObjBench.cpp +OBJ1 := $(SRC1:.cpp=.o) +BIN2 := SmallObjSingleton$(BIN_SUFFIX) +SRC2 := SmallObjSingleton.cpp +OBJ2 := $(SRC2:.cpp=.o) +CXXFLAGS := $(CXXWARNFLAGS) -g -fexpensive-optimizations -O3 .PHONY: all clean all: $(BIN1) $(BIN2) -clean: +clean: cleandeps $(RM) $(BIN1) $(RM) $(OBJ1) $(RM) $(BIN2) @@ -19,3 +21,5 @@ $(BIN1): $(OBJ1) $(BIN2): $(OBJ2) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/SmartPtr/Makefile b/test/SmartPtr/Makefile index e7ddab8..ee1351a 100755 --- a/test/SmartPtr/Makefile +++ b/test/SmartPtr/Makefile @@ -1,12 +1,17 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp strong.cpp LockTest.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp strong.cpp LockTest.cpp +OBJ := $(SRC:.cpp=.o) +LDLIBS += -lpthread .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/Visitor/Makefile b/test/Visitor/Makefile index 4c75a8b..d15cc73 100755 --- a/test/Visitor/Makefile +++ b/test/Visitor/Makefile @@ -1,12 +1,16 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps diff --git a/test/flex_string/Makefile b/test/flex_string/Makefile index 5e1ed2c..d15cc73 100755 --- a/test/flex_string/Makefile +++ b/test/flex_string/Makefile @@ -1,14 +1,16 @@ -BIN = main$(BIN_SUFFIX) -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) -override LDFLAGS = -override LDLIBS = +include ../Makefile.common + +BIN := main$(BIN_SUFFIX) +SRC := main.cpp +OBJ := $(SRC:.cpp=.o) .PHONY: all clean all: $(BIN) -clean: +clean: cleandeps $(RM) $(BIN) $(RM) $(OBJ) $(BIN): $(OBJ) $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +include ../../Makefile.deps