Makefile to compile multiple C programs?

前端 未结 8 1178
予麋鹿
予麋鹿 2020-12-02 09:41

This is an incredibly simple question, but I\'m new to makefiles. I am trying to make a makefile that will compile two independent programs:

program1:
    gc         


        
8条回答
  •  心在旅途
    2020-12-02 10:15

    Pattern rules let you compile multiple c files which require the same compilation commands using make as follows:

    objects = program1 program2
    all: $(objects)
    
    $(objects): %: %.c
            $(CC) $(CFLAGS) -o $@ $<
    

提交回复
热议问题