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

Subversion Repositories zipcpu

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

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 tags
17 110 dgisselq
#       make install
18
#               Attempts to copy zasm, zpp and zdump to the install directory,
19
#               defined herein
20 2 dgisselq
#
21 13 dgisselq
#
22 2 dgisselq
# Creator:      Dan Gisselquist, Ph.D.
23 69 dgisselq
#               Gisselquist Technology, LLC
24 2 dgisselq
#
25
################################################################################
26
#
27
# Copyright (C) 2015, Gisselquist Technology, LLC
28
#
29
# This program is free software (firmware): you can redistribute it and/or
30
# modify it under the terms of  the GNU General Public License as published
31
# by the Free Software Foundation, either version 3 of the License, or (at
32
# your option) any later version.
33
#
34
# This program is distributed in the hope that it will be useful, but WITHOUT
35
# ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
36
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
37
# for more details.
38
#
39
# License:      GPL, v3, as defined and found on www.gnu.org,
40
#               http://www.gnu.org/licenses/gpl.html
41
#
42
#
43
################################################################################
44
#
45
OBJDIR= obj-pc
46
CXX=    g++
47
CC=     gcc
48 13 dgisselq
YACC=   bison
49
LEX=    flex
50 2 dgisselq
YYMMDD=`date +%Y%m%d`
51
DBGFLAGS= -g -O0
52
OPTFLAGS= -O3
53
CCFLAGS= $(DBGFLAGS)
54 110 dgisselq
PROGRAMS= zasm zdump zpp
55
INSTALLD= ../install/cross-tools/bin
56 2 dgisselq
 
57
.PHONY: programs
58
all:    $(OBJDIR)/ programs
59
 
60 110 dgisselq
install: zasm zdump zpp
61
        cp $^ $(INSTALLD)/
62
 
63 2 dgisselq
programs:       $(PROGRAMS)
64
 
65 13 dgisselq
$(OBJDIR)/zpp.cpp: zpp.l
66
        $(LEX) -o $@ $^
67
$(OBJDIR)/zpp.o: $(OBJDIR)/zpp.cpp
68
        $(CXX) -c $(CCFLAGS) $(OBJDIR)/zpp.cpp -o $@
69
zpp: $(OBJDIR)/zpp.o
70
        $(CXX) -o $@ $(CCFLAGS) $^
71 2 dgisselq
 
72 13 dgisselq
$(OBJDIR)/zasm.tab.h: zasm.y asmdata.h zparser.h
73
        $(YACC) -b $(OBJDIR)/zasm -d zasm.y
74
zasm.output: zasm.y asmdata.h
75
        $(YACC) -v -b $(OBJDIR)/zasm -d zasm.y
76
$(OBJDIR)/zasm.lex.cpp: zasm.l $(OBJDIR)/zasm.tab.h
77
        $(LEX) -o $@ zasm.l
78
$(OBJDIR)/zasm.lex.o: $(OBJDIR)/zasm.lex.cpp
79
        $(CXX) -c -I. -I$(OBJDIR)/ $(CCFLAGS) $(OBJDIR)/zasm.lex.cpp -o $@
80 46 dgisselq
$(OBJDIR)/zasm.tab.o: $(OBJDIR)/zasm.tab.c $(OBJDIR)/zasm.tab.h
81 13 dgisselq
        $(CXX) -c -I. -I$(OBJDIR)/ $(CCFLAGS) $(OBJDIR)/zasm.tab.c -o $@
82
$(OBJDIR)/asmdata.o: asmdata.cpp zopcodes.h zparser.h
83
        $(CXX) -c -I. $(CCFLAGS) asmdata.cpp -o $@
84
zasm: $(OBJDIR)/zasm.lex.o $(OBJDIR)/zasm.tab.o $(OBJDIR)/asmdata.o
85
zasm: $(OBJDIR)/zparser.o $(OBJDIR)/zopcodes.o $(OBJDIR)/twoc.o
86
        $(CXX) -o $@ $(CCFLAGS) $^
87
 
88 2 dgisselq
ZDMPSRC= zdump.cpp zopcodes.cpp twoc.cpp
89
ZDMPOBJ= $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(ZDMPSRC)))
90
zdump:  $(ZDMPOBJ)
91
        $(CXX) $(CCFLAGS) $(ZDMPOBJ) -o $@
92
 
93
$(OBJDIR)/%.o: %.cpp
94
        $(CXX) -c $(CCFLAGS) $< -o $@
95
 
96
$(OBJDIR)/:
97
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
98
 
99 13 dgisselq
.PHONY: test
100
test:   dumpd.txt
101 34 dgisselq
z.out:  test.S sys.i zasm zdump zpp
102 13 dgisselq
        ./zasm test.S -o z.out
103
dumpd.txt:      z.out zdump
104
        ./zdump z.out > dumpd.txt
105
 
106 2 dgisselq
define  build-depends
107
        @echo "Building dependency file(s)"
108 13 dgisselq
        @$(CXX) -I $(OBJDIR)/ $(CCFLAGS) -MM *.cpp > xd.txt
109 46 dgisselq
        @$(CXX) -I $(OBJDIR)/ -I. $(CCFLAGS) -MM $(OBJDIR)/zasm.tab.c >> xd.txt
110
        @$(CXX) -I $(OBJDIR)/ -I. $(CCFLAGS) -MM $(OBJDIR)/zpp.cpp >> xd.txt
111 2 dgisselq
        @sed -e 's/^.*.o: /$(OBJDIR)\/&/' < xd.txt > $(OBJDIR)/depends.txt
112
        @rm xd.txt
113
endef
114
 
115
tags: $(SOURCES) $(HEADERS)
116
        @echo "Generating tags"
117
        @ctags *.cpp *.h # $(SOURCES) $(HEADERS)
118
 
119
.PHONY: depends
120
depends: tags
121
        $(build-depends)
122
 
123 13 dgisselq
$(OBJDIR)/depends.txt: $(SOURCES) $(HEADERS)
124 2 dgisselq
        $(build-depends)
125
 
126
.PHONY: clean
127
clean:
128 13 dgisselq
        rm -rf $(OBJDIR) $(PROGRAMS) z.out dumpd.txt
129 2 dgisselq
 
130
-include $(OBJDIR)/depends.txt
131
 
132
 

powered by: WebSVN 2.1.0

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