文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>my work Makefile

my work Makefile

时间:2007-05-28  来源:qfox

###########################################################
# Jasper Makefile
# @author qiuf
# Description:
# The makefile searches in <SRCDIRS> directories for the source files
# with extensions specified in .c, then compiles the sources
# and finally produces the <TARGET>, the executable file, by linking
# the objectives.
#
# BUG: make driver/ not very well

# Usage:
#   $ make           compile and link the program.
#   $ make objs      compile only (no linking. Rarely used).
#   $ make dep      create dependecy files only (Rarely used).
#   $ make lib      ar libjapser.a
#   $ make clean     clean the objectives and dependencies.
#   $ make cleanall  clean the objectives, dependencies and executable.
#   $ make rebuild   rebuild the program. The same as make clean && make all.

# the final bulid elf file
TARGET := Jasper

# add your source dir here!
SRCDIRS := app vfs fs vos codec unicode test driver/src

# gdb_dir, the dir that gdb.exe in, copy TARGET to GDB dir to download
GDBDIR := ../lupine_gdb_5

# OBJDIR, the objects and dependecies
#OBJSDIR = objects

# ecos install dir
ECOSDIR := ./install

# use ecos make rules
include $(ECOSDIR)/include/pkgconf/ecos.mak

# search dir
#vpath %.c $(SRCDIRS)
#vpath %.o $(SRCDIRS)
VPATH=$(SRCDIRS) ./include driver/include

# complier
CC := $(ECOS_COMMAND_PREFIX)gcc

# linker
LD := $(ECOS_COMMAND_PREFIX)ld

# ar
AR := $(ECOS_COMMAND_PREFIX)ar

# objdump
OBJDUMP := $(ECOS_COMMAND_PREFIX)objdump

# objcopy
OBJCOPY := $(ECOS_COMMAND_PREFIX)objcopy

# complie options
CFLAGS = $(ECOS_GLOBAL_CFLAGS)
MY_CFLAGS = -I$(ECOSDIR)/include
MY_CFLAGS += -I./include
MY_CFLAGS += -Idriver/include
CFLAGS  += $(MY_CFLAGS)

# link options
LDFLAGS = $(ECOS_GLOBAL_LDFLAGS)
MY_LDFLAGS = -nostartfiles -L$(ECOSDIR)/lib -Ttarget.ld
LDFLAGS += $(MY_LDFLAGS)

SOURCES = $(foreach d, $(SRCDIRS), $(wildcard $(d)/*.c))
DEPS = $(patsubst %.c, %.d, $(SOURCES))
OBJS = $(patsubst %.d, %.o, $(DEPS))

.PHONY : all objs clean rebuild cleanall dep lib
all :$(TARGET)

# Rules for creating dependecy files
dep : $(DEPS)
%.d : %.c
 @$(CC) -MM -MD $(CFLAGS) $< -o $@

# Rules for producing the objects
objs : $(OBJS)
%.o:%.c %.d
 @$(CC) $(CFLAGS) -c $< -o $@
-include $(DEPS)

# Rules for bulid elf
$(TARGET) : $(OBJS)
 @$(CC) $(LDFLAGS) $^  -o $@
 @$(OBJDUMP) -D $@ > [email protected]
 @$(OBJCOPY) -O binary $@ [email protected]
 @cp $@ $(GDBDIR) -f

# Rules for lib
lib : $(OBJS)
 @$(AR) r libjapser.a $(OBJS)

# rebuild
rebuild : clean all

# clean
clean:
 @$(RM) $(OBJS) $(DEPS)

cleanall: clean
 @$(RM) $(TARGET) $(TARGET).* libjasper.a

相关阅读 更多 +
排行榜 更多 +
匿名爱人游戏

匿名爱人游戏

冒险解谜 下载
魔方仆从冲刺

魔方仆从冲刺

休闲益智 下载
跑山越野摩托

跑山越野摩托

体育竞技 下载