目录
1. 源文件
test.cpp
#include <iostream>
int main(int argc,char**argv)
{
int itest = 100;
const char *str = "this is a test";
std::cout << "itest is " << itest << " str is " << str << std::endl;
std::cout << "param is " << std::endl;
for ( int i = 0; i < argc;i++)
{
std::cout << argv[i] << std::endl;
}
std::cout << "hello world \n";
return 0;
}
Makefile
EXE:=section1
EXECUTABLE:= $(EXE)
LIBDIR:=
LIBS:=
INCLUDES:=.
SRCDIR:=
CC:=g++
#CFLAGS:= -g -Wall -o0
CPPFLAGS:= -g
CPPFLAGS+= $(addprefix -I,$(INCLUDES))
CPPFLAGS+= -I.
CPPFLAGS+= -MMD
RM-F:= rm -f
SRCS:= $(wildcard *.cpp) $(wildcard $(addsuffix /*.cpp,$(SRCDIR)))
OBJS:= $(patsubst %.cpp,%.o,$(SRCS))
DEPS:= $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS:= $(filter-out $(wildcard $(DEPS)),$(DEPS))
.PHONY : all deps objs clean
all:$(EXECUTABLE)
deps:$(DEPS)
objs:$(OBJS)
clean:
@$(RM-F) *.o
@$(RM-F) *.d
@$(RM-F) $(EXE)
ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS):
@$(RM-F) $(patsubst %.d,%.o,$@)
endif
-include