블로그 테스트를 위한 임시...
bash# cc -O2 -Wall -Werror -fomit-frame-pointer -c -o test.o test.c bash# ls test.c test.o bash# ld -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o test.o bash# ./test Hello world ! bash# _
<Target>: <Depend> ?... [[;] <Command>] <탭문자><Command>
test: test.o
ld -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o test.o
test.o: test.c
cc -O2 -Wall -Werror -fomit-frame-pointer -c -o test.o test.c
bash# make test cc -O2 -Wall -Werror -fomit-frame-pointer -c -o test.o test.c ld -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o test.o bash# _
bash# make test make: `test'는 이미 갱신되었습니다. bash# _
bash# touch test.c bash# make test cc -O2 -Wall -Werror -fomit-frame-pointer -c -o test.o test.c ld -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o test.o bash# _
<Macro name> = <Macro 내용>
CC = cc
LD = ld
CFLAGS = -O2 -Wall -Werror -fomit-frame-pointer -c
LDFLAGS = -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2
STARTUP = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o
test: test.o
$(LD) $(LDFLAGS) -o test $(STARTUP) test.o
test.o: test.c
$(CC) $(CFLAGS) -o test.o test.c
.c.o:
$(CC) $(CFLAGS) -o $@ $<
CC = cc
LD = ld
CFLAGS = -O2 -Wall -Werror -fomit-frame-pointer -c
LDFLAGS = -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2
STARTUP = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o
test: test.o
$(LD) $(LDFLAGS) -o $@ $(STARTUP) $^
.c.o:
$(CC) $(CFLAGS) -o $@ $<
CC = cc
LD = ld
RM = rm -f
CFLAGS = -O2 -Wall -Werror -fomit-frame-pointer -c
LDFLAGS = -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2
STARTUP = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o
clean:
$(RM) test.o test
test: test.o
$(LD) $(LDFLAGS) -o $@ $(STARTUP) $^
.c.o:
$(CC) $(CFLAGS) -o $@ $<
CC = cc
LD = ld
RM = rm -f
CFLAGS = -O2 -Wall -Werror -fomit-frame-pointer -c
LDFLAGS = -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2
STARTUP = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o
.PHONY: all clean
all: test
clean:
$(RM) test.o test
test: test.o
$(LD) $(LDFLAGS) -o $@ $(STARTUP) $^
.c.o:
$(CC) $(CFLAGS) -o $@ $<
#include <stdio.h>
void HelloWorld(void)
{
fprintf(stdout, "Hello world.\n");
}
#include <stdio.h>
#include "hello.h"
int main(void)
{
HelloWorld();
return(0);
}
extern void HelloWorld(void);
CC = cc LD = ld RM = rm -f CFLAGS = -O2 -Wall -Werror -fomit-frame-pointer -v -c LDFLAGS = -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 STARTUP = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o BUILD = test OBJS = test.o hello.o .PHONY: all clean all: $(BUILD) clean: ; $(RM) *.o $(BUILD) test: $(OBJS) ; $(LD) $(LDFLAGS) -o $@ $(STARTUP) $^ # 의존관계 성립 hello.o: $($@:.o=.c) $($@:.o=.h) Makefile test.o: $($@:.o=.c) hello.h Makefile # 확장자 규칙 (컴파일 공통 규칙) .c.o: ; $(CC) $(CFLAGS) -o $@ $<
CC = cc LD = ld RM = rm -f CFLAGS = -O2 -Wall -Werror -fomit-frame-pointer -v -c LDFLAGS = -lc -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 STARTUP = /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o BUILD = test OBJS = test.o hello.o .PHONY: all clean all: $(BUILD) clean: ; $(RM) *.o $(BUILD) test: $(OBJS) ; $(LD) $(LDFLAGS) -o $@ $(STARTUP) $^ # 의존관계 성립 $(OBJS): $($@:.o=.c) hello.h Makefile # test.o hello.o: $($@:.o=.c) hello.h Makefile # 확장자 규칙 (컴파일 공통 규칙) .c.o: ; $(CC) $(CFLAGS) -o $@ $<