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

Subversion Repositories s6soc

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

Go to most recent revision | 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
all:
49 45 dgisselq
PROGRAMS := helloworld doorbell doorbell2 kptest blinky
50 12 dgisselq
all: $(OBJDIR)/ $(PROGRAMS)
51
 
52
 
53
OBJDIR := obj-zip
54
CROSS := zip
55
CC    := $(CROSS)-gcc
56
AS    := $(CROSS)-as
57
LD    := $(CROSS)-ld
58
SED   := sed
59
OBJDUMP := $(CROSS)-objdump
60
 
61
# Not for build, for for building tags and dependency files, we need to know
62
# what the sources and headers are
63 45 dgisselq
DEVDRVR:= keypad.c display.c rtcsim.c txfns.c
64 29 dgisselq
SOURCES:= helloworld.c doorbell.c doorbell2.c kptest.c $(DEVDRVR)
65 12 dgisselq
HEADERS:= board.h
66 15 dgisselq
OBJDRVR := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(DEVDRVR)))
67 12 dgisselq
 
68
CPPFLAGS := -I../zipos -I.
69 45 dgisselq
DUMPFLAGS := # -fdump-rtl-all
70
CFLAGS   := $(CPPFLAGS) $(DUMPFLAGS) -O3 -Wall -Wextra -nostdlib -fno-builtin -Wa,-nocis
71 12 dgisselq
LDFLAGS   = -T cmod.ld -Wl,-Map,$(OBJDIR)/$@.map -Wl,--unresolved-symbols=report-all -nostdlib
72
 
73
$(OBJDIR)/:
74 45 dgisselq
        $(mk-objdir)
75 12 dgisselq
 
76
%.o: $(OBJDIR)/%.o
77
 
78
$(OBJDIR)/%.o: %.c
79 45 dgisselq
        $(mk-objdir)
80 12 dgisselq
        $(CC) $(CFLAGS) -c $< -o $@
81 45 dgisselq
$(OBJDIR)/%.o: ../zipos/%.c
82
        $(mk-objdir)
83
        $(CC) $(CFLAGS) -c $< -o $@
84 12 dgisselq
 
85
$(OBJDIR)/%.s: %.c
86 45 dgisselq
        $(mk-objdir)
87 12 dgisselq
        $(CC) -S $(CFLAGS) -c $< -o $@
88
 
89
$(OBJDIR)/%.txt: $(OBJDIR)/%.o
90 45 dgisselq
        $(mk-objdir)
91 12 dgisselq
        $(OBJDUMP) -dr $^ > $@
92 45 dgisselq
%.txt: %
93
        $(OBJDUMP) -Dr $< > $@
94 12 dgisselq
 
95
 
96 45 dgisselq
helloworld: $(OBJDIR)/helloworld.o cmod.ld
97 12 dgisselq
        $(CC) $(LDFLAGS) $(OBJDIR)/helloworld.o -o $@
98
$(OBJDIR)/helloworld.txt: helloworld
99
        $(OBJDUMP) -dr $^ > $@
100
 
101 45 dgisselq
doorbell: $(OBJDIR)/doorbell.o cmod.ld
102
        $(CC) $(LDFLAGS) $(OBJDIR)/doorbell.o -o $@
103
 
104
doorbell2: $(OBJDIR)/doorbell2.o $(OBJDRVR) $(OBJDIR)/string.o cmod.ld
105
        $(CC) $(LDFLAGS) $(OBJDIR)/doorbell2.o $(OBJDRVR) $(OBJDIR)/string.o -o $@
106 15 dgisselq
$(OBJDIR)/doorbell2.txt: doorbell2
107
        $(OBJDUMP) -dr $^ > $@
108
 
109 45 dgisselq
KPSRCS := kptest.c keypad.c txfns.c
110
KPOBJS := $(addprefix $(OBJDIR)/,$(subst .c,.o,$(KPSRCS)))
111
kptest: $(KPOBJS) cmod.ld
112
        $(CC) $(LDFLAGS) $(KPOBJS) -o $@
113 29 dgisselq
$(OBJDIR)/kptest.txt: kptest
114
        $(OBJDUMP) -dr $^ > $@
115
 
116 45 dgisselq
blinky: $(OBJDIR)/blinky.o cmod.ld
117
        $(CC) $(LDFLAGS) $(OBJDIR)/blinky.o -o $@
118
 
119
define  mk-objdir
120
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
121
endef
122
 
123 12 dgisselq
define  build-depends
124
        @echo "Building dependency file(s)"
125
        $(CC) $(CPPFLAGS) -MM $(SOURCES) > $(OBJDIR)/xdep.txt
126
        $(SED) -e 's/^.*.o: /$(OBJDIR)\/&/' < $(OBJDIR)/xdep.txt > $(OBJDIR)/depends.txt
127
        @rm $(OBJDIR)/xdep.txt
128
endef
129
 
130
.PHONY: depends
131
depends: $(OBJDIR)/ tags
132
        $(build-depends)
133
 
134
tags: $(SOURCES) $(HEADERS)
135
        @echo "Generating tags"
136
        @ctags $(SOURCES) $(HEADERS)
137
 
138
.PHONY: clean
139
clean:
140
        rm -rf $(OBJDIR)/ $(PROGRAMS)
141
 
142
-include $(OBJDIR)/depends.txt

powered by: WebSVN 2.1.0

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