| 1 | # Predefined User Makefile | 
|---|
| 2 |  | 
|---|
| 3 | #------------------------------------------------------------------------------ | 
|---|
| 4 | # Default plateform architecture and default CPU | 
|---|
| 5 | #------------------------------------------------------------------------------ | 
|---|
| 6 | ARCH        = $(ALMOS_ARCH) | 
|---|
| 7 | CPU         = $(ALMOS_CPU) | 
|---|
| 8 | ARCH_CLASS  = $(ALMOS_ARCH_CLASS) | 
|---|
| 9 |  | 
|---|
| 10 | #------------------------------------------------------------------------------ | 
|---|
| 11 | # CC tools and parameters | 
|---|
| 12 | #------------------------------------------------------------------------------ | 
|---|
| 13 | DIR_INC  = $(ALMOS_DISTRIB)/include | 
|---|
| 14 | DIR_LIB  = $(ALMOS_DISTRIB)/lib | 
|---|
| 15 | GCC_LIB  = $(CCTOOLS)/lib | 
|---|
| 16 | CC       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-gcc | 
|---|
| 17 | AR       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-ar | 
|---|
| 18 | AS       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-as | 
|---|
| 19 | OD       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-objdump | 
|---|
| 20 | OCPY     = $(CCTOOLS)/bin/$(CPU)-unknown-elf-objcopy | 
|---|
| 21 | LD       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-ld | 
|---|
| 22 | NM       = $(CCTOOLS)/bin/$(CPU)-unknown-elf-nm | 
|---|
| 23 |  | 
|---|
| 24 | ifneq ($(ADD-LDSCRIPT),) | 
|---|
| 25 | LDSCRIPT=$(ADD-LDSCRIPT) | 
|---|
| 26 | else | 
|---|
| 27 | LDSCRIPT=uldscript | 
|---|
| 28 | endif | 
|---|
| 29 |  | 
|---|
| 30 | ifeq ($(CPU), mipsel) | 
|---|
| 31 | CPU-CFLAGS = -mips32 -EL -G0 | 
|---|
| 32 | endif | 
|---|
| 33 |  | 
|---|
| 34 | ifeq ($(CPU), i386) | 
|---|
| 35 | CPU-CFLAGS = -g | 
|---|
| 36 | endif | 
|---|
| 37 |  | 
|---|
| 38 | CFLAGS = -c -fomit-frame-pointer $(ADD-CFLAGS) | 
|---|
| 39 | LIBS =  -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 | #------------------------------------------------------------------------------- | 
|---|
| 45 | OBJ=$(addsuffix .o,$(FILES)) | 
|---|
| 46 | SRC=$(addsuffix .c,$(FILES)) | 
|---|
| 47 | BIN ?= soft.bin | 
|---|
| 48 |  | 
|---|
| 49 | ifndef TARGET | 
|---|
| 50 | RULE=usage | 
|---|
| 51 | endif | 
|---|
| 52 |  | 
|---|
| 53 | ifeq ($(TARGET), tsar) | 
|---|
| 54 | RULE=almos | 
|---|
| 55 | CFLAGS += $(CPU-CFLAGS) -I$(DIR_INC) -D_ALMOS_ | 
|---|
| 56 | endif | 
|---|
| 57 |  | 
|---|
| 58 | ifeq ($(TARGET), linux) | 
|---|
| 59 | RULE=linux | 
|---|
| 60 | CFLAGS += -g | 
|---|
| 61 | CC=gcc | 
|---|
| 62 | endif | 
|---|
| 63 |  | 
|---|
| 64 | ifeq ($(TARGET), ibmpc) | 
|---|
| 65 | RULE=almos | 
|---|
| 66 | CFLAGS += $(CPU-CFLAGS) -I$(DIR_INC) -D_ALMOS_ | 
|---|
| 67 | endif | 
|---|
| 68 |  | 
|---|
| 69 | ifndef RULE | 
|---|
| 70 | RULE=usage | 
|---|
| 71 | endif | 
|---|
| 72 |  | 
|---|
| 73 | #------------------------------------------------------------------------------ | 
|---|
| 74 | # Building rules | 
|---|
| 75 | #------------------------------------------------------------------------------ | 
|---|
| 76 | .PHONY : usage linux soclib clean realclean | 
|---|
| 77 |  | 
|---|
| 78 | all: $(RULE) $(ADD-RULE) | 
|---|
| 79 |  | 
|---|
| 80 | usage: | 
|---|
| 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 |  | 
|---|
| 87 | linux: $(OBJ) | 
|---|
| 88 | @echo '   [  CC  ]        '$^ | 
|---|
| 89 | @$(CC) -o $(BIN) $^ -lpthread $(ADD-LIBS) | 
|---|
| 90 |  | 
|---|
| 91 | almos : $(BIN) | 
|---|
| 92 |  | 
|---|
| 93 | $(BIN) : $(OBJ) | 
|---|
| 94 | @echo '   [  LD  ]        '$@ | 
|---|
| 95 | @$(LD) -o $@ $(LIBS) | 
|---|
| 96 |  | 
|---|
| 97 | %.o : %.c | 
|---|
| 98 | @echo '   [  CC  ]        '$< | 
|---|
| 99 | @$(CC) $(CFLAGS) $< -o $@ | 
|---|
| 100 |  | 
|---|
| 101 | clean : | 
|---|
| 102 | @echo '   [  RM  ]        *.o *~ *.dump *.nm '"$(BOJ)" | 
|---|
| 103 | @$(RM) $(OBJ) *.o *~ *.dump *.nm 2> /dev/null||true | 
|---|
| 104 |  | 
|---|
| 105 | realclean : clean | 
|---|
| 106 | @echo '   [  RM  ]        '$(BIN) tty* vcitty* | 
|---|
| 107 | @$(RM) $(BIN) tty* vcitty* | 
|---|
| 108 |  | 
|---|