changeset 252:fbdb69cb1b53

Add examples to new build system
author Jamie Bullock <jamie@jamiebullock.com>
date Fri, 07 Nov 2014 12:45:35 +0000
parents bc1fc8985170
children 17531082a918
files Make.config Makefile examples/Make.config examples/Makefile examples/simpletest/Make.config examples/simpletest/Makefile src/Make.config src/Makefile
diffstat 8 files changed, 243 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/Make.config	Thu Nov 06 17:29:37 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-NAME := xtract
-DIRS := src src/c-ringbuf src/ooura src/dywapitchtrack
-
-ifeq ($(PLATFORM), Darwin)
-    LDFLAGS = -framework Accelerate
-endif
--- a/Makefile	Thu Nov 06 17:29:37 2014 +0000
+++ b/Makefile	Fri Nov 07 12:45:35 2014 +0000
@@ -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
--- a/examples/Make.config	Thu Nov 06 17:29:37 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-DIRS := simpletest
-LIBRARY := 
-SUFFIX := .cpp
-FLAGS += -I../
-LDFLAGS = -lxtract -L..
--- a/examples/Makefile	Thu Nov 06 17:29:37 2014 +0000
+++ b/examples/Makefile	Fri Nov 07 12:45:35 2014 +0000
@@ -1,1 +1,8 @@
-../Makefile
\ No newline at end of file
+
+.PHONY: simpletest clean
+
+simpletest:
+	@$(MAKE) -C $@
+
+clean:
+	@$(MAKE) -C simpletest clean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/simpletest/Make.config	Fri Nov 07 12:45:35 2014 +0000
@@ -0,0 +1,9 @@
+
+ifeq ($(PLATFORM), Darwin)
+    DARWIN_LDFLAGS = -framework Accelerate
+endif
+
+LIBRARY := 
+SUFFIX := .cpp
+FLAGS += -I../../
+LDFLAGS = -lxtract -L../../src $(DARWIN_LDFLAGS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/simpletest/Makefile	Fri Nov 07 12:45:35 2014 +0000
@@ -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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Make.config	Fri Nov 07 12:45:35 2014 +0000
@@ -0,0 +1,6 @@
+NAME := xtract
+DIRS := src src/c-ringbuf src/ooura src/dywapitchtrack
+
+ifeq ($(PLATFORM), Darwin)
+    LDFLAGS = -framework Accelerate
+endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Makefile	Fri Nov 07 12:45:35 2014 +0000
@@ -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)