# # (C) Copyleft 2011 # Late Lee from http://www.latelee.org # # A simple file to specify compier and macros and flags # and ways to compile .c & .cpp #
# cross compile... CROSS_COMPILE =
CC = $(CROSS_COMPILE)gcc CXX = $(CROSS_COMPILE)g++ AR = $(CROSS_COMPILE)ar
# # (C) Copyleft 2011 # Late Lee from http://www.latelee.org # # A simple way to generate depend file(.depend) for .c & .cpp, # so you change the head file, it will recompile the # file(s) which include the head file. #
_depend: $(obj).depend
$(obj).depend: $(SRCTREE)/config.mk $(SRC_C) $(SRC_CPP) @rm -f $@ @for f in $(SRC_C); do \ g=`echo $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \ $(CC) -MM $(CFLAGS) -E -MQ $(obj)$$g $$f >> $@ ; \ done @for f in $(SRC_CPP); do \ g=`echo $$f | sed -e 's/\(.*\)\...\w/\1.o/'`; \ $(CC) -MM $(CFLAGS) -E -MQ $(obj)$$g $$f >> $@ ; \ done
# Attempt to create a output directory. $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
# Verify if it was successful. BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist)) endif # ifneq ($(BUILD_DIR),)
############################################################################### # libs ### your libs here LIBS :=
LIBS := $(addprefix $(obj),$(LIBS))
LDFLAGS = $(LIBS)
# source file(s), including c file(s) cpp file(s) # you can also use $(wildcard *.c), etc. ### main source here MAIN_DIR = #main/ SRC_C := SRC_CPP := $(wildcard $(MAIN_DIR)*.cpp)
# # (C) Copyleft 2011 # Late Lee from http://www.latelee.org # # A simple Makefile for lib(libxxx.a) # You just need to change library name and source file(s) #
include $(TOPDIR)/config.mk
# here you can set your own flags CFLAGS += # -D_A_
# static library name LIB = # $(obj)libfoo.a
# source file(s), including c file(s) cpp file(s) # you can also use $(wildcard *.c), etc. SRC_C := # foo.c SRC_CPP :=