顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2012年4月26日 星期四

GNU Cross Compiler 編譯程序

寫了一個 Makefile,可以半自動的編譯 GNU Cross Compiler
做個記錄,怕以後忘記

#TARGET = arm-elf
#TARGET = mips-elf
TARGET = sparc-elf

PKG_DIR = $(CURDIR)/PKG
SRC_DIR = $(CURDIR)/SRC
BUILD_DIR = $(CURDIR)/BUILD-$(TARGET)
TARGET_DIR = /srv/xfile/compiler/$(TARGET)-4.7.0

BINUTILS_VER = binutils-2.22
GCC_VER = gcc-4.7.0
MPC_VER = mpc-0.9
MPFR_VER = mpfr-3.1.0
GMP_VER = gmp-5.0.4
NEWLIB_VER = newlib-1.20.0
GDB_VER = gdb-7.3.1
INSIGHT_VER = insight-6.8-1

GCC_PACKAGE = $(PKG_DIR)/gcc/$(GCC_VER).tar.bz2
GCC_SRC_DIR = $(SRC_DIR)/$(GCC_VER)
GCC_BUILD_DIR = $(BUILD_DIR)/$(GCC_VER)

GMP_PACKAGE = $(PKG_DIR)/gmp/$(GMP_VER).tar.bz2
GMP_SRC_DIR = $(SRC_DIR)/$(GMP_VER)
GMP_BUILD_DIR = $(BUILD_DIR)/$(GMP_VER)

MPFR_PACKAGE = $(PKG_DIR)/mpfr/$(MPFR_VER).tar.bz2
MPFR_SRC_DIR = $(SRC_DIR)/$(MPFR_VER)
MPFR_BUILD_DIR = $(BUILD_DIR)/$(MPFR_VER)

MPC_PACKAGE = $(PKG_DIR)/mpc/$(MPC_VER).tar.gz
MPC_SRC_DIR = $(SRC_DIR)/$(MPC_VER)
MPC_BUILD_DIR = $(BUILD_DIR)/$(MPC_VER)

BINUTILS_PACKAGE = $(PKG_DIR)/binutils/$(BINUTILS_VER).tar.bz2
BINUTILS_SRC_DIR = $(SRC_DIR)/$(BINUTILS_VER)
BINUTILS_BUILD_DIR = $(BUILD_DIR)/$(BINUTILS_VER)

GDB_PACKAGE = $(PKG_DIR)/gdb/$(GDB_VER).tar.gz
GDB_SRC_DIR = $(SRC_DIR)/$(GDB_VER)
GDB_BUILD_DIR = $(BUILD_DIR)/$(GDB_VER)

NEWLIB_PACKAGE = $(PKG_DIR)/newlib/$(NEWLIB_VER).tar.gz
NEWLIB_SRC_DIR = $(SRC_DIR)/$(NEWLIB_VER)
NEWLIB_BUILD_DIR = $(BUILD_DIR)/$(NEWLIB_VER)

INSIGHT_PACKAGE = $(PKG_DIR)/insight/$(INSIGHT_VER).tar.bz2
INSIGHT_SRC_DIR = $(SRC_DIR)/$(INSIGHT_VER)
INSIGHT_BUILD_DIR = $(BUILD_DIR)/$(INSIGHT_VER)

CONFIG_FLAGS = --target=$(TARGET) \
--prefix=$(TARGET_DIR)
note:
@echo ----------------------------------------
@echo make binutils # Build binutils
@echo make gcc-p0 # Build GMP, MPFR, MPC
@echo make gcc-p1 # Build GCC Pass-1
@echo make newlib # Build newlib
@echo make gcc-p2 # Build GCC Pass-2
@echo make insight # Build insight
@echo ----------------------------------------

all: binutils gcc-p0 gcc-p1 newlib gcc-p2 insight

dir : src_dir

# Source Decompress

src_dir: $(BINUTILS_SRC_DIR) $(NEWLIB_SRC_DIR) $(GCC_SRC_DIR) $(GDB_SRC_DIR) $(INSIGHT_SRC_DIR) $(GMP_SRC_DIR) $(MPFR_SRC_DIR) $(MPC_SRC_DIR)

build_dir: $(BINUTILS_BUILD_DIR) $(NEWLIB_BUILD_DIR) $(GCC_BUILD_DIR) $(GDB_BUILD_DIR)

# ------------- BINUTIL ----------------

BINUTILS_CONF = $(CONFIG_FLAGS) --disable-nls

binutils: $(BINUTILS_BUILD_DIR)
@echo "****** Build $(BINUTILS_VER) ***********"
(cd $(BINUTILS_BUILD_DIR); $(BINUTILS_SRC_DIR)/configure $(BINUTILS_CONF);)
(cd $(BINUTILS_BUILD_DIR); make all install)

$(BINUTILS_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(BINUTILS_PACKAGE) ***********"
-@mkdir $(BINUTILS_SRC_DIR)
(cd $(SRC_DIR); tar -jxvf $(BINUTILS_PACKAGE))

$(BINUTILS_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(BINUTILS_BUILD_DIR) ***********"
-@mkdir $(BINUTILS_BUILD_DIR)

# ------------- NEWLIB ----------------

NEWLIB_CONF = $(CONFIG_FLAGS) --disable-nls

newlib: $(NEWLIB_BUILD_DIR)
@echo "****** Build $(NEWLIB_VER) ***********"
(set path = $(TARGET_DIR)/bin;cd $(NEWLIB_BUILD_DIR);$(NEWLIB_SRC_DIR)/configure $(NEWLIB_CONF);)
(cd $(NEWLIB_BUILD_DIR); make all install)

$(NEWLIB_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(NEWLIB_PACKAGE) ***********"
(cd $(SRC_DIR); tar -zxvf $(NEWLIB_PACKAGE))

$(NEWLIB_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(NEWLIB_BUILD_DIR) ***********"
-@mkdir $(NEWLIB_BUILD_DIR)

# ------------- GDB ----------------

GDB_CONF = $(CONFIG_FLAGS) --disable-nls

gdb: $(GDB_BUILD_DIR)
@echo "****** Build $(GDB_VER) ***********"
(cd $(GDB_BUILD_DIR); $(GDB_SRC_DIR)/configure $(GDB_CONF);)
(cd $(GDB_BUILD_DIR); make all install))

$(GDB_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(GDB_PACKAGE) ***********"
(cd $(SRC_DIR); tar -zxvf $(GDB_PACKAGE))

$(GDB_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(GDB_BUILD_DIR) ***********"
-@mkdir $(GDB_BUILD_DIR)

# ------------- INSIGHT ----------------
INSIGHT_CONF = $(CONFIG_FLAGS) --disable-nls --disable-werror

insight: $(INSIGHT_BUILD_DIR)
@echo "****** Build $(INSIGHT_VER) ***********"
(cd $(INSIGHT_BUILD_DIR); $(INSIGHT_SRC_DIR)/configure $(INSIGHT_CONF);)
(cd $(INSIGHT_BUILD_DIR); make all install)

$(INSIGHT_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(INSIGHT_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(INSIGHT_PACKAGE))

$(INSIGHT_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(INSIGHT_BUILD_DIR) ***********"
-@mkdir $(INSIGHT_BUILD_DIR)

# ------------- gcc-p0 ----------------

gcc-p0: gmp mpfr mpc

# ------------- GMP ----------------

GMP_CONF = --prefix=$(TARGET_DIR)

gmp: $(GMP_BUILD_DIR)
@echo "****** Build $(GMP_VER) ***********"
(cd $(GMP_BUILD_DIR); $(GMP_SRC_DIR)/configure $(GMP_CONF);)
(cd $(GMP_BUILD_DIR); make all install)

$(GMP_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(INSIGHT_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(GMP_PACKAGE))

$(GMP_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(GMP_BUILD_DIR) ***********"
-@mkdir $(GMP_BUILD_DIR)

# ------------- MPFR ----------------

MPFR_CONF = --prefix=$(TARGET_DIR) \
--with-gmp=$(TARGET_DIR)

mpfr: $(MPFR_BUILD_DIR)
@echo "****** Build $(MPFR_VER) ***********"
(cd $(MPFR_BUILD_DIR); $(MPFR_SRC_DIR)/configure $(MPFR_CONF);)
(cd $(MPFR_BUILD_DIR); make all install)

$(MPFR_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(MPFR_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(MPFR_PACKAGE))

$(MPFR_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(MPFR_BUILD_DIR) ***********"
-@mkdir $(MPFR_BUILD_DIR)

# ------------- MPC ----------------

MPC_CONF = --prefix=$(TARGET_DIR) \
--with-gmp=$(TARGET_DIR) \
--with-mpfr=$(TARGET_DIR)

mpc: $(MPC_BUILD_DIR)
@echo "****** Build $(MPC_VER) ***********"
(cd $(MPC_BUILD_DIR); $(MPC_SRC_DIR)/configure $(MPC_CONF);)
(cd $(MPC_BUILD_DIR); make all install)

$(MPC_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(MPC_PACKAGE) ***********"
(cd $(SRC_DIR); tar -zxvf $(MPC_PACKAGE))

$(MPC_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(MPC_BUILD_DIR) ***********"
-@mkdir $(MPC_BUILD_DIR)

# ------------- GCC ----------------
GCC_CONF = $(CONFIG_FLAGS) \
--enable-interwork \
--disable-multilib \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-decimal-float \
--disable-libmudflap \
--disable-libssp \
--disable-libgomp \
--disable-libquadmath \
--without-ppl \
--without-cloog \
--enable-languages=c,c++ \
--with-newlib \
--with-headers=$(NEWLIB_SRC_DIR)/newlib/libc/include \
--with-gmp=$(TARGET_DIR) \
--with-mpfr=$(TARGET_DIR) \
--with-mpc=$(TARGET_DIR) \
--enable-obsolete \

# --with-mpfr-include=$(GCC_SRC_DIR)/mpfr/src \
# --with-mpfr-lib=$(GCC_SRC_DIR)/mpfr/src/.lib

gcc-p1: $(GCC_BUILD_DIR)
@echo "****** Build $(GCC_VER) Phase-1 ***********"
(cd $(GCC_BUILD_DIR); $(GCC_SRC_DIR)/configure $(GCC_CONF);)
(cd $(GCC_BUILD_DIR); make all-gcc install-gcc)

gcc-p2:
@echo "****** Build $(GCC_VER) Phase-2 ***********"
(cd $(GCC_BUILD_DIR); make all install)

$(GCC_SRC_DIR): $(SRC_DIR)
@echo "****** Decompress $(GCC_PACKAGE) ***********"
(cd $(SRC_DIR); tar -jxvf $(GCC_PACKAGE))

$(GCC_BUILD_DIR): $(BUILD_DIR)
@echo "****** create directory $(GCC_BUILD_DIR) ***********"
-@mkdir $(GCC_BUILD_DIR)

# ------------- misc ----------------

$(SRC_DIR):
@echo "****** create directory $(SRC_DIR) ***********"
-@mkdir $(SRC_DIR)

$(BUILD_DIR):
@echo "****** create directory $(BUILD_DIR) ***********"
-@mkdir $(BUILD_DIR)

$(PKG_DIR):
@echo ERROR! No $(GNU_DIR) found!
exit

clean: clean-build clean-src

clean-src:
@rm -rf $(SRC_DIR)

clean-build:
@rm -rf BUILD-*

Issues while build insight-6.8-1 with --target=spare-elf configuration

使用 insight-6.8-1

% ../insight-6.8-1/configure --target=sparc-elf --prefix=$OPT/sparc-elf-4.7.0 --disable-nls --disable-werror

會出現以下 error messages:

...
/GNU/SRC/insight-6.8-1/sim/erc32/float.c:173:2: warning: #warning no fpu trap support for this target [-Wcpp]
gcc -DHAVE_CONFIG_H -DPROFILE=1 -DWITH_PROFILE=-1 -DDEFAULT_INLINE=0 -DSTAT -DFAST_UART -DIUREV0 -DMECREV0 -I. -I/GNU/SRC/insight-6.8-1/sim/erc32 -I../common -I/GNU/SRC/insight-6.8-1/sim/erc32/../common -I../../include -I/GNU/SRC/insight-6.8-1/sim/erc32/../../include -I../../bfd -I/GNU/SRC/insight-6.8-1/sim/erc32/../../bfd -I../../opcodes -I/GNU/SRC/insight-6.8-1/sim/erc32/../../opcodes -g -O2 -o sis \
sis.o exec.o erc32.o func.o help.o float.o ../../bfd/libbfd.a ../../opcodes/libopcodes.a ../../libiberty/libiberty.a -lnsl ../../readline/libreadline.a -lm
../../readline/libreadline.a(display.o): In function `cr':
/GNU/SRC/insight-6.8-1/readline/display.c:2205: undefined reference to `tputs'
../../readline/libreadline.a(display.o): In function `_rl_move_cursor_relative':
/GNU/SRC/insight-6.8-1/readline/display.c:1719: undefined reference to `tputs'
/GNU/SRC/insight-6.8-1/readline/display.c:1745: undefined reference to `tputs'
../../readline/libreadline.a(display.o): In function `_rl_move_vert':
/GNU/SRC/insight-6.8-1/readline/display.c:1783: undefined reference to `tputs'
...

查了很久之後,發現是 link erc32 時少了 ncurses 這個 library,也就是少了 -lncurses。
解法:patch insight-6.8-1 source code:
edit ./insight-6.8-1/sim/erc32/Makefile.in
 
Line.25: SIM_EXTRA_LIBS = $(READLINE_LIB) $(TERMCAP_LIB) -lm -lncurses

重新編譯安裝就OK了!

% ../insight-6.8-1/configure --target=sparc-elf --prefix=$OPT/sparc-elf-4.7.0 --disable-nls --disable-werror
% make
% make install

2010年6月24日 星期四

SVN + http + NIS Authentication on OpenSUSE 11.2

Step.1 Install OpenSUSE 11.2
  • New Installation
  • English
  • select GNOME Desktop
  • LVM Partitioning

      /boot : 70.57MB
      / : 40GB
      /srv : max
      swap : 4GB

  • disable Fireware
  • NTP: time.stdtime.gov.tw
Step.2 Network
  • IP : 192.168.103.xxx
  • Gateway : 192.168.103.254
  • Subnet Mask : 255.255.0.0
  • DNS : 192.168.xxx.xxx
  • Hostname : svn
Step.3 NIS Client
  • domain: xxx
  • server: 192.168.xxx.xxx
  • Enable automount
  • Check /etc/nsswitch.conf setting

      passwd: files nis
      group: files nis
      shadow: files nis
      hosts: files nis dns
Step.4 Add Software Repository
  • Apache Module
      http://download.opensuse.org/repositories/Apaches:/Modules/OpenSUSE_11.2
  • RemoteDesktop
      http://download.opensuse.org/repositories/X11:/RemoteDesktop/OpenSUSE_11.2
Step.5 Install Nvidia Driver
    Visit http://en.opensuse.org/NVIDIA_drivers
Step.6 Software Install by using yast2
  • Update All Patches
  • Install Apache

      apache2
      apache2-mod_perl, apache2-mod_php5,
      apache2-mod_authnz_external
      apache2-mod_security2
      yast2-http-server

  • Install FTP server

      pure-ftpd
      yast2-ftp-server

  • Install Development Tools

      gcc, gcc-c++, make, autoconf, compat
Step.7 Enable Network Service
    enable sshd, autofs, httpd service
Step.8 SVN Repository
  • create directory

      #mkdir /srv/svn/projects
      #mkdir /srv/svn/users

  • Change Owner

      # chown -R wwwrun /srv/svn
      # chgrp -R www /srv/svn

  • Create SVN Repository

      # sudo -u wwwrun svnadmin create /srv/svn/projects
      # sudo -u wwwrun svnadmin create /srv/svn/users
Step.9 Apache + NIS Auth
    Reference: http://forums.opensuse.org/get-help-here/network-internet/436171-nis-system-auth-apache-subversion.html
  • Download pwauth source code, modify and Recompile

      Download pwauth-2.3.8.tar.gz from http://code.google.com/p/pwauth/downloads/list

        # tar -zxvf pwauth-2.3.8.tar.gz
        # cd pwauth-2.3.8
        # vi config.h

          change
            #define SERVER_UIDS 72 /* user "nobody" */

          to
            #define SERVER_UIDS 30 /* user "wwwrun" */


        # make
        # cp ./pwauth /usr/bin
        # chmod 4755 /usr/bin/pwauth


  • Install checkpassword-pam

      Download checkpassword-pam-0.99.tar.gz from http://sourceforge.net/projects/checkpasswd-pam/files

        # tar -zxvf checkpassword-pam-0.99.tar.gz
        # cd checkpassword-pam-0.99
        # ./configure
        # make
        # make install

  • create /etc/pam.d/httpd is

      auth include common-auth
      account include common-account
      password include common-password
      session include common-session

  • In /etc/apache2/default-server.conf, add:

      AddExternalAuth pwauth /usr/bin/pwauth
      AddExternalAuth checkpassword-pam "/usr/local/bin/checkpassword-pam -H --noenv --debug --stdout -s httpd -- /bin/true"
      SetExternalAuthMethod checkpassword-pam checkpassword
      AddExternalGroup unixgroup /usr/bin/unixgroup
      SetExternalGroupMethod unixgroup environment

  • In the /etc/apache2/conf.d/subversion.conf:



        DAV svn
        SVNParentPath /home/srv/svn
        SVNListParentPath on
        # Limit write permission to list of valid users.
        # Require SSL connection for password protection.
        # SSLRequireSSL
        AuthType Basic
        AuthName "Subversion Server"
        AuthExternal checkpassword-pam
        AuthBasicProvider external
        Require valid-user
        AuthzSVNAccessFile /srv/svnaccess.conf


  • In the /etc/apache2/conf.d/authnz_external.conf :

      AddExternalAuth pwauth /usr/sbin/pwauth
      SetExternalAuthMethod pwauth pipe

  • Enable aoache module and restart apache2

      # a2enmod authnz_external
      # a2enmod dav
      # a2enmod dav_svn
      # a2enmod authz_svn
      # a2enmod perl
      # rcapache2 restart
Step.10 Setup FreeNX
    # nxsetup --install --setup-nomachine-key --clean