This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathMakefile.am
325 lines (272 loc) · 12.6 KB
/
Makefile.am
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
# File: Makefile.am
#
# GridLAB-D 4.0
# Copyright (C) 2008 Battelle Memorial Institute
# This file is distributed under the same terms as GridLAB-D.
#
# HiPAS GridLAB-D 4.2
# Copyright (C) 2020 Regents of the Leland Stanford Junior University
#
# Authors:
# DP Chassin (dchassin@slac.stanford.edu)
$(info Current target is $(shell $(top_srcdir)/build-aux/version.sh --name))
# !!! must match version specified in configure.ac
OPT=$(shell mkdir -p /usr/local/opt/gridlabd)
PYVER = $(shell $(top_srcdir)/build-aux/version.sh --python)
PYCFLAGS = $(shell python$(PYVER)-config --cflags)
PYLDFLAGS = $(shell python$(PYVER)-config --ldflags)
SYSPYTHON = python$(PYVER)
PYTHONCONFIG = $(SYSPYTHON)-config
AM_INIT_AUTOMAKE = subdir-objects
AUTOMAKE_OPTIONS = -Wno-portability
ACLOCAL_AMFLAGS = -I m4
CC = $(PTHREAD_CC)
CXX = $(PTHREAD_CXX)
AM_CPPFLAGS = -Wall -fPIC
AM_CPPFLAGS += -I$(top_srcdir)/source #-I$(top_srcdir)/build-dir/source
AM_CPPFLAGS += $(GLD_CPPFLAGS)
AM_CPPFLAGS += $(PYCFLAGS)
AM_CFLAGS = -Wall
AM_CFLAGS += -I$(top_srcdir)/source #-I$(top_srcdir)/build-dir/source
AM_CFLAGS += $(PTHREAD_CFLAGS)
AM_CFLAGS += $(GLD_CFLAGS) #-I$(top_srcdir)/build-dir/source
AM_CFLAGS += $(PYCFLAGS)
AM_CXXFLAGS = -Wall -fPIC
AM_CXXFLAGS += $(PTHREAD_CFLAGS)
AM_CXXFLAGS += $(GLD_CXXFLAGS) #-I$(top_srcdir)/build-dir/source
AM_CXXFLAGS += $(PYCFLAGS)
AM_LDFLAGS = $(PYLDFLAGS)
AM_LDFLAGS += -no-undefined
AM_LDFLAGS += -module
AM_LDFLAGS += -avoid-version
AM_LDFLAGS += -export-dynamic
AM_LDFLAGS += $(GLD_LDFLAGS) -lpython$(PYVER)
# makefile fragments populate these variables
BUILT_SOURCES =
CLEANFILES =
EXTRA_DIST =
dist_pkgdata_DATA = requirements.txt
pkgdata_DATA =
noinst_LTLIBRARIES =
pkglib_LTLIBRARIES =
bin_PROGRAMS =
bin_SCRIPTS =
dist_doc_DATA =
docs_targets =
check-target:
@test $(prefix) = $(shell build-aux/version.sh --install) || ( echo "ERROR [Makefile]: prefix and target mismatch; ./configure is outdated. Build using '--clean' option to fix this." > /dev/stderr ; false )
# required modules
include $(top_srcdir)/third_party/Makefile.mk
include $(top_srcdir)/source/Makefile.mk
include $(top_srcdir)/runtime/Makefile.mk
include $(top_srcdir)/converters/Makefile.mk
include $(top_srcdir)/tools/Makefile.mk
include $(top_srcdir)/cloud/Makefile.mk
include $(top_srcdir)/utilities/Makefile.mk
include $(top_srcdir)/python/Makefile.mk
include $(top_srcdir)/geodata/Makefile.mk
include $(top_srcdir)/subcommands/Makefile.mk
# approved modules
include $(top_srcdir)/module/Makefile.mk
BUILT_SOURCES += python-requirements
#
# Post install report
#
install-exec-hook: | index docs
@cp ${top_srcdir}/{COPYRIGHT,LICENSE} $(prefix)
@echo ""
@echo "Install complete. Here are some useful commands now:"
@echo ""
@echo "To include this version in your command path:"
@echo " export PATH='$(DESTDIR)$(bindir):$$PATH'"
@echo ""
@echo "To run this version directly without using the command path:"
@echo " $(DESTDIR)$(bindir)/gridlabd"
@echo ""
@echo "To make this version the default for all users on this system:"
@echo " $(DESTDIR)$(bindir)/gridlabd version set $(shell basename $(exec_prefix))"
@echo ""
#
# Python setup
#
PYENV=$(prefix)
PYBIN=$(PYENV)/bin
PYLIB=$(PYENV)/lib
PYINC=$(PYENV)/include
ENVPYTHON=$(PYBIN)/python$(PYVER)
PYACTIVATE=source $(PYBIN)/activate
python-requirements: | $(PYENV) python-venv check-target
python-venv:
@test ! -z "$(VIRTUAL_ENV)" || ( echo "ERROR [Makefile]: no active python venv; did you forget to run '. $(HOME)/.gridlabd/bin/activate'" > /dev/stderr ; false )
# NB: it's ok to use the runner's python to generate the requirements.txt file
requirements.txt: python/requirements.csv
@python3 -m pip -q install pandas==2.0.0
@python3 python/requirements.py $< >$@
$(PYENV): requirements.txt
@$(SYSPYTHON) --version 1>/dev/null || ( echo "ERROR [Makefile]: $(SYSPYTHON) is not found" > /dev/stderr ; false )
@python$(PYVER)-config --prefix 1>/dev/null || ( echo "ERROR [Makefile]: python$(PYVER)-dev is not installed" > /dev/stderr ; false )
@echo "Processing python requirements..."
@mkdir -p $(PYBIN) $(PYLIB) $(PYINC)
@(deactivate 1>/dev/null 2>&1 || true ; $(SYSPYTHON) -m venv $(PYENV))
@$(ENVPYTHON) --version 1>/dev/null || ( echo "ERROR [Makefile]: $(ENVPYTHON) is not found" > /dev/stderr ; false )
@$(ENVPYTHON) -m pip install --upgrade pip
@$(ENVPYTHON) -m pip install pandas==2.0.0
@$(ENVPYTHON) python/requirements.py --buildenv | bash
@$(ENVPYTHON) -m pip install -r requirements.txt
@touch $(PYENV)
# for doxygen commands
include $(top_srcdir)/aminclude.mk
dist_doc_DATA += COPYRIGHT
dist_doc_DATA += LICENSE
help:
@echo "Cleaning targets:"
@echo " clean - Erase from the build tree the files built by 'make all'"
@echo " distclean - Same as 'make clean' plus erase anything ./configure created"
@echo " mostlyclean - Erase intermediate files (such as .o files)"
@echo ""
@echo "Building targets:"
@echo " all - Build $(PACKAGE) (same as 'make')"
@echo " install - Install $(PACKAGE) to $(prefix)"
@echo " system - Build and install $(PACKAGE) to the system folders"
@echo " install-strip - Same as install, but follow by stripping debug symbols"
@echo " install-clean - Same as install-system, but runs distclean, autoreconf, and configure first"
@echo " install-system - Same as install, but links target to /usr/local for all system users"
@echo " uninstall - Erase files installed by 'make install'"
@echo ""
@echo "Cleaning targets:"
@echo " clean - Erase from the build tree the files built by 'make all'"
@echo " distclean - Same as 'make clean' plus erase anything ./configure created"
@echo " mostlyclean - Erase intermediate files (such as .o files)"
@echo ""
@echo "Testing targets:"
@echo " validate - Run the test/validation suite (requires Python)"
@echo ""
@echo "Install images:"
@echo " image - Create install image"
@echo " aws-image - Upload AWS install image"
@echo " aws-image-default - Upload AWS install image as default for this platform"
@wcho " aws-install - Upload AWS install script"
@echo ""
@echo "Documentation targets:"
@echo " html - Generate all html documentation"
@echo " module-html - Generate module documentation (only if doxygen was found"
@echo " by ./configure)"
@echo " developer-html - Generate developer documentation (only if natural-docs was"
@echo " found by ./configure)"
@echo " troubleshooting-html - Generate troubleshooting documentation (only if gawk was"
@echo " was found by ./configure)"
@echo ""
@echo "Data targets:"
@echo " index - Download all indexes from data archives"
@echo " weather - Download the weather data index from the weather archive"
@echo " library - Download the library index from the library archive"
@echo " template - Download the template index from the template archive"
@echo ""
@echo "Developer targets (may require special tools):"
@echo " clean-wc - Recursively remove all files and directories not under"
@echo " revision control (will prompt to confirm first)"
@echo " ctags - Generate vi-style tags files"
@echo " tags - Generate emacs-style TAGS files"
@echo " maintainer-clean"
over: clean all
S3BUCKET=$(shell $(top_srcdir)/build-aux/version.sh --bucket)
LONGNAME=$(shell $(top_srcdir)/build-aux/version.sh --name)
SHORTNAME=$(shell $(top_srcdir)/build-aux/version.sh --sysspec)
image: $(prefix).tarz
$(prefix).tarz: $(prefix)
@echo "Creating $(prefix).tarz..."
@grep INSTALL $(top_srcdir)/setup/$(shell $(top_srcdir)/build-aux/version.sh --system).sh 1>$(prefix)/share/gridlabd/setup.sh
@cd $(dir $(prefix)); tar cfz $(LONGNAME).tarz $(notdir $(prefix))
aws-image: | $(prefix).tarz
@aws --version || ( echo "ERROR [Makefile]: aws CLI is required to upload image" >/dev/stderr ; false )
@aws s3 cp $(realpath $(prefix).tarz) s3://$(S3BUCKET)/$(LONGNAME).tarz --acl public-read
aws-image-default: aws-image
@aws --version || ( echo "ERROR [Makefile]: aws CLI is required to create default image" >/dev/stderr ; false )
@aws s3 cp s3://$(S3BUCKET)/$(LONGNAME).tarz s3://$(S3BUCKET)/$(SHORTNAME).tarz --acl public-read
aws-install:
@aws --version || ( echo "ERROR [Makefile]: aws CLI is required to upload installer" >/dev/stderr ; false )
@aws s3 cp $(top_srcdir)/install.sh s3://$(S3BUCKET)/install.sh --acl public-read
# Recursively remove all files and directories not under revision control
clean-wc:
@echo -e "\nThis removes all unversioned files and directories in the working copy."
@unset REPLY && read -t 60 -p "Clean working copy (type 'yes' to proceed)? " && test "`echo "$$REPLY" | tr '[:upper:]' '[:lower:]'`" = "yes"
. $(top_srcdir)/utilities/cleanwc
install-validate: install validate
check-local validate:
@(export LD_LIBRARY_PATH=.:$${LD_LIBRARY_PATH:-${libdir}}; ${bindir}/gridlabd -D keep_progress=TRUE --validate -D keep_progress=TRUE || (utilities/save_validation_output;exit 1))
clean-local: python-clean
@rm -rf $(top_srcdir)/documents/html
@rm -rf $(top_srcdir)/validate.txt
@rm -f $(top_srcdir)/gridlabd.spec
@rm -f $(top_srcdir)/gridlabd.bin origin.txt
@rm -rf $(top_srcdir)/build
@(cd $(top_srcdir) ; build-aux/clean_dirs.sh)
distclean-local: python-clean
@(cd $(top_srcdir) ; build-aux/clean_dirs.sh --depends)
@rm -rf $(top_srcdir)/autom4te.cache
@rm -f $(top_srcdir)/aclocal.m4
@rm -f $(top_srcdir)/autoscan.log
@rm -f $(top_srcdir)/m4/libtool.m4
@rm -f $(top_srcdir)/ltoptions.m4
@rm -f $(top_srcdir)/ltsugar.m4
@rm -f $(top_srcdir)/ltversion.m4
@rm -f $(top_srcdir)/lt~obsolete.m4
@rm -f $(top_srcdir)/configure
@rm -f $(top_srcdir)/config.log
@rm -f $(top_srcdir)/config.status
@rm -f $(top_srcdir)/gridlabd.spec
@rm -f $(top_srcdir)/libtool
@rm -f $(top_srcdir)/Makefile
@rm -f $(top_srcdir)/Makefile.in
@rm -f $(top_srcdir)/build-aux/ar-lib
@rm -f $(top_srcdir)/build-aux/compile
@rm -f $(top_srcdir)/build-aux/config.log
@rm -f $(top_srcdir)/build-aux/config.guess
@rm -f $(top_srcdir)/build-aux/config.sub
@rm -f $(top_srcdir)/build-aux/install-sh
@rm -f $(top_srcdir)/build-aux/ltmain.sh
@rm -f $(top_srcdir)/build-aux/missing
@rm -f $(top_srcdir)/build-aux/depcomp
@rm -f $(top_srcdir)/gridlabd.spec
@rm -f $(top_srcdir)/gridlabd.bin origin.txt
@rm -rf $(top_srcdir)/build
@rm -rf $(top_srcdir)/documents/html
@rm -f $(top_srcdir)/validate.txt
libtool: $(LIBTOOL_DEPS)
$(SHELL) $(PWD)/config.status libtool > /dev/null
#
# Run this after changes that affect build-aux/version.sh output
#
docker: $(PREFIX)/docker.img
docker-debug: docker/Dockerfile Makefile
docker build -f docker/Dockerfile -t $(PACKAGE)/$(PACKAGE_VERSION)-$(PACKAGE_BRANCH):latest --build-arg BRANCH=$(PACKAGE_ORIGIN) --build-arg RUN_VALIDATION=no docker
@mkdir -p $(prefix)
docker save $(PACKAGE)/$(PACKAGE_VERSION)-$(PACKAGE_BRANCH):latest -o $(prefix)/docker.img
$(PREFIX)/docker.img: docker/Dockerfile Makefile
docker build -f docker/Dockerfile -t $(PACKAGE)/$(PACKAGE_VERSION)-$(PACKAGE_BRANCH):latest --build-arg BRANCH=$(PACKAGE_ORIGIN) --build-arg RUN_VALIDATION=yes docker
@mkdir -p $(prefix)
docker save $(PACKAGE)/$(PACKAGE_VERSION)-$(PACKAGE_BRANCH):latest -o $(prefix)/docker.img
system: python-install install
@echo "Setting $$($(top_srcdir)/build-aux/version.sh --install) to the current system version"
@$(prefix)/bin/gridlabd version set
@test "$$(gridlabd --version=install)" = "$$($(top_srcdir)/build-aux/version.sh --install)" || echo 'WARNING : build and install versions differ; use build `--clean` option to fix this problem'
index: weather library template
html-local: module-html developer-html troubleshooting-html
@mkdir -p $(prefix)/share/doc/developer
@cp $(top_srcdir)/documents/index.html $(prefix)/share/doc/index.html
@cp -R $(top_srcdir)/documents/html/* $(prefix)/share/doc/
@cp -R $(top_srcdir)/source/html/* $(prefix)/share/doc/developer/
module-html:
@mkdir -p $(top_srcdir)/documents/html/modules
@doxygen $(top_srcdir)/doxygen/gridlabd.conf
developer-html: # TODO
@(cd $(top_srcdir)/source/html ; natural_docs . ; cd - > /dev/null )
troubleshooting-html:
@mkdir -p $(top_srcdir)/documents/html/troubleshooting/
@(cd $(top_srcdir) ; gawk -f utilities/troubleshooting.awk */*.cpp > $(top_srcdir)/documents/html/troubleshooting/index.html )
documents/gridlabd.pdf: documents/gridlabd.glm
(cd documents ; $(DESTDIR)$(bindir)/gridlabd gridlabd.glm | echo "WARNING: unable to update documents/gridlabd.pdf")
test -f documents/gridlabd.md && pandoc -V geometry:landscape documents/gridlabd.md -o documents/gridlabd.pdf
docs: $(docs_targets) # documents/gridlabd.pdf
docs_toc:
utilities/regen_toc >'docs/User manual/0 - Cover/1 - Contents.md'