source: trunk/sys/mk/include/appli.mk @ 221

Last change on this file since 221 was 1, checked in by alain, 8 years ago

First import

File size: 2.8 KB
Line 
1# Predefined User Makefile
2
3#------------------------------------------------------------------------------
4# Default plateform architecture and default CPU
5#------------------------------------------------------------------------------
6ARCH        = $(ALMOS_ARCH)
7CPU         = $(ALMOS_CPU)
8ARCH_CLASS  = $(ALMOS_ARCH_CLASS)
9
10#------------------------------------------------------------------------------
11# CC tools and parameters
12#------------------------------------------------------------------------------
13DIR_INC  = $(ALMOS_DISTRIB)/include
14DIR_LIB  = $(ALMOS_DISTRIB)/lib
15GCC_LIB  = $(CCTOOLS)/lib
16CC       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-gcc               
17AR       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-ar
18AS       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-as
19OD       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-objdump
20OCPY     = $(CCTOOLS)/bin/$(CPU)-unknown-elf-objcopy
21LD       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-ld
22NM       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-nm
23
24ifneq ($(ADD-LDSCRIPT),)
25LDSCRIPT=$(ADD-LDSCRIPT)
26else
27LDSCRIPT=uldscript
28endif
29
30ifeq ($(CPU), mipsel)
31CPU-CFLAGS = -mips32 -EL -G0
32endif
33
34ifeq ($(CPU), i386)
35CPU-CFLAGS = -g
36endif
37
38CFLAGS = -c -fomit-frame-pointer $(ADD-CFLAGS)
39LIBS =  -L$(DIR_LIB) -L$(GCC_LIB) $(CPU-LFLAGS) -T$(LDSCRIPT) $(OBJ) $(ADD-LIBS) \
40        -lpthread -lgomp -lc $(ADD-LIBS) -lgomp -lpthread -lc -lgcc --hash-style=sysv
41
42#-------------------------------------------------------------------------------
43# Sources and targets files name
44#-------------------------------------------------------------------------------
45OBJ=$(addsuffix .o,$(FILES))
46SRC=$(addsuffix .c,$(FILES))
47BIN ?= soft.bin
48
49ifndef TARGET
50RULE=usage
51endif
52
53ifeq ($(TARGET), tsar)
54RULE=almos
55CFLAGS += $(CPU-CFLAGS) -I$(DIR_INC) -D_ALMOS_
56endif
57
58ifeq ($(TARGET), linux)
59RULE=linux
60CFLAGS += -g
61CC=gcc
62endif
63
64ifeq ($(TARGET), ibmpc)
65RULE=almos
66CFLAGS += $(CPU-CFLAGS) -I$(DIR_INC) -D_ALMOS_
67endif
68
69ifndef RULE
70RULE=usage
71endif
72
73#------------------------------------------------------------------------------
74# Building rules
75#------------------------------------------------------------------------------
76.PHONY : usage linux soclib clean realclean
77
78all: $(RULE) $(ADD-RULE)
79
80usage:
81        @echo "AlmOS Application Compiler";\
82        echo "> make TARGET=tsar     : targets the MIPS TSAR simulator";\
83        echo "> make TARGET=ibmpc    : targets the Intel X86 for IBM-PC compatible plateform";\
84        echo "> make TARGET=linux    : targets the GNU/Linux plateform";\
85        echo ""
86
87linux: $(OBJ)
88        @echo '   [  CC  ]        '$^
89        @$(CC) -o $(BIN) $^ -lpthread $(ADD-LIBS)
90
91almos : $(BIN)
92
93$(BIN) : $(OBJ)
94        @echo '   [  LD  ]        '$@
95        @$(LD) -o $@ $(LIBS)
96
97%.o : %.c
98        @echo '   [  CC  ]        '$<
99        @$(CC) $(CFLAGS) $< -o $@
100
101clean :
102        @echo '   [  RM  ]        *.o *~ *.dump *.nm '"$(BOJ)"
103        @$(RM) $(OBJ) *.o *~ *.dump *.nm 2> /dev/null||true 
104
105realclean : clean
106        @echo '   [  RM  ]        '$(BIN) tty* vcitty*
107        @$(RM) $(BIN) tty* vcitty*
108
Note: See TracBrowser for help on using the repository browser.