[Makefile]
# Makefile Test
include FileList
CC = gcc
CFG = release
OBJS = $(addsuffix .o, $(basename $(SOURCE)))
EXE = hello
# release
CFLAGS_RELEASE = -O2
DFLAGS_RELEASE = LINUX OS_POSIX
# debug
CFLAGS_DEBUG =
DFLAGS_DEBUG = _DEBUG LINUX OS_POSIX
# switch CFG
ifeq ($(CFG), release)
CFLAGS = $(CFLAGS_RELEASE)
DFLAGS = $(addprefix -D, $(DFLAGS_RELEASE))
else
CFLAGS = $(CFLAGS_DEBUG)
DFLAGS = $(addprefix -D, $(DFLAGS_DEBUG))
endif
# make rules
all: $(EXE)
$(EXE): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) $(DFLAGS) -c $<
clean:
rm -f $(EXE) $(OBJS)
[filelist.sh]
#!/bin/sh
FileList=`find -name '*.c'`
echo "SOURCE =" '\'
for i in $FileList; do
echo $i '\'
done
echo
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment