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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [sim-plugins/] [breakpoint/] [sim-scarts_32-Makefile] - Blame information for rev 27

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 jlechner
#############################################################################
2
#
3
# Generic Makefile for C/C++ Program
4
#
5
# License: GPL (General Public License)
6
# Author:  whyglinux 
7
# Date:    2006/03/04 (version 0.1)
8
#          2007/03/24 (version 0.2)
9
#          2007/04/09 (version 0.3)
10
#          2007/06/26 (version 0.4)
11
#          2008/04/05 (version 0.5)
12
#
13
# Description:
14
# ------------
15
# This is an easily customizable makefile template. The purpose is to
16
# provide an instant building environment for C/C++ programs.
17
#
18
# It searches all the C/C++ source files in the specified directories,
19
# makes dependencies, compiles and links to form an executable.
20
#
21
# Besides its default ability to build C/C++ programs which use only
22
# standard C/C++ libraries, you can customize the Makefile to build
23
# those using other libraries. Once done, without any changes you can
24
# then build programs using the same or less libraries, even if source
25
# files are renamed, added or removed. Therefore, it is particularly
26
# convenient to use it to build codes for experimental or study use.
27
#
28
# GNU make is expected to use the Makefile. Other versions of makes
29
# may or may not work.
30
#
31
# Usage:
32
# ------
33
# 1. Copy the Makefile to your program directory.
34
# 2. Customize in the "Customizable Section" only if necessary:
35
#    * to use non-standard C/C++ libraries, set pre-processor or compiler
36
#      options to  and linker ones to 
37
#      (See Makefile.gtk+-2.0 for an example)
38
#    * to search sources in more directories, set to 
39
#    * to specify your favorite program name, set to 
40
# 3. Type make to start building your program.
41
#
42
# Make Target:
43
# ------------
44
# The Makefile provides the following targets to make:
45
#   $ make           compile and link
46
#   $ make NODEP=yes compile and link without generating dependencies
47
#   $ make objs      compile only (no linking)
48
#   $ make tags      create tags for Emacs editor
49
#   $ make ctags     create ctags for VI editor
50
#   $ make install   make all and install the executable file
51
#   $ make clean     clean objects and the executable file
52
#   $ make distclean clean objects, the executable and dependencies
53
#   $ make help      get the usage of the makefile
54
#
55
#===========================================================================
56
 
57
## Customizable Section: adapt those variables to suit your program.
58
##==========================================================================
59
 
60
# The pre-processor and compiler options.
61
MY_CFLAGS = -D__SCARTS_32__ -I$(INST_SCARTS_TOOLCHAIN_NEWLIB_LIBGLOSS_DIR)/scarts_32 -shared -fPIC
62
 
63
# The linker options.
64
MY_LIBS   =
65
 
66
# The pre-processor options used by the cpp (man cpp for more).
67
CPPFLAGS  = -Wall
68
 
69
# The options used in linking as well as in any direct use of ld.
70
LDFLAGS   = -Wl,-soname,libbreakpoint.so
71
 
72
# The directories in which source files reside.
73
# If not specified, only the current directory will be serached.
74
SRCDIRS   =
75
 
76
# The directory into which the compiled files will be installed.
77
# If not specified, executable will be installed into the current directory.
78
DESTDIR   = $(SCARTS_TOOLCHAIN_LIB_SIM_DIR)/scarts_32
79
 
80
# The executable file name.
81
# If not specified, current directory name or `a.out' will be used.
82
PROGRAM   = libbreakpoint.so
83
 
84
## Implicit Section: change the following only when necessary.
85
##==========================================================================
86
 
87
# The source file types (headers excluded).
88
# .c indicates C source files, and others C++ ones.
89
SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
90
 
91
# The header file types.
92
HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
93
 
94
# The pre-processor and compiler options.
95
# Users can override those variables from the command line.
96
CFLAGS  = -O2
97
CXXFLAGS= -O2
98
 
99
# The C program compiler.
100
CC     = gcc
101
 
102
# The C++ program compiler.
103
#CXX    = g++
104
 
105
# Un-comment the following line to compile C programs as C++ ones.
106
#CC     = $(CXX)
107
 
108
# The command used to install file.
109
INSTALL= install
110
 
111
# The command used to delete file.
112
#RM     = rm -f
113
 
114
ETAGS = etags
115
ETAGSFLAGS =
116
 
117
CTAGS = ctags
118
CTAGSFLAGS =
119
 
120
## Stable Section: usually no need to be changed. But you can add more.
121
##==========================================================================
122
SHELL   = /bin/sh
123
EMPTY   =
124
SPACE   = $(EMPTY) $(EMPTY)
125
ifeq ($(PROGRAM),)
126
  CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
127
  PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
128
  ifeq ($(PROGRAM),)
129
    PROGRAM = a.out
130
  endif
131
endif
132
ifeq ($(SRCDIRS),)
133
  SRCDIRS = .
134
endif
135
SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
136
HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
137
SRC_CXX = $(filter-out %.c,$(SOURCES))
138
OBJS    = $(addsuffix .o, $(basename $(SOURCES)))
139
DEPS    = $(OBJS:.o=.d)
140
 
141
## Define some useful variables.
142
DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
143
                  echo "-MM -MP"; else echo "-M"; fi )
144
DEPEND      = $(CC)  $(DEP_OPT)  $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
145
DEPEND.d    = $(subst -g ,,$(DEPEND))
146
COMPILE.c   = $(CC)  $(MY_CFLAGS) $(CFLAGS)   $(CPPFLAGS) -c
147
COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
148
LINK.c      = $(CC)  $(MY_CFLAGS) $(CFLAGS)   $(CPPFLAGS) $(LDFLAGS)
149
LINK.cxx    = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
150
 
151
.PHONY: all objs tags ctags install clean distclean help show
152
 
153
# Delete the default suffixes
154
.SUFFIXES:
155
 
156
all: $(PROGRAM)
157
 
158
# Rules for creating dependency files (.d).
159
#------------------------------------------
160
 
161
%.d:%.c
162
        @echo -n $(dir $<) > $@
163
        @$(DEPEND.d) $< >> $@
164
 
165
%.d:%.C
166
        @echo -n $(dir $<) > $@
167
        @$(DEPEND.d) $< >> $@
168
 
169
%.d:%.cc
170
        @echo -n $(dir $<) > $@
171
        @$(DEPEND.d) $< >> $@
172
 
173
%.d:%.cpp
174
        @echo -n $(dir $<) > $@
175
        @$(DEPEND.d) $< >> $@
176
 
177
%.d:%.CPP
178
        @echo -n $(dir $<) > $@
179
        @$(DEPEND.d) $< >> $@
180
 
181
%.d:%.c++
182
        @echo -n $(dir $<) > $@
183
        @$(DEPEND.d) $< >> $@
184
 
185
%.d:%.cp
186
        @echo -n $(dir $<) > $@
187
        @$(DEPEND.d) $< >> $@
188
 
189
%.d:%.cxx
190
        @echo -n $(dir $<) > $@
191
        @$(DEPEND.d) $< >> $@
192
 
193
# Rules for generating object files (.o).
194
#----------------------------------------
195
objs:$(OBJS)
196
 
197
%.o:%.c
198
        $(COMPILE.c) $< -o $@
199
 
200
%.o:%.C
201
        $(COMPILE.cxx) $< -o $@
202
 
203
%.o:%.cc
204
        $(COMPILE.cxx) $< -o $@
205
 
206
%.o:%.cpp
207
        $(COMPILE.cxx) $< -o $@
208
 
209
%.o:%.CPP
210
        $(COMPILE.cxx) $< -o $@
211
 
212
%.o:%.c++
213
        $(COMPILE.cxx) $< -o $@
214
 
215
%.o:%.cp
216
        $(COMPILE.cxx) $< -o $@
217
 
218
%.o:%.cxx
219
        $(COMPILE.cxx) $< -o $@
220
 
221
# Rules for generating the tags.
222
#-------------------------------------
223
tags: $(HEADERS) $(SOURCES)
224
        $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
225
 
226
ctags: $(HEADERS) $(SOURCES)
227
        $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
228
 
229
# Rules for generating the executable.
230
#-------------------------------------
231
$(PROGRAM):$(OBJS)
232
ifeq ($(SRC_CXX),)              # C program
233
        $(LINK.c)   $(OBJS) $(MY_LIBS) -o $@
234
else                            # C++ program
235
        $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@
236
endif
237
 
238
ifndef NODEP
239
ifneq ($(DEPS),)
240
  sinclude $(DEPS)
241
endif
242
endif
243
 
244
install: all
245
ifeq ($(DESTDIR),)
246
        DESTDIR = .
247
endif
248
 
249
ifneq ($(DESTDIR),.)
250
        @if test ! -d $(DESTDIR); then mkdir -p $(DESTDIR); fi
251
endif
252
        $(INSTALL) -m 755 $(PROGRAM)     $(DESTDIR)
253
        $(INSTALL) -m 644 $(PROGRAM).int $(DESTDIR)
254
 
255
clean:
256
        $(RM) $(OBJS) $(PROGRAM)
257
 
258
distclean: clean
259
        $(RM) $(DEPS) TAGS
260
 
261
# Show help.
262
help:
263
        @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
264
        @echo 'Copyright (C) 2007, 2008 whyglinux '
265
        @echo
266
        @echo 'Usage: make [TARGET]'
267
        @echo 'TARGETS:'
268
        @echo '  all       (=make) compile and link.'
269
        @echo '  NODEP=yes make without generating dependencies.'
270
        @echo '  objs      compile only (no linking).'
271
        @echo '  tags      create tags for Emacs editor.'
272
        @echo '  ctags     create ctags for VI editor.'
273
        @echo '  install   make all and install the executable file.'
274
        @echo '  clean     clean objects and the executable file.'
275
        @echo '  distclean clean objects, the executable and dependencies.'
276
        @echo '  show      show variables (for debug use only).'
277
        @echo '  help      print this message.'
278
        @echo
279
        @echo 'Report bugs to .'
280
 
281
# Show variables (for debug use only.)
282
show:
283
        @echo 'PROGRAM     :' $(PROGRAM)
284
        @echo 'DESTDIR     :' $(DESTDIR)
285
        @echo 'SRCDIRS     :' $(SRCDIRS)
286
        @echo 'HEADERS     :' $(HEADERS)
287
        @echo 'SOURCES     :' $(SOURCES)
288
        @echo 'SRC_CXX     :' $(SRC_CXX)
289
        @echo 'OBJS        :' $(OBJS)
290
        @echo 'DEPS        :' $(DEPS)
291
        @echo 'DEPEND      :' $(DEPEND)
292
        @echo 'COMPILE.c   :' $(COMPILE.c)
293
        @echo 'COMPILE.cxx :' $(COMPILE.cxx)
294
        @echo 'link.c      :' $(LINK.c)
295
        @echo 'link.cxx    :' $(LINK.cxx)
296
 
297
## End of the Makefile ##  Suggestions are welcome  ## All rights reserved ##
298
#############################################################################

powered by: WebSVN 2.1.0

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