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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
# 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@
EXEEXT=@EXEEXT@
SOEXT=@SOEXT@
PIC_FLAGS=@PIC_FLAGS@
gcc_src_dir=@gcc_src_dir@
LLVM_CONFIG=@llvm_config@
LDFLAGS=@LDFLAGS@
LIBBACKTRACE=@backtrace_lib@
llvm_be=@llvm_be@
llvm_be_ver=@llvm_be_ver@
build_mode=@build_mode@
INSTALL_PROGRAM=install -m 755
INSTALL_DATA=install -m 644
DESTDIR=
bindir=$(prefix)/bin
libdir=$(prefix)/lib
incdir=$(prefix)/include
MKDIR=mkdir
LN=ln -s
CP=cp
SED=sed
GRT_RANLIB=ranlib
VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)
ADAC=$(CC)
# Debug
OPT_FLAGS=-g
ADA_FLAGS=-gnata
LIB_CFLAGS=
# Optimize, do not forget to use MODE=--genfast for iirs.adb.
#ADA_FLAGS+=-gnatpn
#OPT_FLAGS+=-O
#LIB_CFLAGS=-O
# Profiling.
#ADA_FLAGS+=-gnatn
#OPT_FLAGS+=-pg -O
# Coverage
ifeq "$(build_mode)" "coverage"
OPT_FLAGS+=-fprofile-arcs -ftest-coverage
endif
GNATFLAGS=-gnaty3befhkmr -gnatwae -aO. -gnatf -gnat05 $(OPT_FLAGS) $(ADA_FLAGS)
GRT_FLAGS=$(OPT_FLAGS)
WARN_CFLAGS=-Wall
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
GHDL_COMMON_INCFLAGS=-aI$(srcdir)/src -aI$(srcdir)/src/vhdl -aI$(srcdir)/src/psl -aI$(srcdir)/src/vhdl/translate
GRTSRCDIR=$(srcdir)/src/grt
include $(GRTSRCDIR)/Makefile.inc
#################### For mcode backend ##############################
all.mcode: ghdl_mcode$(EXEEXT) libs.vhdl.mcode all.vpi
GHDL_MCODE_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/ortho -aI$(srcdir)/src/ortho/mcode
ghdl_mcode$(EXEEXT): GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
ghdl_mcode$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) $(ORTHO_DEPS) \
memsegs_c.o chkstk.o force
$(GNATMAKE) -o $@ $(GHDL_MCODE_INCFLAGS) $(GNATFLAGS) -gnatw.A 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 $(OPT_FLAGS) -o $@ $<
libs.vhdl.mcode: vhdl.libs.all
install.mcode.program: install.dirs ghdl_mcode$(EXEEXT)
$(INSTALL_PROGRAM) ghdl_mcode$(EXEEXT) $(DESTDIR)$(bindir)/ghdl$(EXEEXT)
install.mcode: install.mcode.program install.vhdllib install.vpi
oread-mcode$(EXEEXT): force
$(MAKE) -f $(srcdir)/src/ortho/mcode/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="-aI$(srcdir)/src/ortho/oread $(GNATFLAGS)" all
#################### For gcc backend ##############################
gcc_vhdl_dir=$(gcc_src_dir)/gcc/vhdl
all.gcc:
echo "For installing sources in gcc, do:"
echo "1) make copy-sources"
echo "2) configure, build and install gcc"
echo "3) make ghdllib"
echo "4) make install"
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)/ghdldrv
$(CP) -pR $(srcdir)/src/ghdldrv/*.ad? $(gcc_vhdl_dir)/ghdldrv
$(CP) -p $(srcdir)/dist/gcc/Make-lang.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)
libs.vhdl.gcc:
$(MAKE) GHDL=$(bindir)/ghdl$(EXEEXT) vhdl.libs.all libs.vhdl.standard
ghdllib: libs.vhdl.gcc libgrt.a
install.gcc: install.vhdllib install.grt install.vpi
#################### For gcc backend - development only (local build) ####
GHDL_GCC_INCFLAGS=$(GHDL_COMMON_INCFLAGS)
ghdl1-gcc$(EXEEXT): force
$(MAKE) -f $(srcdir)/src/ortho/gcc/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="$(GHDL_GCC_INCFLAGS) $(GNATFLAGS)" all
ghdl_gcc$(EXEEXT): 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 .; \
if test "x$(LIBBACKTRACE)" != x; then \
ln -sf $(libdirreverse)/libbacktrace.a .; \
fi
libs.vhdl.local_gcc: ghdl_gcc$(EXEEXT) ghdl1-gcc$(EXEEXT)
$(MAKE) GHDL=$(PWD)/ghdl_gcc$(EXEEXT) ANALYZE_OPTS="--GHDL1=ghdl1-gcc$(EXEEXT)" STD_GHDL_FLAGS="--GHDL1=$(PWD)/ghdl1-gcc$(EXEEXT)" vhdl.libs.all libs.vhdl.standard
ghdl1-debug$(EXEEXT): force
$(MAKE) -f $(srcdir)/src/ortho/debug/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="$(GHDL_GCC_INCFLAGS) $(GNATFLAGS)" \
GNATMAKE="$(GNATMAKE)" all
oread-gcc$(EXEEXT): force
$(MAKE) -f $(srcdir)/src/ortho/gcc/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="-aI$(srcdir)/src/ortho/oread $(GNATFLAGS)" all
#################### For llvm backend ##############################
GHDL_LLVM_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/grt -aI$(srcdir)/src/ortho -aI$(srcdir)/src/ortho/$(llvm_be)
all.llvm: ghdl1-llvm$(EXEEXT) ghdl_llvm$(EXEEXT) grt-all libs.vhdl.llvm all.vpi
all.llvm_jit: ghdl_llvm_jit$(EXEEXT)
ghdl_llvm_jit$(EXEEXT): GRT_FLAGS+=-DWITH_GNAT_RUN_TIME
ghdl_llvm_jit$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) $(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)) --LINK=$(CXX) \
`$(LLVM_CONFIG) --ldflags --libs --system-libs` $(LDFLAGS)
llvm-cbindings.o: $(srcdir)/src/ortho/$(llvm_be)/llvm-cbindings.cpp
$(CXX) -c `$(LLVM_CONFIG) --includedir --cxxflags` \
$(OPT_FLAGS) -o $@ $<
libs.vhdl.llvmjit: ghdl_llvm_jit$(EXEEXT)
$(MAKE) GHDL=$(PWD)/ghdl_llvm_jit$(EXEEXT) vhdl.libs.all
libs.vhdl.llvm: ghdl_llvm$(EXEEXT) ghdl1-llvm$(EXEEXT)
$(MAKE) GHDL=$(PWD)/ghdl_llvm$(EXEEXT) ANALYZE_OPTS="--GHDL1=ghdl1-llvm$(EXEEXT)" vhdl.libs.all libs.vhdl.standard
ghdl_llvm$(EXEEXT): force
$(GNATMAKE) $(GHDL_LLVM_INCFLAGS) -aI$(srcdir)/src/ghdldrv $(GNATFLAGS)\
ghdl_llvm $(GNAT_BARGS) -largs $(GNAT_LARGS)
ghdl1-llvm$(EXEEXT): force
$(MAKE) -f $(srcdir)/src/ortho/$(llvm_be)/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNAT_FLAGS="$(GHDL_LLVM_INCFLAGS) $(GNATFLAGS)" LDFLAGS="$(LDFLAGS)" \
LLVM_CONFIG="$(LLVM_CONFIG)" llvm_be_ver="$(llvm_be_ver)" all
oread-llvm$(EXEEXT): force
$(MAKE) -f $(srcdir)/src/ortho/$(llvm_be)/Makefile \
ortho_srcdir=$(srcdir)/src/ortho ortho_exec=$@ \
GNATMAKE="$(GNATMAKE)" \
GNAT_FLAGS="-aI$(srcdir)/src/ortho/oread $(GNATFLAGS)" \
LLVM_CONFIG="$(LLVM_CONFIG)" llvm_be_ver="$(llvm_be_ver)"
install.llvm.program: install.dirs ghdl1-llvm$(EXEEXT) ghdl_llvm$(EXEEXT)
$(INSTALL_PROGRAM) ghdl_llvm$(EXEEXT) $(DESTDIR)$(bindir)/ghdl$(EXEEXT)
$(INSTALL_PROGRAM) ghdl1-llvm$(EXEEXT) $(DESTDIR)$(bindir)/ghdl1-llvm$(EXEEXT)
install.llvm: install.llvm.program install.vhdllib install.grt install.vpi
################ For simul (no code generation, interpretation) ##########
GHDL_SIMUL_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/vhdl/simulate -aI$(srcdir)/src/grt
ghdl_simul$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) force
$(GNATMAKE) $(GHDL_SIMUL_INCFLAGS) $(GNATFLAGS) ghdl_simul $(GNAT_BARGS) -largs $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB))
libs.vhdl.simul: ghdl_simul$(EXEEXT) vhdl.libs.all
################ mhdlsim (library for the vhdl part) ####################
GHDL_MHDLSIM_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/mhdlsim -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/vhdl/simulate -aI$(srcdir)/src/grt
libmhdlsimvhdl.a: $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) force
$(GNATMAKE) -c mhdlsim $(GNATFLAGS) $(GHDL_MHDLSIM_INCFLAGS)
gnatbind -Lmhdlsim_vhdl_ mhdlsim.ali -O > mhdlsim.files
gnatbind -Lmhdlsim_vhdl_ mhdlsim.ali -K -Z > mhdlsim.link
$(GNATMAKE) -c b~mhdlsim.adb
rm -f $@
ar rc $@ b~mhdlsim.o `cat mhdlsim.files` $(GRT_ADD_OBJS)
################ ghwdump #################################################
GHWDUMP_OBJS=ghwdump.o ghwlib.o
ghwdump: $(GHWDUMP_OBJS)
$(CC) -o $@ $(GHWDUMP_OBJS)
ghwdump.o: $(srcdir)/src/grt/ghwdump.c $(srcdir)/src/grt/ghwlib.h
$(CC) -c -o $@ $< $(OPT_FLAGS) $(WARN_CFLAGS)
ghwlib.o: $(srcdir)/src/grt/ghwlib.c $(srcdir)/src/grt/ghwlib.h
$(CC) -c -o $@ $< $(OPT_FLAGS) $(WARN_CFLAGS)
############### grt #####################################################
install.grt: libgrt.a grt.lst install.dirs
$(INSTALL_DATA) libgrt.a $(DESTDIR)$(VHDL_LIB_DIR)/libgrt.a
$(INSTALL_DATA) grt.lst $(DESTDIR)$(VHDL_LIB_DIR)/grt.lst
$(INSTALL_DATA) $(GRTSRCDIR)/grt.ver $(DESTDIR)$(VHDL_LIB_DIR)/grt.ver
################ VPI #####################################################
vpi_thunk.o: $(GRTSRCDIR)/vpi_thunk.c $(GRTSRCDIR)/vpi_thunk.h
# Do not use OPT_FLAGS (do not enable coverage)
$(CC) -c -o $@ $< $(PIC_FLAGS) -O $(WARN_CFLAGS)
libghdlvpi.so: vpi_thunk.o
$(CC) -o $@ $< -shared -Wl,-soname,libghdlvpi.so
libghdlvpi.dll: vpi_thunk.o
$(CC) -o $@ $< -shared
libghdlvpi.dylib: vpi_thunk.o
# Allow the use of -rpath in executable
$(CC) -o $@ $< -shared -Wl,-install_name,@rpath/libghdlvpi.dylib
all.vpi: libghdlvpi$(SOEXT)
install.vpi: all.vpi install.dirs
$(INSTALL_DATA) -p libghdlvpi$(SOEXT) $(DESTDIR)$(libdir)/
$(INSTALL_DATA) -p $(GRTSRCDIR)/vpi_user.h $(DESTDIR)$(incdir)/
################ Libraries ###############################################
LIBSRC_DIR:=$(srcdir)/libraries
LIBDST_DIR:=$(libdirsuffix)
GHDL=$(PWD)/ghdl_$(backend)$(EXEEXT)
ANALYZE_OPTS:=
ANALYZE:=$(GHDL) -a $(ANALYZE_OPTS) $(LIB_CFLAGS)
ANALYZE_DEP:=$(GHDL)
# TODO?: don't include, make it separate
include $(srcdir)/libraries/Makefile.inc
# TODO?: move std_standard in libraries/Makefile
ifeq "$(backend)" "gcc"
# ghdl with gcc backend is already installed, no need to specify ghdl1
# (and we don't know where it is).
STD_GHDL_FLAGS=
else
# Specify ghdl1 path, as it is spawned by ghdl.
STD_GHDL_FLAGS=--GHDL1=$(PWD)/ghdl1-$(backend)$(EXEEXT)
endif
$(LIB93_DIR)/std/std_standard.o: $(GHDL)
cd $(LIB93_DIR)/std; \
$(GHDL) --bootstrap-standard $(STD_GHDL_FLAGS) --std=93 $(LIB_CFLAGS)
$(LIB87_DIR)/std/std_standard.o: $(GHDL)
cd $(LIB87_DIR)/std; \
$(GHDL) --bootstrap-standard $(STD_GHDL_FLAGS) --std=87 $(LIB_CFLAGS)
$(LIB08_DIR)/std/std_standard.o: $(GHDL)
cd $(LIB08_DIR)/std; \
$(GHDL) --bootstrap-standard $(STD_GHDL_FLAGS) --std=08 $(LIB_CFLAGS)
libs.vhdl.standard: $(LIB93_DIR)/std/std_standard.o \
$(LIB87_DIR)/std/std_standard.o \
$(LIB08_DIR)/std/std_standard.o
install.dirs:
[ -d $(DESTDIR)$(prefix) ] || $(MKDIR) -p $(DESTDIR)$(prefix)
[ -d $(DESTDIR)$(bindir) ] || $(MKDIR) -p $(DESTDIR)$(bindir)
[ -d $(DESTDIR)$(libdir) ] || $(MKDIR) -p $(DESTDIR)$(libdir)
[ -d $(DESTDIR)$(prefix)/$(libdirsuffix) ] || \
$(MKDIR) -p $(DESTDIR)$(prefix)/$(libdirsuffix)
[ -d $(DESTDIR)$(incdir) ] || $(MKDIR) -p $(DESTDIR)$(incdir)
install.vhdllib: install.dirs
for d in $(VHDLLIB_SUBDIRS); do \
$(MKDIR) -p $(DESTDIR)$(VHDL_LIB_DIR)/$$d; \
$(INSTALL_DATA) -p \
$(LIBDST_DIR)/$$d/* $(DESTDIR)$(VHDL_LIB_DIR)/$$d; \
done
# Vendors scripts
$(MKDIR) -p $(DESTDIR)$(VHDL_LIB_DIR)/vendors
$(INSTALL_DATA) -p \
$(LIBSRC_DIR)/vendors/* $(DESTDIR)$(VHDL_LIB_DIR)/vendors/
$(INSTALL_PROGRAM) -p \
$(LIBSRC_DIR)/vendors/*.sh $(DESTDIR)$(VHDL_LIB_DIR)/vendors/
####################### clean ############################################
clean: force
$(RM) -f *.o *.ali b~*.ad? *~ *.d b__*.ad? *.a *.deps *.bexch
$(RM) -f ghdl_gcc$(EXEEXT) ghdl_mcode$(EXEEXT) ghdl$(EXEEXT) ghdl_llvm$(EXEEXT) ghdl_llvm_jit$(EXEEXT) ghdl_simul$(EXEEXT)
$(RM) -f ghdl1-gcc$(EXEEXT) ghdl1-llvm$(EXEEXT) ghdl1-debug$(EXEEXT)
$(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 grt-backtrace-impl.ads
$(RM) -f Makefile config.status ghdl.gpr
clean-c: force
$(RM) -f memsegs_c.o chkstk.o jumps.o times.o grt-cbinding.o grt-cvpi.o
$(RM) -f fstapi.o fastlz.o lz4.o
force:
.PHONY: force clean distclean clean-c
|