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

Subversion Repositories zipcpu

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

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 137 dgisselq
CFILES= asmdata.cpp twoc.cpp zdump.cpp zopcodes.cpp zparser.cpp
57
HFILES= asmdata.h twoc.h zopcodes.h zparser.h
58 2 dgisselq
 
59
.PHONY: programs
60
all:    $(OBJDIR)/ programs
61
 
62 110 dgisselq
install: zasm zdump zpp
63 200 dgisselq
        bash -c "if [[ ! -e $(INSTALLD) ]]; then mkdir -p $(INSTALLD); fi"
64 110 dgisselq
        cp $^ $(INSTALLD)/
65
 
66 2 dgisselq
programs:       $(PROGRAMS)
67
 
68 13 dgisselq
$(OBJDIR)/zpp.cpp: zpp.l
69
        $(LEX) -o $@ $^
70
$(OBJDIR)/zpp.o: $(OBJDIR)/zpp.cpp
71
        $(CXX) -c $(CCFLAGS) $(OBJDIR)/zpp.cpp -o $@
72
zpp: $(OBJDIR)/zpp.o
73
        $(CXX) -o $@ $(CCFLAGS) $^
74 2 dgisselq
 
75 200 dgisselq
$(OBJDIR)/zasm.tab.h: $(OBJDIR)/ zasm.y asmdata.h zparser.h
76 13 dgisselq
        $(YACC) -b $(OBJDIR)/zasm -d zasm.y
77 200 dgisselq
$(OBJDIR)/zasm.tab.c: $(OBJDIR)/zasm.tab.h
78
$(OBJDIR)/zasm.tab.c: ;
79 13 dgisselq
zasm.output: zasm.y asmdata.h
80
        $(YACC) -v -b $(OBJDIR)/zasm -d zasm.y
81
$(OBJDIR)/zasm.lex.cpp: zasm.l $(OBJDIR)/zasm.tab.h
82
        $(LEX) -o $@ zasm.l
83
$(OBJDIR)/zasm.lex.o: $(OBJDIR)/zasm.lex.cpp
84
        $(CXX) -c -I. -I$(OBJDIR)/ $(CCFLAGS) $(OBJDIR)/zasm.lex.cpp -o $@
85 46 dgisselq
$(OBJDIR)/zasm.tab.o: $(OBJDIR)/zasm.tab.c $(OBJDIR)/zasm.tab.h
86 13 dgisselq
        $(CXX) -c -I. -I$(OBJDIR)/ $(CCFLAGS) $(OBJDIR)/zasm.tab.c -o $@
87
$(OBJDIR)/asmdata.o: asmdata.cpp zopcodes.h zparser.h
88
        $(CXX) -c -I. $(CCFLAGS) asmdata.cpp -o $@
89
zasm: $(OBJDIR)/zasm.lex.o $(OBJDIR)/zasm.tab.o $(OBJDIR)/asmdata.o
90
zasm: $(OBJDIR)/zparser.o $(OBJDIR)/zopcodes.o $(OBJDIR)/twoc.o
91
        $(CXX) -o $@ $(CCFLAGS) $^
92
 
93 2 dgisselq
ZDMPSRC= zdump.cpp zopcodes.cpp twoc.cpp
94
ZDMPOBJ= $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(ZDMPSRC)))
95
zdump:  $(ZDMPOBJ)
96
        $(CXX) $(CCFLAGS) $(ZDMPOBJ) -o $@
97
 
98
$(OBJDIR)/%.o: %.cpp
99
        $(CXX) -c $(CCFLAGS) $< -o $@
100
 
101
$(OBJDIR)/:
102
        @bash -c "if [ ! -e $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi"
103
 
104 13 dgisselq
.PHONY: test
105
test:   dumpd.txt
106 34 dgisselq
z.out:  test.S sys.i zasm zdump zpp
107 13 dgisselq
        ./zasm test.S -o z.out
108
dumpd.txt:      z.out zdump
109
        ./zdump z.out > dumpd.txt
110
 
111 2 dgisselq
define  build-depends
112
        @echo "Building dependency file(s)"
113 137 dgisselq
        @$(CXX) -I $(OBJDIR)/ $(CCFLAGS) -MM $(CFILES) > xd.txt
114 46 dgisselq
        @$(CXX) -I $(OBJDIR)/ -I. $(CCFLAGS) -MM $(OBJDIR)/zasm.tab.c >> xd.txt
115
        @$(CXX) -I $(OBJDIR)/ -I. $(CCFLAGS) -MM $(OBJDIR)/zpp.cpp >> xd.txt
116 2 dgisselq
        @sed -e 's/^.*.o: /$(OBJDIR)\/&/' < xd.txt > $(OBJDIR)/depends.txt
117
        @rm xd.txt
118
endef
119
 
120
tags: $(SOURCES) $(HEADERS)
121
        @echo "Generating tags"
122 137 dgisselq
        @ctags $(CFILES) $(HFILES) # $(SOURCES) $(HEADERS)
123 2 dgisselq
 
124
.PHONY: depends
125
depends: tags
126
        $(build-depends)
127
 
128 200 dgisselq
$(OBJDIR)/depends.txt: $(OBJDIR)/ $(SOURCES) $(HEADERS)
129 2 dgisselq
        $(build-depends)
130
 
131
.PHONY: clean
132
clean:
133 13 dgisselq
        rm -rf $(OBJDIR) $(PROGRAMS) z.out dumpd.txt
134 2 dgisselq
 
135
-include $(OBJDIR)/depends.txt
136
 
137
 

powered by: WebSVN 2.1.0

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