Last active
October 11, 2015 16:58
-
-
Save Akagi201/3890590 to your computer and use it in GitHub Desktop.
Akagi201's Makefiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @file Makefile | |
# | |
# @author Akagi201 | |
# @date 2014/03/20 | |
# | |
# Linux Application Generic Makefile | |
# | |
# History: | |
# <author> <time> <version> <desc> | |
# liuboyf1 2012-09-03 V1.0.0 创建文件 | |
# liuboyf1 2012-09-26 V1.0.1 修复了DEBFLAGS调试 | |
# liuboyf1 2012-09-28 V1.0.2 修改rm为-rm更健壮 | |
# liuboyf1 2012-09-28 V1.0.3 修改了部分注释 | |
# liuboyf1 2012-10-09 V1.0.4 修改了rm注释不能在同一行 | |
# liuboyf1 2012-10-15 V1.0.5 修改了调试参数和布局 | |
# liuboyf1 2012-10-18 V1.0.6 修改了TOOL_DIR和TOOL_PREFIX | |
# | |
# The prefix to be added before the GNU compiler tools (optionally including | |
# path), i.e. "arm-linux-" or "/opt/bin/arm-linux-". | |
#TOOL_DIR=$(shell if [ -e /home/v5t_le-mv401_uc ]; then echo /home; else echo /opt; fi) | |
# 交叉编译工具 | |
#TOOL_PREFIX=$(TOOL_DIR)/v5t_le-mv401_uc/bin/arm_v5t_le- | |
# Comment/uncomment the following line to enable/disable debugging | |
#DEBUG = y | |
ifeq ($(DEBUG),y) | |
DEBFLAGS = -O -g # "-O" is needed to expand inlines | |
#DEBFLAGS += -DDEBUG # 控制是否打印调试和错误信息 | |
else | |
DEBFLAGS = -O2 | |
endif | |
CFLAGS += -Wall | |
#INCLUDES = -I/xxx | |
#LIBS = -lpthread | |
#tool chain | |
CC = $(TOOL_PREFIX)gcc | |
SRCS = $(wildcard *.c) # 当前目录下所有以.c结尾的源文件,wildcard 扩展通配符 | |
OBJS = $(SRCS:.c = .o) # .c=.o是做一个替换,把变量$(sources)所有[.c]的字串都替换成.o | |
PWD := $(shell pwd) | |
# 生成的可执行文件名称 | |
TARGET = test | |
$(TARGET) : $(OBJS) | |
$(CC) $^ -o $@ $(CFLAGS) $(DEBFLAGS) $(INCLUDES) $(LIBS) | |
#cp $(TARGET) $(PWD)/.. | |
%.o : %.c | |
$(CC) -c $< $(CFLAGS) $(DEBFLAGS) | |
clean : | |
# 忽略某些文件问题,继续做后面的事情 | |
-rm -f *.o $(TARGET) | |
.PHONY : clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @file Makefile | |
# | |
# @author Akagi201 | |
# @date 2014/03/20 | |
# | |
# Linux Device Driver Generic Makefile | |
# | |
# History: | |
# <author> <time> <version> <desc> | |
# liuboyf1 2012-08-30 V1.0.0 创建文件 | |
# liuboyf1 2012-09-26 V1.0.1 修改了CFLAGS为EXTRA_CFLAGS | |
# liuboyf1 2012-09-26 V1.0.2 简化了调试宏部分 | |
# liuboyf1 2012-09-28 V1.0.3 修改rm为-rm | |
# liuboyf1 2012-10-08 V1.0.4 修改make clean | |
# liuboyf1 2012-10-10 V1.0.5 修改KERNELDIR | |
# liuboyf1 2012-10-15 V1.0.6 修改了调试参数和布局 | |
# liuboyf1 2012-10-18 V1.0.7 修改了TOOL_DIR和TOOL_PREFIX | |
# | |
# The prefix to be added before the GNU compiler tools (optionally including | |
# path), i.e. "arm-linux-" or "/opt/bin/arm-linux-". | |
#TOOL_DIR=$(shell if [ -e /home/v5t_le-mv401_uc ]; then echo /home; else echo /opt; fi) | |
# 交叉编译工具 | |
#TOOL_PREFIX=$(TOOL_DIR)/v5t_le-mv401_uc/bin/arm_v5t_le- | |
# Comment/uncomment the following line to enable/disable debugging | |
#DEBUG = y | |
ifeq ($(DEBUG),y) | |
DEBFLAGS = -O -g # "-O" is needed to expand inlines | |
DEBFLAGS += -DDEBUG # 控制是否打印调试和错误信息 | |
else | |
DEBFLAGS = -O2 | |
endif | |
EXTRA_CFLAGS += -Wall | |
EXTRA_CFLAGS += $(DEBFLAGS) | |
#EXTRA_CFLAGS += -I$(LDDINC) | |
#tool chain | |
CC = $(TOOL_PREFIX)gcc | |
#AR:= $(TOOL_PREFIX)ar -rv | |
MODULE_NAME = mycdev | |
ifneq ($(KERNELRELEASE),) | |
obj-m := $(MODULE_NAME).o | |
#$(MODULE_NAME)-objs := file_opr.o mem_proc.o main.o | |
else | |
# in my Debian6 2.6.32 | |
KERNELVER ?= $(shell uname -r) | |
KERNELDIR ?= /lib/modules/$(KERNELVER)/build | |
# in my IPC 2.6.18 | |
#KERNELDIR ?= /home/akagi201/kernel_step | |
PWD := $(shell pwd) | |
modules: | |
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules | |
#cp $(MODULE_NAME).ko $(PWD)/.. | |
modules_install: | |
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install | |
endif | |
clean: | |
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean | |
.PHONY: modules modules_install clean | |
depend .depend dep: | |
$(CC) $(EXTRA_CFLAGS) -M *.c > .depend | |
ifeq (.depend,$(wildcard .depend)) | |
include .depend | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @file Makefile | |
# | |
# @author Akagi201 | |
# @date 2014/03/20 | |
# | |
# Generic Makefile for SD / RAM on S5PV210 | |
# usage: make ENV=RAM -> RAM boot / make -> SD boot | |
# | |
#define var - 每次修改 | |
TARGET := led.bin | |
BUILD := led | |
ENV ?= SD # 如果ENV没有被赋值过, 则赋值为SD, 即默认SD | |
SDTOOLS := ./mk210 # s5pv210打包加头程序 | |
COBJS += main.o | |
COBJS += start.o | |
COBJS += led.o | |
CROSS_COMPILE := arm-linux- | |
CC := $(CROSS_COMPILE)gcc | |
LD := $(CROSS_COMPILE)ld | |
OBJCOPY := $(CROSS_COMPILE)objcopy | |
CFLAGS += -Wall | |
CFLAGS += -I./inc | |
LDFLAGS += -Tmap.lds | |
ifeq ($(ENV), RAM) | |
LDFLAGS += -Ttext=0x0 | |
else | |
LDFLAGS += -Ttext=0x20000000 | |
endif | |
# Way - 每次不用修改 | |
all:$(TARGET) | |
ifeq ($(ENV),SD) | |
$(TARGET):$(BUILD) | |
$(OBJCOPY) -O binary $^ $@ | |
cp $@ ../binary -f | |
else | |
$(TARGET):$(BUILD) | |
$(OBJCOPY) -O binary $^ [email protected] | |
$(SDTOOLS) [email protected] $@ | |
cp $@ ../binary -f | |
endif | |
$(BUILD):$(COBJS) | |
$(LD) $(LDFLAGS) -o $@ $^ | |
%.o:%.c | |
$(CC) $(CFLAGS) -c -o $@ $^ | |
%.o:%.S | |
$(CC) $(CFLAGS) -c -o $@ $^ | |
clean: | |
rm -f $(TARGET) $(BUILD) *.o *.TMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @file Makefile | |
# | |
# @author Akagi201 | |
# @date 2014/03/20 | |
# | |
# Top Generic Mkefile | |
# | |
# History: | |
# <author> <time> <version> <desc> | |
# liuboyf1 2012-09-11 V1.0.0 创建文件 | |
# liuboyf1 2012-09-26 V1.0.1 添加make app make dev分别编译功能 | |
# | |
PWD = $(shell pwd) | |
all: app dev | |
app: | |
make -C $(PWD)/app | |
dev: | |
make -C $(PWD)/dev | |
clean: | |
make clean -C $(PWD)/app | |
make clean -C $(PWD)/dev | |
.PHONY: all app dev clean | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @file map.lds | |
# | |
# @author Akagi201 | |
# @date 2014/03/20 | |
# | |
# Generic map.lds for SD / RAM on S5PV210 copied from uboot | |
# usage: make ENV=RAM -> RAM boot / make -> SD boot | |
# | |
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") | |
OUTPUT_ARCH(arm) | |
ENTRY(_start) | |
SECTIONS | |
{ | |
. = 0x0; | |
. = ALIGN(4); | |
.text : | |
{ | |
start.o | |
*(.text) | |
} | |
. = ALIGN(4); | |
.rodata : | |
{ | |
*(.rodata) | |
} | |
. = ALIGN(4); | |
.data : | |
{ | |
*(.data) | |
} | |
. = ALIGN(4); | |
.bss : | |
{ | |
*(.bss) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
linux下, 我的Makefiles, 目前仅仅是把应用和驱动分开成两个目录,现在所做的工程还比较小以后有必要更细致的划分,将.c文件和.h文件放在不同的目录,不过lua居然也没有分很多目录,所以暂定就这样吧
to do lists: