Makefile减少依赖文件编译

发布时间 2023-12-11 22:02:19作者: 西北小蚂蚁

Makefile减少依赖文件编译

%.o:%.c

makefile

all:test1.o test2.o test3.o
	gcc *.o -o elf
	echo "sucess!!"

%.o:%.c
	gcc -c $^ -o $@


CL:
	rm -rf *.o elf

test1

#include <stdio.h>

extern void test2(void);
extern void test3(void);

void test1(void)
{
    printf("hello word test1!\r\n");
}


void main()
{
    test1();
    test2();
    test3();
}

test2

#include <stdio.h>


void test2(void)
{
    printf("hello word test2!\r\n");
}

test3

#include <stdio.h>


void test3(void)
{
    printf("hello word test3!\r\n");
}