#* #*********************************************************************************************** # Makefile # # Author : Lyu Yang # Description : M
#* #*********************************************************************************************** # Makefile # # Author : Lyu Yang # Description : Makefile for GNU/GCC # #*********************************************************************************************** #* # Project Name PROJECT = main # Architecture and Platform ARCH = x86 PLATFORM = Debug CROSS = # Include Dirs and Library Dirs INCLUDE_DIRS = -I ./ LIBRARY_DIRS = -L ./ # GCC Parameters CC = $(CROSS)gcc CFLAGS = -c $(INCLUDE_DIRS) CXX = $(CROSS)g++ CXXFLAGS = -c $(INCLUDE_DIRS) AS = $(CROSS)gcc ASFLAGS = -x assembler-with-cpp LD = $(CROSS)g++ LDFLAGS = $(LIBRARY_DIRS) OBJCP = $(CROSS)objcopy OBJCPFLAGS = -O binary -S -R .note -R .commen AR = $(CROSS)ar ARFLAGS = cr DUMP = $(CROSS)objdump DUMPFLAG = -d SIZE = $(CROSS)size # Make Temp Dirs $(shell mkdir $(PLATFORM) && mkdir $(PLATFORM)/$(ARCH)) # Source Files SRCS := $(wildcard dir1/*.cpp) SRCS += $(wildcard dir2/*.cpp) # Build Objects OBJS = $(SRCS:.cpp=.o) OBJB = $(patsubst %.cpp, $(PLATFORM)/$(ARCH)/%.o, $(notdir ${SRCS})) # Make ALL .PHONY: all clean debug all: $(PROJECT).exe $(PROJECT).exe: $(OBJB) @$(LD) $(LDFLAGS) $^ -o $(PLATFORM)/$(ARCH)/$@ @echo "$(CXX) $(notdir $^) -o $(notdir $@)" $(OBJB): $(OBJS) %.o: %.cpp @$(CXX) $(CFLAGS) $^ -o $(PLATFORM)/$(ARCH)/$(notdir $@) @echo "$(CXX) $(notdir $^) -o $(notdir $@)" clean: @rm -rf $(PLATFORM) @echo "Clean All!" debug: @$(CROSS)gdb $(PLATFORM)/$(ARCH)/$(PROJECT).exe