removed the cfg package from go code.
All checks were successful
continuous-integration/drone/push Build is passing

instead, started using -ldflags "-X var=val" to set constant values
This commit is contained in:
hyung-hwan 2024-01-22 01:27:39 +09:00
parent ca9a6b9eb7
commit a02c323393
9 changed files with 14 additions and 35 deletions

View File

@ -45,14 +45,12 @@ hclgo_LINK = cp -pf hclgo.bin hclgo$(EXEEXT) || echo "FAILED TO LINK"
hclgo.bin: lib/libhcl.la $(hclgo_OBJECTS) hclgo.bin: lib/libhcl.la $(hclgo_OBJECTS)
cp -pf $(srcdir)/go.mod $(builddir)/go.mod >/dev/null 2>&1 || true cp -pf $(srcdir)/go.mod $(builddir)/go.mod >/dev/null 2>&1 || true
chmod u+w $(builddir)/go.mod ## with `make distcheck`, the echo's redirection to the file fails without this permission change chmod u+w $(builddir)/go.mod ## with `make distcheck`, the echo's redirection to the file fails without this permission change
sed -r -i -e "/^[[:space:]]*replace[[:space:]]+cfg[[:space:]]*=>/d" $(builddir)/go.mod
echo -e "\nreplace cfg => $(abs_builddir)/go/cfg" >> $(builddir)/go.mod
[ -f $(srcdir)/go.sum ] && cp -pf $(srcdir)/go.sum $(builddir)/go.sum >/dev/null 2>&1 || true [ -f $(srcdir)/go.sum ] && cp -pf $(srcdir)/go.sum $(builddir)/go.sum >/dev/null 2>&1 || true
## --------------------------------------------------------------- ## ---------------------------------------------------------------
CC=$(CC) \ CC=$(CC) \
CGO_CFLAGS="-I$(abs_srcdir)/lib -I$(abs_builddir)/lib $(CFLAGS)" \ CGO_CFLAGS="-I$(abs_srcdir)/lib -I$(abs_builddir)/lib $(CFLAGS)" \
CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhcl -ldl -lquadmath" \ CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhcl -ldl -lquadmath" \
go build -C $(srcdir) -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod go build -C $(srcdir) -ldflags "-X 'main.BINDIR=$(bindir)' -X 'main.SBINDIR=$(sbindir)' -X 'main.LIBDIR=$(libdir)' -X 'main.SYSCONFDIR=$(sysconfdir)'" -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod
## --------------------------------------------------------------- ## ---------------------------------------------------------------
go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod
rm -rf $(builddir)/go.mod $(builddir)/go.sum rm -rf $(builddir)/go.mod $(builddir)/go.sum

View File

@ -106,7 +106,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/lib/hcl-cfg.h CONFIG_HEADER = $(top_builddir)/lib/hcl-cfg.h
CONFIG_CLEAN_FILES = go/cfg/go.mod go/cfg/cfg.go CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS) PROGRAMS = $(bin_PROGRAMS)
@ -173,10 +173,9 @@ am__define_uniq_tagged_files = \
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \ $(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing README.md \
$(top_srcdir)/go/cfg/cfg.go.in $(top_srcdir)/go/cfg/go.mod.in \ ac/ar-lib ac/compile ac/config.guess ac/config.sub ac/depcomp \
README.md ac/ar-lib ac/compile ac/config.guess ac/config.sub \ ac/install-sh ac/ltmain.sh ac/missing
ac/depcomp ac/install-sh ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir) top_distdir = $(distdir)
@ -410,10 +409,6 @@ $(top_srcdir)/configure: $(am__configure_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps) $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps): $(am__aclocal_m4_deps):
go/cfg/go.mod: $(top_builddir)/config.status $(top_srcdir)/go/cfg/go.mod.in
cd $(top_builddir) && $(SHELL) ./config.status $@
go/cfg/cfg.go: $(top_builddir)/config.status $(top_srcdir)/go/cfg/cfg.go.in
cd $(top_builddir) && $(SHELL) ./config.status $@
install-binPROGRAMS: $(bin_PROGRAMS) install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
@ -940,13 +935,11 @@ clean-local:
@ENABLE_HCLGO_TRUE@hclgo.bin: lib/libhcl.la $(hclgo_OBJECTS) @ENABLE_HCLGO_TRUE@hclgo.bin: lib/libhcl.la $(hclgo_OBJECTS)
@ENABLE_HCLGO_TRUE@ cp -pf $(srcdir)/go.mod $(builddir)/go.mod >/dev/null 2>&1 || true @ENABLE_HCLGO_TRUE@ cp -pf $(srcdir)/go.mod $(builddir)/go.mod >/dev/null 2>&1 || true
@ENABLE_HCLGO_TRUE@ chmod u+w $(builddir)/go.mod ## with `make distcheck`, the echo's redirection to the file fails without this permission change @ENABLE_HCLGO_TRUE@ chmod u+w $(builddir)/go.mod ## with `make distcheck`, the echo's redirection to the file fails without this permission change
@ENABLE_HCLGO_TRUE@ sed -r -i -e "/^[[:space:]]*replace[[:space:]]+cfg[[:space:]]*=>/d" $(builddir)/go.mod
@ENABLE_HCLGO_TRUE@ echo -e "\nreplace cfg => $(abs_builddir)/go/cfg" >> $(builddir)/go.mod
@ENABLE_HCLGO_TRUE@ [ -f $(srcdir)/go.sum ] && cp -pf $(srcdir)/go.sum $(builddir)/go.sum >/dev/null 2>&1 || true @ENABLE_HCLGO_TRUE@ [ -f $(srcdir)/go.sum ] && cp -pf $(srcdir)/go.sum $(builddir)/go.sum >/dev/null 2>&1 || true
@ENABLE_HCLGO_TRUE@ CC=$(CC) \ @ENABLE_HCLGO_TRUE@ CC=$(CC) \
@ENABLE_HCLGO_TRUE@ CGO_CFLAGS="-I$(abs_srcdir)/lib -I$(abs_builddir)/lib $(CFLAGS)" \ @ENABLE_HCLGO_TRUE@ CGO_CFLAGS="-I$(abs_srcdir)/lib -I$(abs_builddir)/lib $(CFLAGS)" \
@ENABLE_HCLGO_TRUE@ CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhcl -ldl -lquadmath" \ @ENABLE_HCLGO_TRUE@ CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhcl -ldl -lquadmath" \
@ENABLE_HCLGO_TRUE@ go build -C $(srcdir) -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod @ENABLE_HCLGO_TRUE@ go build -C $(srcdir) -ldflags "-X 'main.BINDIR=$(bindir)' -X 'main.SBINDIR=$(sbindir)' -X 'main.LIBDIR=$(libdir)' -X 'main.SYSCONFDIR=$(sysconfdir)'" -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod
@ENABLE_HCLGO_TRUE@ go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod @ENABLE_HCLGO_TRUE@ go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod
@ENABLE_HCLGO_TRUE@ rm -rf $(builddir)/go.mod $(builddir)/go.sum @ENABLE_HCLGO_TRUE@ rm -rf $(builddir)/go.mod $(builddir)/go.sum

4
configure vendored
View File

@ -18740,7 +18740,7 @@ printf "%s\n" "#define HCL_CONFIGURE_ARGS \"$ac_configure_args\"" >>confdefs.h
printf "%s\n" "#define HCL_CONFIGURE_CMD \"$hcl_configure_cmd\"" >>confdefs.h printf "%s\n" "#define HCL_CONFIGURE_CMD \"$hcl_configure_cmd\"" >>confdefs.h
ac_config_files="$ac_config_files Makefile lib/Makefile mod/Makefile bin/Makefile go/cfg/go.mod go/cfg/cfg.go t/Makefile" ac_config_files="$ac_config_files Makefile lib/Makefile mod/Makefile bin/Makefile t/Makefile"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
@ -19792,8 +19792,6 @@ do
"lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
"mod/Makefile") CONFIG_FILES="$CONFIG_FILES mod/Makefile" ;; "mod/Makefile") CONFIG_FILES="$CONFIG_FILES mod/Makefile" ;;
"bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;; "bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;;
"go/cfg/go.mod") CONFIG_FILES="$CONFIG_FILES go/cfg/go.mod" ;;
"go/cfg/cfg.go") CONFIG_FILES="$CONFIG_FILES go/cfg/cfg.go" ;;
"t/Makefile") CONFIG_FILES="$CONFIG_FILES t/Makefile" ;; "t/Makefile") CONFIG_FILES="$CONFIG_FILES t/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;

View File

@ -690,8 +690,6 @@ AC_CONFIG_FILES([
lib/Makefile lib/Makefile
mod/Makefile mod/Makefile
bin/Makefile bin/Makefile
go/cfg/go.mod
go/cfg/cfg.go
t/Makefile t/Makefile
]) ])
AC_OUTPUT AC_OUTPUT

2
go.mod
View File

@ -1,5 +1,3 @@
module code.miflux.com/hyung-hwan/hcl module code.miflux.com/hyung-hwan/hcl
go 1.20 go 1.20
require cfg v0.0.0

View File

@ -1,5 +0,0 @@
package cfg
const BINDIR string = "@bindir@"

View File

@ -1,6 +0,0 @@
module cfg
go 1.20
// this package is not supposed to be used by other parties.
// it's intended for internal use only to work around buld issues with autotools.

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
_ "cfg"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@ -19,6 +18,12 @@ import (
`)) `))
*/ */
/* to be set in build time */
var BINDIR = "."
var SBINDIR = "."
var LIBDIR = "."
var SYSCONFDIR = "."
type Param struct { type Param struct {
log_file string log_file string
input_file string input_file string

View File

@ -478,7 +478,7 @@ check_SCRIPTS = \
ret-01.hcl \ ret-01.hcl \
retvar-01.hcl \ retvar-01.hcl \
va-01.hcl \ va-01.hcl \
var-01.hcl var-02.hcl
check_ERRORS = \ check_ERRORS = \
call-01.err \ call-01.err \