Blame view

GUI/SW2/SRC/src/Makefile 13.2 KB
886c558b   Steve Greedy   SACAMOS Public Re...
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
#***************************************************************************************************
#                                             Makefile                                             *
#                                            ----------                                            *
# Description : Build system for the GNU SPICE GUI project C++ source files.                       *
# Started     : 2003-03-18                                                                         *
# Last update : 2016-11-06                                                                         *
# Copyright   : (C) 2003-2016 MSWaters                                                             *
#***************************************************************************************************

#***************************************************************************************************
#                                                                                                  *
#       This program 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 3 of the License, or (at your option) any later version.                    *
#                                                                                                  *
#***************************************************************************************************

#***************************************************************************************************
# Any or all of the values in this section may be set below or on the command line when envoking
# make eg. :
#
#   make GSPICEUI_DBG=1 GSPICEUI_WXLIB=2.8
#
# Note : Values specified on the command line over-ride those specified below.
#***************************************************************************************************

# Create bin file containing debug information (ie. for gdb)
GSPICEUI_DBG = 0

# Specify the version of the wxWidgets library to compile against
GSPICEUI_WXLIB = 3.0

# Specify the install directory
DESTDIR = /usr/local/bin

#***************************************************************************************************
# Specify string values
#***************************************************************************************************

# Which compiler and linker
CXX = g++
LD  = g++

# Application name
PROG = gspiceui

# wxWidgets configuration utility
WXCFG = wx-config --unicode --version=$(GSPICEUI_WXLIB)

# Dependency file
DEPS = Makefile.deps

# Directories
# Long winded but unambiguous
#ROOT     := $(shell cd .. ; pwd)
# Short form but possibly ambiguous
ROOT       = ..
SRCDIR     = $(ROOT)/src
OBJDIR     = obj
BINDIR     = $(ROOT)/bin

# Compiler options :
#  -Wall         Enable all optional warnings desirable for normal code
#  -Wextra       Enable extra warning flags not enabled by "-Wall"
#  -pipe         Use pipes rather than temp. files for comms. between various stages of compilation
#  -O0           Reduce compilation time but don't break debugging (this is the default)
#  -O1           Optimize
#  -O2           Optimize even more
#  -O3           Optimize yet more
#  -Ofast        Optimize till it hurts : "-O3" + enable opts not valid for all standard-compliants
#  -Os           Optimize for size
#  -Og           Optimize debugging experience but don't break debugging
#  -std=[C++NO]  The C++ standard to use where C++NO is eg. c++98, c++03, c++11, c++14, c++1z, etc.
ifeq ($(GSPICEUI_DBG),0)
  # Options for release (not using -Wall since it's GCC specific)
  CXXFLAGS := -O3 -pipe $(shell $(WXCFG) --cxxflags)
else
  # Options for development
  CXXFLAGS := -g -Og -Wall -Wextra -pipe $(shell $(WXCFG) --cxxflags)
endif

# Suppress warnings not of interest
CXXFLAGS += -Wno-unused-parameter -Wno-misleading-indentation
# The following suppresses spurious warnings from gcc with wxWidgets v2.8.12
ifeq ($(GSPICEUI_WXLIB),2.8)
  CXXFLAGS += -Wno-unused-local-typedefs
endif

# Includes
INCLUDES = -I.

# Libraries
# (The pkg-config stuff was requested by a user, somehow pangox was missing)
LIBS := $(shell $(WXCFG) --libs core,base,html) $(shell pkg-config --libs-only-l pangox)

# Source files
#HDRS := $(wildcard *.hpp) $(wildcard */*.hpp) $(wildcard */*/*.hpp)
SRCS := $(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard */*/*.cpp)

# Objects
OBJS := $(SRCS)
OBJS := $(filter-out tests/%.cpp, $(OBJS))
OBJS := $(notdir $(OBJS))
OBJS := $(patsubst %.cpp, obj/%.o, $(OBJS))

# Specify list of directories that `make' should search for prerequisite files
VPATH = $(BINDIR)

# Set search paths for the specific file types
vpath   %.cpp    base main netlist process utility tests                 \
	               ngspice ngspice/commands ngspice/dialogs ngspice/panels \
	               gnucap  gnucap/commands  gnucap/dialogs  gnucap/panels
vpath   %.o      $(OBJDIR)
vpath   test_%   $(BINDIR)

#***************************************************************************************************
# Make these targets
#***************************************************************************************************

all : bnr_beg $(OBJS) $(PROG) bnr_end

bnr_beg :
	@echo -e "\n**************************** Build gSpiceUI binary ****************************\n"

bnr_end :
	@echo -e "\n*************************** Build process completed ***************************\n"

#***************************************************************************************************
# Rules to make targets
#***************************************************************************************************

# Compiler Rules :
#   $<  is the name of the first dependency
#   $@  is the file name of the target
#   -c  compile only, don't link, produces object file ie. <name>.o files
#   -o  place output file in $@

$(OBJDIR)/%.o : %.cpp
	$(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@
	@echo

# Linker Rules :
#   -pipe  use pipes rather temporary files for interprocess communications
#   -o     specify the output file name

$(BINDIR)/$(PROG) : $(OBJS)
	$(LD) -pipe -o $(BINDIR)/$(PROG) obj/*.o $(LIBS)
ifeq ($(ROOT)/GSpiceUI.app,$(wildcard $(ROOT)/GSpiceUI.app))
	cp $(BINDIR)/$(PROG) $(ROOT)/GSpiceUI.app/Contents/MacOS/gspiceui
endif

#***************************************************************************************************
# Include the dependencies file
#***************************************************************************************************

ifeq ($(DEPS),$(wildcard $(DEPS)))
  include $(DEPS)
endif

#***************************************************************************************************
# Create the dependencies file
#***************************************************************************************************

deps :
	@echo -e "\n***************************** Build dependencies ******************************\n"
	$(CXX) -MM -D wxCHECK_VERSION="" -I. $(SRCS) | \
	gawk 'BEGIN {} { printf "%s%s\n", (index($$0," ")!=1 ? "$(OBJDIR)/" : ""), $$0 }' > $(DEPS)
	@echo -e "\n**************************** Build deps completed *****************************\n"

#***************************************************************************************************
# Build the test utilities
#***************************************************************************************************

tests : test_Component test_NetList test_CnvtType test_CmdNgSpiceOPT test_CmdNgSpicePR           \
	      test_CmdNgSpiceDC test_CmdNgSpiceAC test_CmdNgSpiceTR test_CmdGnuCapOPT test_CmdGnuCapPR \
	      test_CmdGnuCapOP  test_CmdGnuCapDC  test_CmdGnuCapAC  test_CmdGnuCapTR  test_CmdGnuCapFO \
	      test_CmdGnuCapGEN test_StrUtils test_Config test_AppConfig test_AppPnlValue

# Compiler options

test_% : CXXFLAGS  = -Wall -g -pipe $(shell $(WXCFG) --cxxflags)
ifeq ($(GSPICEUI_WXLIB),2.8)  # This suppresses spurious warnings from gcc with wxWidgets v2.8.12
  test_% : CXXFLAGS += -Wno-unused-local-typedefs
endif
test_% : CXXFLAGS += -D $(shell echo $@ | tr "[:lower:]" "[:upper:]")
# Libraries
test_% : LIBS      = $(shell $(WXCFG) --libs core,base)

# Compiler Rules for test utilities :
#   $^  is the names of all the prerequisites
#   $@  is the file name of the target

test_% : %.cpp
	@echo
	$(CXX) $(CXXFLAGS) $(INCLUDES) $^ -o $(BINDIR)/$@ $(LIBS)
	@echo

test_StrUtils      : StrUtils.cpp Component.cpp CnvtType.cpp
test_CnvtType      : CnvtType.cpp
test_Config        : Config.cpp TypeDefs.cpp StrUtils.cpp Component.cpp CnvtType.cpp
test_Component     : Component.cpp CnvtType.cpp StrUtils.cpp
test_NetList       : NetList.cpp Component.cpp StrUtils.cpp TypeDefs.cpp CnvtType.cpp

test_CmdNgSpiceOPT : CmdNgSpiceOPT.cpp CmdBase.cpp CnvtType.cpp
test_CmdNgSpiceDC  : CmdNgSpiceDC.cpp  CmdBase.cpp CnvtType.cpp
test_CmdNgSpiceAC  : CmdNgSpiceAC.cpp  CmdBase.cpp CnvtType.cpp
test_CmdNgSpiceTR  : CmdNgSpiceTR.cpp  CmdBase.cpp CnvtType.cpp
test_CmdNgSpicePR  : CmdNgSpicePR.cpp  CmdBase.cpp CnvtType.cpp TypeDefs.cpp StrUtils.cpp \
                     Component.cpp NetList.cpp

test_CmdGnuCapOPT  : CmdGnuCapOPT.cpp  CmdBase.cpp CnvtType.cpp
test_CmdGnuCapOP   : CmdGnuCapOP.cpp   CmdBase.cpp CnvtType.cpp
test_CmdGnuCapDC   : CmdGnuCapDC.cpp   CmdBase.cpp CnvtType.cpp
test_CmdGnuCapAC   : CmdGnuCapAC.cpp   CmdBase.cpp CnvtType.cpp
test_CmdGnuCapTR   : CmdGnuCapTR.cpp   CmdBase.cpp CnvtType.cpp
test_CmdGnuCapFO   : CmdGnuCapFO.cpp   CmdBase.cpp CnvtType.cpp
test_CmdGnuCapGEN  : CmdGnuCapGEN.cpp  CmdBase.cpp CnvtType.cpp
test_CmdGnuCapPR   : CmdGnuCapPR.cpp   CmdBase.cpp CnvtType.cpp TypeDefs.cpp StrUtils.cpp \
	                   Component.cpp NetList.cpp

test_AppConfig     : AppConfig.cpp Config.cpp TypeDefs.cpp StrUtils.cpp Component.cpp CnvtType.cpp
test_AppPnlValue   : AppPnlValue.cpp PnlValue.cpp UnitsBase.cpp ChoUnits.cpp LblUnits.cpp \
	                   PnlTxtSpn.cpp PnlLblTxt.cpp CnvtType.cpp

#***************************************************************************************************
# Install the application
#***************************************************************************************************

install :
	mkdir -p $(DESTDIR)/bin
	cp ../bin/$(PROG) $(DESTDIR)/bin

#***************************************************************************************************
# Uninstall the application
#***************************************************************************************************

uninstall :
	rm -f $(DESTDIR)/bin/$(PROG)
#	rmdir --ignore-fail-on-non-empty $(DESTDIR)/bin

#***************************************************************************************************
# Check for bugs using cppcheck (a tool for static C/C++ code analysis)
#***************************************************************************************************

check :
	@echo -e "\n************************** Perform static bug check ***************************\n"
	@cppcheck --enable=all --std=c++11 .
	@echo -e "\n************************* Static bug check completed **************************\n"

#***************************************************************************************************
# Remove old versions of the main application binary and object files
#***************************************************************************************************

clean :
	rm -f $(BINDIR)/$(PROG) $(OBJDIR)/*.o

#***************************************************************************************************
# Remove old versions of test utility binaries
#***************************************************************************************************

cleantests :
	rm -f $(BINDIR)/test_*

#***************************************************************************************************
# Remove old versions of all application and test utility binaries and object files
#***************************************************************************************************

cleanall : clean cleantests

#***************************************************************************************************
# Display a help message
#***************************************************************************************************

help :
	@echo
	@echo -e "gSpiceUI source code build system. "
	@echo
	@echo -e "Available make targets :"
	@echo -e "  all        - Build the application binary (default)"
	@echo -e "  deps       - Create the dependencies file"
	@echo -e "  tests      - Build the all test utilities"
	@echo -e "  test_*     - Build a particular test utility"
	@echo -e "  install    - Install   the application binary"
	@echo -e "  uninstall  - Uninstall the application binary"
	@echo -e "  check      - Check for bugs using cppcheck"
	@echo -e "  clean      - Remove the application binary and object files"
	@echo -e "  cleantests - Remove the test utility binaries"
	@echo -e "  cleanall   - Remove the application and test utility binaries and object files"
	@echo -e "  help       - Display this message"
	@echo

#***************************************************************************************************
# Specify phony targets (ie. targets which are not files)
#***************************************************************************************************

.PHONY : bnr_beg bnr_end deps install uninstall check clean cleantests help

#***************************************************************************************************