summaryrefslogtreecommitdiff
path: root/src/Makefile
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2014-04-14 08:14:45 +0800
committerJoe Zhao <ztuowen@gmail.com>2014-04-14 08:14:45 +0800
commitcccccbf6cca94a3eaf813b4468453160e91c332b (patch)
tree23418cb73a10ae3b0688681a7f0ba9b06424583e /src/Makefile
downloadtnet-cccccbf6cca94a3eaf813b4468453160e91c332b.tar.gz
tnet-cccccbf6cca94a3eaf813b4468453160e91c332b.tar.bz2
tnet-cccccbf6cca94a3eaf813b4468453160e91c332b.zip
First commit
Diffstat (limited to 'src/Makefile')
-rw-r--r--src/Makefile162
1 files changed, 162 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..eb071fb
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,162 @@
+
+include tnet.mk
+
+##### Check that CUDA Toolkit directory was set
+ifneq ($(HAVE_CUDA), true)
+ $(warning %%% WARNING!!!)
+ $(warning %%% CUDA not found! Incorrect path in CUDA_TK_BASE: $(CUDA_TK_BASE))
+ $(warning %%% Try setting CUDA_TK_BASE in 'trunk/src/tnet.mk')
+ $(warning %%% WARNING!!!)
+else
+ #$(warning %%% INFO: Using CUDA from CUDA_TK_BASE: $(CUDA_TK_BASE))
+endif
+
+
+##### Includes
+INCLUDE := -IKaldiLib -ITNetLib -ISTKLib
+INCLUDE += -ICuBaseLib -ICuTNetLib
+INCLUDE += -I$(CUDA_TK_BASE)/include
+
+CXXFLAGS += $(INCLUDE)
+
+##### CPU implementation libs
+LDFLAGS := -LTNetLib -lTNetLib
+LDFLAGS += -LKaldiLib -lKaldiLib
+LDFLAGS += -pthread
+
+##### Link with GotoBLAS
+ifeq ($(BITS64), true)
+ LDFLAGS += -LGotoBLASLib -lgoto2_64 -lgfortran
+else
+ LDFLAGS += -LGotoBLASLib -lgoto2 -lgfortran
+endif
+LDFLAGS += -Wl,-rpath,$(PWD)/GotoBLASLib
+
+##### CUDA implementation libs
+ifeq ($(CUDA), true)
+ #TNet libs
+ LDFLAGS_CUDA := -LCuTNetLib -lCuTNet
+ LDFLAGS_CUDA += -LCuBaseLib -lCuBase
+ #CUDA toolkit libs
+ ifeq ($(BITS64), true)
+ LDFLAGS_CUDA += -L$(CUDA_TK_BASE)/lib64 -Wl,-rpath,$(CUDA_TK_BASE)/lib64
+ else
+ LDFLAGS_CUDA += -L$(CUDA_TK_BASE)/lib -Wl,-rpath,$(CUDA_TK_BASE)/lib
+ endif
+ LDFLAGS_CUDA += -lcublas -lcudart -lcuda
+endif
+
+
+##############################################################
+# Target programs
+##############################################################
+
+#CPU tools
+BINS := TNet TNorm TFeaCat TSegmenter TJoiner
+all : $(BINS)
+$(BINS): lib
+
+#GPU tools
+CUBINS := TNetCu TNormCu TFeaCatCu TRbmCu TRecurrentCu
+ifeq ($(STK), true)
+ CUBINS += TMpeCu TMmiCu
+endif
+ifeq ($(CUDA), true)
+cubins : $(CUBINS)
+##HINT: Link CUDA libs only with CUDA tools!!!##
+##(recursive target-specific variable value)##
+cubins : LDFLAGS += $(LDFLAGS_CUDA)
+##
+all : cubins
+$(CUBINS): lib culib
+endif
+
+
+##############################################################
+# program compliling implicit rule
+##############################################################
+% : %.o
+ $(CXX) -o $@ $< $(CXXFLAGS) $(INCLUDE) $(LDFLAGS)
+
+
+##############################################################
+# module compliling implicit rule
+##############################################################
+%.o : %.cc lib
+ $(CXX) -o $@ -c $< $(CFLAGS) $(CXXFLAGS) $(INCLUDE)
+
+
+##############################################################
+# STK specific rules
+##############################################################
+#TMpeCu depends on STK
+TMpeCu.o: stklib
+TMpeCu: LDFLAGS := -LSTKLib -lSTKLib $(LDFLAGS) $(LDFLAGS_CUDA)
+#TMmiCu depends on STK
+TMmiCu.o: stklib
+TMmiCu: LDFLAGS := -LSTKLib -lSTKLib $(LDFLAGS) $(LDFLAGS_CUDA)
+
+
+##############################################################
+# Source files for CPU/GPU tools
+##############################################################
+CC_BINS=$(addsuffix .cc, $(BINS))
+CC_CUBINS=$(addsuffix .cc, $(CUBINS))
+
+O_BINS=$(addsuffix .o, $(BINS))
+O_CUBINS=$(addsuffix .o, $(CUBINS))
+
+$(O_BINS) : $(CC_BINS)
+$(O_CUBINS) : $(CC_CUBINS)
+
+$(BINS) : $(O_BINS)
+$(CUBINS) : $(O_CUBINS)
+
+##############################################################
+.PHONY: lib culib stklib clean doc depend
+
+lib:
+ @cd KaldiLib && make $(FWDPARAM)
+ @cd TNetLib && make $(FWDPARAM)
+
+culib:
+ @cd CuBaseLib && make $(FWDPARAM)
+ @cd CuTNetLib && make $(FWDPARAM)
+
+stklib:
+ @cd STKLib && make $(FWDPARAM)
+
+clean:
+ rm -f *.o $(BINS) $(CUBINS)
+ @cd STKLib && make clean
+ @cd KaldiLib && make clean
+ @cd TNetLib && make clean
+ @cd CuBaseLib && make clean
+ @cd CuTNetLib && make clean
+
+doc:
+ doxygen ../doc/doxyfile_TNet
+
+depend:
+ $(CXX) -M $(CXXFLAGS) $(CC_BINS) $(INCLUDE) > .depend.mk1
+ @cd KaldiLib && make depend
+ @cd TNetLib && make depend
+ touch .depend.mk{1,2}
+ cat .depend.mk{1,2} > .depend.mk
+ rm .depend.mk{1,2}
+
+cudepend:
+ $(CXX) -M $(CXXFLAGS) $(CC_CUBINS) $(INCLUDE) > .depend.mk2
+ @cd CuBaseLib && make depend
+ @cd CuTNetLib && make depend
+ifeq ($(HAVE_CUDA), true)
+depend: cudepend
+endif
+ifeq ($(STK), true)
+cudepend: stklib
+endif
+
+
+-include .depend.mk
+
+