1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
########################################################################
# Use TARG_COMPILER_FAMILY to set the C compiler name
ifeq ($(TARG_COMPILER_FAMILY),gcc)
CC := gcc
endif
ifeq ($(TARG_COMPILER_FAMILY),intel)
CC := icc
endif
########################################################################
# Use O_DIR as equal to $(TARG)/ so that if TARG is empty then O_DIR
# will be empty. But if $(TARG) as a value then O_DIR will have a
# trailing slash.
ifneq ($(TARG),)
override O_DIR := $(TARG)/
endif
########################################################################
# Use TARG_BUILD_SCENARIO to set the compiler options for either
# debug or optimize.
ifeq ($(TARG_BUILD_SCENARIO),dbg)
CF := -g -O0
endif
ifeq ($(TARG_BUILD_SCENARIO),opt)
CF := -O3
endif
EXEC := $(O_DIR)hello
SRC := main.c hello.c
override CFLAGS := $(CFLAGS) $(CF)
OBJS := $(O_DIR)main.o $(O_DIR)hello.o
all: $(O_DIR) $(EXEC)
$(O_DIR):
mkdir -p $(O_DIR)
$(EXEC): $(OBJS)
$(LINK.c) -o $@ $^
neat:
$(RM) *~
clean: neat
$(RM) $(OBJS)
clobber: clean
$(RM) $(EXEC)
######################## compilation rules ###############################
$(O_DIR)%.o : %.c
$(COMPILE.c) -o $@ -c $<
######################## Dependancies ####################################
$(O_DIR)main.o : main.c hello.h
$(O_DIR)hello.o: hello.c hello.h
|