URN Logo
UNIX Resources » Linux » China Linux Forum » C/C++编程版 » 20 » 一个通用的Makefile
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
一个通用的Makefile
Author: lenn    Posted: 2006-01-18 09:59    Length: 4,511 byte(s)
[Original] [Print] [Top]
我用了好多年了,好处是添加文件,不需要修改Makefile,会自动扫描新增加的文件,不足的地方是不能同时编译2个可执行文件.不过我所有的工程都在用,实在是很方便, 用的时候请把前面的空格转换成tab, 否则会出错
Makefile :
######################################
#
# Generic makefile
#
# by George Foot
# email: george.foot@merton.ox.ac.uk
# updated by Lenn
# email: liangvy@bigfoot.com
#
# Copyright (c) 1997 George Foot
# All rights reserved.
#
######################################

### Customising
#
# Adjust the following if necessary; EXECUTABLE is the target
# executable's filename, and LIBS is a list of libraries to link in
# (e.g. alleg, stdcx, iostr, etc). You can override these on make's
# command line of course, if you prefer to do it that way.
#
OPENET_LIB := $(HOME)/openetlib
ORACLE_LIB := $(HOME)/orapp-2.0.3
MY_LIB := $(HOME)/lib

ORACLE_VERSION := 9
ORACLE_INCLUDES := -I$(ORACLE_HOME)/rdbms/demo -I$(ORACLE_HOME)/rdbms/public

ORACLE_LIBS := $(ORACLE_HOME)/lib/libclntsh.so
$(ORACLE_HOME)/lib/libwtc$(ORACLE_VERSION).so


VERSION := 1
EXECUTABLE := ubas_gd

LIB_TAG := $(MY_LIB)/libpubd.a $(MY_LIB)/liborapp.a $(ORACLE_LIBS)
LIBS := pthread dl resolv
# Now alter any implicit rules' variables if you like, e.g.:
#

PTHREAD := -pthread -D_PTHREADS

#ORA_FLAGS = -fno-exceptions -fno-rtti -D_REENTRANT=1
ORA_FLAGS = -fno-exceptions -D_REENTRANT=1
CFLAGS := -ggdb -Wall $(ORACLE_INCLUDES) -I$(OPENET_LIB)/include
-I$(OPENET_LIB)/package
-I$(ORACLE_LIB) $(ORA_FLAGS)
# -I/usr/local/include -fno-exceptions -O9 -funroll-loops

CPU_OPTI:= -O9 -funroll-loops -ffast-math -malign-double
-mcpu=pentiumpro -march=pentiumpro
-fomit-frame-pointer -fno-exceptions

CXXFLAGS := $(CFLAGS)

# The next bit checks to see whether rm is in your djgpp bin
# directory; if not it uses del instead, but this can cause (harmless)
# `File not found' error messages. If you are not using DOS at all,
# set the variable to something which will unquestioningly remove
# files.

AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
CCC = $(CROSS_COMPILE)g++
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
RANLIB = $(CROSS_COMPILE)ranlib
MAKE = make

RM := rm -f

# You shouldn't need to change anything below this point.
#

CC := g++
SOURCE := $(wildcard *.c) $(wildcard *.cc)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE)))
DEPS := $(patsubst %.o,%.d,$(OBJS))
MISSING_DEPS := $(filter-out $(wildcard $(DEPS)),$(DEPS))
MISSING_DEPS_SOURCES := $(wildcard $(patsubst %.d,%.c,$(MISSING_DEPS))
$(patsubst %.d,%.cc,$(MISSING_DEPS)))
CPPFLAGS += -MD

.PHONY : everything deps objs clean veryclean rebuild

everything : $(EXECUTABLE)

deps : $(DEPS)

objs : $(OBJS)

clean :
@$(RM) *.o
@$(RM) *.d
@$(RM) $(EXECUTABLE)

rebuild: veryclean everything

ifneq ($(MISSING_DEPS),)
$(MISSING_DEPS) :
@$(RM) $(patsubst %.d,%.o,$@)
endif

-include $(DEPS)

$(EXECUTABLE) : $(OBJS)
echo const char *version = "`date`"; > version.cc
g++ -c -o version.o version.cc
g++ -ggdb -o $(EXECUTABLE) $(OBJS) $(addprefix -l,$(LIBS)) $(LIB_TAG)

----
--
MSN:liangvy@bigfoot.com
[Original] [Print] [Top]
« Previous thread
关于tcp server 的几个简单问题
C/C++编程版
20
Next thread »
请教linux下写大于2G文件问题。
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 03:52:22, cost 0.0366530418396 ms.