작성일: 2012-11-09
주의: 띄어쓰기 4칸을 TAB으로 바꾸어야 실행 가능함.
응용프로그램용:
CC=g++ CFLAGS=-c -Wall LDFLAGS= SOURCES=main.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=a.out all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ .cpp.o: $(CC) $(CFLAGS) $< -o $@ clean: rm -f $(OBJECTS)
정적 라이브러리용:
CC=g++ CFLAGS=-c -Wall SOURCES=name.cpp OBJECTS=$(SOURCES:.cpp=.o) TARGET=libXxx all: $(SOURCES) $(TARGET) $(TARGET): $(OBJECTS) ar cr $(TARGET).a $(OBJECTS) .cpp.o: $(CC) $(CFLAGS) $< -o $@ clean: rm -f $(OBJECTS) $(TARGET).a
요건 작업중인거:
#This is prefix for the cross compiler #Example: arm-linux- CROSS_COMPILE ?= arm-linux- CC=$(CROSS_COMPILE)gcc CXX=$(CROSS_COMPILE)g++ CFLAGS=-c -Wall LDFLAGS= SOURCES=main.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=a.out all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CXX) $(LDFLAGS) $(OBJECTS) -o $@ .cpp.o: $(CXX) $(CFLAGS) $< -o $@ clean: rm -f $(OBJECTS)
댓글 없음:
댓글 쓰기