** Reference
☞ 'Embedded Recipes'(히언, 코너북)
☞ http://recipes.egloos.com/5017957
< Instructions for ARM >
http://www.sourceware.org/cgen/gen-doc/arm-thumb-insn.html
** Compile Option
C:\apps\ADS12\Bin> tcc
1. tcc -o ramen.o sphagetti.c
2. -E, -C : Preprocessing only -> output '*.i'
3. -S : Assemby only -> Output '*.s'
4. -o : Linkable Ojbect only -> Output : elf 형식의 '*.o'
5. -I, -J : Search directory option ->
6. -D, -U : Define / Undefine option
-DFEATURE_OPT == #define FEATURE_OPT
-UFEATURE_OPT == #undef FEATURE_OPT
#ifdef WINDOWS_XP
#define KERNEL_VER 100
#elif defined (WINDOWS_NT)
#define KERNEL_VER 200
#elif defined (LINUX)
#define KERNEL_VER 202
#endif
** Compile via Make file
[spaghetti.h]
#define ...
typdef struct { ... } member_type
extern int add(int a, int b);
[spaghetti.c]
#include "spaghetti.h"
...
extern int relocate EQUAL 3;
member_type member = {TRUE,10,2};
main() {
int stack;
volatile int local, local2, local3;
...
local3 EQUAL add (local, local2);
stack EQUAL local3;
return stack;
}
[manupulation.c]
#include "spaghetti.h"
extern member_type member;
int add (int a, int b) { return (a+b+member.memberWord); }
----- Manual Compile
tcc -c spaghetti.c manupulation.c // Linkable object file
armlink -elf -o spaghetti.elf spaghetti.o manupulation.o // elf 형태의 executive file
fromelf -o spaghetti.bin spaghetti.elf // binary 형태의 executive file
----- Compile via Make file
1. Make file ( 'tab' 사용 주의 )
## Rules
CC = tcc // macro definition
output_file1 : input_file11 input_file12 ...
command // command 앞에 'tab' 필요
output_file2 : input_file21 input_file22 ...
command
....
[spaghetti.mak]
spaghetti.bin : spaghetti.elf
fromelf -o spaghetti.bin spaghetti.elf
spaghetti.elf : spaghetti.o manupulation.o
armlink -elf -o spaghetti.elf spaghetti.o manupulation.o
spaghetti.o : spaghetti.c
tcc -c spaghetti.c
manupulation.o : manupulation.c
tcc -c manupulation.c
2. Compile
work_dir:> make -f spaghetti.mak
cf. *.c와 *.o의 시간을 비교해서 같으면 skip ( 변경된 *.c에 대해서 object file 만듦 )
- Log 남기기
work_dir:> make -f paghetti.mak 2>&1 | tee recipes.log
cf. 2 : stderr / 1 : stdout ( stderr를 stdout log로 저장 후에 tee를 이용해서 display )
cf. >, tee : compiler에 따라서 stdout만 지원할 수 있음