[완료]make 로 여러개 오브젝트 컴파일하기 질문입니다.

poplinux의 이미지

약간 아리송한 부분이 있어서 질문 올립니다.

OBJS = test1.o test2.o test3.o
 
all:
    ${CC} -c ${OBJS} 

제가 하고 싶은 작업은 test1.c test2.c test3.c 를 오브젝트로 컴파일하는 것입니다. 그래서 위와 같이 make를 만들었는데 다음과 같이 진행됩니다.

cc    -c -o test1.o test1.c
cc    -c -o test2.o test2.c
cc    -c -o test3.o test3.c
cc -c test1.o test2.o test3.o
cc: test1.o: linker input file unused because linking not done
cc: test2.o: linker input file unused because linking not done
cc: test3.o: linker input file unused because linking not done

제가 예상한 작업은 다음과 같습니다.

cc    -c  test1.o test1.c
cc    -c  test2.o test2.c
cc    -c  test3.o test3.c

제가 원하는 작업을 하려면 어떻게 수정해야 할까요?

poplinux의 이미지

앗. 찾아 냈습니다.

all:
   ${CC} -c ${SRCS}

로 하면 되는군요.

========================
조직 : E.L.D(Embedded Linux Developer/Designer)
블로그 : poplinux@tistory.com
카페 : cafe.naver.com/poplinux

임베디드 리눅스 관련 프리렌서 지향

ktd2004의 이미지

이런 방법은 어떨까요?

TARGET = test
SRCS = test1.c test2.c test3.c
OBJS = $(SRCS:.c=.o)
 
all : $(TARGET)
 
$(TARGET) : $(OBJS)
        gcc -o $@ $^
 
.c.o :
        gcc -Wall -c -o $@ $<