1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
# Top level -*- Makefile -*- for GHDL.
# Copyright (C) 2002 - 2014 Tristan Gingold
#
# GHDL is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later
# version.
#
# GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING. If not, write to the Free
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
CC=@CC@
build=@build@
srcdir=@srcdir@
GNATMAKE=@GNATMAKE@
prefix=@prefix@
backend=@backend@
libdirsuffix=@libdirsuffix@
libdirreverse=@libdirreverse@
gcc_src_dir=@gcc_src_dir@
llvm_prefix=@llvm_prefix@
INSTALL_PROGRAM=install -m 755
INSTALL_DATA=install -m 644
DESTDIR=
bindir=$(prefix)/bin
MKDIR=mkdir
LN=ln -s
CP=cp
SED=sed
GRT_RANLIB=ranlib
VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)
ADAC=$(CC)
GNATFLAGS=-gnaty3befhkmr -gnata -gnatwae -aO. -g -gnatf -gnat05
GRT_FLAGS=-g
LIB_CFLAGS=-g -O2
# Optimize, do not forget to use MODE=--genfast for iirs.adb.
#GNATFLAGS+=-O -gnatn
#GRT_FLAGS+=-O
# Profiling.
#GNATFLAGS+=-pg -gnatn -O
#GRT_FLAGS+=-pg -O
# Coverage
#GNATFLAGS+=-fprofile-arcs -ftest-coverage
GNAT_BARGS=-bargs -E
target=$(build)
#target=i686-pc-linux-gnu
#target=x86_64-pc-linux-gnu
#target=i686-apple-darwin
#target=x86_64-apple-darwin
#target=i386-pc-mingw32
all: Makefile all.$(backend)
install: install.$(backend)
check: check.$(backend)
copy-sources: copy-sources.$(backend)
Makefile: $(srcdir)/Makefile.in
./config.status
#################### For mcode backend ##############################
all.mcode: ghdl_mcode libs.vhdl.mcode
GRTSRCDIR=$(srcdir)/src/grt
include $(GRTSRCDIR)/Makefile.inc
GHDL_COMMON_INCFLAGS=-aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/vhdl/translate -aI$(srcdir)/src/ortho
GHDL_MCODE_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/ortho/mcode
ghdl_mcode: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
ghdl_mcode: $(GRT_ADD_OBJS) $(ORTHO_DEPS) memsegs_c.o chkstk.o force
$(GNATMAKE) -o $@ $(GHDL_MCODE_INCFLAGS) $(GNATFLAGS) ghdl_jit.adb $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
memsegs_c.o: $(srcdir)/src/ortho/mcode/memsegs_c.c
$(CC) -c -g -o $@ $<
libs.vhdl.mcode: libs.vhdl.all
install.vhdl.mcode: install.dirs #libs.vhdl.mcode
# Copy libraries and relocate source files.
for d in v08/ieee v08/std v87/ieee v87/std v87/synopsys \
v93/ieee v93/mentor v93/std v93/synopsys; do \
$(MKDIR) -p $(DESTDIR)$(VHDL_LIB_DIR)/$$d; \
$(INSTALL_DATA) -p \
$(libdirsuffix)/$$d/* $(DESTDIR)$(VHDL_LIB_DIR)/$$d; \
for c in $(libdirsuffix)/$$d/*.cf; do \
$(SED) -e '/file/s@".*/libraries@"../../src@g' \
< $$c > $(DESTDIR)$(prefix)/$$c; \
done; \
done
install.mcode.program: install.dirs ghdl_mcode
$(INSTALL_PROGRAM) ghdl_mcode $(DESTDIR)$(bindir)/ghdl
install.mcode: install.mcode.program install.vhdl.srcs install.vhdl.mcode
#################### For gcc backend ##############################
gcc_vhdl_dir=$(gcc_src_dir)/gcc/vhdl
all.gcc:
echo "For installing sources in gcc, do: make copy-sources"
echo "Then configure gcc"
copy-sources.gcc:
$(RM) -rf $(gcc_vhdl_dir)
$(MKDIR) $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/*.ad? $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/vhdl/*.ad? $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/vhdl/translate/*.ad? $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/psl/*.ad? $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/ortho/*.ad? $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/ortho/gcc/*.ad? $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/ortho/gcc/*.c $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/src/ortho/gcc/*.opt $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/doc/ghdl.texi $(srcdir)/doc/ghdl.1 $(gcc_vhdl_dir)
$(MKDIR) $(gcc_vhdl_dir)/grt
$(CP) -pR $(srcdir)/src/grt/* $(gcc_vhdl_dir)/grt
$(MKDIR) $(gcc_vhdl_dir)/libraries
$(CP) -pR $(srcdir)/libraries/* $(gcc_vhdl_dir)/libraries
$(MKDIR) $(gcc_vhdl_dir)/ghdldrv
$(CP) -pR $(srcdir)/src/ghdldrv/*.ad? $(gcc_vhdl_dir)/ghdldrv
$(CP) -p $(srcdir)/dist/gcc/Make-lang.in $(gcc_vhdl_dir)
$(SED) \
-e "/^####libraries Makefile.inc/r $(srcdir)/libraries/Makefile.inc" \
-e "/^####grt Makefile.inc/r $(srcdir)/src/grt/Makefile.inc" \
< $(srcdir)/dist/gcc/Makefile.in > $(gcc_vhdl_dir)/Makefile.in
$(CP) -p $(srcdir)/dist/gcc/Makefile.in $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/dist/gcc/config-lang.in $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/dist/gcc/lang-options.h $(gcc_vhdl_dir)
$(CP) -p $(srcdir)/dist/gcc/lang-specs.h $(gcc_vhdl_dir)
GHDL_GCC_INCFLAGS=-aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/vhdl/translate
ghdl1-gcc: force
$(MAKE) -f $(srcdir)/src/ortho/gcc/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="$(GHDL_GCC_INCFLAGS) $(GNATFLAGS)" all
ghdl_gcc: force
$(GNATMAKE) $(GHDL_GCC_INCFLAGS) -aI$(srcdir)/src/ghdldrv \
$(GNATFLAGS) ghdl_gcc $(GNAT_BARGS) -largs $(GNAT_LARGS)
grt.links:
cd $(libdirsuffix); ln -sf $(libdirreverse)/grt.lst .; ln -sf $(libdirreverse)/libgrt.a .; ln -sf $(libdirreverse)/grt.ver .
libs.vhdl.gcc: ghdl_gcc ghdl1-gcc
$(MAKE) GHDL=ghdl_gcc libs.vhdl.all
$(MAKE) GHDL1=./ghdl1-gcc libs.vhdl.standard
#################### For llvm backend ##############################
LLVM_CONFIG=$(llvm_prefix)/bin/llvm-config
GHDL_LLVM_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/ortho/llvm
all.llvm: ghdl_llvm_jit
ghdl_llvm_jit: GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
ghdl_llvm_jit: $(GRT_ADD_OBJS) $(ORTHO_DEPS) llvm-cbindings.o force
$(GNATMAKE) -o $@ $(GHDL_LLVM_INCFLAGS) $(GNATFLAGS) ghdl_jit.adb $(GNAT_BARGS) -largs llvm-cbindings.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) `$(LLVM_CONFIG) --ldflags --libs --system-libs` -lc++
llvm-cbindings.o: $(srcdir)/src/ortho/llvm/llvm-cbindings.cpp
$(CXX) -c -m64 `$(LLVM_CONFIG) --includedir --cxxflags` -g -o $@ $<
ghdl_llvm: force
$(GNATMAKE) $(GHDL_LLVM_INCFLAGS) -aI$(srcdir)/src/ghdldrv $(GNATFLAGS)\
ghdl_llvm $(GNAT_BARGS) -largs $(GNAT_LARGS)
ghdl1-llvm: force
$(MAKE) -f $(srcdir)/src/ortho/llvm/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="$(GHDL_LLVM_INCFLAGS) $(GNATFLAGS)" \
LLVM_CONFIG="$(LLVM_CONFIG)" all
################ For simul (no code generation, interpretation) ##########
ghdl_simul: $(GRT_ADD_OBJS) force
$(GNATMAKE) -aI../../simulate $(GNATFLAGS) ghdl_simul $(GNAT_BARGS) -largs $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
################ Libraries ###############################################
LIB87_DIR:=$(libdirsuffix)/v87
LIB93_DIR:=$(libdirsuffix)/v93
LIB08_DIR:=$(libdirsuffix)/v08
LIBSRC_DIR:=$(srcdir)/libraries
REL_DIR:=$(libdirreverse)/../..
GHDL=ghdl_$(backend)
ANALYZE:=$(REL_DIR)/$(GHDL) -a $(LIB_CFLAGS)
ANALYZE_DEP:=$(GHDL)
$(LIB87_DIR) $(LIB93_DIR) $(LIB08_DIR):
[ -d $(libdirsuffix) ] || mkdir -p $(libdirsuffix)
[ -d $@ ] || mkdir $@
include $(srcdir)/libraries/Makefile.inc
GHDL1=./ghdl1-gcc
$(LIB93_DIR)/std/std_standard.o: $(GHDL1)
ifeq ($(GHDL),ghdl_llvm)
$(GHDL1) --std=93 -quiet $(LIB_CFLAGS) -c -o $@ --compile-standard
else
$(GHDL1) --std=93 -quiet $(LIB_CFLAGS) -o std_standard.s \
--compile-standard
$(CC) -c -o $@ std_standard.s
$(RM) std_standard.s
endif
$(LIB87_DIR)/std/std_standard.o: $(GHDL1)
ifeq ($(GHDL),ghdl_llvm)
$(GHDL1) --std=87 -quiet $(LIB_CFLAGS) -c -o $@ --compile-standard
else
$(GHDL1) --std=87 -quiet $(LIB_CFLAGS) -o std_standard.s \
--compile-standard
$(CC) -c -o $@ std_standard.s
$(RM) std_standard.s
endif
$(LIB08_DIR)/std/std_standard.o: $(GHDL1)
ifeq ($(GHDL),ghdl_llvm)
$(GHDL1) --std=08 -quiet $(LIB_CFLAGS) -c -o $@ --compile-standard
else
$(GHDL1) --std=08 -quiet $(LIB_CFLAGS) -o std_standard.s \
--compile-standard
$(CC) -c -o $@ std_standard.s
$(RM) std_standard.s
endif
libs.vhdl.v93: std.v93 ieee.v93 synopsys.v93 mentor.v93
libs.vhdl.v87: std.v87 ieee.v87 synopsys.v87
libs.vhdl.v08: std.v08 ieee.v08
libs.vhdl.all: libs.vhdl.v87 libs.vhdl.v93 libs.vhdl.v08
libs.vhdl.standard: $(LIB93_DIR)/std/std_standard.o \
$(LIB87_DIR)/std/std_standard.o \
$(LIB08_DIR)/std/std_standard.o
libs.vhdl.simul:
$(MAKE) GHDL=ghdl_simul libs.vhdl.all
libs.vhdl.llvmjit:
$(MAKE) GHDL=ghdl_llvm_jit libs.vhdl.all
libs.vhdl.llvm:
$(MAKE) GHDL=ghdl_llvm libs.vhdl.all
$(MAKE) GHDL1=./ghdl1-llvm libs.vhdl.standard
install.dirs:
[ -d $(DESTDIR)$(prefix) ] || $(MKDIR) -p $(DESTDIR)$(prefix)
[ -d $(DESTDIR)$(bindir) ] || $(MKDIR) -p $(DESTDIR)$(bindir)
install.vhdl.srcs:
# Install VHDL sources.
$(RM) -rf $(DESTDIR)$(VHDL_LIB_DIR)/src
$(MKDIR) -p $(DESTDIR)$(VHDL_LIB_DIR)/src
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/std
for i in $(STD93_SRCS) $(STD87_SRCS) $(STD08_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/std; \
done
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/ieee
for i in $(IEEE93_SRCS) $(IEEE87_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/ieee; \
done
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/vital95
for i in $(VITAL95_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/vital95; \
done
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/vital2000
for i in $(VITAL2000_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/vital2000; \
done
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/synopsys
for i in $(SYNOPSYS_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/synopsys; \
done
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/mentor
for i in $(MENTOR93_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/mentor; \
done
$(MKDIR) $(DESTDIR)$(VHDL_LIB_DIR)/src/ieee2008
for i in $(IEEE08_SRCS); do \
$(INSTALL_DATA) -p $$i $(DESTDIR)$(VHDL_LIB_DIR)/src/ieee2008; \
done
####################### clean ############################################
clean: force
$(RM) -f *.o *.ali b~*.ad? *~ *.d b__*.ad? *.a *.deps *.bexch
$(RM) -f ghdl_gcc ghdl_mcode ghdl ghdl_llvm ghdl_llvm_jit ghdl_simul
$(RM) -f ghdl1-gcc ghdl1-llvm
$(RM) -f run-bind.ad? grt.lst grt-files grt-files.in
$(RM) -rf lib
distclean: clean
$(RM) -f default_pathes.ads ortho_code-x86-flags.ads
$(RM) -f Makefile config.status ghdl.gpr
clean-c: force
$(RM) -f memsegs_c.o chkstk.o linux.o times.o grt-cbinding.o grt-cvpi.o
force:
.PHONY: force clean distclean clean-c
|