File: GNUmakefile.in

package info (click to toggle)
cif-tools 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 640 kB
  • sloc: sh: 3,260; cpp: 2,421; makefile: 19
file content (200 lines) | stat: -rw-r--r-- 4,851 bytes parent folder | download
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
# SPDX-License-Identifier: BSD-2-Clause
# 
# Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions and the following disclaimer
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

firstTarget: all

CXX					= @CXX@
CXXFLAGS			= @CXXFLAGS@ @CPPFLAGS@ @PTHREAD_CFLAGS@ @CIFPP_CFLAGS@
LDFLAGS				= @LDFLAGS@ @PTHREAD_CFLAGS@
LIBS				= @LIBS@ \
					  @CIFPP_LIBS@ \
					  @BOOST_IOSTREAMS_LIB@ \
					  @BOOST_PROGRAM_OPTIONS_LIB@ \
					  @BOOST_DATE_TIME_LIB@

prefix				= $(DESTDIR)@prefix@
exec_prefix			= @exec_prefix@
bindir				= @bindir@
datarootdir			= @datarootdir@
datadir				= @datadir@
mandir				= @mandir@

GNUmakefile: config.status GNUmakefile.in
	$(SHELL) ./config.status

ifneq "$(CHECK_CONFIG)" ""

config.status: configure
	$(SHELL) ./config.status --recheck

configure: configure.ac
	autoconf

endif

# main build variables
VERSION				= @PACKAGE_VERSION@

CXXFLAGS            += -Wall -Wno-multichar

CIFPP_RSRC			= @CIFPP_RSRC@

ifneq "$(CIFPP_RSRC)" ""
DATADIR				= $(CIFPP_RSRC)
else
DATADIR				= $(datadir)/libcifpp
endif
DEFINES				+= DATADIR='"$(DATADIR)"'

# Use the DEBUG flag to build debug versions of the code
DEBUG               = @DEBUG@

ifeq "$(DEBUG)" "1"
DEFINES				+= DEBUG
CXXFLAGS            += -g -O0
LDFLAGS				+= -g
else
CXXFLAGS			+= -O2
DEFINES				+= NDEBUG
endif

MRC					= @MRC@
USE_RSRC			= @USE_RSRC@

# targets

VPATH += src:test

CXXFLAGS			+= $(DEFINES:%=-D%)

OBJDIR = obj
ifeq "$(DEBUG)" "1"
	OBJDIR	:= $(OBJDIR).dbg
endif

$(OBJDIR):
	mkdir -p $(OBJDIR)

$(OBJDIR)/%.o: %.cpp | $(OBJDIR)
	@ echo ">>" $<
	@ $(CXX) -MD -c -o $@ $< $(CFLAGS) $(CXXFLAGS)

COMMON_OBJECTS = pr-main.o

# We have development releases and official releases, for each we
# maintain different versioning schemes.

ifneq "x@UPDATE_REVISION@" "x"

REVISION = $(shell git log --pretty=format:%h --max-count=1)
REVISION_FILE = version-info-$(REVISION).txt

$(REVISION_FILE):
	rm -f version-info-*.txt
	@ echo ciftools-version: $(VERSION) > $@
	@ git describe --match=build --dirty >> $@
	@ git log --pretty=medium --date=iso8601 -1 >> $@

src/revision.hpp: $(REVISION_FILE)
	@ echo 'const char kRevision[] = R"(' > $@
	@ cat $? >> $@
	@ echo ')";' >> $@

else

src/revision.hpp:
	@ echo 'const char kRevision[] = R"(' > $@
	@ echo ciftools-version: $(VERSION) >> $@
	@ echo Date:   $$(date --iso-8601) >> $@
	@ echo ')";' >> $@

endif

$(OBJDIR)/pr-main.o: src/revision.hpp

ifneq "$(USE_RSRC)" "0"
COMMON_RSRC = $(DATADIR)/mmcif_pdbx_v50.dic

rsrc:
	@ mkdir -p $@

rsrc/version.txt: $(REVISION_FILE) | rsrc
	cp $? $@

endif

# The program rules

PROGRAMS = \
	pdb2cif cif2pdb cif-diff cif-drop cif-grep cif-merge cif-validate mmCQL

define PROGRAM_template =

$(1)_OBJECTS += $(1).o $(COMMON_OBJECTS)

ifneq "$(USE_RSRC)" "0"
$(1)_OBJECTS += $(1).o $(1)_rsrc.o

$$(OBJDIR)/$(1)_rsrc.o: $$($(1)_RSRC) $$(COMMON_RSRC)
	$(MRC) -o $$@ $$^
endif

$(1): $$($(1)_OBJECTS:%=$(OBJDIR)/%)

endef

$(foreach program,$(PROGRAMS),$(eval $(call PROGRAM_template,$(program))))

$(PROGRAMS):
	@ echo '->' $@
	@ $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) $(LIBS)

OBJECTS = $(sort $(foreach program,$(PROGRAMS),$($(program)_OBJECTS)))

$(OBJDIR)/%.d: $(OBJDIR)/%.o

-include $(OBJECTS:%.o=$(OBJDIR)/%.d)

.PHONY: clean all
clean:
	rm -rf $(PROGRAMS) $(OBJDIR)/* $(REVISION_FILE) src/revision.hpp

all: $(PROGRAMS)

.PHONY: install
install: $(PROGRAMS)
	install -d $(bindir)
	for p in $(PROGRAMS); do install $$p $(bindir)/$$p; done
	install -d $(mandir)/man1
	for p in $(PROGRAMS); do \
		install -m 644 doc/$${p}.1 $(mandir)/man1/$${p}.1; \
		gzip $(mandir)/man1/$${p}.1; \
	done

.PHONY: FORCE
FORCE:

.PHONY: test
test:
	@ echo $(OBJECTS)