LinuxÏÂCÓïÑÔ±à³Ì»ù´¡(Makefile)
LinuxÏÂCÓïÑÔ±à³Ì»ù´¡(Makefile)
2005-01-18 10:28:23 À´×Ô£ºÈüµÏÍø
¼ÙÉèÎÒÃÇÓÐÏÂÃæÕâÑùµÄÒ»¸ö³ÌÐò£¬Ô´´úÂëÈçÏ£º
/* main.c */
#include "mytool1.h"
#include "mytool2.h"
int main(int argc£¬char **argv)
{
mytool1_print("hello")£»
mytool2_print("hello")£»
}
/* mytool1.h */
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H
void mytool1_print(char *print_str)£»
#endif
/* mytool1.c */
#include "mytool1.h"
void mytool1_print(char *print_str)
{
printf("This is mytool1 print %s "£¬print_str)£»
}
/* mytool2.h */
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_H
void mytool2_print(char *print_str)£»
#endif
/* mytool2.c */
#include "mytool2.h"
void mytool2_print(char *print_str)
{
printf("This is mytool2 print %s "£¬print_str)£»
}
µ±È»ÓÉÓÚÕâ¸ö³ÌÐòºÜ¶Ì£¬ÎÒÃÇ¿ÉÒÔÕâÑùÀ´±àÒë:
gcc -c main.c
gcc -c mytool1.c
gcc -c mytool2.c
gcc -o main main.o mytool1.o mytool2.o
Õâ
ÑùµÄ»°ÎÒÃÇÒ²¿ÉÒÔ²úÉúmain³ÌÐò£¬¶øÇÒÒ²²»ÊǺÜÂé·³¡£µ«ÊÇÈç¹ûÎÒÃÇ¿¼ÂÇÒ»ÏÂÈç¹ûÓÐÒ»ÌìÎÒÃÇÐÞ¸ÄÁËÆäÖеÄÒ»¸öÎļþ(±ÈÈç˵mytool1.c)ÄÇôÎÒÃÇÄÑ
µÀ»¹ÒªÖØÐÂÊäÈëÉÏÃæµÄÃüÁî?Ò²ÐíÄã»á˵£¬Õâ¸öºÜÈÝÒ×½â¾ö°¡£¬ÎÒдһ¸ö
SHELL½Å±¾£¬ÈÃËü°ïÎÒÈ¥Íê³É²»¾Í¿ÉÒÔÁË¡£ÊǵĶÔÓÚÕâ¸ö³ÌÐòÀ´Ëµ£¬ÊÇ¿ÉÒÔÆðµ½×÷Óõġ£µ«Êǵ±ÎÒÃǰÑÊÂÇéÏëµÄ¸ü¸´ÔÓÒ»µã£¬Èç¹ûÎÒÃǵijÌÐòÓм¸°Ù¸öÔ´³ÌÐòµÄ
ʱºò£¬ÄѵÀÒ²Òª±àÒëÆ÷ÖØÐÂÒ»¸öÒ»¸öµÄÈ¥±àÒë?
Ϊ´Ë£¬´ÏÃ÷µÄ³ÌÐòÔ±ÃÇÏë³öÁËÒ»¸öºÜºÃµÄ¹¤¾ßÀ´×öÕâ¼þÊÂÇ飬Õâ¾ÍÊÇmake¡£ÎÒÃÇÖ»ÒªÖ´ÐÐ
ÒÔÏÂmake£¬¾Í¿ÉÒÔ°ÑÉÏÃæµÄÎÊÌâ½â¾öµô¡£ÔÚÎÒÃÇÖ´ÐÐmake֮ǰ£¬ÎÒÃÇÒªÏȱàдһ¸ö·Ç³£ÖØÒªµÄÎļþ¡£--Makefile¡£¶ÔÓÚÉÏÃæµÄÄǸö³ÌÐòÀ´Ëµ£¬¿É
ÄܵÄÒ»¸öMakefileµÄÎļþÊÇ£º
# ÕâÊÇÉÏÃæÄǸö³ÌÐòµÄMakefileÎļþ:
main£ºmain.o mytool1.o mytool2.o
gcc -o main main.o mytool1.o mytool2.o
main.o£ºmain.c mytool1.h mytool2.h
gcc -c main.c
mytool1.o£ºmytool1.c mytool1.h
gcc -c mytool1.c
mytool2.o£ºmytool2.c mytool2.h
gcc -c mytool2.c
ÓÐÁËÕâ¸öMakefileÎļþ£¬²»ÂÛÎÒÃÇʲôʱºòÐÞ¸ÄÁËÔ´³ÌÐòµ±ÖеÄʲôÎļþ£¬ÎÒÃÇÖ»ÒªÖ´ÐÐmakeÃüÁÎÒÃǵıà
Ïà¹ØÎĵµ£º
1.ÇóÏÂÃæº¯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
¡¡¡¡int func(x)
¡¡¡¡{
¡¡¡¡int countx = 0;
¡¡¡¡while(x)
¡¡¡¡{
¡¡¡¡countx ++;
¡¡¡¡x = x&(x-1);
¡¡¡¡}
¡¡¡¡return countx;
¡¡¡¡}
¡¡¡¡¼Ù¶¨x = 9999¡£ ´ð°¸£º8
¡¡¡¡Ë¼Â·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
¡¡¡¡2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓ ......
ÕâÁ½Ìì¿´µ½ÓÐÈËÌÖÂ۵绰¼üÅÌÉϵÄ×Öĸ¡¢ºÅÂëºÍ×ÖĸµÄת»»£¬ÎÒÒ²Ëæ±ãдÁËÒ»¶Î
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_LEN 15
char *tbl_itoa[] =
{
"0", // 0
"1", // 1
"ABC", // 2
"DEF", // 3
"GHI", // 4
"JKL", // 5
"MNO", ......
/*
kmalloc can apply 128KB memory only. This func support any continous memory allocate more than 2MB.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#define KMEM_PAGES &nb ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå" ......
Ò»±ßѧϰubuntu,Ò»±ß·¢ÏÖÎÊÌ⣬Ŀǰ·¢ÏÖµÄÎÊÌâÓÐÒÔϼ¸¸ö£¬²¢³É¹¦½â¾ö¡£
Ê×ÏÈ£¬´ò¿ªfirefox,flash²»ÄÜÕýÈ·ÏÔʾ£¬°²×°adobe flash ×îвå¼þ¾Í¿ÉÒÔ½â¾ö£¬ÆäËûflash²å¼þЧ¹û²»Ì«ºÃ¡£ºóÀ´´ò¿ªQQÅ©³¡µÄflash£¬ÖÐÎÄÏÔʾ¿Õ¸ñ£¬½â¾ö·½·¨£¬´ò¿ªÖÕ¶Ë£¬ÊäÈëÒÔÏÂÃüÁ ......