TARGET = Cidw-mips OBJ_PATH = $(shell pwd)/debug PREFIX_BIN = CC = g++ STRIP = strip INCLUDES = -I../cidw_lib \ -I../cidw_lib/ibtdms-gpl-0.3/include \ -I../cidw_lib/include \ -I../third_party/boost/include \ -I../third_party/fftw/include \ -I../third_party/curl/include \ -I../third_party/Jsoncpp/include \ -I/usr/include/python2.7 LIBS = -L../cidw_lib/mips \ -L/usr/lib/python2.7 \ -L../third_party/boost/lib \ -L../third_party/fftw/lib \ -L../third_party/curl/lib \ -L../third_party/ssl/lib \ -L../third_party/Jsoncpp/libs \ -L../third_party/mqtt/lib \ -lpython2.7 -lsqlite3 -lboost_system -lpthread -lboost_thread -lboost_date_time -lboost_atomic -lfftw3 -lssl -lcrypto -lcurl -ljson -lmosquitto CFLAGS = -O2 #-Wall -Werror LINKFLAGS = AllDirs :=$(shell ls -R | grep '^\./.*:' | awk '{if( \ substr($$1,3,5) != "debug") {gsub(":",""); print}}') . Sources := $(foreach n,$(AllDirs) , $(wildcard $(n)/*.cpp)) #C_SOURCES = $(wildcard *.c) C_SRCDIR = $(AllDirs) C_SOURCES = $(foreach d,$(C_SRCDIR),$(wildcard $(d)/*.c) ) C_OBJS = $(patsubst %.c, $(OBJ_PATH)/%.o, $(C_SOURCES)) #CPP_SOURCES = $(wildcard *.cpp) CPP_SRCDIR = $(AllDirs) CPP_SOURCES = $(foreach d,$(CPP_SRCDIR),$(wildcard $(d)/*.cpp) ) CPP_OBJS = $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(CPP_SOURCES)) default:init compile strip $(C_OBJS):$(OBJ_PATH)/%.o:%.c $(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@ $(CPP_OBJS):$(OBJ_PATH)/%.o:%.cpp $(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@ init: $(foreach d,$(AllDirs), mkdir -p $(OBJ_PATH)/$(d);) test: @echo "C_SOURCES: $(C_SOURCES)" @echo "C_OBJS: $(C_OBJS)" @echo "CPP_SOURCES: $(CPP_SOURCES)" @echo "CPP_OBJS: $(CPP_OBJS)" compile:$(C_OBJS) $(CPP_OBJS) $(CC) -O2 -o $(TARGET) $^ $(LINKFLAGS) $(LIBS) clean: rm -rf $(OBJ_PATH) rm -f $(TARGET) install: $(TARGET) cp $(TARGET) $(PREFIX_BIN) uninstall: rm -f $(PREFIX_BIN)/$(TARGET) strip: $(STRIP) $(TARGET) rebuild: clean compile