Skip to content

Commit 68c51c9

Browse files
committed
check for required tools, some formatting
1 parent 12fc380 commit 68c51c9

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

Makefile

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,53 @@ TEST_EXE = $(patsubst $(SRCDIR)/tests/%.c, $(BINDIR)/force-test/%, $(TEST_SRC))
113113
DEPENDENCIES = $(CROSS_OBJ:.o=.d) $(LOWER_OBJ:.o=.d) $(HIGHER_OBJ:.o=.d) $(AUX_OBJ:.o=.d)
114114

115115
# Targets
116-
all: exe tests scripts misc
116+
all: check-required exe tests scripts misc
117117
exe: aux higher lower
118118
aux: $(MAIN_AUX_EXE)
119119
higher: $(MAIN_HIGHER_EXE)
120120
lower: $(MAIN_LOWER_EXE)
121121
tests: $(TEST_EXE)
122122
scripts: bash rstats python external
123123
dev: $(BINDIR)/force-stratified-sample # specific target for development
124-
.PHONY: bash rstats python external scripts misc install
125-
#.PHONY: temp all install install_ bash python rstats misc external clean build check
124+
.PHONY: check-required bash rstats python external scripts misc install
126125

127126
# Include dependencies
128127
-include $(DEPENDENCIES)
129128

130129

131-
print-vars:
132-
@echo "main source files: $(TEST_SRC)"
133-
@echo "main program files: $(TEST_EXE)"
134-
@echo "Object files: $(CROSS_OBJ)"
135-
@echo "Compiler flags: $(CFLAGS)"
130+
##########################################################################
131+
132+
### Check external tools
133+
134+
REQUIRE = gcc g++ \
135+
parallel \
136+
gdalinfo gdal_translate gdaladdo gdalwarp gdalbuildvrt \
137+
gdal_merge.py gdal_rasterize gdaltransform gdalsrsinfo \
138+
gdal_edit.py gdal_calc.py gdal-config \
139+
ogrinfo ogr2ogr \
140+
gsl-config curl-config \
141+
unzip tar lockfile-create lockfile-remove rename dos2unix \
142+
python3 pip3 \
143+
R \
144+
landsatlinks \
145+
opencv_version
146+
147+
check-required:
148+
@missing=$$(for exec in $(REQUIRE); do \
149+
if ! command -v $$exec > /dev/null; then \
150+
echo $$exec; \
151+
fi; \
152+
done); \
153+
if [ "$$missing" ]; then \
154+
echo "No executable(s) in PATH: $$missing. Please install the dependencies!"; \
155+
exit 1; \
156+
fi
157+
136158

137159
##########################################################################
138160

139161
# Modules
162+
140163
$(OBJDIR)/%.o: $(SRCDIR)/modules/cross-level/%.c
141164
@echo "Compiling $<..."
142165
$(CXX) $(CFLAGS) $(INCLUDES) $(FLAGS) -c $< -o $@ $(LIBS)
@@ -155,28 +178,6 @@ $(OBJDIR)/%.o: $(SRCDIR)/modules/aux-level/%.c
155178

156179
##########################################################################
157180

158-
159-
### DEPENDENCIES
160-
161-
#EXECUTABLES = gcc g++ \
162-
# parallel \
163-
# gdalinfo gdal_translate gdaladdo gdalwarp gdalbuildvrt \
164-
# gdal_merge.py gdal_rasterize gdaltransform gdalsrsinfo \
165-
# gdal_edit.py gdal_calc.py gdal-config \
166-
# ogrinfo ogr2ogr \
167-
# gsl-config curl-config \
168-
# unzip tar lockfile-create lockfile-remove rename dos2unix \
169-
# python3 pip3 \
170-
# R \
171-
# landsatlinks \
172-
# opencv_version
173-
174-
#OK := $(foreach exec,$(EXECUTABLES),\
175-
# $(if $(shell which $(exec)),OK,$(error "No $(exec) in PATH, install dependencies!")))
176-
177-
178-
##########################################################################
179-
180181
# Main executables
181182

182183
$(BINDIR)/%: $(SRCDIR)/main/aux-level/%.c $(CROSS_OBJ) $(AUX_OBJ)
@@ -199,6 +200,8 @@ $(BINDIR)/force-test/%: $(SRCDIR)/tests/%.c $(SRCDIR)/tests/unity/unity.c $(CROS
199200
$(CXX) $(CFLAGS) $(INCLUDES) $(FLAGS) -o $@ $^ $(LIBS)
200201

201202

203+
##########################################################################
204+
202205
# Bash scripts
203206

204207
bash:
@@ -243,6 +246,8 @@ misc:
243246
# $(G11) $(CFLAGS) $(GDAL) $(GSL) $(CURL) $(SPLITS) $(OPENCV) $(PYTHON) $(PYTHON2) $(RSTATS) -o $(TB)/dummy src/dummy.c $(TC)/*.o $(TA)/*.o $(TH)/*.o $(LDGDAL) $(LDGSL) $(LDCURL) $(LDSPLITS) $(LDOPENCV) $(LDPYTHON) $(LDRSTATS)
244247

245248

249+
##########################################################################
250+
246251
# install the software
247252

248253
install: all

misc/force-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.12-dev:::2024-10-24_13:59:27
1+
3.7.12-dev:::2024-10-24_14:10:15

0 commit comments

Comments
 (0)