OpenCores
URL https://opencores.org/ocsvn/s6soc/s6soc/trunk

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [Makefile] - Blame information for rev 53

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 dgisselq
################################################################################
2
##
3
## Filename:    Makefile        (sw/dev)
4
##
5
## Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
##
7
## Purpose:     This makefile supports (directs) the building of the various
8
##              software for the S6 Cmod board.
9
##
10
##      Targets:
11
##
12
##      (all)           Builds all of the program files
13
##
14
##      clean           Removes all object files, the dependency file,
15
##                              and any programs that have been built.
16
##
17
##      depends         Builds a master dependency file
18
##
19
## Creator:     Dan Gisselquist, Ph.D.
20
##              Gisselquist Technology, LLC
21
##
22
################################################################################
23
##
24
## Copyright (C) 2015-2016, Gisselquist Technology, LLC
25
##
26
## This program is free software (firmware): you can redistribute it and/or
27
## modify it under the terms of  the GNU General Public License as published
28
## by the Free Software Foundation, either version 3 of the License, or (at
29
## your option) any later version.
30
##
31
## This program is distributed in the hope that it will be useful, but WITHOUT
32
## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
33
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
34
## for more details.
35
##
36
## You should have received a copy of the GNU General Public License along
37
## with this program.  (It's in the $(ROOT)/doc directory, run make with no
38
## target there if the PDF file isn't present.)  If not, see
39
##  for a copy.
40
##
41
## License:     GPL, v3, as defined and found on www.gnu.org,
42
##              http://www.gnu.org/licenses/gpl.html
43
##
44
##
45
################################################################################
46
##
47
##
48 53 dgisselq
# Declare "all" to be the default target
49 12 dgisselq
all:
50 53 dgisselq
PROGRAMS := helloworld doorbell doorbell2 kptest blinky cputest uartecho
51 12 dgisselq
all: $(OBJDIR)/ $(PROGRAMS)
52
 
53
 
54
OBJDIR := obj-zip
55
CROSS := zip
56
CC    := $(CROSS)-gcc
57
AS    := $(CROSS)-as
58
LD    := $(CROSS)-ld
59
SED   := sed
60
OBJDUMP := $(CROSS)-objdump
61
 
62
# Not for build, for for building tags and dependency files, we need to know
63
# what the sources and headers are
64 45 dgisselq
DEVDRVR:= keypad.c display.c rtcsim.c txfns.c
65 53 dgisselq
SOURCES:= helloworld.c doorbell.c doorbell2.c kptest.c uartecho.c $(DEVDRVR)
66 12 dgisselq
HEADERS:= board.h
67 15 dgisselq
OBJDRVR := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(DEVDRVR)))
68 12 dgisselq
 
69
CPPFLAGS := -I../zipos -I.
70 45 dgisselq
DUMPFLAGS := # -fdump-rtl-all
71 53 dgisselq
CFLAGS   := $(CPPFLAGS) $(DUMPFLAGS) -O3 -Wall -Wextra -nostdlib -fno-builtin
72 12 dgisselq
LDFLAGS   = -T cmod.ld -Wl,-Map,$(OBJDIR)/$@.map -Wl,--unresolved-symbols=report-all -nostdlib
73 53 dgisselq
STARTUP := resetdump.s
74
STARTOBJ:= $(addprefix $(OBJDIR)/,$(subst .s,.o,$(STARTUP)))
75 12 dgisselq
 
76
$(OBJDIR)/:
77 45 dgisselq
        $(mk-objdir)
78 12 dgisselq
 
79
%.o: $(OBJDIR)/%.o
80
 
81
$(OBJDIR)/%.o: %.c
82 45 dgisselq
        $(mk-objdir)
83 12 dgisselq
        $(CC) $(CFLAGS) -c $< -o $@
84 53 dgisselq
$(OBJDIR)/cputest.o: cputest.c
85
        $(mk-objdir)
86
        $(CC) $(CFLAGS) -Wa,-nocis -c $< -o $@
87
$(OBJDIR)/cputestcis.o: cputest.c
88
        $(mk-objdir)
89
        $(CC) $(CFLAGS) -Wa,-cis -c $< -o $@
90 45 dgisselq
$(OBJDIR)/%.o: ../zipos/%.c
91
        $(mk-objdir)
92
        $(CC) $(CFLAGS) -c $< -o $@
93 53 dgisselq
$(OBJDIR)/%.o: %.s
94
        $(mk-objdir)
95
        $(AS) -nocis $< -o $@
96 12 dgisselq
 
97
$(OBJDIR)/%.s: %.c
98 45 dgisselq
        $(mk-objdir)
99 12 dgisselq
        $(CC) -S $(CFLAGS) -c $< -o $@
100
 
101
$(OBJDIR)/%.txt: $(OBJDIR)/%.o
102 45 dgisselq
        $(mk-objdir)
103 12 dgisselq
        $(OBJDUMP) -dr $^ > $@
104 45 dgisselq
%.txt: %
105
        $(OBJDUMP) -Dr $< > $@
106 12 dgisselq
 
107
 
108 53 dgisselq
helloworld: $(OBJDIR)/helloworld.o $(STARTOBJ) cmod.ld
109
        $(CC) $(LDFLAGS) $(STARTOBJ) $(OBJDIR)/helloworld.o -o $@
110 12 dgisselq
$(OBJDIR)/helloworld.txt: helloworld
111
        $(OBJDUMP) -dr $^ > $@
112
 
113 53 dgisselq
uartecho: $(OBJDIR)/uartecho.o $(STARTOBJ) cmod.ld
114
        $(CC) $(LDFLAGS) $(STARTOBJ) $(OBJDIR)/uartecho.o -o $@
115 45 dgisselq
 
116 53 dgisselq
doorbell: $(OBJDIR)/doorbell.o $(STARTOBJ) cmod.ld
117
        $(CC) $(LDFLAGS) $(STARTOBJ) $(OBJDIR)/doorbell.o -o $@
118
 
119
doorbell2: $(OBJDIR)/doorbell2.o $(OBJDRVR) $(STARTOBJ) $(OBJDIR)/string.o cmod.ld
120
        $(CC) $(LDFLAGS) $(STARTOBJ) $(OBJDIR)/doorbell2.o $(OBJDRVR) $(OBJDIR)/string.o -o $@
121 15 dgisselq
$(OBJDIR)/doorbell2.txt: doorbell2
122
        $(OBJDUMP) -dr $^ > $@
123
 
124 45 dgisselq
KPSRCS := kptest.c keypad.c txfns.c
125
KPOBJS := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(KPSRCS)))
126 53 dgisselq
kptest: $(KPOBJS) $(STARTOBJ) cmod.ld
127
        $(CC) $(LDFLAGS) $(STARTOBJ) $(KPOBJS) -o $@
128 29 dgisselq
$(OBJDIR)/kptest.txt: kptest
129
        $(OBJDUMP) -dr $^ > $@
130
 
131 45 dgisselq
blinky: $(OBJDIR)/blinky.o cmod.ld
132 53 dgisselq
        $(CC) $(LDFLAGS) $(STARTOBJ) $(OBJDIR)/blinky.o -o $@
133 45 dgisselq
 
134 53 dgisselq
cputest: $(OBJDIR)/cputest.o cmod.ld
135
        $(CC) $(LDFLAGS) $(OBJDIR)/cputest.o -o $@
136
 
137
cputestcis: $(OBJDIR)/cputestcis.o cmod.ld
138
        $(CC) $(LDFLAGS) $(OBJDIR)/cputestcis.o -o $@
139
 
140 45 dgisselq
define  mk-objdir
141
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
142
endef
143
 
144 12 dgisselq
define  build-depends
145
        @echo "Building dependency file(s)"
146
        $(CC) $(CPPFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdep.txt
147
        $(SED) -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdep.txt > $(OBJDIR)/depends.txt
148
        @rm $(OBJDIR)/xdep.txt
149
endef
150
 
151
.PHONY: depends
152
depends: $(OBJDIR)/ tags
153
        $(build-depends)
154
 
155
tags: $(SOURCES) $(HEADERS)
156
        @echo "Generating tags"
157
        @ctags $(SOURCES) $(HEADERS)
158
 
159
.PHONY: clean
160
clean:
161
        rm -rf $(OBJDIR)/ $(PROGRAMS)
162
 
163
-include $(OBJDIR)/depends.txt

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.