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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [Makefile] - Blame information for rev 26

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
################################################################################
2
#
3
# Filename:     Makefile
4
#
5
# Project:      Zip CPU -- a small, lightweight, RISC CPU soft core
6
#
7 13 dgisselq
# Purpose:      This makefile builds an assembler preprocessor (zpp), an
8
#               assembler (zasm) and a disassembler (zdump).  Make with no
9
#               arguments will produce these files.  Other targets include:
10 2 dgisselq
#
11 13 dgisselq
#       make clean
12
#       make test
13
#               Assembles a test file and then produces a disassembly of it.
14
#       make depends
15
#               Doesn't work.  Dependencies are currently all hand coded.
16
#       make optest
17
#       make tags
18 2 dgisselq
#
19 13 dgisselq
#
20 2 dgisselq
# Creator:      Dan Gisselquist, Ph.D.
21
#               Gisselquist Tecnology, LLC
22
#
23
################################################################################
24
#
25
# Copyright (C) 2015, Gisselquist Technology, LLC
26
#
27
# This program is free software (firmware): you can redistribute it and/or
28
# modify it under the terms of  the GNU General Public License as published
29
# by the Free Software Foundation, either version 3 of the License, or (at
30
# your option) any later version.
31
#
32
# This program is distributed in the hope that it will be useful, but WITHOUT
33
# ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
34
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35
# for more details.
36
#
37
# License:      GPL, v3, as defined and found on www.gnu.org,
38
#               http://www.gnu.org/licenses/gpl.html
39
#
40
#
41
################################################################################
42
#
43
OBJDIR= obj-pc
44
CXX=    g++
45
CC=     gcc
46 13 dgisselq
YACC=   bison
47
LEX=    flex
48 2 dgisselq
YYMMDD=`date +%Y%m%d`
49
DBGFLAGS= -g -O0
50
OPTFLAGS= -O3
51
CCFLAGS= $(DBGFLAGS)
52 13 dgisselq
PROGRAMS= zasm optest zdump zpp
53 2 dgisselq
 
54
.PHONY: programs
55
all:    $(OBJDIR)/ programs
56
 
57
programs:       $(PROGRAMS)
58
 
59 13 dgisselq
$(OBJDIR)/zpp.cpp: zpp.l
60
        $(LEX) -o $@ $^
61
$(OBJDIR)/zpp.o: $(OBJDIR)/zpp.cpp
62
        $(CXX) -c $(CCFLAGS) $(OBJDIR)/zpp.cpp -o $@
63
zpp: $(OBJDIR)/zpp.o
64
        $(CXX) -o $@ $(CCFLAGS) $^
65 2 dgisselq
 
66 13 dgisselq
$(OBJDIR)/zasm.tab.h: zasm.y asmdata.h zparser.h
67
        $(YACC) -b $(OBJDIR)/zasm -d zasm.y
68
zasm.output: zasm.y asmdata.h
69
        $(YACC) -v -b $(OBJDIR)/zasm -d zasm.y
70
$(OBJDIR)/zasm.lex.cpp: zasm.l $(OBJDIR)/zasm.tab.h
71
        $(LEX) -o $@ zasm.l
72
$(OBJDIR)/zasm.lex.o: $(OBJDIR)/zasm.lex.cpp
73
        $(CXX) -c -I. -I$(OBJDIR)/ $(CCFLAGS) $(OBJDIR)/zasm.lex.cpp -o $@
74
$(OBJDIR)/zasm.tab.o: $(OBJDIR)/zasm.tab.c
75
        $(CXX) -c -I. -I$(OBJDIR)/ $(CCFLAGS) $(OBJDIR)/zasm.tab.c -o $@
76
$(OBJDIR)/asmdata.o: asmdata.cpp zopcodes.h zparser.h
77
        $(CXX) -c -I. $(CCFLAGS) asmdata.cpp -o $@
78
zasm: $(OBJDIR)/zasm.lex.o $(OBJDIR)/zasm.tab.o $(OBJDIR)/asmdata.o
79
zasm: $(OBJDIR)/zparser.o $(OBJDIR)/zopcodes.o $(OBJDIR)/twoc.o
80
        $(CXX) -o $@ $(CCFLAGS) $^
81
 
82 2 dgisselq
optest: optest.cpp zopcodes.cpp twoc.cpp twoc.h zopcodes.h
83
        $(CXX) $(CCFLAGS) optest.cpp zopcodes.cpp twoc.cpp -o optest
84
 
85
ZDMPSRC= zdump.cpp zopcodes.cpp twoc.cpp
86
ZDMPOBJ= $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(ZDMPSRC)))
87
zdump:  $(ZDMPOBJ)
88
        $(CXX) $(CCFLAGS) $(ZDMPOBJ) -o $@
89
 
90
$(OBJDIR)/%.o: %.cpp
91
        $(CXX) -c $(CCFLAGS) $< -o $@
92
 
93
$(OBJDIR)/:
94
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
95
 
96 13 dgisselq
.PHONY: test
97
test:   dumpd.txt
98 26 dgisselq
z.out:  test.S zasm zdump zpp
99 13 dgisselq
        ./zasm test.S -o z.out
100
dumpd.txt:      z.out zdump
101
        ./zdump z.out > dumpd.txt
102
 
103 2 dgisselq
define  build-depends
104
        @echo "Building dependency file(s)"
105 13 dgisselq
        @$(CXX) -I $(OBJDIR)/ $(CCFLAGS) -MM *.cpp > xd.txt
106 2 dgisselq
        @sed -e 's/^.*.o: /$(OBJDIR)\/&/' < xd.txt > $(OBJDIR)/depends.txt
107
        @rm xd.txt
108
endef
109
 
110
tags: $(SOURCES) $(HEADERS)
111
        @echo "Generating tags"
112
        @ctags *.cpp *.h # $(SOURCES) $(HEADERS)
113
 
114
.PHONY: depends
115
depends: tags
116
        $(build-depends)
117
 
118 13 dgisselq
$(OBJDIR)/depends.txt: $(SOURCES) $(HEADERS)
119 2 dgisselq
        $(build-depends)
120
 
121
.PHONY: clean
122
clean:
123 13 dgisselq
        rm -rf $(OBJDIR) $(PROGRAMS) z.out dumpd.txt
124 2 dgisselq
 
125
-include $(OBJDIR)/depends.txt
126
 
127
 

powered by: WebSVN 2.1.0

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