aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-11-07 12:45:35 +0000
committerJamie Bullock <jamie@jamiebullock.com>2014-11-07 12:45:35 +0000
commitdf68c095949b4a5d1bad697e2785bd9cd8661f52 (patch)
tree5ab41aa547c1d756bd6d3b5b3e6c5831fa29f46e
parentf7bcd97626f1a990106e88e1dfcb56806dfb0419 (diff)
downloadLibXtract-df68c095949b4a5d1bad697e2785bd9cd8661f52.tar.gz
LibXtract-df68c095949b4a5d1bad697e2785bd9cd8661f52.tar.bz2
LibXtract-df68c095949b4a5d1bad697e2785bd9cd8661f52.zip
Add examples to new build system
-rw-r--r--Makefile108
-rw-r--r--examples/Make.config5
-rw-r--r--[l---------]examples/Makefile9
-rw-r--r--examples/simpletest/Make.config9
-rw-r--r--examples/simpletest/Makefile105
-rw-r--r--src/Make.config (renamed from Make.config)0
-rw-r--r--src/Makefile105
7 files changed, 237 insertions, 104 deletions
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 <jamie@jamiebullock.com>
-####
-###################################
-### 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
diff --git a/examples/Make.config b/examples/Make.config
deleted file mode 100644
index 8713b3b..0000000
--- a/examples/Make.config
+++ /dev/null
@@ -1,5 +0,0 @@
-DIRS := simpletest
-LIBRARY :=
-SUFFIX := .cpp
-FLAGS += -I../
-LDFLAGS = -lxtract -L..
diff --git a/examples/Makefile b/examples/Makefile
index d0b0e8e..46ef826 120000..100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1 +1,8 @@
-../Makefile \ No newline at end of file
+
+.PHONY: simpletest clean
+
+simpletest:
+ @$(MAKE) -C $@
+
+clean:
+ @$(MAKE) -C simpletest clean
diff --git a/examples/simpletest/Make.config b/examples/simpletest/Make.config
new file mode 100644
index 0000000..6d21ed7
--- /dev/null
+++ b/examples/simpletest/Make.config
@@ -0,0 +1,9 @@
+
+ifeq ($(PLATFORM), Darwin)
+ DARWIN_LDFLAGS = -framework Accelerate
+endif
+
+LIBRARY :=
+SUFFIX := .cpp
+FLAGS += -I../../
+LDFLAGS = -lxtract -L../../src $(DARWIN_LDFLAGS)
diff --git a/examples/simpletest/Makefile b/examples/simpletest/Makefile
new file mode 100644
index 0000000..f120975
--- /dev/null
+++ b/examples/simpletest/Makefile
@@ -0,0 +1,105 @@
+####
+#### Generic Makefile for C or C++ projects
+####
+#### This file is public domain.
+#### Jamie Bullock 2014 <jamie@jamiebullock.com>
+####
+
+###################################
+### 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)
diff --git a/Make.config b/src/Make.config
index 036344a..036344a 100644
--- a/Make.config
+++ b/src/Make.config
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..f120975
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,105 @@
+####
+#### Generic Makefile for C or C++ projects
+####
+#### This file is public domain.
+#### Jamie Bullock 2014 <jamie@jamiebullock.com>
+####
+
+###################################
+### 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)