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

Subversion Repositories jtag_stapl_player

[/] [jtag_stapl_player/] [trunk/] [makefile] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sukhanov
#############################################################################
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 clean     clean objects and the executable file
51
#   $ make distclean clean objects, the executable and dependencies
52
#   $ make help      get the usage of the makefile
53
#
54
#===========================================================================
55
 
56
## Customizable Section: adapt those variables to suit your program.
57
##==========================================================================
58
 
59
# The pre-processor and compiler options.
60
MY_CFLAGS =
61
 
62
# The linker options.
63
MY_LIBS   = -lwiringPi
64
 
65
# The pre-processor options used by the cpp (man cpp for more).
66
CPPFLAGS  = -Wall
67
 
68
# The options used in linking as well as in any direct use of ld.
69
LDFLAGS   =
70
 
71
# The directories in which source files reside.
72
# If not specified, only the current directory will be serached.
73
SRCDIRS   =
74
 
75
# The executable file name.
76
# If not specified, current directory name or `a.out' will be used.
77
PROGRAM   =
78
 
79
## Implicit Section: change the following only when necessary.
80
##==========================================================================
81
 
82
# The source file types (headers excluded).
83
# .c indicates C source files, and others C++ ones.
84
SRCEXTS = .c .C .cc .cpp .CPP .c++ .cxx .cp
85
 
86
# The header file types.
87
HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp
88
 
89
# The pre-processor and compiler options.
90
# Users can override those variables from the command line.
91
#&RA/CFLAGS  = -O2
92
CFLAGS  = -O0
93
#&RA/CFLAGS  = -g -O0
94
CXXFLAGS= -g -O2
95
 
96
# The C program compiler.
97
CC     = gcc
98
 
99
# The C++ program compiler.
100
#CXX    = g++
101
 
102
# Un-comment the following line to compile C programs as C++ ones.
103
#CC     = $(CXX)
104
 
105
# The command used to delete file.
106
#RM     = rm -f
107
 
108
ETAGS = etags
109
ETAGSFLAGS =
110
 
111
CTAGS = ctags
112
CTAGSFLAGS =
113
 
114
## Stable Section: usually no need to be changed. But you can add more.
115
##==========================================================================
116
SHELL   = /bin/sh
117
EMPTY   =
118
SPACE   = $(EMPTY) $(EMPTY)
119
ifeq ($(PROGRAM),)
120
  CUR_PATH_NAMES = $(subst /,$(SPACE),$(subst $(SPACE),_,$(CURDIR)))
121
  PROGRAM = $(word $(words $(CUR_PATH_NAMES)),$(CUR_PATH_NAMES))
122
  ifeq ($(PROGRAM),)
123
    PROGRAM = a.out
124
  endif
125
endif
126
ifeq ($(SRCDIRS),)
127
  SRCDIRS = .
128
endif
129
SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
130
HEADERS = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
131
SRC_CXX = $(filter-out %.c,$(SOURCES))
132
OBJS    = $(addsuffix .o, $(basename $(SOURCES)))
133
DEPS    = $(OBJS:.o=.d)
134
 
135
## Define some useful variables.
136
DEP_OPT = $(shell if `$(CC) --version | grep "GCC" >/dev/null`; then \
137
                  echo "-MM -MP"; else echo "-M"; fi )
138
DEPEND      = $(CC)  $(DEP_OPT)  $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS)
139
DEPEND.d    = $(subst -g ,,$(DEPEND))
140
COMPILE.c   = $(CC)  $(MY_CFLAGS) $(CFLAGS)   $(CPPFLAGS) -c
141
COMPILE.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c
142
LINK.c      = $(CC)  $(MY_CFLAGS) $(CFLAGS)   $(CPPFLAGS) $(LDFLAGS)
143
LINK.cxx    = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
144
 
145
.PHONY: all objs tags ctags clean distclean help show
146
 
147
# Delete the default suffixes
148
.SUFFIXES:
149
 
150
all: $(PROGRAM)
151
 
152
# Rules for creating dependency files (.d).
153
#------------------------------------------
154
 
155
%.d:%.c
156
        @echo -n $(dir $<) > $@
157
        @$(DEPEND.d) $< >> $@
158
 
159
%.d:%.C
160
        @echo -n $(dir $<) > $@
161
        @$(DEPEND.d) $< >> $@
162
 
163
%.d:%.cc
164
        @echo -n $(dir $<) > $@
165
        @$(DEPEND.d) $< >> $@
166
 
167
%.d:%.cpp
168
        @echo -n $(dir $<) > $@
169
        @$(DEPEND.d) $< >> $@
170
 
171
%.d:%.CPP
172
        @echo -n $(dir $<) > $@
173
        @$(DEPEND.d) $< >> $@
174
 
175
%.d:%.c++
176
        @echo -n $(dir $<) > $@
177
        @$(DEPEND.d) $< >> $@
178
 
179
%.d:%.cp
180
        @echo -n $(dir $<) > $@
181
        @$(DEPEND.d) $< >> $@
182
 
183
%.d:%.cxx
184
        @echo -n $(dir $<) > $@
185
        @$(DEPEND.d) $< >> $@
186
 
187
# Rules for generating object files (.o).
188
#----------------------------------------
189
objs:$(OBJS)
190
 
191
%.o:%.c
192
        $(COMPILE.c) $< -o $@
193
 
194
%.o:%.C
195
        $(COMPILE.cxx) $< -o $@
196
 
197
%.o:%.cc
198
        $(COMPILE.cxx) $< -o $@
199
 
200
%.o:%.cpp
201
        $(COMPILE.cxx) $< -o $@
202
 
203
%.o:%.CPP
204
        $(COMPILE.cxx) $< -o $@
205
 
206
%.o:%.c++
207
        $(COMPILE.cxx) $< -o $@
208
 
209
%.o:%.cp
210
        $(COMPILE.cxx) $< -o $@
211
 
212
%.o:%.cxx
213
        $(COMPILE.cxx) $< -o $@
214
 
215
# Rules for generating the tags.
216
#-------------------------------------
217
tags: $(HEADERS) $(SOURCES)
218
        $(ETAGS) $(ETAGSFLAGS) $(HEADERS) $(SOURCES)
219
 
220
ctags: $(HEADERS) $(SOURCES)
221
        $(CTAGS) $(CTAGSFLAGS) $(HEADERS) $(SOURCES)
222
 
223
# Rules for generating the executable.
224
#-------------------------------------
225
$(PROGRAM):$(OBJS)
226
ifeq ($(SRC_CXX),)              # C program
227
        $(LINK.c)   $(OBJS) $(MY_LIBS) -o $@
228
        @echo Type ./$@ to execute the program.
229
else                            # C++ program
230
        $(LINK.cxx) $(OBJS) $(MY_LIBS) -o $@
231
        @echo Type ./$@ to execute the program.
232
endif
233
 
234
ifndef NODEP
235
ifneq ($(DEPS),)
236
  sinclude $(DEPS)
237
endif
238
endif
239
 
240
clean:
241
        $(RM) $(OBJS) $(PROGRAM) $(PROGRAM).exe
242
 
243
distclean: clean
244
        $(RM) $(DEPS) TAGS
245
 
246
# Show help.
247
help:
248
        @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 0.5'
249
        @echo 'Copyright (C) 2007, 2008 whyglinux '
250
        @echo
251
        @echo 'Usage: make [TARGET]'
252
        @echo 'TARGETS:'
253
        @echo '  all       (=make) compile and link.'
254
        @echo '  NODEP=yes make without generating dependencies.'
255
        @echo '  objs      compile only (no linking).'
256
        @echo '  tags      create tags for Emacs editor.'
257
        @echo '  ctags     create ctags for VI editor.'
258
        @echo '  clean     clean objects and the executable file.'
259
        @echo '  distclean clean objects, the executable and dependencies.'
260
        @echo '  show      show variables (for debug use only).'
261
        @echo '  help      print this message.'
262
        @echo
263
        @echo 'Report bugs to .'
264
 
265
# Show variables (for debug use only.)
266
show:
267
        @echo 'PROGRAM     :' $(PROGRAM)
268
        @echo 'SRCDIRS     :' $(SRCDIRS)
269
        @echo 'HEADERS     :' $(HEADERS)
270
        @echo 'SOURCES     :' $(SOURCES)
271
        @echo 'SRC_CXX     :' $(SRC_CXX)
272
        @echo 'OBJS        :' $(OBJS)
273
        @echo 'DEPS        :' $(DEPS)
274
        @echo 'DEPEND      :' $(DEPEND)
275
        @echo 'COMPILE.c   :' $(COMPILE.c)
276
        @echo 'COMPILE.cxx :' $(COMPILE.cxx)
277
        @echo 'link.c      :' $(LINK.c)
278
        @echo 'link.cxx    :' $(LINK.cxx)
279
 
280
## End of the Makefile ##  Suggestions are welcome  ## All rights reserved ##
281
#############################################################################

powered by: WebSVN 2.1.0

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