Blame view

Giac_maj/epsilon-giac/Makefile 2.99 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  include build/config.mak
  
  VERSION ?= 1.1.3
  
  ifndef USE_LIBA
    $(error platform.mak should define USE_LIBA)
  endif
  ifndef EXE
    $(error platform.mak should define EXE, the extension for executables)
  endif
  
  HOSTCC = gcc
  HOSTCXX = g++
  
  # Flags - Optimizations
  SFLAGS += $(OPTIM_SFLAGS)
  
  # Flags - Header search path
  SFLAGS += -Ilib -I.
  
  # Flags - Building options
  SFLAGS += -Wall
  
  # Flags - Header dependency tracking
  SFLAGS += -MD -MP
  
  # Language-specific flags
  CFLAGS = -std=c99
  CXXFLAGS = -std=c++11 -fno-exceptions -fno-rtti -fno-threadsafe-statics
  LDFLAGS := -L../giac-1.4.9/src -L../libtommath-0.39 -lgiac -ltommath $(LDFLAGS)
  
  products :=
  
  ifeq ($(VERBOSE),1)
  default: info clean app_size app_memory_map
  else
  default: app.$(EXE)
  endif
  run: app_run
  
  .PHONY: info
  info:
  	@echo "========= BUILD SETTINGS ======"
  	@echo "DEBUG = $(DEBUG)"
  	@echo "PLATFORM = $(PLATFORM)"
  	@echo "CC = $(CC)"
  	@echo "CXX = $(CXX)"
  	@echo "LD = $(LD)"
  	@echo "CFLAGS = $(CFLAGS)"
  	@echo "CXXFLAGS = $(CXXFLAGS)"
  	@echo "SFLAGS = $(SFLAGS)"
  	@echo "LDFLAGS = $(LDFLAGS)"
  	@echo "==============================="
  
  # Each sub-Makefile can either add objects to the $(objs) variable or define a
  # new executable target. The $(objs) variable lists the objects that will be
  # linked to every executable being generated. Each Makefile is also responsible
  # for keeping the $(product) variable updated. This variable lists all files
  # that could be generated during the build and that needs to be cleaned up
  # afterwards.
  
  # Library Makefiles
  ifeq ($(USE_LIBA),0)
  include liba/Makefile.bridge
  else
  SFLAGS += -ffreestanding -nostdinc -nostdlib
  include liba/Makefile
  include libaxx/Makefile
  endif
  include ion/Makefile
  include kandinsky/Makefile
  include poincare/Makefile
  include python/Makefile
  include escher/Makefile
  # Executable Makefiles
  include apps/Makefile
  include build/struct_layout/Makefile
  include quiz/Makefile # Quiz needs to be included at the end
  
  products += $(objs)
  
  all_objs = $(filter %.o, $(products))
  dependencies = $(all_objs:.o=.d)
  -include $(dependencies)
  products += $(dependencies)
  
  .SECONDARY: $(objs)
  %.$(EXE): $(objs)
  	@echo "LD      $@"
  	@$(LD) $^ $(LDFLAGS) -o $@
  
  .PHONY: %_size
  %_size: %.$(EXE)
  	@echo "========= BUILD OUTPUT ========"
  	@echo "File:  $<"
  	@$(SIZE) $< | tail -n 1 | awk '{print "Code:  " $$1 " bytes";print "Data:  " $$2 " bytes"; print "Total: " int(($$1+$$2)/1024) " kB (" $$1 + $$2 " bytes)";}'
  	@echo "==============================="
  
  ifdef OBJCOPY
  products += $(products:.$(EXE)=.hex) $(products:.$(EXE)=.bin)
  %.hex: %.$(EXE)
  	@echo "OBJCOPY $@"
  	@$(OBJCOPY) -O ihex $< $@
  %.bin: %.$(EXE)
  	@echo "OBJCOPY $@"
  	@$(OBJCOPY) -O binary -R.giac $< $@
  %-extflash.bin: %.$(EXE)
  	@echo "OBJCOPY $@"
  	@$(OBJCOPY) -O binary -j.giac --gap-fill 0xff --pad-to 0x90800000 $< $@
  endif
  
  %.o: %.c
  	@echo "CC      $@"
  	@$(CC) $(SFLAGS) $(CFLAGS) -c $< -o $@
  
  %.o: %.s
  	@echo "AS      $@"
  	@$(CC) $(SFLAGS) -c $< -o $@
  
  %.o: %.cpp
  	@echo "CXX     $@"
  	@$(CXX) $(SFLAGS) $(CXXFLAGS) -c $< -o $@
  
  .PHONY: clean
  clean:
  	@echo "CLEAN"
  	@rm -f $(products)