10 2012 档案

摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]Postmaster 作为父进程,要对很多子进程进行监控,当遇到各种信号的时候,也要适当地进行传达。/* * pmdie -- signal handler for processing various postmaster signals. */ static void ... 阅读全文
posted @ 2012-10-31 16:15 健哥的数据花园 阅读(564) 评论(0) 推荐(0) 编辑
摘要:上代码学习网络上的文章,http://blog.sina.com.cn/s/blog_602a39250100xfxx.html 非常感谢但是和我的环境有点不一样,我简单改了改程序: [root@localhost wait]# cat waittest.c#include <sys/types.h>#include <sys/wait.h>#include <unistd.h>#include <stdio.h>#include<stdlib.h>main(){ pid_t pc, pr; pc=fork(); if(pc<0 阅读全文
posted @ 2012-10-31 13:29 健哥的数据花园 阅读(182) 评论(0) 推荐(0) 编辑
摘要:如果 我直接 kill 掉 bgwriter 的进程,会发生什么呢?[root@localhost postgresql-9.2.0]# ps -ef|grep postroot 2928 2897 0 10:34 pts/1 00:00:00 su - postgrespostgres 2929 2928 0 10:34 pts/1 00:00:00 -bashpostgres 3101 2929 0 11:09 pts/1 00:00:00 ./postgres -D /usr/local/pgsql/datapostgres 3103 31... 阅读全文
posted @ 2012-10-31 11:16 健哥的数据花园 阅读(280) 评论(0) 推荐(0) 编辑
摘要:bgwriter.c 的代码中有如下部分: pqsignal(SIGQUIT, bg_quickdie); /* hard crash time */[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]还有:/* * bg_quickdie() occurs when signalled SIGQUIT by the postmaster. * * Some backend has bought the farm, * so we need to stop what we're doing and exit. */static voidbg_... 阅读全文
posted @ 2012-10-31 11:07 健哥的数据花园 阅读(523) 评论(0) 推荐(0) 编辑
摘要:上例子 [作者:技术者高健@博客园 mail:luckyjackgao@gmail.com][root@localhost test]# cat exem.c#include <unistd.h>#include <stdio.h>#include <stdlib.h>int main(){ pid_t mpid; mpid=fork(); if( mpid<0) { } else if (mpid==0) { //the child itself ... 阅读全文
posted @ 2012-10-31 09:39 健哥的数据花园 阅读(191) 评论(0) 推荐(0) 编辑
摘要:我用例子来说明:只是一个模拟,我自己做的 假的 bgwriter.c[root@localhost test]# cat bgwriter.c#include<stdio.h>#include<stdlib.h>#include<signal.h>#include "bgwriter.h"#include "guc.h"//some conditions make it change, eg:signalint BgWriterDelay=100;void sighandler(int sig);int main(){ 阅读全文
posted @ 2012-10-31 08:45 健哥的数据花园 阅读(293) 评论(0) 推荐(0) 编辑
摘要:/usr/include/bits/types.h:typedef int __pid_t;/usr/include/unistd.h:typedef __pid_t pid_t; 阅读全文
posted @ 2012-10-31 08:39 健哥的数据花园 阅读(322) 评论(0) 推荐(0) 编辑
摘要:学习网络上的文章:http://blog.sina.com.cn/s/blog_7ffcb1410100s0ut.html然后我自己做了一下简单地验证:[root@localhost test]# cat testjmp.c#include<stdio.h>#include<setjmp.h>jmp_buf ebuf;int ftaste();int main(){ int i; fprintf(stderr,"1\n"); i=setjmp(ebuf); if (i==0) { ftaste(); fprintf(stderr,"This 阅读全文
posted @ 2012-10-30 08:48 健哥的数据花园 阅读(195) 评论(0) 推荐(0) 编辑
摘要:学习了网络上的这篇文章:http://liyong-zone.blog.sohu.com/102060659.html致谢。编译的时候用:g++ -o testsig.o testsig.cpp试着运行了一下:[root@localhost test]# cat testsig.cpp#include <iostream>#include <signal.h>using namespace std;void CatchSigUsr1(int sig){ cout<<"SIGUSR1 Caught"<<endl;}void Ca 阅读全文
posted @ 2012-10-29 16:31 健哥的数据花园 阅读(20472) 评论(0) 推荐(1) 编辑
摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]在bgwriter的代码中,有这样一段,其中的MyProc显得很突兀:/* * Loop forever */ for (;;) { bool can_hibernate; int rc; ... 阅读全文
posted @ 2012-10-29 14:39 健哥的数据花园 阅读(1045) 评论(0) 推荐(0) 编辑
摘要:我找了很多的地方,都没有找到合适的例子。最后从PostgreSQL 的代码入手,找到一些例子,于是我做了一个小练习,还不错。[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]#include "postgres.h"#include "executor/spi.h"#include "utils/builtins.h"#include "catalog/pg_type.h"#ifdef PG_MODULE_MAGICPG_MODULE_MAGIC;#endifint plantes 阅读全文
posted @ 2012-10-29 13:06 健哥的数据花园 阅读(614) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]参考这个例子:http://www.postgresql.org/docs/9.1/static/spi-examples.html如果我们在 src/backend/executor/spi.c 的 SPI_finish 函数处进行调试(增加打印 SPI_finish called)可以发现,如果不在SPI 程序中调用 SPI_finish,其实会有问题。启动PostgreSQL:[root@localhost ~]# su - postgres[postgres@localhost ~]$ cd /usr/ 阅读全文
posted @ 2012-10-29 09:56 健哥的数据花园 阅读(463) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]http://www.postgresql.org/docs/9.1/static/spi-examples.htmlSPI 的例子里面没有说,是如何编译和部署的,我这里补充下:编译与部署:[root@localhost soft]# export LD_LIBRARY_PATH=/usr/local/pgsql/lib[root@localhost soft]# echo $LD_LIBRARY_PATH/usr/local/pgsql/lib[root@localhost test]# cc -fpic - 阅读全文
posted @ 2012-10-29 08:33 健哥的数据花园 阅读(760) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]这个也是从 oid2name 中扒出来的:[postgres@localhost bin]$ ./oid2name -d postgresFrom database "postgres":now: SELECT pg_catalog.pg_relation_filenode(c.oid) as "Filenode", relname as "Table Name" FROM pg_class c LEFT JOIN pg_catalog.pg_name 阅读全文
posted @ 2012-10-26 15:47 健哥的数据花园 阅读(12144) 评论(0) 推荐(0) 编辑
摘要:从 oid2name的代码里扒出来的:postgres=# SELECT d.oid AS Oid,datname AS DatabaseName,spcname AS Tablespacepostgres-# FROM pg_catalog.pg_database d JOIN pg_catalog.pg_tablespace t postgres-# ON (dattablespace = t.oid) order by 2; oid | databasename | tablespace -------+--------------+------------ 12788 | p... 阅读全文
posted @ 2012-10-26 15:02 健哥的数据花园 阅读(619) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]depency.h 中:/* * This enum covers all system catalogs whose OIDs can appear in * pg_depend.classId or pg_shdepend.classId. */ typedef enum ObjectCl... 阅读全文
posted @ 2012-10-26 14:24 健哥的数据花园 阅读(494) 评论(0) 推荐(0) 编辑
摘要:代码位于src/backend/catalog/dependency.c,这里有一个 dodeletion 函数。不过这个函数是通用的。[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]/* * doDeletion: actually delete a single object */ static void doDeletion(const... 阅读全文
posted @ 2012-10-26 13:02 健哥的数据花园 阅读(299) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]模式删除:drop schema 模式名那么具体对应的源代码是那些呢?src/backend/commands/schemacmds.c/* * Guts of schema deletion. */ void RemoveSche... 阅读全文
posted @ 2012-10-26 12:26 健哥的数据花园 阅读(438) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com]主要代码在src/backend/catalog/pg_namespace.c/* ---------------- * NamespaceCreate * * Create a namespace (schema) with the given name and owner OID. * ... 阅读全文
posted @ 2012-10-26 10:38 健哥的数据花园 阅读(370) 评论(0) 推荐(0) 编辑
摘要:shift +G 阅读全文
posted @ 2012-10-26 09:55 健哥的数据花园 阅读(821) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com]PostgreSQL 的模式,我感觉是后来添加的概念。因为在物理存储上,是:base目录下, 一个子目录代表一个数据库。然后再进去,就是一个文件代表一个table了。虽然逻辑上,是 数据库 ->模式->表 但是物理结构确实 /数据库/表 的形式。那么模式的信息存储在什么地方呢?作实验如下:先建立模式:postgres#create schema abababab; CREATE SCHEMA postgres=# \dn List of schemas Name ... 阅读全文
posted @ 2012-10-26 09:36 健哥的数据花园 阅读(3365) 评论(0) 推荐(0) 编辑
摘要:[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com]如果我们不建立自己的表空间,建立表的时候,也不指定表空间。那么,PostgreSQL 不会建立你的表空间,所建立的表,都放入缺省表空间里。如果进行查询:postgres=# select * from pg_tablespace; spcname | spcowner | spcacl | spcoptions ------------+----------+--------+------------ pg_default | 10 | | pg_global | ... 阅读全文
posted @ 2012-10-26 09:25 健哥的数据花园 阅读(2232) 评论(0) 推荐(0) 编辑
摘要:先看有没有脏数据:postgres=# select isdirty from pg_buffercache where isdirty='t'; isdirty ---------(0 rows)此时尚未有脏数据。进一步确认:postgres=# select count(*) from pg_buffercache where isdirty='f'; count ------- 180(1 row)postgres=# select count(*) from pg_buffercache where isdirty='t'; count 阅读全文
posted @ 2012-10-25 13:49 健哥的数据花园 阅读(448) 评论(1) 推荐(0) 编辑
摘要:磨砺技术珠矶,践行数据之道,追求卓越价值回到上一级页面:PostgreSQL内部结构与源代码研究索引页 回到顶级页面:PostgreSQL索引页[作者:技术者高健@博客园 mail:luckyjackgao@gmail.com]pg_buffercache 代码位于 contrib 目录,总体上代码量200多行。刚接触,感觉直接访问PostgreSQL 中的内存结构很神奇,特意学习了一下。/*------------------------------------------------------------------------- * ... 阅读全文
posted @ 2012-10-25 10:59 健哥的数据花园 阅读(1581) 评论(2) 推荐(0) 编辑
摘要:开启postgresql 服务的前提下进入:contrib/pg_buffercache 目录运行 :gmake 然后,运行 gmake install再运行 psql , 在psql 状态下,运行: create extension pg_buffercache然后,仍然在 psql 下, 可以 select * from pg_buffercache 表示安装已经成功。 阅读全文
posted @ 2012-10-25 07:53 健哥的数据花园 阅读(697) 评论(0) 推荐(0) 编辑
摘要:基本关系是:BackgroundWriterMain 循环中,调用 BgBufferSync() -->SyncOneBuffer -->FlushBuffer -->smgrwrite看代码:/* * Main entry point for bgwriter process * * This is invoked from AuxiliaryProcessMain, which has already created the * b... 阅读全文
posted @ 2012-10-24 16:59 健哥的数据花园 阅读(816) 评论(1) 推荐(1) 编辑
摘要:先看代码:src\backend\storage\buffer\bufmgr.c/* * BgBufferSync -- Write out some dirty buffers in the pool. * * This is called periodically by the background writer process. ... 阅读全文
posted @ 2012-10-24 15:32 健哥的数据花园 阅读(880) 评论(0) 推荐(0) 编辑
摘要:代码缩略如下:/* * Main entry point for bgwriter process * * This is invoked from AuxiliaryProcessMain, which has already created the ... 阅读全文
posted @ 2012-10-24 15:05 健哥的数据花园 阅读(594) 评论(0) 推荐(0) 编辑
摘要:看 Postmaster 中如下的代码 /* StartChildProcess -- start an auxiliary process for the postmaster * * xlop determines what kind of child will be started. All child types * initially go to AuxiliaryProcessMain, which will hand... 阅读全文
posted @ 2012-10-24 14:31 健哥的数据花园 阅读(2649) 评论(0) 推荐(0) 编辑
摘要:启动PostgreSQL 进程后,可以看到:[root@localhost ~]# ps -ef | grep post root 2991 2925 0 10:42 pts/1 00:00:00 su - postgres postgres 2992 2991 0 10:42 pts/1 00:00:00 -bash postgres 3029 2992 0 10:42 pts/1 00:00:00 /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data po... 阅读全文
posted @ 2012-10-24 11:22 健哥的数据花园 阅读(5953) 评论(0) 推荐(0) 编辑
摘要:如果设定了虚拟机属性的 General Advance 的Shared Clipboard: Bidirectional 后, 仍然不行。则还需装 Virtual Box 的 增强patch。 然后再在虚拟机启动后,Device-->Install Guest Addition挂Guest Addition光盘。cd /mediacp -r ./VBOXADDITIONS_4.2.0_80737/ /tmp/plus/然后进入/tmp/plus 目录,执行安装程序。 阅读全文
posted @ 2012-10-24 11:10 健哥的数据花园 阅读(3705) 评论(0) 推荐(0) 编辑
摘要:如果采用 Bridge Adapter,如果选择 Intel(R) Gentrino(R) Advanced-N 6205 ,安装CentOS时选 从 DHCP 获得地址(局域网里的DHCP),则会失败。如果把网卡改为 :Intel(R) 82579V Gigabit Network ,则可以成功获得IP地址。 阅读全文
posted @ 2012-10-22 17:17 健哥的数据花园 阅读(291) 评论(0) 推荐(0) 编辑
摘要:在 /etc/init.d 查看,发现有 yum-updatesd用 chkconfig --list yum-updatesd0:off 1:off 2:off 3:on 4:on 5:on 6:off然后 chkconfig --del yum-updatesd再看 chkconfig --list yum-updatesd 就看不到了。重启动后再看看:chkconfig --list yum-updatesd 仍然看不到 yum-updatesd 阅读全文
posted @ 2012-10-22 15:55 健哥的数据花园 阅读(223) 评论(0) 推荐(0) 编辑
摘要:比如我有第二块硬盘。也作好了格式化,那么可以先手工试试好不好用:mount /dev/sdb1 /test成功后,我可以修改 /etc/fstab文件:加入一行:/dev/sdb1 /test ext2 auto 0 0 1. 第一项是 我的存储实体 2. 第二项就是挂入点。 3. 第三项就是文件系统类型 4. 第四项就是mount时,设定的状态,如auto表示自动挂载 5. 第五项是系统DUMP时是否需要BACKUP的标志位。 6. 第六项是是否要在开机时做check的动作。然后启动后,发现确实挂载成功。 阅读全文
posted @ 2012-10-19 15:04 健哥的数据花园 阅读(6087) 评论(0) 推荐(0) 编辑
摘要:比如挂载了磁盘,不知道其类型,可以执行: mount -l 阅读全文
posted @ 2012-10-19 14:51 健哥的数据花园 阅读(266) 评论(0) 推荐(0) 编辑
摘要:出现:WARNING: Re-reading the partition table failed with error 22: Invalid argument.错误,常常是因为在 fdisk 命令中 增删改的顺序有误,导致 fdisk 无所适从。实际已经发生的(被操作改变的)和系统里记录的(也许是 etc/fstab)不一致。此时,可以马上执行 partprobe 来保持一致,然后继续运行 fdisk 阅读全文
posted @ 2012-10-19 14:27 健哥的数据花园 阅读(6742) 评论(0) 推荐(1) 编辑
摘要:磨砺技术珠矶,践行数据之道,追求卓越价值回到上一级页面:PostgreSQL杂记页 回到顶级页面:PostgreSQL索引页首先,由于 历史上的原因,各个操作系统为共存的需要而约定俗成。一个物理磁盘最多有4个主分区。http://www.express.nec.co.jp/linux/distributions/knowledge/system/fdisk.html可以是这样:比如第一块物理磁盘,它一般会有启动分区部分用来包含系统。其余的可以作其他用途。它可能最多包含四个主分区: 第一区:主分区(被设为活动者,启动时,此分区被引导) 第二区:主分区 第三区:主分区 第四区:主分区也可... 阅读全文
posted @ 2012-10-19 14:02 健哥的数据花园 阅读(16318) 评论(0) 推荐(0) 编辑
摘要:根据对PC BIOS 的了解,引导时首先要读入引导扇区。我安装完毕Oracle Enterprise Linux x86_64 5.3以后,用 fdisk -l 看,可以看到:[root@localhost ~]# fdisk -lDisk /dev/sda: 12.8 GB, 12884901888 bytes255 heads, 63 sectors/track, 1566 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks ... 阅读全文
posted @ 2012-10-19 12:42 健哥的数据花园 阅读(1428) 评论(0) 推荐(0) 编辑
摘要:http://stackoverflow.com/search?q=pty+tty&submit=search 阅读全文
posted @ 2012-10-17 15:36 健哥的数据花园 阅读(163) 评论(0) 推荐(0) 编辑
摘要:http://blog.kghost.info/index.php/2012/08/tty-multi-tasking/ 阅读全文
posted @ 2012-10-17 15:25 健哥的数据花园 阅读(165) 评论(0) 推荐(0) 编辑
摘要:Grid Infrastructure 的较好的例子:http://wiki.kinusati.net/index.php/Oracle:Oracle11gR2%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB_with_grid_infrastructure(ASM_%E3%82%B9%E3%82%BF%E3%83%B3%E3%83%88%E3%82%A2%E3%83%AD%E3%83%B3%E6%A7%8B%E6%88%90)(x64_Linux) 阅读全文
posted @ 2012-10-16 17:00 健哥的数据花园 阅读(177) 评论(0) 推荐(0) 编辑
摘要:--安装oracle环境准备创建组和用户groupadd dbagroupadd oinstalluseradd -g oinstall -G dba oraclepasswd oracle修改linux系统内核参数vi /etc/sysctl.conf fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 536870912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 阅读全文
posted @ 2012-10-12 14:38 健哥的数据花园 阅读(1100) 评论(0) 推荐(0) 编辑
摘要:net.ipv4.ip_local_port_range:表示应用程序可使用的IPv4端口范围。net.core.rmem_default:表示套接字接收缓冲区大小的缺省值。net.core.rmem_max:表示套接字接收缓冲区大小的最大值。net.core.wmem_default:表示套接字发送缓冲区大小的缺省值。net.core.wmem_max:表示套接字发送缓冲区大小的最大值。net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.co 阅读全文
posted @ 2012-10-12 14:13 健哥的数据花园 阅读(349) 评论(0) 推荐(0) 编辑
摘要:参考如下链接:http://www.c-lang.net/semctl/index.html不过是日语的。把他的程序重新改动一下,改为一次性为信号集合申请两个信号量:代码变成:#include <stdio.h> #include <unistd.h> #include <sys/wait.h> #include <stdlib.h> #include <sys/sem.h> #define LOCK -1 #define UNLOCK 1 /* semophore operati... 阅读全文
posted @ 2012-10-12 14:09 健哥的数据花园 阅读(500) 评论(0) 推荐(0) 编辑
摘要:推荐以下文章http://www.myexception.cn/operating-system/445637.html#cat /proc/sys/kernel/sem 250 32000 32 128#ipcs -lsmax number of arrays=128max semophore per array = 250max semophores system wide = 32000max ops per semop call =32由此,可以看出, cat /proc/sys/kernel/sem 时候,其顺序是:SEMMNI: Maximum number of semaphor 阅读全文
posted @ 2012-10-12 09:28 健哥的数据花园 阅读(1916) 评论(0) 推荐(1) 编辑
摘要:fs.file-max = 6815744其意义是: 系统中可以同时打开的文件数目。其值相当于 6.5×1024×1024=6.5M 阅读全文
posted @ 2012-10-12 08:39 健哥的数据花园 阅读(5231) 评论(0) 推荐(0) 编辑
摘要:由于看了网上一篇文章很好,特此备忘:http://www.cnblogs.com/hustcat/archive/2009/09/18/1569661.html其中,对异步阻塞机制,以read/poll 函数为例,其实际上是 等待事件通知。调用者仍然会被poll调用阻塞住,停止在poll那个地方。所谓异步,说的是 可以有很多I/O在工作,有了结果会通知调用者,此时poll获得结果。用生活中的例子来看:同步阻塞:一个人早上起来去遛狗,一旦开遛,就一直到结束。同步非阻塞:比如你去发传真,你发了就发了,不用等待对方回应。 再比如你去麦当劳买快餐,你发现人多就决定不买了, ... 阅读全文
posted @ 2012-10-11 13:52 健哥的数据花园 阅读(238) 评论(0) 推荐(0) 编辑
摘要:这个 fs.aio-max-nr 参数,指的是 同时可以拥有的的异步IO请求数目。值出现在 /etc/sysctl.conf 文件中,推荐值是:1048576 其实它等于 1024*1024 也就是 1024K 个。可以参阅网上这篇文章http://johanlouwers.blogspot.com/2010/02/aio-max-nr-parameter-for-oracle.htmlhttp://www.ibm.com/developerworks/linux/library/l-async/ 阅读全文
posted @ 2012-10-11 10:20 健哥的数据花园 阅读(17742) 评论(0) 推荐(1) 编辑
摘要:#ipcs -lmmax number of segments = 4096max seg size(kbytes) = 67108864...而# cat /proc/sys/kernel/shmmax68719476736这个 shmmax 是字节单位,是 单个共享内存段最大字节数。而 ipcs -lm 中的 max seg size 是 k 字节的 。其实是一样的:67108864×1024=68719476736再看#cat /proc/sys/kernel/shmmni4096此值与 ipcs -lm 的 max number of segments 相同。表示共享内存段最 阅读全文
posted @ 2012-10-11 08:09 健哥的数据花园 阅读(446) 评论(0) 推荐(0) 编辑
摘要:继续翻译 For example, you might have a list of object files: objects = foo.o bar.o baz.o To get the list of corresponding source files, you could simply write: $(objects:.o=.c) instead of using the general form: $(patsubst %.o,%.c,$(objects))`$(strip STRING)' ... 阅读全文
posted @ 2012-10-09 15:03 健哥的数据花园 阅读(400) 评论(0) 推荐(0) 编辑
摘要:继续翻译8.2 Functions for String Substitution and Analysis==================================================Here are some functions that operate on strings:`$(subst FROM,TO,TEXT)' Performs a textual replacement on the text TEXT: each occurrence of FROM is replaced by TO. The result is substitut... 阅读全文
posted @ 2012-10-09 14:56 健哥的数据花园 阅读(349) 评论(0) 推荐(0) 编辑
摘要:继续翻译8 Functions for Transforming Text*********************************Functions allow you to do text processing in the makefile to computethe files to operate on or the commands to use in recipes. You use afunction in a "function call", where you give the name of the functionand some text 阅读全文
posted @ 2012-10-09 13:56 健哥的数据花园 阅读(248) 评论(0) 推荐(0) 编辑
摘要:继续翻译7.3 Conditionals that Test Flags================================You can write a conditional that tests `make' command flags such as`-t' by using the variable `MAKEFLAGS' together with the `findstring'function (*note Functions for String Substitution and Analysis: TextFunctions.). 阅读全文
posted @ 2012-10-09 10:20 健哥的数据花园 阅读(261) 评论(0) 推荐(0) 编辑
摘要:继续翻译`ifndef VARIABLE-NAME' If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE is effective; otherwise, the TEXT-IF-FALSE, if any, is effective. The rules for expansion and testing of VARIABLE-NAME are identical to the `ifdef' directive. Extra spaces are allowed and ... 阅读全文
posted @ 2012-10-09 09:46 健哥的数据花园 阅读(219) 评论(0) 推荐(0) 编辑
摘要:继续翻译`ifdef VARIABLE-NAME' The `ifdef' form takes the _name_ of a variable as its argument, not a reference to a variable. The value of that variable has a non-empty value, the TEXT-IF-TRUE is effective; otherwise, the TEXT-IF-FALSE, if any, is effective. Variables that have never ... 阅读全文
posted @ 2012-10-08 14:36 健哥的数据花园 阅读(235) 评论(0) 推荐(0) 编辑
摘要:继续翻译 The syntax of the CONDITIONAL-DIRECTIVE is the same whether theconditional is simple or complex; after an `else' or not. There arefour different directives that test different conditions. Here is atable of them:`ifeq (ARG1, ARG2)'`ifeq 'ARG1' 'ARG2''`ifeq "ARG1& 阅读全文
posted @ 2012-10-08 14:20 健哥的数据花园 阅读(209) 评论(0) 推荐(0) 编辑
摘要:继续翻译7.2 Syntax of Conditionals==========================The syntax of a simple conditional with no `else' is as follows: CONDITIONAL-DIRECTIVE TEXT-IF-TRUE endifThe TEXT-IF-TRUE may be any lines of text, to be considered as part ofthe makefile if the condition is true. If the condition ... 阅读全文
posted @ 2012-10-08 13:59 健哥的数据花园 阅读(169) 评论(0) 推荐(0) 编辑
摘要:继续翻译 As this example illustrates, conditionals work at the textual level:the lines of the conditional are treated as part of the makefile, orignored, according to the condition. This is why the larger syntacticunits of the makefile, such as rules, may cross the beginning or theend of the conditio... 阅读全文
posted @ 2012-10-08 13:47 健哥的数据花园 阅读(226) 评论(0) 推荐(0) 编辑
摘要:继续翻译7 Conditional Parts of Makefiles********************************A "conditional" directive causes part of a makefile to be obeyed orignored depending on the values of variables. Conditionals can comparethe value of one variable to another, or the value of a variable to aconstant string. 阅读全文
posted @ 2012-10-05 14:58 健哥的数据花园 阅读(246) 评论(0) 推荐(0) 编辑
摘要:继续翻译`.FEATURES' Expands to a list of special features supported by this version of `make'. Possible values include: `archives' Supports `ar' (archive) files using special filename syntax. *Note Using `make' to Update Archive Files: Archives. `check-symlink' ... 阅读全文
posted @ 2012-10-05 14:55 健哥的数据花园 阅读(294) 评论(0) 推荐(0) 编辑
摘要:继续翻译`MAKE_RESTARTS' This variable is set only if this instance of `make' has restarted (*note How Makefiles Are Remade: Remaking Makefiles.): it will contain the number of times this instance has restarted. Note this is not the same as recursion (counted by the `MAKELEVEL' varia... 阅读全文
posted @ 2012-10-05 14:29 健哥的数据花园 阅读(382) 评论(0) 推荐(0) 编辑
摘要:继续翻译`.DEFAULT_GOAL' Sets the default goal to be used if no targets were specified on the command line (*note Arguments to Specify the Goals: Goals.). The `.DEFAULT_GOAL' variable allows you to discover the current default goal, restart the default goal selection algorithm by clea... 阅读全文
posted @ 2012-10-05 14:06 健哥的数据花园 阅读(461) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.14 Other Special Variables============================GNU `make' supports some variables that have special properties.`MAKEFILE_LIST' Contains the name of each makefile that is parsed by `make', in the order in which it was parsed. The name is appended just before `make' begins 阅读全文
posted @ 2012-10-05 13:38 健哥的数据花园 阅读(300) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.13 Suppressing Inheritance============================As described in previous sections, `make' variables are inherited byprerequisites. This capability allows you to modify the behavior of aprerequisite based on which targets caused it to be rebuilt. Forexample, you might set a target-spe 阅读全文
posted @ 2012-10-05 13:27 健哥的数据花园 阅读(275) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.12 Pattern-specific Variable Values=====================================In addition to target-specific variable values (*note Target-specificVariable Values: Target-specific.), GNU `make' supportspattern-specific variable values. In this form, the variable isdefined for any target that mat 阅读全文
posted @ 2012-10-05 12:55 健哥的数据花园 阅读(276) 评论(0) 推荐(0) 编辑
摘要:继续翻译 Target-specific variables have the same priority as any othermakefile variable. Variables provided on the command line (and in theenvironment if the `-e' option is in force) will take precedence.Specifying the `override' directive will allow the target-specificvariable value to be prefe 阅读全文
posted @ 2012-10-05 12:05 健哥的数据花园 阅读(267) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.11 Target-specific Variable Values====================================Variable values in `make' are usually global; that is, they are thesame regardless of where they are evaluated (unless they're reset, ofcourse). One exception to that is automatic variables (*note AutomaticVariables: 阅读全文
posted @ 2012-10-05 11:04 健哥的数据花园 阅读(284) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.10 Variables from the Environment===================================Variables in `make' can come from the environment in which `make' isrun. Every environment variable that `make' sees when it starts up istransformed into a `make' variable with the same name and value.However, 阅读全文
posted @ 2012-10-05 09:54 健哥的数据花园 阅读(297) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.9 Undefining Variables========================If you want to clear a variable, setting its value to empty is usuallysufficient. Expanding such a variable will yield the same result (emptystring) regardless of whether it was set or not. However, if you areusing the `flavor' (*note Flavor Fu 阅读全文
posted @ 2012-10-04 16:55 健哥的数据花园 阅读(292) 评论(0) 推荐(0) 编辑
摘要:上例子foo:=foobar=barall: @echo $(flavor $(foo)) @echo $(flavor $(bar))结果:simplerecursive结束 阅读全文
posted @ 2012-10-04 16:53 健哥的数据花园 阅读(374) 评论(0) 推荐(0) 编辑
摘要:继续翻译 You may nest `define' directives: `make' will keep track of nesteddirectives and report an error if they are not all properly closed with`endef'. Note that lines beginning with the recipe prefix characterare considered part of a recipe, so any `define' or `endef' stringsappe 阅读全文
posted @ 2012-10-04 16:19 健哥的数据花园 阅读(288) 评论(0) 推荐(0) 编辑
摘要:上例子define funcfoo: @echo "at foo"endefall: foo @echo "final"$(eval $(call func, foo,abc.c))先不整那些函数参数传递之类的幺蛾子,做一个个简单的例子,运行 make结果是:at foofinal然后再变化下:define func$1: @echo "at foo"endefall: foo @echo "final"$(eval $(call func, foo,abc.c))这次,传递 foo 作为 $1,得到结果相同。基本 阅读全文
posted @ 2012-10-04 15:52 健哥的数据花园 阅读(7337) 评论(0) 推荐(1) 编辑
摘要:上例子reverse=$(2) $(1)foo=$(call reverse, a, b)all: @echo $(foo)运行结果: makeb a结束 阅读全文
posted @ 2012-10-04 15:03 健哥的数据花园 阅读(6668) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.8 Defining Multi-Line Variables=================================Another way to set the value of a variable is to use the `define'directive. This directive has an unusual syntax which allows newlinecharacters to be included in the value, which is convenient fordefining both canned sequences 阅读全文
posted @ 2012-10-04 14:31 健哥的数据花园 阅读(279) 评论(0) 推荐(0) 编辑
摘要:上例子override gao=abcgao=12345all: @echo $(gao)运行的结果,makeabcoverride 指令比其他的变量赋值优先级要高。结束 阅读全文
posted @ 2012-10-04 13:46 健哥的数据花园 阅读(407) 评论(0) 推荐(0) 编辑
摘要:上例子override gao += abcall: @echo $(gao)如果执行 make gao=12345结果为:12345 abc直接写gao += abcall: @echo $(gao)执行 make gao=12345结果是:12345当然,如果直接 make,结果就是 abc 了。结束 阅读全文
posted @ 2012-10-04 13:36 健哥的数据花园 阅读(222) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.7 The `override' Directive============================If a variable has been set with a command argument (*note OverridingVariables: Overriding.), then ordinary assignments in the makefile areignored. If you want to set the variable in the makefile even thoughit was set with a command argu 阅读全文
posted @ 2012-10-04 13:06 健哥的数据花园 阅读(201) 评论(0) 推荐(0) 编辑
摘要:继续翻译 When you add to a variable's value with `+=', `make' actsessentially as if you had included the extra text in the initialdefinition of the variable. If you defined it first with `:=', makingit a simply-expanded variable, `+=' adds to that simply-expandeddefinition, and expan 阅读全文
posted @ 2012-10-04 10:55 健哥的数据花园 阅读(211) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.6 Appending More Text to Variables====================================Often it is useful to add more text to the value of a variable alreadydefined. You do this with a line containing `+=', like this: objects += another.oThis takes the value of the variable `objects', and adds the text 阅读全文
posted @ 2012-10-04 10:28 健哥的数据花园 阅读(196) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.5 Setting Variables=====================To set a variable from the makefile, write a line starting with thevariable name followed by `=' or `:='. Whatever follows the `=' or`:=' on the line becomes the value. For example, objects = main.o foo.o bar.o utils.odefines a variable n 阅读全文
posted @ 2012-10-04 10:05 健哥的数据花园 阅读(183) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.4 How Variables Get Their Values==================================Variables can get values in several different ways: * You can specify an overriding value when you run `make'. *Note Overriding Variables: Overriding. * You can specify a value in the makefile, either with an assignment... 阅读全文
posted @ 2012-10-04 09:32 健哥的数据花园 阅读(171) 评论(0) 推荐(0) 编辑
摘要:上例子首先,在linux 环境中,如此设置:#test=1234567#export test#echo $test1234567#然后编辑 Makefileall: @echo $(test)运行结果:#make 1234567#结束 阅读全文
posted @ 2012-10-04 09:29 健哥的数据花园 阅读(2562) 评论(0) 推荐(0) 编辑
摘要:上例子gao:=123all: @echo $(gao)如果运行 make ,结果是 123如果运行 make gao=456, 结果是456那么如果改变一下呢。比如我们想要:即便你在命令行给出了变量的值,我也不想放弃呢?修改例子:override gao:=123all: @echo $(gao)如果运行 make ,结果是 123因为有 override 的存在,make gao=456 的结果仍然是 123结束 阅读全文
posted @ 2012-10-04 09:02 健哥的数据花园 阅读(626) 评论(0) 推荐(0) 编辑
摘要:继续翻译 The only restriction on this sort of use of nested variablereferences is that they cannot specify part of the name of a functionto be called. This is because the test for a recognized function nameis done before the expansion of nested references. For example, ifdef do_sort func := sort ... 阅读全文
posted @ 2012-10-04 08:51 健哥的数据花园 阅读(221) 评论(0) 推荐(0) 编辑
摘要:继续翻译 A computed variable name need not consist entirely of a singlevariable reference. It can contain several variable references, aswell as some invariant text. For example, a_dirs := dira dirb 1_dirs := dir1 dir2 a_files := filea fileb 1_files := file1 file2 ifeq "$(use_a)"... 阅读全文
posted @ 2012-10-04 08:10 健哥的数据花园 阅读(261) 评论(0) 推荐(0) 编辑
摘要:继续翻译 The previous example shows two levels of nesting, but any number oflevels is possible. For example, here are three levels: x = y y = z z = u a := $($($(x)))Here the innermost `$(x)' expands to `y', so `$($(x))' expands to`$(y)' which in turn expands to `z'; now we have `$(z) 阅读全文
posted @ 2012-10-04 08:04 健哥的数据花园 阅读(201) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.3.2 Computed Variable Names-----------------------------Computed variable names are a complicated concept needed only forsophisticated makefile programming. For most purposes you need notconsider them, except to know that making a variable with a dollar signin its name might have strange resu. 阅读全文
posted @ 2012-10-03 17:31 健哥的数据花园 阅读(201) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.3 Advanced Features for Reference to Variables================================================This section describes some advanced features you can use to referencevariables in more flexible ways.6.3.1 Substitution References-----------------------------A "substitution reference" sub 阅读全文
posted @ 2012-10-03 17:13 健哥的数据花园 阅读(255) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.2 The Two Flavors of Variables================================There are two ways that a variable in GNU `make' can have a value; wecall them the two "flavors" of variables. The two flavors aredistinguished in how they are defined and in what they do when expanded. The first flavo 阅读全文
posted @ 2012-10-03 14:27 健哥的数据花园 阅读(364) 评论(0) 推荐(0) 编辑
摘要:继续翻译6.1 Basics of Variable References=================================To substitute a variable's value, write a dollar sign followed by thename of the variable in parentheses or braces: either `$(foo)' or`${foo}' is a valid reference to the variable `foo'. This specialsignificance of 阅读全文
posted @ 2012-10-03 11:01 健哥的数据花园 阅读(255) 评论(0) 推荐(0) 编辑
摘要:继续翻译6 How to Use Variables**********************A "variable" is a name defined in a makefile to represent a string oftext, called the variable's "value". These values are substituted byexplicit request into targets, prerequisites, recipes, and other partsof the makefile. (In 阅读全文
posted @ 2012-10-03 10:19 健哥的数据花园 阅读(270) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.9 Using Empty Recipes=======================It is sometimes useful to define recipes which do nothing. This is donesimply by giving a recipe that consists of nothing but whitespace. Forexample: target: ;defines an empty recipe for `target'. You could also use a linebeginning with a reci... 阅读全文
posted @ 2012-10-02 15:27 健哥的数据花园 阅读(341) 评论(0) 推荐(0) 编辑
摘要:继续翻译 To use the canned sequence, substitute the variable into the recipeof a rule. You can substitute it like any other variable (*note Basicsof Variable References: Reference.). Because variables defined by`define' are recursively expanded variables, all the variablereferences you wrote inside 阅读全文
posted @ 2012-10-02 14:48 健哥的数据花园 阅读(229) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.8 Defining Canned Recipes===========================When the same sequence of commands is useful in making various targets,you can define it as a canned sequence with the `define' directive, andrefer to the canned sequence from the recipes for those targets. Thecanned sequence is actually 阅读全文
posted @ 2012-10-02 14:09 健哥的数据花园 阅读(173) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.7.4 The `--print-directory' Option------------------------------------If you use several levels of recursive `make' invocations, the `-w' or`--print-directory' option can make the output a lot easier tounderstand by showing each directory as `make' starts processing it anda 阅读全文
posted @ 2012-10-02 13:10 健哥的数据花园 阅读(300) 评论(0) 推荐(0) 编辑
摘要:继续翻译 A similar variable `MFLAGS' exists also, for historicalcompatibility. It has the same value as `MAKEFLAGS' except that itdoes not contain the command line variable definitions, and it alwaysbegins with a hyphen unless it is empty (`MAKEFLAGS' begins with ahyphen only when it begins 阅读全文
posted @ 2012-10-02 12:37 健哥的数据花园 阅读(317) 评论(0) 推荐(0) 编辑
摘要:继续翻译 If you do not want to pass the other flags down, you must change thevalue of `MAKEFLAGS', like this: subsystem: cd subdir && $(MAKE) MAKEFLAGS= The command line variable definitions really appear in the variable`MAKEOVERRIDES', and `MAKEFLAGS' contains a reference to this va 阅读全文
posted @ 2012-10-02 10:33 健哥的数据花园 阅读(315) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.7.3 Communicating Options to a Sub-`make'-------------------------------------------Flags such as `-s' and `-k' are passed automatically to the sub-`make'through the variable `MAKEFLAGS'. This variable is set upautomatically by `make' to contain the flag letters that `m 阅读全文
posted @ 2012-10-02 10:04 健哥的数据花园 阅读(213) 评论(0) 推荐(0) 编辑
摘要:继续翻译 You may notice that the `export' and `unexport' directives work in`make' in the same way they work in the shell, `sh'. If you want all variables to be exported by default, you can use`export' by itself: exportThis tells `make' that variables which are not explicitly ment 阅读全文
posted @ 2012-10-01 17:42 健哥的数据花园 阅读(389) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.7.2 Communicating Variables to a Sub-`make'---------------------------------------------Variable values of the top-level `make' can be passed to the sub-`make'through the environment by explicit request. These variables aredefined in the sub-`make' as defaults, but do not overr 阅读全文
posted @ 2012-10-01 16:02 健哥的数据花园 阅读(417) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.7.1 How the `MAKE' Variable Works-----------------------------------Recursive `make' commands should always use the variable `MAKE', notthe explicit command name `make', as shown here: subsystem: cd subdir && $(MAKE) The value of this variable is the file name with whic 阅读全文
posted @ 2012-10-01 14:08 健哥的数据花园 阅读(308) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.7 Recursive Use of `make'===========================Recursive use of `make' means using `make' as a command in a makefile.This technique is useful when you want separate makefiles for varioussubsystems that compose a larger system. For example, suppose you havea subdirectory `subdi 阅读全文
posted @ 2012-10-01 14:07 健哥的数据花园 阅读(338) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.6 Interrupting or Killing `make'==================================If `make' gets a fatal signal while a shell is executing, it may deletethe target file that the recipe was supposed to update. This is doneif the target file's last-modification time has changed since `make'first 阅读全文
posted @ 2012-10-01 13:41 健哥的数据花园 阅读(211) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.5 Errors in Recipes=====================After each shell invocation returns, `make' looks at its exit status.If the shell completed successfully (the exit status is zero), the nextline in the recipe is executed in a new shell; after the last line isfinished, the rule is finished. If there 阅读全文
posted @ 2012-10-01 13:02 健哥的数据花园 阅读(374) 评论(0) 推荐(0) 编辑
摘要:继续翻译 We will change how this aspect of `make' works if we find a betteralternative. In the mean time, you should not rely on any recipe usingstandard input at all if you are using the parallel execution feature;but if you are not using this feature, then standard input worksnormally in all recip 阅读全文
posted @ 2012-10-01 10:58 健哥的数据花园 阅读(192) 评论(0) 推荐(0) 编辑
摘要:继续翻译5.4 Parallel Execution======================GNU `make' knows how to execute several recipes at once. Normally,`make' will execute only one recipe at a time, waiting for it to finishbefore executing the next. However, the `-j' or `--jobs' option tells`make' to execute many rec 阅读全文
posted @ 2012-10-01 10:15 健哥的数据花园 阅读(277) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示