嵌入式Linux关于交叉编译的问题,求大神指导
已知一个项目中的所有程序文件为:main.c、head.h、fun1.c、fun2.c和fun3.c,其中,main.c文件包含了头文件head.h。编写一个Makefi...
已知一个项目中的所有程序文件为:main.c、head.h、fun1.c、fun2.c和fun3.c,其中,main.c文件包含了头文件head.h。编写一个Makefile文件,生成可执行文件prj_a。要求:显示规则完成,使用交叉编译器、变量和伪目标clean。
展开
1个回答
展开全部
参考一个makefile就行啊。
#THe Newest Modify Time: 2013-01-20
# DVSDK4.0.1 DIR
DVSDK_DIR = /home/dvsdk4_01
include $(DVSDK_DIR)/Rules.make
# Comment this out if you want to see full compiler and linker output.
override VERBOSE = @
TARGET = sys
INSTALL_DIR = /home/BeagleBoard/rootfs/usr/share/run_bin
# use CROSS_COMPILE arm-none-linux-gnueabi-gcc
C_FLAGS += -Wall -g
CPP_FLAGS += -I$(LINUXKERNEL_INSTALL_DIR)/include -I$(LINUXKERNEL_INSTALL_DIR)/arch/arm/include
CPP_FLAGS += -I../commom_lib/include
LD_FLAGS += -L$(LINUXLIBS_INSTALL_DIR)/lib -L/opt/DigitalPersona/lib_arm -L../commom_lib/lib\
-ldpfpdd -ldpfj \
-lipc_socket -lipc_sem -lipc_shm -lsys_log -lfd_poll \
-Wl,-rpath,/usr/lib/lib_finger:/usr/lib/lib_ipc\
-lm -lc -lpthread
GCC_COMPILE = $(CSTOOL_PREFIX)gcc $(C_FLAGS) $(CPP_FLAGS) -c
GCC_LINK = $(CSTOOL_PREFIX)gcc $(LD_FLAGS)
# Source file *.c,*.h
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard *.h)
# Object file *.o
OBJFILES = $(patsubst %.c,%.o,$(SOURCES))
#OBJFILES = $(SOURCES:%.c=%.o)
#Command For Build
all: $(TARGET) install
$(TARGET): $(OBJFILES)
@echo
@echo Linking $@ from $^..
$(GCC_LINK) $^ -o $@
$(OBJFILES): %.o:%.c $(HEADERS)
@echo
@echo Compiling $@ from $<..
$(GCC_COMPILE) $< -o $@
.PHONY: install clean
install:
@echo
@echo Install $(TARGET)..
mkdir -p $(INSTALL_DIR)
install $(TARGET) $(INSTALL_DIR)
clean:
@echo Removing generated files..
rm -f $(INSTALL_DIR)/$(TARGET) $(TARGET) *.o *~
#THe Newest Modify Time: 2013-01-20
# DVSDK4.0.1 DIR
DVSDK_DIR = /home/dvsdk4_01
include $(DVSDK_DIR)/Rules.make
# Comment this out if you want to see full compiler and linker output.
override VERBOSE = @
TARGET = sys
INSTALL_DIR = /home/BeagleBoard/rootfs/usr/share/run_bin
# use CROSS_COMPILE arm-none-linux-gnueabi-gcc
C_FLAGS += -Wall -g
CPP_FLAGS += -I$(LINUXKERNEL_INSTALL_DIR)/include -I$(LINUXKERNEL_INSTALL_DIR)/arch/arm/include
CPP_FLAGS += -I../commom_lib/include
LD_FLAGS += -L$(LINUXLIBS_INSTALL_DIR)/lib -L/opt/DigitalPersona/lib_arm -L../commom_lib/lib\
-ldpfpdd -ldpfj \
-lipc_socket -lipc_sem -lipc_shm -lsys_log -lfd_poll \
-Wl,-rpath,/usr/lib/lib_finger:/usr/lib/lib_ipc\
-lm -lc -lpthread
GCC_COMPILE = $(CSTOOL_PREFIX)gcc $(C_FLAGS) $(CPP_FLAGS) -c
GCC_LINK = $(CSTOOL_PREFIX)gcc $(LD_FLAGS)
# Source file *.c,*.h
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard *.h)
# Object file *.o
OBJFILES = $(patsubst %.c,%.o,$(SOURCES))
#OBJFILES = $(SOURCES:%.c=%.o)
#Command For Build
all: $(TARGET) install
$(TARGET): $(OBJFILES)
@echo
@echo Linking $@ from $^..
$(GCC_LINK) $^ -o $@
$(OBJFILES): %.o:%.c $(HEADERS)
@echo
@echo Compiling $@ from $<..
$(GCC_COMPILE) $< -o $@
.PHONY: install clean
install:
@echo
@echo Install $(TARGET)..
mkdir -p $(INSTALL_DIR)
install $(TARGET) $(INSTALL_DIR)
clean:
@echo Removing generated files..
rm -f $(INSTALL_DIR)/$(TARGET) $(TARGET) *.o *~
追问
哎……
看不懂啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询