Skip to content

Commit

Permalink
Unix builds: move generated headers to a generated_headers subdirectory
Browse files Browse the repository at this point in the history
This moves port/cpl_config.h and gcore/gdal_version.h to
generated_headers/. This should not be visible from outside users, since
the header will still be installed in ${prefix}/include.

The motivation behind this is to be able, in a same git checkout, to
continue to do autoconf in-source-tree builds as well as cmake
out-of-source-tree builds. The cmake builds would be confused by the
existing autoconf generateds files in port/ and gcore/ if there were
present (a check in the cmake build has been already put in place to avoid
doing builds that would use such stale files)

Something similar could probably be done for makefile.vc builds, but
this is more pressing for my own needs.
  • Loading branch information
rouault committed Nov 5, 2021
1 parent d77cda8 commit 4d69681
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 20 deletions.
4 changes: 2 additions & 2 deletions GDALmake.opt.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ INST_DOCS = @htmldir@
INST_MAN = @mandir@
INST_WEB = $(HOME)/www/gdal

CPPFLAGS := @CPPFLAGS@ -iquote $(GDAL_ROOT)/port @EXTRA_INCLUDES@ -DGDAL_COMPILATION
CPPFLAGS := @CPPFLAGS@ -iquote $(GDAL_ROOT)/port -iquote $(GDAL_ROOT)/generated_headers @EXTRA_INCLUDES@ -DGDAL_COMPILATION
CFLAGS = @CFLAGS@ @C_WFLAGS@ $(USER_DEFS)
CXXFLAGS = @CXXFLAGS@ @CXX_WFLAGS@ $(USER_DEFS)
CFLAGS_NOFTRAPV = @CFLAGS_NOFTRAPV@ @C_WFLAGS@ $(USER_DEFS)
Expand Down Expand Up @@ -120,7 +120,7 @@ else
HAVE_LD_SHARED = yes
endif

GDAL_INCLUDE = -iquote $(GDAL_ROOT)/port -iquote $(GDAL_ROOT)/gcore \
GDAL_INCLUDE = -iquote $(GDAL_ROOT)/port -iquote $(GDAL_ROOT)/generated_headers -iquote $(GDAL_ROOT)/gcore \
-iquote $(GDAL_ROOT)/alg \
-iquote $(GDAL_ROOT)/ogr -iquote $(GDAL_ROOT)/ogr/ogrsf_frmts \
-iquote $(GDAL_ROOT)/gnm -iquote $(GDAL_ROOT)/apps
Expand Down
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ swig-modules: apps-target

clean: lclean
(cd port; $(MAKE) clean)
(cd generated_headers; $(MAKE) clean)
(cd ogr; $(MAKE) clean)
(cd gnm; $(MAKE) clean)
(cd gcore; $(MAKE) clean)
Expand All @@ -156,7 +157,7 @@ lclean:
distclean: dist-clean

dist-clean: clean
rm -f GDALmake.opt port/cpl_config.h config.cache config.status
rm -f GDALmake.opt generated_headers/cpl_config.h config.cache config.status
rm -f libtool
rm -rf autom4te.cache

Expand Down Expand Up @@ -200,6 +201,7 @@ install-static-lib: static-lib gdal.pc
$(INSTALL_DIR) $(DESTDIR)$(INST_INCLUDE)
(cd port; $(MAKE) install)
(cd gcore; $(MAKE) install)
(cd generated_headers; $(MAKE) install)
(cd frmts; $(MAKE) install)
(cd alg; $(MAKE) install)
(cd ogr; $(MAKE) install)
Expand Down Expand Up @@ -228,6 +230,7 @@ ifeq ($(MACOSX_FRAMEWORK),yes)
endif
(cd port; $(MAKE) install)
(cd gcore; $(MAKE) install)
(cd generated_headers; $(MAKE) install)
(cd frmts; $(MAKE) install)
(cd alg; $(MAKE) install)
(cd ogr; $(MAKE) install)
Expand Down
2 changes: 1 addition & 1 deletion apps/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ gdal-config: gdal-config.in ../GDALmake.opt ./GNUmakefile ../VERSION
echo 'CONFIG_LIBS="$(CONFIG_LIBS)"' >> gdal-config
echo 'CONFIG_DEP_LIBS="$(LIBS)"' >> gdal-config
echo 'CONFIG_PREFIX="$(GDAL_ROOT)"' >> gdal-config
echo 'CONFIG_CFLAGS="-I$(GDAL_ROOT)/port -I$(GDAL_ROOT)/gcore -I$(GDAL_ROOT)/alg -I$(GDAL_ROOT)/gnm -I$(GDAL_ROOT)/ogr -I$(GDAL_ROOT)/ogr/ogrsf_frmts -I$(GDAL_ROOT)/frmts/vrt -I$(GDAL_ROOT)/apps"' >> gdal-config
echo 'CONFIG_CFLAGS="-I$(GDAL_ROOT)/port -I$(GDAL_ROOT)/generated_headers -I$(GDAL_ROOT)/gcore -I$(GDAL_ROOT)/alg -I$(GDAL_ROOT)/gnm -I$(GDAL_ROOT)/ogr -I$(GDAL_ROOT)/ogr/ogrsf_frmts -I$(GDAL_ROOT)/frmts/vrt -I$(GDAL_ROOT)/apps"' >> gdal-config
echo 'CONFIG_DATA="$(GDAL_ROOT)/data"' >> gdal-config
echo 'CONFIG_VERSION="'`cat ../VERSION`'"' >> gdal-config
echo 'CONFIG_OGR_ENABLED=yes' >> gdal-config # Deprecated. Always true.
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AC_INIT
AC_CONFIG_SRCDIR([GDALmake.opt.in])
AC_SUBST(PACKAGE, gdal)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_HEADERS([port/cpl_config.h:port/cpl_config.h.in])
AC_CONFIG_HEADERS([generated_headers/cpl_config.h:port/cpl_config.h.in])
AH_TOP([#ifndef CPL_CONFIG_H])
AH_TOP([#define CPL_CONFIG_H])
AH_BOTTOM([#include "cpl_config_extras.h"])
Expand Down
6 changes: 2 additions & 4 deletions gcore/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ $(OBJ): gdal_priv.h gdal_proxy.h

clean: mdreader-clean
$(RM) *.o $(O_OBJ)
$(RM) -f gdal_version.h

docs:
(cd ..; $(MAKE) docs)

gdal_misc.$(OBJ_EXT): gdal_misc.cpp gdal_version.h
gdal_misc.$(OBJ_EXT): gdal_misc.cpp ../generated_headers/gdal_version.h

gdaldrivermanager.$(OBJ_EXT): gdaldrivermanager.cpp ../GDALmake.opt
$(CXX) -c $(GDAL_INCLUDE) $(CPPFLAGS) $(CXXFLAGS) -DINST_DATA=\"$(INST_DATA)\" \
Expand All @@ -82,8 +81,7 @@ INST_H_FILES = \
gdal_priv.h \
gdal_proxy.h \
gdal_rat.h \
rawdataset.h \
gdal_version.h
rawdataset.h

install:
for f in $(INST_H_FILES) ; do $(INSTALL_DATA) $$f $(DESTDIR)$(INST_INCLUDE) ; done
14 changes: 7 additions & 7 deletions gcore/generate_gdal_version_h.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
set -e

if test "x$GDAL_SHA1SUM" != "x"; then
if test -f gdal_version.h; then
cp gdal_version.h gdal_version.h.bak
if test -f ../generated_headers/gdal_version.h; then
cp ../generated_headers/gdal_version.h gdal_version.h.bak
else
touch gdal_version.h.bak
fi
Expand All @@ -20,15 +20,15 @@ if test "x$GDAL_SHA1SUM" != "x"; then
fi
diff -u gdal_version.h.new gdal_version.h.bak >/dev/null || \
(echo "Update gdal_version.h"; \
cp gdal_version.h.new gdal_version.h)
cp gdal_version.h.new ../generated_headers/gdal_version.h)
rm -f gdal_version.h.bak
rm -f gdal_version.h.new
elif git log -1 >/dev/null 2>/dev/null && grep dev gdal_version.h.in >/dev/null; then
REV=$(git log -1 --format="%h")
DATE=$(git log -1 --date=format:'%Y%m%d' --format="%ad" 2>/dev/null) || DATE=""
if git status --porcelain -uno | grep . >/dev/null; then REV="$REV-dirty"; fi
if test -f gdal_version.h; then
cp gdal_version.h gdal_version.h.bak
if test -f ../generated_headers/gdal_version.h; then
cp ../generated_headers/gdal_version.h gdal_version.h.bak
else
touch gdal_version.h.bak
fi
Expand All @@ -41,7 +41,7 @@ elif git log -1 >/dev/null 2>/dev/null && grep dev gdal_version.h.in >/dev/null;
fi
diff -u gdal_version.h.new gdal_version.h.bak >/dev/null || \
(echo "Update gdal_version.h"; \
cp gdal_version.h.new gdal_version.h)
cp gdal_version.h.new ../generated_headers/gdal_version.h)
rm -f gdal_version.h.bak
rm -f gdal_version.h.new
else
Expand All @@ -50,6 +50,6 @@ else
cat gdal_version.h.in >> gdal_version.h.new
diff -u gdal_version.h.new gdal_version.h 2>/dev/null >/dev/null || \
(echo "Update gdal_version.h"; \
cp gdal_version.h.new gdal_version.h)
cp gdal_version.h.new ../generated_headers/gdal_version.h)
rm -f gdal_version.h.new
fi
2 changes: 2 additions & 0 deletions generated_headers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cpl_config.h
gdal_version.h
11 changes: 11 additions & 0 deletions generated_headers/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include ../GDALmake.opt

INST_H_FILES = \
cpl_config.h \
gdal_version.h

clean:
$(RM) -f gdal_version.h

install:
for f in $(INST_H_FILES) ; do $(INSTALL_DATA) $$f $(DESTDIR)$(INST_INCLUDE) ; done
1 change: 0 additions & 1 deletion port/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ clean:
INST_H_FILES = \
cpl_atomic_ops.h \
cpl_config_extras.h \
cpl_config.h \
cpl_conv.h \
cpl_csv.h \
cpl_error.h \
Expand Down
4 changes: 3 additions & 1 deletion scripts/cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ GDAL_ROOT=$SCRIPT_DIR/..

if test -f port/cpl_config.h; then
CPL_CONFIG_H=$PWD/port/cpl_config.h
elif test -f generated_headers/cpl_config.h; then
CPL_CONFIG_H=$PWD/generated_headers/cpl_config.h
else
echo "No cpl_config.h file found"
exit 1
Expand Down Expand Up @@ -91,7 +93,7 @@ for dirname in alg port gcore ogr frmts gnm apps fuzzers; do
--include="${CPL_CONFIG_H}" \
--include=port/cpl_port.h \
-I "${CPL_CONFIG_H_DIR}" \
-I port -I gcore -I ogr -I ogr/ogrsf_frmts -I ogr/ogrsf_frmts/geojson \
-I port -I generated_headers -I gcore -I ogr -I ogr/ogrsf_frmts -I ogr/ogrsf_frmts/geojson \
-I ogr/ogrsf_frmts/geojson/libjson \
-i cpl_mem_cache.h \
-i ogrdissolve.cpp \
Expand Down
2 changes: 1 addition & 1 deletion swig/python/fallback_build_mingw32_under_unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
HAS_NUMPY=no
fi

INCFLAGS="-I${PYTHONHOME}/include -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../apps/"
INCFLAGS="-I${PYTHONHOME}/include -I../../port -I../../generated_headers -I../../gcore -I../../alg -I../../ogr/ -I../../apps/"
LINKFLAGS="-L../../.libs -lgdal -L${PYTHONHOME}/libs -l${PYTHONLIB}"
CFLAGS="-O2 -D__MSVCRT_VERSION__=0x0601"

Expand Down
2 changes: 1 addition & 1 deletion swig/python/fallback_build_mingw32_under_unix_py37.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
HAS_NUMPY=no
fi

INCFLAGS="-I${PYTHONHOME}/include -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../gnm -I../../apps/"
INCFLAGS="-I${PYTHONHOME}/include -I../../port -I../../generated_headers -I../../gcore -I../../alg -I../../ogr/ -I../../gnm -I../../apps/"
LINKFLAGS="-L../../.libs -lgdal -L${PYTHONHOME}/libs -l${PYTHONLIB}"
CFLAGS="-O2 -D__MSVCRT_VERSION__=0x0601"

Expand Down

0 comments on commit 4d69681

Please sign in to comment.