linux gcc 万能makefile的收集
2017-07-03 08:53
591 查看
1. mbcrawfo/GenericMakefile
makefile的github的地址是https://github.com/mbcrawfo/GenericMakefile1.1 c
#### PROJECT SETTINGS #### # The name of the executable to be created BIN_NAME := hello # Compiler used CC ?= gcc # Extension of source files used in the project SRC_EXT = c # Path to the source directory, relative to the makefile SRC_PATH = . # Space-separated pkg-config libraries used by this project LIBS = # General compiler flags COMPILE_FLAGS = -std=c99 -Wall -Wextra -g # Additional release-specific flags RCOMPILE_FLAGS = -D NDEBUG # Additional debug-specific flags DCOMPILE_FLAGS = -D DEBUG # Add additional include paths INCLUDES = -I $(SRC_PATH) # General linker settings LINK_FLAGS = # Additional release-specific linker settings RLINK_FLAGS = # Additional debug-specific linker settings DLINK_FLAGS = # Destination directory, like a jail or mounted system DESTDIR = / # Install path (bin/ is appended automatically) INSTALL_PREFIX = usr/local #### END PROJECT SETTINGS #### # Optionally you may move the section above to a separate config.mk file, and # uncomment the line below # include config.mk # Generally should not need to edit below this line # Obtains the OS type, either 'Darwin' (OS X) or 'Linux' UNAME_S:=$(shell uname -s) # Function used to check variables. Use on the command line: # make print-VARNAME # Useful for debugging and adding features print-%: ; @echo $*=$($*) # Shell used in this makefile # bash is used for 'echo -en' SHELL = /bin/bash # Clear built-in rules .SUFFIXES: # Programs for installation INSTALL = install INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) -m 644 # Append pkg-config specific libraries if need be ifneq ($(LIBS),) COMPILE_FLAGS += $(shell pkg-config --cflags $(LIBS)) LINK_FLAGS += $(shell pkg-config --libs $(LIBS)) endif # Verbose option, to output compile and link commands export V := false export CMD_PREFIX := @ ifeq ($(V),true) CMD_PREFIX := endif # Combine compiler and linker flags release: export CFLAGS := $(CFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS) release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) debug: export CFLAGS := $(CFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) # Build and output paths release: export BUILD_PATH := build/release release: export BIN_PATH := bin/release debug: export BUILD_PATH := build/debug debug: export BIN_PATH := bin/debug install: export BIN_PATH := bin/release # Find all source files in the source directory, sorted by most # recently modified ifeq ($(UNAME_S),Darwin) SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' | sort -k 1nr | cut -f2-) else SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' -printf '%T@\t%p\n' \ | sort -k 1nr | cut -f2-) endif # fallback in case the above fails rwildcard = $(foreach d, $(wildcard $1*), $(call rwildcard,$d/,$2) \ $(filter $(subst *,%,$2), $d)) ifeq ($(SOURCES),) SOURCES := $(call rwildcard, $(SRC_PATH), *.$(SRC_EXT)) endif # Set the object file names, with the source directory stripped # from the path, and the build path prepended in its place OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o) # Set the dependency files that will be used to add header dependencies DEPS = $(OBJECTS:.o=.d) # Macros for timing compilation ifeq ($(UNAME_S),Darwin) CUR_TIME = awk 'BEGIN{srand(); print srand()}' TIME_FILE = $(dir $@).$(notdir $@)_time START_TIME = $(CUR_TIME) > $(TIME_FILE) END_TIME = read st < $(TIME_FILE) ; \ $(RM) $(TIME_FILE) ; \ st=$$((`$(CUR_TIME)` - $$st)) ; \ echo $$st else TIME_FILE = $(dir $@).$(notdir $@)_time START_TIME = date '+%s' > $(TIME_FILE) END_TIME = read st < $(TIME_FILE) ; \ $(RM) $(TIME_FILE) ; \ st=$$((`date '+%s'` - $$st - 86400)) ; \ echo `date -u -d @$$st '+%H:%M:%S'` endif # Version macros # Comment/remove this section to remove versioning USE_VERSION := false # If this isn't a git repo or the repo has no tags, git describe will return non-zero ifeq ($(shell git describe > /dev/null 2>&1 ; echo $$?), 0) USE_VERSION := true VERSION := $(shell git describe --tags --long --dirty --always | \ sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)-\?.*-\([0-9]*\)-\(.*\)/\1 \2 \3 \4 \5/g') VERSION_MAJOR := $(word 1, $(VERSION)) VERSION_MINOR := $(word 2, $(VERSION)) VERSION_PATCH := $(word 3, $(VERSION)) VERSION_REVISION := $(word 4, $(VERSION)) VERSION_HASH := $(word 5, $(VERSION)) VERSION_STRING := \ "$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH).$(VERSION_REVISION)-$(VERSION_HASH)" override CFLAGS := $(CFLAGS) \ -D VERSION_MAJOR=$(VERSION_MAJOR) \ -D VERSION_MINOR=$(VERSION_MINOR) \ -D VERSION_PATCH=$(VERSION_PATCH) \ -D VERSION_REVISION=$(VERSION_REVISION) \ -D VERSION_HASH=\"$(VERSION_HASH)\" endif # Standard, non-optimized release build .PHONY: release release: dirs ifeq ($(USE_VERSION), true) @echo "Beginning release build v$(VERSION_STRING)" else @echo "Beginning release build" endif @$(START_TIME) @$(MAKE) all --no-print-directory @echo -n "Total build time: " @$(END_TIME) # Debug build for gdb debugging .PHONY: debug debug: dirs ifeq ($(USE_VERSION), true) @echo "Beginning debug buil dac4 d v$(VERSION_STRING)" else @echo "Beginning debug build" endif @$(START_TIME) @$(MAKE) all --no-print-directory @echo -n "Total build time: " @$(END_TIME) # Create the directories used in the build .PHONY: dirs dirs: @echo "Creating directories" @mkdir -p $(dir $(OBJECTS)) @mkdir -p $(BIN_PATH) # Installs to the set path .PHONY: install install: @echo "Installing to $(DESTDIR)$(INSTALL_PREFIX)/bin" @$(INSTALL_PROGRAM) $(BIN_PATH)/$(BIN_NAME) $(DESTDIR)$(INSTALL_PREFIX)/bin # Uninstalls the program .PHONY: uninstall uninstall: @echo "Removing $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BIN_NAME)" @$(RM) $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BIN_NAME) # Removes all build files .PHONY: clean clean: @echo "Deleting $(BIN_NAME) symlink" @$(RM) $(BIN_NAME) @echo "Deleting directories" @$(RM) -r build @$(RM) -r bin # Main rule, checks the executable and symlinks to the output all: $(BIN_PATH)/$(BIN_NAME) @echo "Making symlink: $(BIN_NAME) -> $<" @$(RM) $(BIN_NAME) @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME) # Link the executable $(BIN_PATH)/$(BIN_NAME): $(OBJECTS) @echo "Linking: $@" @$(START_TIME) $(CMD_PREFIX)$(CC) $(OBJECTS) $(LDFLAGS) -o $@ @echo -en "\t Link time: " @$(END_TIME) # Add dependency files, if they exist -include $(DEPS) # Source file rules # After the first compilation they will be joined with the rules from the # dependency files to provide header dependencies $(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT) @echo "Compiling: $< -> $@" @$(START_TIME) $(CMD_PREFIX)$(CC) $(CFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@ @echo -en "\t Compile time: " @$(END_TIME)
1.2 cpp
#### PROJECT SETTINGS #### # The name of the executable to be created BIN_NAME := hello # Compiler used CXX ?= g++ # Extension of source files used in the project SRC_EXT = cpp # Path to the source directory, relative to the makefile SRC_PATH = . # Space-separated pkg-config libraries used by this project LIBS = # General compiler flags COMPILE_FLAGS = -std=c++11 -Wall -Wextra -g # Additional release-specific flags RCOMPILE_FLAGS = -D NDEBUG # Additional debug-specific flags DCOMPILE_FLAGS = -D DEBUG # Add additional include paths INCLUDES = -I $(SRC_PATH) # General linker settings LINK_FLAGS = # Additional release-specific linker settings RLINK_FLAGS = # Additional debug-specific linker settings DLINK_FLAGS = # Destination directory, like a jail or mounted system DESTDIR = / # Install path (bin/ is appended automatically) INSTALL_PREFIX = usr/local #### END PROJECT SETTINGS #### # Optionally you may move the section above to a separate config.mk file, and # uncomment the line below # include config.mk # Generally should not need to edit below this line # Obtains the OS type, either 'Darwin' (OS X) or 'Linux' UNAME_S:=$(shell uname -s) # Function used to check variables. Use on the command line: # make print-VARNAME # Useful for debugging and adding features print-%: ; @echo $*=$($*) # Shell used in this makefile # bash is used for 'echo -en' SHELL = /bin/bash # Clear built-in rules .SUFFIXES: # Programs for installation INSTALL = install INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) -m 644 # Append pkg-config specific libraries if need be ifneq ($(LIBS),) COMPILE_FLAGS += $(shell pkg-config --cflags $(LIBS)) LINK_FLAGS += $(shell pkg-config --libs $(LIBS)) endif # Verbose option, to output compile and link commands export V := false export CMD_PREFIX := @ ifeq ($(V),true) CMD_PREFIX := endif # Combine compiler and linker flags release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS) release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS) debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS) debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS) # Build and output paths release: export BUILD_PATH := build/release release: export BIN_PATH := bin/release debug: export BUILD_PATH := build/debug debug: export BIN_PATH := bin/debug install: export BIN_PATH := bin/release # Find all source files in the source directory, sorted by most # recently modified ifeq ($(UNAME_S),Darwin) SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' | sort -k 1nr | cut -f2-) else SOURCES = $(shell find $(SRC_PATH) -name '*.$(SRC_EXT)' -printf '%T@\t%p\n' \ | sort -k 1nr | cut -f2-) endif # fallback in case the above fails rwildcard = $(foreach d, $(wildcard $1*), $(call rwildcard,$d/,$2) \ $(filter $(subst *,%,$2), $d)) ifeq ($(SOURCES),) SOURCES := $(call rwildcard, $(SRC_PATH), *.$(SRC_EXT)) endif # Set the object file names, with the source directory stripped # from the path, and the build path prepended in its place OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o) # Set the dependency files that will be used to add header dependencies DEPS = $(OBJECTS:.o=.d) # Macros for timing compilation ifeq ($(UNAME_S),Darwin) CUR_TIME = awk 'BEGIN{srand(); print srand()}' TIME_FILE = $(dir $@).$(notdir $@)_time START_TIME = $(CUR_TIME) > $(TIME_FILE) END_TIME = read st < $(TIME_FILE) ; \ $(RM) $(TIME_FILE) ; \ st=$$((`$(CUR_TIME)` - $$st)) ; \ echo $$st else TIME_FILE = $(dir $@).$(notdir $@)_time START_TIME = date '+%s' > $(TIME_FILE) END_TIME = read st < $(TIME_FILE) ; \ $(RM) $(TIME_FILE) ; \ st=$$((`date '+%s'` - $$st - 86400)) ; \ echo `date -u -d @$$st '+%H:%M:%S'` endif # Version macros # Comment/remove this section to remove versioning USE_VERSION := false # If this isn't a git repo or the repo has no tags, git describe will return non-zero ifeq ($(shell git describe > /dev/null 2>&1 ; echo $$?), 0) USE_VERSION := true VERSION := $(shell git describe --tags --long --dirty --always | \ sed 's/v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)-\?.*-\([0-9]*\)-\(.*\)/\1 \2 \3 \4 \5/g') VERSION_MAJOR := $(word 1, $(VERSION)) VERSION_MINOR := $(word 2, $(VERSION)) VERSION_PATCH := $(word 3, $(VERSION)) VERSION_REVISION := $(word 4, $(VERSION)) VERSION_HASH := $(word 5, $(VERSION)) VERSION_STRING := \ "$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH).$(VERSION_REVISION)-$(VERSION_HASH)" override CXXFLAGS := $(CXXFLAGS) \ -D VERSION_MAJOR=$(VERSION_MAJOR) \ -D VERSION_MINOR=$(VERSION_MINOR) \ -D VERSION_PATCH=$(VERSION_PATCH) \ -D VERSION_REVISION=$(VERSION_REVISION) \ -D VERSION_HASH=\"$(VERSION_HASH)\" endif # Standard, non-optimized release build .PHONY: release release: dirs ifeq ($(USE_VERSION), true) @echo "Beginning release build v$(VERSION_STRING)" else @echo "Beginning release build" endif @$(START_TIME) @$(MAKE) all --no-print-directory @echo -n "Total build time: " @$(END_TIME) # Debug build for gdb debugging .PHONY: debug debug: dirs ifeq ($(USE_VERSION), true) @echo "Beginning debug build v$(VERSION_STRING)" else @echo "Beginning debug build" endif @$(START_TIME) @$(MAKE) all --no-print-directory @echo -n "Total build time: " @$(END_TIME) # Create the directories used in the build .PHONY: dirs dirs: @echo "Creating directories" @mkdir -p $(dir $(OBJECTS)) @mkdir -p $(BIN_PATH) # Installs to the set path .PHONY: install install: @echo "Installing to $(DESTDIR)$(INSTALL_PREFIX)/bin" @$(INSTALL_PROGRAM) $(BIN_PATH)/$(BIN_NAME) $(DESTDIR)$(INSTALL_PREFIX)/bin # Uninstalls the program .PHONY: uninstall uninstall: @echo "Removing $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BIN_NAME)" @$(RM) $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BIN_NAME) # Removes all build files .PHONY: clean clean: @echo "Deleting $(BIN_NAME) symlink" @$(RM) $(BIN_NAME) @echo "Deleting directories" @$(RM) -r build @$(RM) -r bin # Main rule, checks the executable and symlinks to the output all: $(BIN_PATH)/$(BIN_NAME) @echo "Making symlink: $(BIN_NAME) -> $<" @$(RM) $(BIN_NAME) @ln -s $(BIN_PATH)/$(BIN_NAME) $(BIN_NAME) # Link the executable $(BIN_PATH)/$(BIN_NAME): $(OBJECTS) @echo "Linking: $@" @$(START_TIME) $(CMD_PREFIX)$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ @echo -en "\t Link time: " @$(END_TIME) # Add dependency files, if they exist -include $(DEPS) # Source file rules # After the first compilation they will be joined with the rules from the # dependency files to provide header dependencies $(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT) @echo "Compiling: $< -> $@" @$(START_TIME) $(CMD_PREFIX)$(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@ @echo -en "\t Compile time: " @$(END_TIME)
2.librakyle/makefile
makefile的github的地址是https://github.com/librakyle/makefile############################################################################# # # Generic Makefile for C/C++ Program # # License: GPL (General Public License) # Author: whyglinux <whyglinux AT gmail DOT com> # Date: 2006/03/04 (version 0.1) # 2007/03/24 (version 0.2) # 2007/04/09 (version 0.3) # 2007/06/26 (version 0.4) # 2008/04/05 (version 0.5) # # Description: # ------------ # This is an easily customizable makefile template. The purpose is to # provide an instant building environment for C/C++ programs. # # It searches all the C/C++ source files in the specified directories, # makes dependencies, compiles and links to form an executable. # # Besides its default ability to build C/C++ programs which use only # standard C/C++ libraries, you can customize the Makefile to build # those using other libraries. Once done, without any changes you can # then build programs using the same or less libraries, even if source # files are renamed, added or removed. Therefore, it is particularly # convenient to use it to build codes for experimental or study use. # # GNU make is expected to use the Makefile. Other versions of makes # may or may not work. # # Usage: # ------ # 1. Copy the Makefile to your program directory. # 2. Customize in the "Customizable Section" only if necessary: # * to use non-standard C/C++ libraries, set pre-processor or compiler # options to <MY_CFLAGS> and linker ones to <MY_LIBS> # (See Makefile.gtk+-2.0 for an example) # * to search sources in more directories, set to <SRCDIRS> # * to specify your favorite program name, set to <PROGRAM> # 3. Type make to start building your program. # # Make Target: # ------------ # The Makefile provides the following targets to make: # $ make compile and link # $ make NODEP=yes compile and link without generating dependencies # $ make objs compile only (no linking) # $ make ctags create ctags for VI editor # $ make clean clean objects, the executable and dependencies # $ make help get the usage of the makefile # #=========================================================================== ## Customizable Section: adapt those variables to suit your program. ##========================================================================== # The pre-processor and compiler options. MY_CFLAGS = `pkg-config --cflags opencv boost` -I$(SRCROOT) # The linker options. MY_LIBS = `pkg-config --libs opencv boost` # The pre-processor options used by the cpp (man cpp for more). CPPFLAGS = -Wall CFLAGS = -g CXXFLAGS= -g # The root of the project. SRCROOT = . SRCDIR = RECURSION = 1 # The executable file name. # If not specified, current directory name or `demo.out' will be used. PROGRAM = Main Main2 Subtitle/aa/bb/Main3 ## Implicit Section: change the following only when necessary. ##========================================================================== # The source file types (headers excluded). # .c indicates C source files, and others C++ ones. SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp # The header file types. HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp # The C++ program compiler. CXX = g++ # The C program compiler. CC = gcc # The command used to delete file. RM = rm -f CTAGS = ctags CTAGSFLAGS = # The directories in which source files reside. SRCROOT := $(foreach d,$(SRCROOT),$(d:/=)) SRCDIRS := $(strip $(SRCROOT) $(SRCDIR)) SRCDIRS := $(foreach d,$(SRCDIRS),$(d:/=)) ifeq ($(RECURSION), 1) SRCDIRS := $(shell find $(SRCDIRS) -type d | grep \\.git -v) endif SRCDIRS := $(sort $(SRCDIRS)) RMOBJS := $(addsuffix /*.o, $(SRCDIRS)) RMDEPS := $(RMOBJS:.o=.d) # The options used in linking as well as in any direct use of ld. LDFLAGS = ## Stable Section: usually no need to be changed. But you can add more. ##========================================================================== SHELL = /bin/bash EMPTY = SPACE = $(EMPTY) $(EMPTY) ifeq ($(PROGRAM),) CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR))) PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES)) ifeq ($(PROGRAM),) PROGRAM = demo.out endif endif ifeq ($(SRCDIRS),) SRCDIRS = . endif SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS)))) HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS)))) SRC_CXX = $(filter-out %.c,$(SOURCES)) OBJS = $(addsuffix .o, $(basename $(SOURCES))) DEPS = $(OBJS:.o=.d) ## Define some useful variables. DEP_OPT = $(shell if `$(CC) --version | grep "gcc" >/dev/null`; then \ echo "-MM -MP"; else echo "-M"; fi ) DEPEND = $(CC) $(DEP_OPT) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) DEPEND.d = $(subst -g ,,$(DEPEND)) COMPILE.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c LINK.c = $(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) .PHONY: all objs tags ctags clean help show # Delete the default suffixes .SUFFIXES: all: $(PROGRAM) # Rules for creating dependency files (.d). #------------------------------------------ %.d:%.c @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.C @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.cc @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.cpp @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.CPP @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.c++ @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.cp @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ %.d:%.cxx @echo -n $(dir $<) > $@ $(DEPEND.d) $< >> $@ # Rules for generating object files (.o). #---------------------------------------- objs:$(OBJS) %.o:%.c $(COMPILE.c) $< -o $@ %.o:%.C $(COMPILE.cxx) $< -o $@ %.o:%.cc $(COMPILE.cxx) $< -o $@ %.o:%.cpp $(COMPILE.cxx) $< -o $@ %.o:%.CPP $(COMPILE.cxx) $< -o $@ %.o:%.c++ $(COMPILE.cxx) $< -o $@ %.o:%.cp $(COMPILE.cxx) $< -o $@ %.o:%.cxx $(COMPILE.cxx) $< -o $@ # Rules for generating the tags. #------------------------------------- tags: $(HEADERS) $(SOURCES) $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES) ctags: $(HEADERS) $(SOURCES) $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES) # Rules for generating the executable. #------------------------------------- COBJS = $(filter-out $(foreach d,$(PROGRAM), \ $(addprefix $(SRCROOT)/,$(d).o)), $(OBJS)) $(PROGRAM):$(OBJS) ifeq ($(SRC_CXX),) # C program $(LINK.c) $(COBJS) $(SRCROOT)/$@.o $(MY_LIBS) -o $@ @echo Type $(SRCROOT)/$@ to execute the program. else # C++ program $(LINK.cxx) $(COBJS) $(SRCROOT)/$@.o $(MY_LIBS) -o $@ @echo Type $(SRCROOT)/$@ to execute the program. endif ifndef NODEP ifneq ($(DEPS),) sinclude $(DEPS) endif endif clean: $(RM) $(RMDEPS) $(RMOBJS) $(RM) $(PROGRAM) $(foreach d,$(PROGRAM),$(addprefix $(d),.exe)) # Show help. help: @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5' @echo 'Copyright (C) 2007, 2008 whyglinux <whyglinux@hotmail.com>' @echo @echo 'Usage: make [TARGET]' @echo 'TARGETS:' @echo ' all (=make) compile and link.' @echo ' NODEP=yes make without generating dependencies.' @echo ' objs compile only (no linking).' @echo ' ctags create ctags for VI editor.' @echo ' clean clean objects, the executable and dependencies.' @echo ' show show variables (for debug use only).' @echo ' help print this message.' @echo @echo 'Report bugs to <whyglinux AT gmail DOT com>.' # Show variables (for debug use only.) show: @echo 'PROGRAM :' $(PROGRAM) @echo 'SRCDIRS :' $(SRCDIRS) @echo 'HEADERS :' $(HEADERS) @echo 'SOURCES :' $(SOURCES) @echo 'SRC_CXX :' $(SRC_CXX) @echo 'OBJS :' $(OBJS) @echo 'DEPS :' $(DEPS) @echo 'DEPEND :' $(DEPEND) @echo 'COMPILE.c :' $(COMPILE.c) @echo 'COMPILE.cxx :' $(COMPILE.cxx) @echo 'LINK.c :' $(LINK.c) @echo 'LINK.cxx :' $(LINK.cxx) ## End of the Makefile ## Suggestions are welcome ## All rights reserved ## #############################################################################
相关文章推荐
- Makefile万能写法(gcc程序以及arm-linux-gcc程序)-转
- Makefile万能写法(gcc程序以及arm-linux-gcc程序)
- Makefile万能写法(gcc程序以及arm-linux-gcc程序)
- Linux之C编译器gcc和makefile使用简介
- Linux中gcc,g++常用编译选项以及makefile的编写
- Linux下gcc与g++用法以及编写makefile
- Linux下GCC和Makefile实例(从GCC的编译到Makefile的引入)
- Linux下gcc与g++用法以及编写makefile
- Linux下GCC和Makefile实例(从GCC的编译到Makefile的引入)
- redhat-linux的gcc安装详解---阿冬收集
- Linux下MAKEFILE写法和GCC参数
- Linux下gcc,g++,makefile的使用
- Linux下gcc与g++用法以及编写makefile
- arm-linux-gcc ld libpthread.so not foud 需要在 Makefile 里添加 -lpthread
- Linux笔记_gcc_gdb_makefile
- Linux下C编程:gcc和Makefile体验
- Linux下GCC和Makefile实例(从GCC的编译到Makefile的引入)
- Linux平台Makefile文件的编写基础篇和GCC参数详解
- Linux下gcc与g++用法以及编写makefile
- Linux下C语言编程基础知识--gcc编译器的使用、MakeFile文件的编写