Skip to content

Commit 54289d4

Browse files
committed
enh: fixed makefile system for copying of sources
Signed-off-by: Nick Papior <[email protected]>
1 parent 1136396 commit 54289d4

File tree

3 files changed

+66
-28
lines changed

3 files changed

+66
-28
lines changed

Makefile

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,10 @@ ifneq (,$(findstring NCDF_4,$(FPPFLAGS)))
7777
CDF = 4
7878
endif
7979

80-
81-
# Include the makefile in the src directory
82-
include $(TOP_DIR)/src/Makefile.inc
83-
84-
85-
8680
# The linker is a fortran compiler
8781
LINK := $(FC)
8882

89-
83+
##
9084
# Figure out if the fdict library is linked manually.
9185
# In this case we do not add dependency on the
9286
ifeq (,$(findstring fdict,$(LIBS)))
@@ -111,6 +105,11 @@ install: install-fdict
111105
settings.bash: lib-fdict FORCE
112106
-cp fdict/obj/settings.bash .
113107

108+
.PHONY: copy-fdict copy
109+
copy-fdict: prep-fdict
110+
$(MAKE) -C fdict/obj copy
111+
copy: copy-fdict
112+
114113
else
115114
# In this instance the fdict library is supplied externally
116115
# The variable FDICT_PREFIX should be present
@@ -127,22 +126,44 @@ settings.bash:
127126

128127
endif
129128

129+
# Create target
130+
.PHONY: lib
131+
lib: settings.bash
132+
133+
# Include the makefile in the src directory
134+
include $(TOP_DIR)/src/Makefile.inc
135+
136+
137+
# Include the makefile in the test directory
138+
include $(TOP_DIR)/test/Makefile.inc
139+
140+
# Libraries depend on the objects
141+
ifneq ($(LIBRARIES),)
142+
143+
$(LIBRARIES): $(OBJECTS)
144+
$(OBJECTS): settings.bash
145+
lib: $(LIBRARIES)
146+
147+
endif
148+
149+
130150

151+
##
131152
# This handy target copies from the SOURCES_DIR all sources
132153
# to the current directory
133154
# But ONLY if the current directory is not the top of the project
134-
.PHONY: copy
155+
.PHONY: copy-ncdf copy
156+
copy-ncdf:
135157
ifeq ($(TOP_DIR),.)
136-
copy:
137158
@echo ""
138159
@echo "make copy does not work when executed from the top ncdf directory"
139160
@echo "Please create an object directory with an appropriate Makefile"
140161
@echo ""
141162
else
142-
copy:
143163
cp $(SOURCES_DIR)/src/*.f90 .
144164
endif
145165

166+
copy: copy-ncdf
146167

147168
# Create source target for creating _only_ the sources.
148169
.PHONY: source
@@ -158,17 +179,36 @@ ifneq ($(MPI),0)
158179
SOURCES_DIR := $(SOURCES_DIR)_parallel
159180
endif
160181

161-
# Libraries depend on the objects
162-
ifneq ($(LIBRARIES),)
163-
$(LIBRARIES): $(OBJECTS)
164-
165-
# Create target
166-
.PHONY: lib
167-
lib: settings.bash $(LIBRARIES)
168-
169-
endif
170-
171-
172-
# Include the makefile in the test directory
173-
include $(TOP_DIR)/test/Makefile.inc
174182

183+
##
184+
# Distribution targets for creating the distribution of flook
185+
# Create distribution for releases
186+
.PHONY: dist-fdict dist-ncdf dist-assemble dist
187+
dist-fdict:
188+
git submodule sync fdict
189+
git submodule init fdict
190+
git submodule update fdict
191+
(cd fdict ; make dist ; mv fdict-*.tar.gz .. )
192+
193+
dist-ncdf:
194+
git archive --format=tar --prefix ncdf-$(PROJECT_VERSION)/ HEAD > ncdf-$(PROJECT_VERSION).tar
195+
# Force the creation of the 3 pre-defined source directories
196+
$(MAKE) source CDF=3 MPI=0
197+
$(MAKE) source CDF=4 MPI=0
198+
$(MAKE) source CDF=4 MPI=1
199+
# Clean up
200+
rm *.inc
201+
tar --transform 's,^,ncdf-$(PROJECT_VERSION)/,' -rf ncdf-$(PROJECT_VERSION).tar sources*
202+
-@rm -f ncdf-$(PROJECT_VERSION).tar.gz
203+
gzip ncdf-$(PROJECT_VERSION).tar
204+
205+
dist-assemble: dist-fdict dist-ncdf
206+
-rm -rf .tmp_dist
207+
(mkdir .tmp_dist ; cd .tmp_dist ; \
208+
tar xfz ../ncdf-$(PROJECT_VERSION).tar.gz ; cd ncdf-$(PROJECT_VERSION) ; \
209+
tar xfz ../../fdict-*.tar.gz ; mv fdict-*/* fdict/ ; rm -rf fdict-* ; \
210+
cd .. ; rm ../ncdf-$(PROJECT_VERSION).tar.gz ; \
211+
tar cfz ../ncdf-$(PROJECT_VERSION).tar.gz ncdf-$(PROJECT_VERSION) ; \
212+
rm -rf .tmp_dist ../fdict-*.tar.gz)
213+
214+
dist: dist-assemble

fdict

src/Makefile.inc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ src_MODS = $(patsubst %.f90, %.mod, $(src_SOURCES))
1111

1212

1313
# Create dependency tree such that we may bypass phony targets
14-
# Note that settings.bash dependency forces netcdf_ncdf.f90 to be generated
15-
# ALWAYS. This is a precaution.
1614
netcdf_ncdf.o: netcdf_ncdf.f90
17-
netcdf_ncdf.f90: netcdf_ncdf_pp.F90 netcdf_ncdf_att_inc.inc netcdf_ncdf_var_inc.inc ncdf.sh settings.bash
15+
netcdf_ncdf.f90: netcdf_ncdf_pp.F90 netcdf_ncdf_att_inc.inc netcdf_ncdf_var_inc.inc ncdf.sh
1816
VPATH="$(TOP_DIR)/src" $(src_DIR)/ncdf.sh
1917
$(FPP) $(FPPFLAGS) $(INCLUDES) -I. $< | sed -f $(src_DIR)/filter.sed > $@
2018

@@ -32,7 +30,7 @@ $(src_FPP_SOURCES): INCLUDES += -I$(src_DIR)
3230
.PHONY: source-src
3331
source-src: $(src_SOURCES)
3432
mkdir -p $(SOURCES_DIR)/src
35-
mv $(src_SOURCES) $(SOURCES_DIR)/src
33+
mv $(src_FPP_SOURCES) $(SOURCES_DIR)/src
3634

3735

3836
.PHONY: clean-src

0 commit comments

Comments
 (0)