From 65300c501c3a057606b641d8898f47b534854e52 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 6 Feb 2014 02:31:46 -0800 Subject: [PATCH] organize files into subdirectories (ugly makefile) --- Makefile | 89 +++++++++++++++----------- README.md | 2 - bin/.gitignore | 2 + crap_delay_test.h => crap/delay_test.h | 3 +- crap_eq.h => crap/eq.h | 2 +- crap_eq_const.h => crap/eq_const.h | 2 +- crap_noise.h => crap/noise.h | 2 +- crap_tube.h => crap/tube.h | 2 +- generate-vst | 15 ----- ladspa.h => include/ladspa.h | 0 param.h => include/param.h | 0 crap_util.h => include/util.h | 2 +- crap_util_def.h => include/util_def.h | 0 template-ladspa.c => template/ladspa.c | 0 template-vst.cpp => template/vst.cpp | 0 bench.c => util/bench.c | 2 +- benchtime => util/benchtime | 0 design.c => util/design.c | 2 +- generate-ladspa => util/generate | 3 +- 19 files changed, 65 insertions(+), 63 deletions(-) create mode 100644 bin/.gitignore rename crap_delay_test.h => crap/delay_test.h (98%) rename crap_eq.h => crap/eq.h (99%) rename crap_eq_const.h => crap/eq_const.h (98%) rename crap_noise.h => crap/noise.h (97%) rename crap_tube.h => crap/tube.h (99%) delete mode 100755 generate-vst rename ladspa.h => include/ladspa.h (100%) rename param.h => include/param.h (100%) rename crap_util.h => include/util.h (97%) rename crap_util_def.h => include/util_def.h (100%) rename template-ladspa.c => template/ladspa.c (100%) rename template-vst.cpp => template/vst.cpp (100%) rename bench.c => util/bench.c (98%) rename benchtime => util/benchtime (100%) rename design.c => util/design.c (96%) rename generate-ladspa => util/generate (78%) diff --git a/Makefile b/Makefile index 7355136..c7768d1 100755 --- a/Makefile +++ b/Makefile @@ -5,33 +5,44 @@ DISTNAME = crap VERSION = git FULLNAME = ${DISTNAME}-${VERSION} -BOTH = crap_eq crap_eq_const crap_noise crap_tube +BIN=./bin +CRAP=./crap +INCLUDE=./include +TEMPLATE=./template +UTIL=./util + +BOTH = eq eq_const noise tube LADSPA_ONLY = -VST_ONLY = crap_delay_test +VST_ONLY = delay_test LADSPA = ${BOTH:=-ladspa} ${LADSPA_ONLY:=-ladspa} VST = ${BOTH:=-vst} ${VST_ONLY:=-vst} PLUGINS = ${LADSPA} ${VST} EXE = design -HEADERS = crap_util.h crap_util_def.h param.h -SHOBJ = ${PLUGINS:=.so} -OBJ = ${PLUGINS:=.o} vstsdk.o +_ = util util_def param +HEADERS = ${_:%=$(INCLUDE)/%.h} +SHOBJ = ${PLUGINS:%=$(BIN)/$(DISTNAME)_%.so} +OBJ = ${PLUGINS:%=$(BIN)/$(DISTNAME)_%.o} $(BIN)/vstsdk.o # only for dist target right now -SRC = ${BOTH:=.h} ${LADSPA_ONLY:=.h} ${VST_ONLY:=.h} ${EXE:=.c} +SRC = ${BOTH:%=$(CRAP)/%.h} +SRC += ${LADSPA_ONLY:%=$(CRAP)/%.h} ${VST_ONLY:%=$(CRAP)/%.h} +SRC += ${EXE:%=$(UTIL)/%.c} BENCH = bench.o AGAINST = ./crap_eq_const-ladspa.so VST_SDK_DIR ?= . VST_CPP = audioeffect.cpp audioeffectx.cpp vstplugmain.cpp -VST_SRC = ${VST_CPP:%=${VST_SDK_DIR}/public.sdk/source/vst2.x/%} +VST_SUB_DIR = public.sdk/source/vst2.x +VST_SRC = ${VST_CPP:%=${VST_SDK_DIR}/${VST_SUB_DIR}/%} # temp objects before combining to vstsdk.o -VST_OBJ = ${VST_CPP:.cpp=.o} +VST_OBJ = ${VST_CPP:%.cpp=$(BIN)/%.o} VST_DEF = ${VST_SDK_DIR}/public.sdk/samples/vst2.x/win/vstplug.def -ALL_CFLAGS = -Wall -Wno-unused-function ${CFLAGS} -std=gnu99 -ALL_CXXFLAGS = -Wno-write-strings ${CXXFLAGS} -I ${VST_SDK_DIR} -DBUILDING_DLL=1 +ALL_CFLAGS = -Wall -Wno-unused-function ${CFLAGS} -std=gnu99 -I $(INCLUDE) +ALL_CXXFLAGS = -Wno-write-strings ${CXXFLAGS} -I ${VST_SDK_DIR} +ALL_CXXFLAGS += -I $(INCLUDE) -DBUILDING_DLL=1 ALL_LDFLAGS = -lm ${LDFLAGS} PREFIX ?= /usr/local @@ -41,14 +52,14 @@ LADSPADIR ?= ${LIBDIR}/ladspa LADSPADEST = ${DESTDIR}${LADSPADIR} -ALL = ${SHOBJ} ${OBJ} ${EXE} +ALL = ${SHOBJ} ${OBJ} ${EXE:%=$(BIN)/%} MISC_CLEAN = bench ${BENCH} ${VST_OBJ} MISC_DIST = LICENSE README.md Makefile -MISC_DIST += benchtime ${BENCH:.o=.c} -MISC_DIST += generate-ladspa generate-vst -MISC_DIST += template-vst.cpp template-ladspa.c ladspa.h +MISC_DIST += $(UTIL)/benchtime $(UTIL)/${BENCH:.o=.c} +MISC_DIST += $(UTIL)/generate +MISC_DIST += $(TEMPLATE)/vst.cpp $(TEMPLATE)/ladspa.c $(INCLUDE)/ladspa.h -all: options ladspa vst ${EXE} +all: ladspa vst ${EXE:%=$(BIN)/%} .PHONY: options options: @@ -61,61 +72,63 @@ options: @echo "LD = ${LD}" @echo -ladspa: ${LADSPA:=.so} +ladspa: ${LADSPA:%=$(BIN)/$(DISTNAME)_%.so} -vst: ${VST:=.so} +vst: ${VST:%=$(BIN)/$(DISTNAME)_%.so} -bench: ${AGAINST} ${BENCH} +$(BIN)/bench: ${BENCH} @echo ' CC '$@ @${CC} ${ALL_CFLAGS} ${BENCH} -o $@ ${ALL_LDFLAGS} -rdynamic -ldl .PHONY: benchmark -benchmark: bench +benchmark: $(BIN)/bench ${AGAINST} ./benchtime ./bench ${AGAINST} -vstsdk.o: ${VST_SRC} +$(VST_OBJ): ${VST_SRC} @echo ' CXX '$@ - @${CXX} -c ${ALL_CXXFLAGS} ${CPPFLAGS} $^ + @${CXX} -c ${ALL_CXXFLAGS} ${CPPFLAGS} ${VST_SDK_DIR}/${VST_SUB_DIR}/$(notdir ${@:.o=.cpp}) -o $@ + +$(BIN)/vstsdk.o: ${VST_OBJ} @echo ' LD '$@ @${LD} -r ${VST_OBJ} -o $@ - rm ${VST_OBJ} -%-ladspa.so: %-ladspa.o - @echo ' CC '$@ +$(BIN)/%-ladspa.so: $(BIN)/%-ladspa.o + @echo ' LD '$@ @${CC} ${ALL_CFLAGS} -shared $^ -o $@ ${ALL_LDFLAGS} -%-vst.so: %-vst.o vstsdk.o - @echo ' CXX '$@ +$(BIN)/%-vst.so: $(BIN)/%-vst.o $(BIN)/vstsdk.o + @echo ' LD '$@ @${CXX} ${ALL_CXXFLAGS} -shared $^ -o $@ ${ALL_LDFLAGS} -%-ladspa.o: %-ladspa.c ${HEADERS} ladspa.h +$(BIN)/$(DISTNAME)_%-ladspa.o: $(CRAP)/%-ladspa.c ${HEADERS} $(INCLUDE)/ladspa.h @echo ' CC '$@ @${CC} -c ${ALL_CFLAGS} ${CPPFLAGS} $< -o $@ -%-vst.o: %-vst.cpp ${HEADERS} +$(BIN)/$(DISTNAME)_%-vst.o: $(CRAP)/%-vst.cpp ${HEADERS} @echo ' CXX '$@ @${CXX} -c ${ALL_CXXFLAGS} ${CPPFLAGS} $< -o $@ -%-ladspa.c: %.h template-ladspa.c generate-ladspa - ./generate-ladspa $< $@ +$(CRAP)/%-ladspa.c: $(CRAP)/%.h $(TEMPLATE)/ladspa.c $(UTIL)/generate + @echo ' gen '$@ + @$(UTIL)/generate $(notdir $<) $@ $(TEMPLATE)/ladspa.c -%-vst.cpp: %.h template-vst.cpp generate-vst - ./generate-vst $< $@ +$(CRAP)/%-vst.cpp: $(CRAP)/%.h $(TEMPLATE)/vst.cpp $(UTIL)/generate + @$(UTIL)/generate $(notdir $<) $@ $(TEMPLATE)/vst.cpp .SUFFIXES: -%: %.o +$(BIN)/%: $(BIN)/%.o @echo ' CC '$@ @${CC} ${ALL_CFLAGS} $< -o $@ ${ALL_LDFLAGS} -%.o: %.c +$(BIN)/%.o: $(UTIL)/%.c @echo ' CC '$@ @${CC} -c ${ALL_CFLAGS} ${CPPFLAGS} $< -o $@ install: all mkdir -p ${LADSPADEST} install -d ${LADSPADEST} - install -m 644 ${LADSPA:=.so} ${LADSPADEST} + install -m 644 $(BIN)/${LADSPA:=.so} ${LADSPADEST} .PHONY: clean clean: @@ -123,9 +136,13 @@ clean: .PHONY: dist dist: + @echo " dist target is broken for now, sorry" + @false -rm -f ${FULLNAME}.tar.gz mkdir ${FULLNAME} - cp ${MISC_DIST} ${HEADERS} ${SRC} ${FULLNAME} + cp ${MISC_DIST} ${FULLNAME} + cp ${HEADERS} ${FULLNAME} + cp ${SRC} ${FULLNAME} tar -cf ${FULLNAME}.tar ${FULLNAME} gzip ${FULLNAME}.tar rm -r ${FULLNAME} diff --git a/README.md b/README.md index f726b49..088f836 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,6 @@ remember to export `VST_SDK_DIR` to the path of your `vstsdk2.4/` ## TODO * rename plugins (fix capitalization consistency and such) -* remove crap\_ prefixes? -* move to subdirs? * reduce input/output buffers on biquads (shared) * ease up on the preprocessor ifs * polish parameter support diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/crap_delay_test.h b/crap/delay_test.h similarity index 98% rename from crap_delay_test.h rename to crap/delay_test.h index 4971172..f7cf78b 100644 --- a/crap_delay_test.h +++ b/crap/delay_test.h @@ -1,5 +1,4 @@ -#define BIQUAD_DOUBLE -#include "crap_util.h" +#include "util.h" typedef unsigned long ulong; diff --git a/crap_eq.h b/crap/eq.h similarity index 99% rename from crap_eq.h rename to crap/eq.h index afe0a46..2d33491 100644 --- a/crap_eq.h +++ b/crap/eq.h @@ -1,7 +1,7 @@ #include #include -#include "crap_util.h" +#include "util.h" #include "param.h" #define BANDS 4 diff --git a/crap_eq_const.h b/crap/eq_const.h similarity index 98% rename from crap_eq_const.h rename to crap/eq_const.h index 4b18a5a..87d9e53 100644 --- a/crap_eq_const.h +++ b/crap/eq_const.h @@ -1,6 +1,6 @@ #include -#include "crap_util.h" +#include "util.h" #define ID 0x0DEFACED #define LABEL "crap_eq_const" diff --git a/crap_noise.h b/crap/noise.h similarity index 97% rename from crap_noise.h rename to crap/noise.h index 1219613..7bcc6ab 100644 --- a/crap_noise.h +++ b/crap/noise.h @@ -1,4 +1,4 @@ -#include "crap_util.h" +#include "util.h" #define ID 0xEC57A71C #define LABEL "crap_noise" diff --git a/crap_tube.h b/crap/tube.h similarity index 99% rename from crap_tube.h rename to crap/tube.h index 6f030f7..17264a4 100644 --- a/crap_tube.h +++ b/crap/tube.h @@ -1,6 +1,6 @@ #include -#include "crap_util.h" +#include "util.h" #define ID 0x50F7BA11 #define LABEL "crap_tube" diff --git a/generate-vst b/generate-vst deleted file mode 100755 index 6a35d98..0000000 --- a/generate-vst +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -set -e -set -u - -pp_include="#include \"$1\"" -out="$2" - -(cat template-vst.cpp | while read -r; do - case "$REPLY" in - - '//#INCLUDE') echo "$pp_include" ;; - - *) echo -E "$REPLY" ;; - esac -done) > "$out" diff --git a/ladspa.h b/include/ladspa.h similarity index 100% rename from ladspa.h rename to include/ladspa.h diff --git a/param.h b/include/param.h similarity index 100% rename from param.h rename to include/param.h diff --git a/crap_util.h b/include/util.h similarity index 97% rename from crap_util.h rename to include/util.h index 037b976..bee8efc 100644 --- a/crap_util.h +++ b/include/util.h @@ -58,4 +58,4 @@ design(double cw, double sw, static double biquad_run(biquad *bq, double x); -#include "crap_util_def.h" +#include "util_def.h" diff --git a/crap_util_def.h b/include/util_def.h similarity index 100% rename from crap_util_def.h rename to include/util_def.h diff --git a/template-ladspa.c b/template/ladspa.c similarity index 100% rename from template-ladspa.c rename to template/ladspa.c diff --git a/template-vst.cpp b/template/vst.cpp similarity index 100% rename from template-vst.cpp rename to template/vst.cpp diff --git a/bench.c b/util/bench.c similarity index 98% rename from bench.c rename to util/bench.c index afd6c44..6f303b3 100644 --- a/bench.c +++ b/util/bench.c @@ -5,7 +5,7 @@ #include "dlfcn.h" #include "ladspa.h" -#include "crap_util.h" +#include "util.h" enum { BLOCK_SIZE=2048 diff --git a/benchtime b/util/benchtime similarity index 100% rename from benchtime rename to util/benchtime diff --git a/design.c b/util/design.c similarity index 96% rename from design.c rename to util/design.c index 22f1d2c..e941963 100644 --- a/design.c +++ b/util/design.c @@ -3,7 +3,7 @@ #include #include -#include "crap_util.h" +#include "util.h" void usage() diff --git a/generate-ladspa b/util/generate similarity index 78% rename from generate-ladspa rename to util/generate index 6b20dc9..e939b62 100755 --- a/generate-ladspa +++ b/util/generate @@ -4,8 +4,9 @@ set -u pp_include="#include \"$1\"" out="$2" +template="$3" -(cat template-ladspa.c | while read -r; do +(cat "$template" | while read -r; do case "$REPLY" in '//#INCLUDE') echo "$pp_include" ;;