發表文章

目前顯示的是 8月, 2010的文章

撰寫Makefile教學

撰寫Makefile教學 這裡我們討論當你在Unix like的系統之中如何透過GNU tool幫你建立你整個專案,也許你的程式只有幾個檔案,慢慢用手編是簡單也沒問題,但是如果是大型的專案,超過幾十個檔案而且需要連結不少的函式庫,那你應該怎麼做呢?最方便的就是學習makefile和make指令,使用這個工具幫你做編譯和連結的動作。 ※ 使用make好處 * 透過你所設定的條件幫你編譯好 * 方便專案管理 * 會透過檔案比對,依照相依性來編譯,不會全都編浪費時間 * 可以同時編譯函式庫或是檔案 ※ make常用指令 * make -k: 會讓make在遇到錯誤的時候仍然運行,而不會停在第一個問題 * make -n: 只印出將會進行的工作,而不會真的去執行 * make -f makefile_name: 告訴make需要用那個makefile檔案。當你的make檔不是叫makefile的時候,需要自行透過-f加上你檔案名字,make才找的到你的makefile ※ make指令格式 make [option] [target] option就是上面的設定項目,而target等等會講到,就是我們將要產生出來的目標,可以接很多個目標,如果目標不寫的話預設是all。 Example: make -n all clean make install make make -f makefile2 install ※ 撰寫makefile檔案 makefile是由一堆「目標」和其「相依性檔案」還有「法則」所組成的,而法則在寫的時候前面不可以使用空格,只能使用Tab鍵,而且同一法則要換行的話需要使用'\'字元,而要加入註解的話要用'#'為開頭字元。 * [target] 目標 - 產生出來的東西或某個項目 * [dependency] 相依性項目 - 目標受相依檔案改變需要重新產生目標 * [rule] 法則 - 如何讓相依性項目編譯和連結來產生目標 Example: #這是makefile的格式(註解) [target]: [dependency] [dependency] [TAB][rule] [TAB][rule] [target]: [dependency]

Start telnetd server

1 . linux kernel config check *File systems --> /dev/pts file system for Unix98 PTYs check *Character devices -> Unix98 PTY support 2 . busybox config check *General Configuration -> Support for devfs check *General Configuration -> Use the devpts filesystem for Unix98 PTYs 3 . check /dev/ptmx mknod -m 666 ptmx c 5 2 4 . add telnet for root logins add the following to the end of the file:0~7 表示可以有 8 個連線。 pts/0 pts/1 pts/2 pts/3 pts/4 pts/5 pts/6 pts/7 可以利用下面的 script 建立。 for i in 0 1 2 3 4 5 6 7 do # /bin/mknod /dev/ttyp$i c 3 $i # /bin/mknod /dev/ptyp$i c 2 $i /bin/mknod /dev/pts/$i c 136 $i done 5 . run telnetd /# telnetd PS: busybox config -> Login/Password Management Utilities -> Support for shadow passwords 不用選,還可以省點 size,並且把 /etc/shadow 移除,因為用不到。 另外在 passwd 及 shadow 的密碼都是要加密的,而非 passwd 內的密碼是明碼。 PS: cat /etc/passwd root::0:0:root:/bin:/bin/sh bin::1:1:bin:/bin:/bin/sh guest::6:6:guest:/bin:/bin/sh nobody::99:99:n