makefile에서
OBJS = a.o b.o
SRC = $(OBJ:.o=.c)

a.o : a.c
b.o : b.c
이런식으로 파일을 일일이 나열을 하는데, 아무래도 귀찮다 -ㅁ-!

하지만 $(wildcard) 라는 함수를 이용하면 나열은 하지 않아도 된다.
SRC = $(wildcard *.c)
OBJ = $(SRC:.c=.o)

이렇게 하면 (의존성은 제외하더라도) 복잡하게 할 필요 없이 간단하게 끝!

[링크 : http://www.viper.pe.kr/docs/make-ko/make-ko_4.html#SEC21]

'프로그램 사용 > make, configure' 카테고리의 다른 글

cross compile 초기화 하기  (0) 2010.05.18
cmake - cross make  (0) 2010.04.06
makefile 정렬하기  (2) 2010.03.31
make, gmake  (0) 2010.03.02
개발환경 자동화 - autoconf, automake, libtool  (0) 2010.03.02
Posted by 구차니
make를 이용하여 컴파일할 소스들의 목록을 작성할때

# cat Makefile
OBJS-$(CONFIG_AAC_DEMUXER)               += raw.o id3v1.o id3v2.o
OBJS-$(CONFIG_AC3_DEMUXER)               += raw.o
OBJS-$(CONFIG_AC3_MUXER)                 += raw.o

위와 같이 OBJS에 += 로 계속 더해나가다 보면
raw.o 가 여러개 붙어지고, 이 상태로 컴파일을 하면 symbol들이 중복되어

Function funcname() is deprecated in path/filename.ext on line 00

이런식으로 에러를 발생한다.
이를 간편하게 해결하기 위해서는 sort를 이용하면 된다.
sort는 중복된 내용을 제거해주는 역활도 한다.

$(sort list)
    Sorts the words of list in lexical order, removing duplicate words.
    The output is a list of words separated by single spaces. Thus,

              $(sort foo bar lose)
        

    returns the value `bar foo lose'.

    Incidentally, since sort removes duplicate words,
    you can use it for this purpose even if you don't care about the sort order.

[링크 : http://www.gnu.org/software/make/manual/make.html#Text-Functions]
[링크 : http://korea.gnu.org/manual/4check/make-3.77/ko/make_8.html#SEC76]
Posted by 구차니
Linux/Ubuntu2010. 2. 5. 20:32
doesn't work ansi escape sequence on ubuntu makefile(make)


$ cat test.sh
#!/bin/bash
echo -e '\E[47;34m'"\033[1mTest\033[0m"

$ cat test.sh
#!/bin/sh
echo -e '\E[47;34m'"\033[1mTest\033[0m" 

위의 결과는 아래의 소스대로, 쉘이 바뀌었다는것 밖에 차이가 없다.
결과는 sh에서 실행된것은 "-e \E[47;34m" 까지 출력되었다.
아마, 우분투의 make 시에 색상이 먹지 않는건 makefile이 기본 쉘로  /bin/sh를 쓰면서
안시 이스케이프 시퀀스가 오작동 한것으로 보인다.

해결방법은 makefile 내에
SHELL=/bin/bash 를 추가하는 것이다.

'Linux > Ubuntu' 카테고리의 다른 글

apt 명령어 정ㅋ벅ㅋ  (0) 2010.03.04
우분투에서 /etc/sysconfig/network 에 대응하는 파일  (0) 2010.02.16
tftp 설정경로  (0) 2010.02.05
sudo 사용가능하도록 설정하기  (0) 2010.02.04
우분투 사용자 자동로그인  (0) 2010.02.04
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2008. 11. 18. 00:15

AVR Studio 에서는 상당 부분이 자동으로 생성된다. (source가 아니라 makefile)
AVR 프로그래밍 처음 단계는 아마도
#include <avr/io.h>가 아닐까 싶은데 이부분을 추적을 해 보았다.

makefile - 자동생성

MCU 에 AVR Studio에서 프로젝트 생성시 선택된 프로세서의 타입이 지정되고
아래의 COMMON 에 -mmcu=atmega128 로 확장이 된다. 일단 avr-gcc의 도움말을 보자면

Usage: avr-gcc [options] file...
Options:
  -pass-exit-codes         Exit with highest error code from a phase
  --help                   Display this information
  --target-help            Display target specific command line options
  --help={target|optimizers|warnings|undocumented|params}[,{[^]joined|[^]separate}]
                           Display specific types of command line options
  (Use '-v --help' to display command line options of sub-processes)
  -dumpspecs               Display all of the built in spec strings
  -dumpversion             Display the version of the compiler
  -dumpmachine             Display the compiler's target processor
  -print-search-dirs       Display the directories in the compiler's search path

  -print-libgcc-file-name  Display the name of the compiler's companion library
  -print-file-name=<lib>   Display the full path to library <lib>
  -print-prog-name=<prog>  Display the full path to compiler component <prog>
  -print-multi-directory   Display the root directory for versions of libgcc
  -print-multi-lib         Display the mapping between command line options and
                           multiple library search directories
  -print-multi-os-directory Display the relative path to OS libraries
  -print-sysroot-headers-suffix Display the sysroot suffix used to find headers
  -Wa,<options>            Pass comma-separated <options> on to the assembler
  -Wp,<options>            Pass comma-separated <options> on to the preprocessor

  -Wl,<options>            Pass comma-separated <options> on to the linker
  -Xassembler <arg>        Pass <arg> on to the assembler
  -Xpreprocessor <arg>     Pass <arg> on to the preprocessor
  -Xlinker <arg>           Pass <arg> on to the linker
  -combine                 Pass multiple source files to compiler at once
  -save-temps              Do not delete intermediate files
  -pipe                    Use pipes rather than intermediate files
  -time                    Time the execution of each subprocess
  -specs=<file>            Override built-in specs with the contents of <file>
  -std=<standard>          Assume that the input sources are for <standard>
  --sysroot=<directory>    Use <directory> as the root directory for headers
                           and libraries
  -B <directory>           Add <directory> to the compiler's search paths
  -b <machine>             Run gcc for target <machine>, if installed
  -V <version>             Run gcc version number <version>, if installed
  -v                       Display the programs invoked by the compiler
  -###                     Like -v but options quoted and commands not executed
  -E                       Preprocess only; do not compile, assemble or link
  -S                       Compile only; do not assemble or link
  -c                       Compile and assemble, but do not link
  -o <file>                Place the output into <file>
  -x <language>            Specify the language of the following input files
                           Permissible languages include: c c++ assembler none
                           'none' means revert to the default behavior of
                           guessing the language based on the file's extension

Options starting with -g, -f, -m, -O, -W, or --param are automatically
 passed on to the various sub-processes invoked by avr-gcc.  In order to pass
 other options on to these processes the -W<letter> options must be used.

For bug reporting instructions, please see:
<URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&func=browse>.

-m 의 경우 avr-gcc 에 의해서 생성된 하위 프로세서로 자동적으로 넘겨져서 처리가 된다고 한다.
아무튼 처음에 설정하는 <avr/io.h> 는 컴파일러의 include 디렉토리에 위치하는데
기본값으로 설치를 했다면 아래의 경로에 위치하게 된다.


이 파일들 중에서 우리가 보고 싶은것은 io.h 인데 이 파일을 열어 보면


와 같이 #if #elif 로 묶여 있고 그 중에 우리가 찾던
__AVR_ATmega128__ 이라는 선언이 존재 한다. 아마도 -mmcu=atmega128이 이런식으로 치환이 되는 듯 하다.


아무튼 치환될 iom128.h 파일을 열어 보면 우리가 사용하는 일반적인 용어(!) 인
PINA DDRA 등의 선언과 그 에 상응하는 주소를 볼 수 있다.
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2008. 10. 28. 09:59
근 2일간을 고생하게 한 문제인데.. 이 문제를 해결하기 위해서 무려 AVR Studio 신버전을 받는데 1시간이나 걸리고,
WinAVR 마저도 업그레이드 했지만..(머.. 덕분에라고 하면 다행인가?) 문제가 해결되지 않았다.

예전에도 AVR Studio를 사용할때 이러한 문제가 없었는데 왜 이번에는 생겼을까 고심을 해봤더니
예전에는 c:\source에 저장을 했었다는 점이 달랐을뿐 차이점이 없었다.

그래서 오늘 출근하면서 지하철에서 실험을 해봤더니. AVR Studio 인지 아니면 avr-gcc plug 쪽인지는 모르겠지만
아무튼 Makefile export 하는 쪽에서 한글 디렉토리명을 인식하지 못한다는 점을 알아 냈다.


아래의 Message를 보면 gcc plug-in : Exported makefile to.. 영문으로된 경로로는 이상이 없었지만
동일한 파일을 한글 디렉토리가 들어간 경로에 저장을 하려고 하면 Failed opening file 이라고 에러를 발생한다.
Posted by 구차니