谁能解释一下这个makefile示例?

时间:2018-03-31 12:15:12

标签: linux gcc makefile

# Makefile to compare sorting routines

BASE = /home/blufox/base
CC = gcc
CFLAGS = -O –Wall
EFILE = $(BASE)/bin/compare_sorts
INCLS = -I$(LOC)/include
LIBS = $(LOC)/lib/g_lib.a \
$(LOC)/lib/h_lib.a
LOC = /usr/local
OBJS = main.o another_qsort.o chk_order.o \
compare.o quicksort.o

$(EFILE): $(OBJS)
    @echo “linking …”
    @$(CC) $(CFLAGS) –o $@ $(OBJS) $(LIBS)

$(OBJS): compare_sorts.h
    $(CC) $(CFLAGS) $(INCLS) –c $*.c

# Clean intermediate files
clean:
    rm *~ $(OBJS)

1 个答案:

答案 0 :(得分:0)

变量替代形式, gcc -O -Wall -o / home / blufox / base / bin / compare_sorts main.o another_qsort.o chk_order.o compare.o quicksort.o main.c another_qsort.c chk_order.c compare.c 例如: $(OBJS)= main.o another_qsort.o chk_order.o compare.o quicksort.o