2007年7月4日 星期三

makefile, go to each modules

MODULES += UMDToday

all:
@for modules in $(MODULES); do \
make -C $$modules; \
cp -rf ./$$modules/release/* ./release; \
done;

clean:
@for modules in $(MODULES); do \
make clean -C $$modules; \
done;

set environment variable to the command

[will@localhost config]$ cat sendmail.sh
#!/bin/sh

LIST="a b c d e"

for list in $LIST; do\

cat /home/will/log.txt | LD_LIBRARY_PATH=/usr/local/lib /home/will/smtpsend $list > /dev/null 2>&1; \
done;

find with exec

find tmp/ -name ".svn" -exec rm -rf {} \;


find tmp/ -name "a" -exec ls {} \;

my indent coding style

[will@localhost config]$ cat indent.sh
# Will.20070509: linux coding style
dos2unix $*
indent -nbad -bap -nbc -bbo -br -bli2 -bls -ncdb -nce -cp1 -cs -di2 -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -psl -nsc -nsob -l100 $*
[will@localhost config]$

use shared library during runtime

[will@localhost DynamicLibrary]$ cat dl.test.c
#include <dlfcn.h>

#include <stdio.h>

main ()

{

void *libc;

void (*printf_call) ();

if (libc = dlopen ("/lib/libc.so.6", RTLD_LAZY))
{


printf_call = dlsym (libc, "printf");
(*printf_call) ("hello, world\n");

}

dlclose (libc);

}

[will@localhost DynamicLibrary]$

Make Dynamic Shared Library

gcc -fPIC -c mylib.*.c
gcc -shared -Wl,-soname,libxxx.so -o libxxx.so *.o

Make a Static Library

gcc -c mylib.*
ar rcs mylib.a *.o
gcc xxx.c mylib.a

網誌存檔

關於我自己