linux下用Makfile多目标编译-用作以后提取
最近一直在用Makefile的单目标(单主函数的)编译,总结文档在 linux下用MakeFile编译代码-用作以后提取,但是一直想写一个多目标的,一直去理解kaldi里面的精华,kaldi里面有太多好东西了。发现kaldi是支持多目标编译的,因此直接把kaldi的进行稍微修改和移植一下就能得到可以编译多目标(多个主函数的Makefile模板了).
1 准备一个公共类
//anjos-keba.h
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#ifndef _ANJOS_KEBA_
#define _ANJOS_KEBA_
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <regex>
#include <time.h>
#ifdef _WIN32
#include <ctime>
#include <Windows.h>
#include <cstring>
#include <direct.h>
#include <io.h>
#define ACCESS _access
#define MKDIR(a) _mkdir((a))
#else
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/types.h>
#include <stdarg.h>
#include <sys/stat.h>
#define ACCESS access
#define MKDIR(a) mkdir((a),0755)
#endif
#ifdef _WIN32
int gettimeofday(struct timeval* tp, void* tzp);
#endif
/**
* 返回当前时间,格式为:20200717 10:52:28.302
*/
std::string now2str();
#endif
//anjos-keba.cpp
#include "anjos-keba.h"
#ifdef _WIN32
int gettimeofday(struct timeval* tp, void* tzp) {
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm.tm_isdst = -1;
clock = mktime(&tm);
tp-