From f7bcd97626f1a990106e88e1dfcb56806dfb0419 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Thu, 6 Nov 2014 17:29:37 +0000 Subject: Actually add Makefiles! - Not added in previous commit due to being in .gitignore --- Makefile | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f120975 --- /dev/null +++ b/Makefile @@ -0,0 +1,105 @@ +#### +#### Generic Makefile for C or C++ projects +#### +#### This file is public domain. +#### Jamie Bullock 2014 +#### + +################################### +### User configurable variables ### +################################### + +#### It is best not to modify this file +#### Instead override these variables in a separate Make.config file if needed + +# The name of the product to build (default uses parent directory name) +NAME ?= $(notdir $(CURDIR)) +# The file suffix of source files, can be .c or .cpp +SUFFIX ?= .c +# List of directories containing source files to be compiled +DIRS ?= . +# Flags to pass to the compiler for release builds +FLAGS ?= -O3 +# Flags to pass to the compiler for debug builds +DEBUG_FLAGS ?= -O0 -g +# Flags to pass to the linker +LDFLAGS ?= +# Type of product to build: "shared" for a shared library, "static" for a static library, empty for standalone +LIBRARY ?= static +# Prefix to the path that the "install" target will install into. libs to $(PREFIX)/lib, executables to $(PREFIX)/bin +PREFIX ?= /usr/local + +############################################## +### Do not modify anything below this line ### +############################################## + +ifeq ($(OS),Windows_NT) +else + PLATFORM := $(shell uname -s) +endif + +-include Make.config + +OUT_DIR := .build +SRC := $(foreach dir, $(DIRS), $(wildcard $(dir)/*$(SUFFIX))) +OBJ_ := $(SRC:$(SUFFIX)=.o) +OBJ := $(addprefix $(OUT_DIR)/,$(OBJ_)) +DEPS := $(OBJ:.o=.d) +SHARED_SUFFIX := dll +STATIC_SUFFIX := lib +INSTALL_DIR := $(PREFIX)/lib + +ifeq "$(PLATFORM)" "Darwin" + SHARED_SUFFIX := dylib + STATIC_SUFFIX := a +endif + +ifeq "$(PLATFORM)" "Linux" + SHARED_SUFFIX := so + STATIC_SUFFIX := a +endif + +ifeq "$(LIBRARY)" "shared" + OUT=lib$(NAME).$(SHARED_SUFFIX) + LDFLAGS += -shared +else ifeq "$(LIBRARY)" "static" + OUT=lib$(NAME).$(STATIC_SUFFIX) +else + OUT=$(NAME) + INSTALL_DIR := $(PREFIX)/bin +endif + +ifeq "$(SUFFIX)" ".cpp" + COMPILER := $(CXX) +else ifeq "$(SUFFIX)" ".c" + COMPILER := $(CC) +endif + +.SUFFIXES: +.PHONY: debug clean install uninstall + +$(OUT): $(OBJ) +ifeq "$(LIBRARY)" "static" + @$(AR) rcs $@ $^ +else + @$(COMPILER) $(LDFLAGS) $^ -o $@ +endif + +debug: FLAGS = $(DEBUG_FLAGS) +debug: $(OUT) + +$(OUT_DIR)/%.o: %$(SUFFIX) + @mkdir -p $(dir $@) + @$(COMPILER) $(CXXFLAGS) $(FLAGS) -MMD -MP -fPIC -c $< -o $@ + +install: $(OUT) + @install -d $(INSTALL_DIR) + @install $(OUT) $(INSTALL_DIR) + +uninstall: + @$(RM) $(INSTALL_DIR)/$(OUT) + +clean: + @$(RM) -r $(OUT) $(OUT_DIR) + +-include: $(DEPS) -- cgit v1.2.3 From df68c095949b4a5d1bad697e2785bd9cd8661f52 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Fri, 7 Nov 2014 12:45:35 +0000 Subject: Add examples to new build system --- Makefile | 108 ++++++--------------------------------------------------------- 1 file changed, 10 insertions(+), 98 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f120975..ece416f 100644 --- a/Makefile +++ b/Makefile @@ -1,105 +1,17 @@ -#### -#### Generic Makefile for C or C++ projects -#### -#### This file is public domain. -#### Jamie Bullock 2014 -#### -################################### -### User configurable variables ### -################################### +static: LIBTYPE = static +shared: LIBTYPE = shared -#### It is best not to modify this file -#### Instead override these variables in a separate Make.config file if needed +.PHONY: examples clean static shared -# The name of the product to build (default uses parent directory name) -NAME ?= $(notdir $(CURDIR)) -# The file suffix of source files, can be .c or .cpp -SUFFIX ?= .c -# List of directories containing source files to be compiled -DIRS ?= . -# Flags to pass to the compiler for release builds -FLAGS ?= -O3 -# Flags to pass to the compiler for debug builds -DEBUG_FLAGS ?= -O0 -g -# Flags to pass to the linker -LDFLAGS ?= -# Type of product to build: "shared" for a shared library, "static" for a static library, empty for standalone -LIBRARY ?= static -# Prefix to the path that the "install" target will install into. libs to $(PREFIX)/lib, executables to $(PREFIX)/bin -PREFIX ?= /usr/local +all: static examples -############################################## -### Do not modify anything below this line ### -############################################## +static shared: + @$(MAKE) -C src LIBRARY=$(LIBTYPE) -ifeq ($(OS),Windows_NT) -else - PLATFORM := $(shell uname -s) -endif - --include Make.config - -OUT_DIR := .build -SRC := $(foreach dir, $(DIRS), $(wildcard $(dir)/*$(SUFFIX))) -OBJ_ := $(SRC:$(SUFFIX)=.o) -OBJ := $(addprefix $(OUT_DIR)/,$(OBJ_)) -DEPS := $(OBJ:.o=.d) -SHARED_SUFFIX := dll -STATIC_SUFFIX := lib -INSTALL_DIR := $(PREFIX)/lib - -ifeq "$(PLATFORM)" "Darwin" - SHARED_SUFFIX := dylib - STATIC_SUFFIX := a -endif - -ifeq "$(PLATFORM)" "Linux" - SHARED_SUFFIX := so - STATIC_SUFFIX := a -endif - -ifeq "$(LIBRARY)" "shared" - OUT=lib$(NAME).$(SHARED_SUFFIX) - LDFLAGS += -shared -else ifeq "$(LIBRARY)" "static" - OUT=lib$(NAME).$(STATIC_SUFFIX) -else - OUT=$(NAME) - INSTALL_DIR := $(PREFIX)/bin -endif - -ifeq "$(SUFFIX)" ".cpp" - COMPILER := $(CXX) -else ifeq "$(SUFFIX)" ".c" - COMPILER := $(CC) -endif - -.SUFFIXES: -.PHONY: debug clean install uninstall - -$(OUT): $(OBJ) -ifeq "$(LIBRARY)" "static" - @$(AR) rcs $@ $^ -else - @$(COMPILER) $(LDFLAGS) $^ -o $@ -endif - -debug: FLAGS = $(DEBUG_FLAGS) -debug: $(OUT) - -$(OUT_DIR)/%.o: %$(SUFFIX) - @mkdir -p $(dir $@) - @$(COMPILER) $(CXXFLAGS) $(FLAGS) -MMD -MP -fPIC -c $< -o $@ - -install: $(OUT) - @install -d $(INSTALL_DIR) - @install $(OUT) $(INSTALL_DIR) - -uninstall: - @$(RM) $(INSTALL_DIR)/$(OUT) +examples: + @$(MAKE) -C examples clean: - @$(RM) -r $(OUT) $(OUT_DIR) - --include: $(DEPS) + @$(MAKE) -C src clean + @$(MAKE) -C examples clean -- cgit v1.2.3 From dbf585ec3763e25db5c34338cbf34af9035fe40f Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Fri, 7 Nov 2014 13:10:51 +0000 Subject: Add "install" target --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ece416f..250d37a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ +PREFIX = dist + static: LIBTYPE = static shared: LIBTYPE = shared -.PHONY: examples clean static shared +.PHONY: examples clean static shared install all: static examples @@ -12,6 +14,12 @@ static shared: examples: @$(MAKE) -C examples +install: + $(MAKE) -C src install PREFIX=$(PWD)/$(PREFIX) + $(MAKE) -C examples install PREFIX=$(PWD)/$(PREFIX) + @mkdir -p $(PREFIX)/include/xtract + @cp include/xtract/* $(PREFIX)/include/xtract + clean: @$(MAKE) -C src clean @$(MAKE) -C examples clean -- cgit v1.2.3 From 8a49f7c3a38fb3f50491dfe962b981e17c9716f4 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Fri, 7 Nov 2014 14:46:17 +0000 Subject: Add Doxygen to build system --- Makefile | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 250d37a..16e7c22 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,32 @@ -PREFIX = dist +PREFIX ?= $(PWD)/dist +HPATH = include/xtract -static: LIBTYPE = static -shared: LIBTYPE = shared +static: LIBRARY = static +shared: LIBRARY = shared -.PHONY: examples clean static shared install +export XTRACT_VERSION PREFIX LIBRARY + +.PHONY: examples clean static shared install doc all: static examples static shared: - @$(MAKE) -C src LIBRARY=$(LIBTYPE) + @$(MAKE) -C src examples: - @$(MAKE) -C examples + @$(MAKE) -C $@ + +doc: + @$(MAKE) -C $@ install: - $(MAKE) -C src install PREFIX=$(PWD)/$(PREFIX) - $(MAKE) -C examples install PREFIX=$(PWD)/$(PREFIX) - @mkdir -p $(PREFIX)/include/xtract - @cp include/xtract/* $(PREFIX)/include/xtract + $(MAKE) -C src install + $(MAKE) -C examples install + @mkdir -p $(PREFIX)/$(HPATH) + @cp $(HPATH)/* $(PREFIX)/$(HPATH) clean: @$(MAKE) -C src clean @$(MAKE) -C examples clean + @$(RM) -r dist -- cgit v1.2.3 From 254bc42e4b1093419754da4a82281653025f52b4 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Fri, 7 Nov 2014 16:12:11 +0000 Subject: Various improvements --- Makefile | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 16e7c22..e2f1cbb 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,27 @@ +LIBRARY ?= static PREFIX ?= $(PWD)/dist -HPATH = include/xtract -static: LIBRARY = static -shared: LIBRARY = shared +HPATH = include/xtract export XTRACT_VERSION PREFIX LIBRARY -.PHONY: examples clean static shared install doc +.PHONY: examples clean install doc src -all: static examples +all: src examples -static shared: - @$(MAKE) -C src - -examples: +src: @$(MAKE) -C $@ doc: @$(MAKE) -C $@ +examples: + @$(MAKE) -C $@ + install: - $(MAKE) -C src install - $(MAKE) -C examples install + @$(MAKE) -C src install + @$(MAKE) -C examples install @mkdir -p $(PREFIX)/$(HPATH) @cp $(HPATH)/* $(PREFIX)/$(HPATH) -- cgit v1.2.3 From 89a9ec7a352dc35141b8f9a87c202fdd448e9a6f Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Sat, 8 Nov 2014 00:06:06 +0000 Subject: Add Python bindings to build system --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e2f1cbb..e880ca9 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ HPATH = include/xtract export XTRACT_VERSION PREFIX LIBRARY -.PHONY: examples clean install doc src +.PHONY: examples clean install doc src swig all: src examples @@ -19,6 +19,9 @@ doc: examples: @$(MAKE) -C $@ +swig: src + @$(MAKE) -C $@ + install: @$(MAKE) -C src install @$(MAKE) -C examples install @@ -28,4 +31,5 @@ install: clean: @$(MAKE) -C src clean @$(MAKE) -C examples clean + @$(MAKE) -C swig clean @$(RM) -r dist -- cgit v1.2.3