Homebrew 설치기 - 2

2014. 1. 3. 23:00 from Code

http://brew.sh


http://spaghetticoder.tistory.com/entry/Build-and-using-glib-in-Mac-os-failed

http://spaghetticoder.tistory.com/entry/Homebrew-설치기-1


자.. 이제 Homebrew 를 설치해보자.

위 링크에 가면 맨 아래쪽에 왠 ruby 명령어가 있다.

그대로 복사하며 터미널에 붙여 넣고 enter.


sanchoui-MacBook-Air:~ sancho$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

==> This script will install:

/usr/local/bin/brew

/usr/local/Library/...

/usr/local/share/man/man1/brew.1


Press ENTER to continue or any other key to abort

==> /usr/bin/sudo /bin/mkdir /usr/local


WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.


To proceed, enter your password, or type Ctrl-C to abort.


Password:

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local

==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local

==> Installing the Command Line Tools (expect a GUI popup):

==> /usr/bin/sudo /usr/bin/xcode-select --install

xcode-select: note: install requested for command line developer tools

Press any key when the installation has completed.


그러면 xcode command line tool 이 설치되어 있지 않았다고 하면서 설치하라고 창이 뜬다.

가볍게 설치 버튼 누르고 계속 진행한다.


==> Downloading and installing Homebrew...

remote: Counting objects: 144698, done.

remote: Compressing objects: 100% (47500/47500), done.

Receiving objects:  42% (61625/144698), 11.97 MiB | 76.00 KiB/s   


그럼 왠 git repository 를 clone 하기 시작한다. 이거 뭐야 무서워..

약 3~4분 후에 완료되고 아래와 같이 나온다.


==> Downloading and installing Homebrew...

remote: Counting objects: 144698, done.

remote: Compressing objects: 100% (47500/47500), done.

remote: Total 144698 (delta 102505), reused 137250 (delta 96133)

Receiving objects: 100% (144698/144698), 21.46 MiB | 346.00 KiB/s, done.

Resolving deltas: 100% (102505/102505), done.

From https://github.com/Homebrew/homebrew

 * [new branch]      master     -> origin/master

HEAD is now at 745311b pyqt: patch handling of qmake inline comments.

==> Installation successful!

You should run `brew doctor' *before* you install anything.

Now type: brew help

sanchoui-MacBook-Air:~ sancho$ 


Installation successful?? 벌써 끝이란 말인가...

아무거나 install 하지말고 먼저 brew doctor 를 실행하란다. brew help 도 실행해보고.

brew help 부터 해볼까나.


sanchoui-MacBook-Air:~ sancho$ brew help

Example usage:

  brew [info | home | options ] [FORMULA...]

  brew install FORMULA...

  brew uninstall FORMULA...

  brew search [foo]

  brew list [FORMULA...]

  brew update

  brew upgrade [FORMULA...]

  brew pin/unpin [FORMULA...]


Troubleshooting:

  brew doctor

  brew install -vd FORMULA

  brew [--env | --config]


Brewing:

  brew create [URL [--no-fetch]]

  brew edit [FORMULA...]

  open https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook


Further help:

  man brew

  brew home


여기서 FORMULA 라고 하는것은 brew 가 관리할 package name 이라고 보면 된다.

brew install/uninstall 은 FORMULA 설치 및 삭제로 보이고..
brew search 는 brew를 통해 설치 가능한 FORMULA 검색,
brew list 는 현재 설치된 FORMULA 리스팅???
brew update 는 homebrew 자체를 update 하는 것으로 보이고..
brew upgrade 는 FORMULA 를 update 하는 것 처럼 보인다.

이정도만 알아도 뭐 사용하는데는 문제 없어 보인다.
install 하기 전에 brew doctor 를 실행하라고 신신당부 하였으니 brew doctor 를 실행해 보자.

sanchoui-MacBook-Air:~ sancho$ brew doctor

Your system is ready to brew.

sanchoui-MacBook-Air:~ sancho$ 


나의 시스템은 brew를 사용할 준비가 되었단다.

자.. 이제 그럼 숙원 사업인 glib를 설치해보자 ㅠㅠ
일단 brew search 명령으로 glib을 검색해 보자.

sanchoui-MacBook-Air:~ sancho$ brew search glib

dbus-glib glib   glib-networking  glibmm     json-glib     taglib

sanchoui-MacBook-Air:~ sancho$ 


2번째에 애증의 glib이 보인다. brew install 명령으로 설치해주자.


sanchoui-MacBook-Air:~ sancho$ brew install glib

==> Installing dependencies for glib: xz, pkg-config, gettext, libffi

==> Installing glib dependency: xz

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/xz-5.0.5.mavericks.bottle.2.tar.gz

######################################################################## 100.0%

==> Pouring xz-5.0.5.mavericks.bottle.2.tar.gz

   /usr/local/Cellar/xz/5.0.5: 58 files, 1.5M

==> Installing glib dependency: pkg-config

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.mavericks.bottle.2.tar.gz

######################################################################## 100.0%

==> Pouring pkg-config-0.28.mavericks.bottle.2.tar.gz

   /usr/local/Cellar/pkg-config/0.28: 10 files, 604K

==> Installing glib dependency: gettext

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gettext-0.18.3.1.mavericks.bottle.1.tar.gz

######################################################################## 100.0%

==> Pouring gettext-0.18.3.1.mavericks.bottle.1.tar.gz

==> Caveats

This formula is keg-only, so it was not symlinked into /usr/local.


OS X provides the BSD gettext library and some software gets confused if both are in the library path.


Generally there are no consequences of this for you. If you build your

own software and it requires this formula, you'll need to add to your

build variables:


    LDFLAGS:  -L/usr/local/opt/gettext/lib

    CPPFLAGS: -I/usr/local/opt/gettext/include


==> Summary

   /usr/local/Cellar/gettext/0.18.3.1: 374 files, 12M

==> Installing glib dependency: libffi

==> Downloading http://mirrors.kernel.org/sources.redhat.com/libffi/libffi-3.0.13.tar.gz

######################################################################## 100.0%

==> ./configure --prefix=/usr/local/Cellar/libffi/3.0.13

==> make install

==> Caveats

This formula is keg-only, so it was not symlinked into /usr/local.


Mac OS X already provides this software and installing another version in

parallel can cause all kinds of trouble.


Some formulae require a newer version of libffi.


Generally there are no consequences of this for you. If you build your

own software and it requires this formula, you'll need to add to your

build variables:


    LDFLAGS:  -L/usr/local/opt/libffi/lib


==> Summary

   /usr/local/Cellar/libffi/3.0.13: 13 files, 388K, built in 14 seconds


이 ㅅㅂ.. 내가 삽질한 작업들을 모두 자동으로.. 성공적으로 수행해 준다.

dependency 있는 library 들을 자동으로 찾아서 소스 다운받고 컴파일 하고 설치한다.. brew 짱짱맨 ㅠㅠ


==> Installing glib

==> Downloading http://ftp.gnome.org/pub/gnome/sources/glib/2.38/glib-2.38.2.tar.xz

######################################################################## 100.0%

==> Downloading patches

######################################################################## 100.0%

######################################################################## 100.0%

==> Patching

patching file aclocal.m4

Hunk #1 succeeded at 1580 (offset 15 lines).

patching file config.h.in

patching file configure

Hunk #2 succeeded at 27737 (offset 41 lines).

patching file configure.ac

Hunk #1 succeeded at 2683 (offset 1 line).

patching file gio/gdbusprivate.c

patching file gio/xdgmime/xdgmime.c

patching file gio/Makefile.am

patching file gio/Makefile.in

patching file gio/gnextstepsettingsbackend.c

patching file gio/gnextstepsettingsbackend.m

==> ./configure --disable-maintainer-mode --disable-silent-rules --disable-dtrace --disable-libelf --prefix=/usr/local/Cellar/glib/2.38.2 --localstatedir=/usr/local/var --with-gio-module-dir=/usr/local/li

==> make

==> make install

   /usr/local/Cellar/glib/2.38.2: 413 files, 17M, built in 99 seconds


dependency library 설치가 끝나고 애증의 glib 을 설치하기 시작한다.

허허 이렇게 간단할 줄이야.. 99초 걸렸단다. 99초.


자 그럼 간단히 hello 소스를 작성하고 실제로 glib을 링크 시켜 보자앗.


1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <glib.h>
 
int main(int c, char **v)
{
    char *str = NULL;
    
    str = g_strdup("Hello world!");
    printf("%s\n", str);
 
    return 0;
}


간단히 g_strdup 이용해서 우리의 친구 Hello world 를 strdup 하고 출력한다.

pkg-config 도 설치 되었으니 pkg-config 이용해서 컴파일 해보자.


sanchoui-MacBook-Air:glib_test sancho$ gcc `pkg-config --cflags --libs glib-2.0` hello.c

sanchoui-MacBook-Air:glib_test sancho$ ./a.out 

Hello world!


굿 잡! 성공이다~!


오픈 소스를 받아서 직접 컴파일 하기란 쉽지가 않다.

아무리 dependency 라이브러리들이 명시가 되어있어도 하나하나 검색해서 소스 다운 받고 컴파일 하고.. 킹왕짱 노가다 작업이다.

우분투를 사용했을적에는 거긴 시스템이 워낙 잘되어 있으니.. 왠만한건 모두 패키징 되어 있고 받아다가 간단히 사용할 수 있다.

mac에서도 비슷한 녀석을 찾아서 다행이다. 



'Code' 카테고리의 다른 글

dbus - 2  (0) 2014.01.23
dbus - 1  (0) 2014.01.15
Homebrew 설치기 - 1  (0) 2014.01.02
Build and using glib in Mac os - failed!  (0) 2014.01.02
bash shell script #1  (0) 2013.12.01
Posted by 스파게티코더 :