前人移植LwIP协议栈时,写了个非常龌龊的Makefile,忍无可忍的逼着我重写了一篇,当后人看到我写的Makefile时,历史也会这样一直在重演。。。。
FILE: .bashrc (CYGWIN platform)
=============================================================================
.....
export GCC_ARM_410=/cygdrive/c/Progra~1/GNUARM.410
export MONITOR=/cygdrive/e/work/S80/Monitor/APP_Monitor
export PATH=${GCC_ARM_410}/bin:${GCC_ARM_410}/arm-elf/bin:${GCC_ARM_410}/libexec/gcc/arm-elf/4.1.0:$PATH
.....
=============================================================================
FILE: Makefile.bat (WINDOW platform)
=============================================================================
@echo off
rem GCC_ARM_410 tool chain and MONITOR path
set GCC_ARM_410=C:\Progra~1\GNUARM.410
set MONITOR=E:\work\S80\Monitor\APP_Monitor
rem path to common enviroment
set MYPATH=%PATH%
set PATH=%GCC_ARM_410%\bin;%GCC_ARM_410%\arm-elf\bin;%GCC_ARM_410%\libexec\gcc\arm-elf\4.1.0;%PATH%
set INSTALL_DIR=%MONITOR%\make
if "%2"=="help" goto out
if "%2"=="?" goto out
if "%2"=="-?" goto out
if "%2"=="clean" (make POS=%1 clean) else if "%2"=="release" (make POS=%1 IP_VERSION_SELECT=release) else if "%2"=="debug" (make POS=%1 IP_VERSION_SELECT=debug) else goto out
goto exit
:out
echo -------------------------------------------------------------
echo Makefile.bat [POS] [argument]
echo argument list:
echo clean --- del all objs
echo debug --- build lib with debug information outputing
echo release --- build lib without debug information outputing
echo example: "Makefile.bat S80 debug"
echo -------------------------------------------------------------
:exit
rem resume to old path
set PATH=%MYPATH%
cmd.exe
=============================================================================
FILE: Makefile
=============================================================================
##################################################################
# @file: Makefile
# @author: NO.773 (xxx@xxx.com)
# history:
# @20110521: initial
#
##################################################################
GCC_PATH = $(GCC_ARM_410)
MONITOR_ROOT_DIR = $(MONITOR)
INSTALL_DIR=${MONITOR}/make
GCC_INC_PATH = \
-I$(GCC_PATH)/arm-elf/include \
-I$(GCC_PATH)/lib/gcc/arm-elf/4.1.0/include
GCC_BIN_PATH = $(GCC_PATH)/arm-elf/bin
MOINTOR_SRC_DIR = $(MONITOR_ROOT_DIR)/source
ENCRYPT_DIR = $(MOINTOR_SRC_DIR)/encrypt
COMM_DIR = $(MOINTOR_SRC_DIR)/comm
###############################################
# Tools
###############################################
GCC = $(GCC_BIN_PATH)/gcc
AR = $(GCC_BIN_PATH)/ar -r
ifdef COMSPEC
DEL = rm
MKDIR = mkdir
COPY = cp
MK = make
else
CYG_BIN = d:/cygwin/bin
DEL = $(CYG_BIN)/rm
MKDIR = $(CYG_BIN)/mkdir
COPY = $(CYG_BIN)/cp
MK = $(CYG_BIN)/make
endif
###############################################
# complier flags
###############################################
CFLAGS = \
-mcpu=arm9tdmi -fsigned-char -mlittle-endian \
-g -O1 -c -mthumb-interwork \
$(GCC_INC_PATH) -I $(MONITOR_ROOT_DIR)/inc
###############################################
# POS type selected, S80 by default
###############################################
POS ?= S80
PRJ_NAME = $(POS)
###############################################
# common part
###############################################
include rule_ex.mk
=============================================================================
FILE: rule_ex.mk
=============================================================================
##################################################################
# @file: rule_ex.mk
# @author: NO.773 (xxx@xxx.com)
# history:
# @20110521: initial
#
##################################################################
GCC_PATH = $(GCC_ARM_410)
MONITOR_ROOT_DIR = $(MONITOR)
ifeq ($(IP_VERSION_SELECT),release)
IP_DEBUG :=
LIB_POSTFIX :=
TESTCASE_OBJ :=
else
IP_DEBUG := -DNET_DEBUG
LIB_POSTFIX := _Debug
ifndef NO_TESTCASE
TESTCASE_OBJ = $(LOCOBJ)/inet_main.o $(LOCOBJ)/read_write.o
endif
endif
TARGET := libip$(PRJ_NAME)$(LIB_POSTFIX).a
all: $(TARGET)
IPS_DIR = ..
PPP_DIR = $(IPS_DIR)/ppp
LOCOBJ = $(IPS_DIR)/objs/$(PRJ_NAME)_objs
IPS_INC = \
-I$(IPS_DIR)/include \
-I$(COMM_DIR) \
-I$(ENCRYPT_DIR) \
-I$(MOINTOR_SRC_DIR) \
IPS_FLAGS = $(CFLAGS) $(IPS_INC) -D$(PRJ_NAME) -DNET_VERSION=0x15 $(IP_DEBUG)
# PPP SOURCE
PPP_SRC = \
$(PPP_DIR)/gprs_ppp.c \
$(PPP_DIR)/pppoe.c \
$(PPP_DIR)/modem_ppp.c \
$(PPP_DIR)/ppp.c \
$(PPP_DIR)/mschap.c \
$(PPP_DIR)/md4.c \
$(PPP_DIR)/cbc_enc.c \
$(PPP_DIR)/des_enc.c \
$(PPP_DIR)/sha1_one.c \
$(PPP_DIR)/sha1dgst.c \
$(PPP_DIR)/ecb_enc.c \
$(PPP_DIR)/set_key.c \
$(PPP_DIR)/ppp_md5.c \
$(PPP_DIR)/md5.c \
# MD5 SOURCE
MD5_SRC = \
$(ENCRYPT_DIR)/md5c.c \
# IP STACK SOURCE
IPS_SRC = \
$(IPS_DIR)/eth_dev/dm9ks.c \
$(IPS_DIR)/core/inet_timer.c \
$(IPS_DIR)/core/ip_addr.c \
$(IPS_DIR)/core/skbuff.c \
$(IPS_DIR)/core/uart_print.c \
$(IPS_DIR)/core/inet.c \
$(IPS_DIR)/core/inet_softirq.c \
$(IPS_DIR)/core/mem_pool.c \
$(IPS_DIR)/ipv4/arp.c \
$(IPS_DIR)/ipv4/ethernet.c \
$(IPS_DIR)/ipv4/ip.c \
$(IPS_DIR)/ipv4/tcp.c \
$(IPS_DIR)/ipv4/tcp_in.c \
$(IPS_DIR)/ipv4/tcp_out.c \
$(IPS_DIR)/ipv4/icmp.c \
$(IPS_DIR)/core/dev.c \
$(IPS_DIR)/ipv4/udp.c \
$(IPS_DIR)/ipv4/dhcpc.c \
$(IPS_DIR)/core/socket.c \
$(IPS_DIR)/core/softirq.c \
$(IPS_DIR)/core/sys_softirq.c \
$(IPS_DIR)/core/netapi.c \
$(IPS_DIR)/core/ip_ver.c \
$(IPS_DIR)/ipv4/dns.c \
$(IPS_DIR)/testcase/read_write.c \
$(IPS_DIR)/testcase/inet_main.c \
$(IPS_DIR)/testcase/s60t_test.c \
$(IPS_DIR)/proxy/base_proxy.c \
$(IPS_DIR)/proxy/app_proxy.c \
$(IPS_DIR)/proxy/app_api.c \
$(IPS_DIR)/proxy/cmd_index.c \
#$(IPS_DIR)/irda/irda_proto.c \
#$(IPS_DIR)/irda/irda_hand_phy.c \
#$(IPS_DIR)/irda/irda_base_phy.c \
#$(IPS_DIR)/irda/irda_test.c \
#$(IPS_DIR)/core/ppp_p60.c \
OBJS := $(subst .c,.o,$(IPS_SRC))
OBJS += $(subst .c,.o,$(PPP_SRC))
OBJS += $(subst .c,.o,$(MD5_SRC))
$(TARGET): $(OBJS)
$(AR) $@ $^
$(MKDIR) -p $(LOCOBJ)
$(COPY) $@ $(INSTALL_DIR)
release:
$(MK) $(TARGET) IP_VERSION_SELECT=release
debug:
$(MK) $(TARGET) IP_VERSION_SELECT=debug
clean:
$(DEL) $(OBJS)
$(DEL) ./libip$(PRJ_NAME)*.a
##################################################
# common part
##################################################
%.o: %.c
$(GCC) $< $(IPS_FLAGS) -o $@
=============================================================================
好,打完收工!
阅读(2362) | 评论(0) | 转发(0) |