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

Subversion Repositories zipcpu

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

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

powered by: WebSVN 2.1.0

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