moved main.go to bin and updated build files accordingly

This commit is contained in:
2025-11-01 17:04:52 +09:00
parent cd9022643c
commit 75687acaef
29 changed files with 2731 additions and 3959 deletions

View File

@ -16,7 +16,6 @@ DIST_SUBDIRS = $(SUBDIRS) pas
distclean-local:
@rm -rf $(top_srcdir)/autom4te.cache
clean-local:
rm -rf $(builddir)/go.mod $(builddir)/go.sum
go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod -cache
@ -31,17 +30,17 @@ if ENABLE_HAKGO
## the following is to trick autoconf/automake as if it's building go files with
## a real compiler whereas the actual building is done thru `go build`
bin_PROGRAMS = hakgo
hakgo_SOURCES = \
go/hak.go \
go/cb.go \
go/inst.go \
main.go \
bin_PROGRAMS = bin/hakgo
bin_hakgo_SOURCES = \
hak.go \
hak-cb.go \
hak-inst.go \
bin/main.go \
go.mod
hakgo_DEPENDENCIES = hakgo.bin
bin_hakgo_DEPENDENCIES = hakgo.bin
## let the linker to move hakgo.bin to the actual target
hakgo_LINK = cp -pf hakgo.bin hakgo$(EXEEXT) || echo "FAILED TO LINK"
##bin_hakgo_LINK = mv -f hakgo.bin hakgo$(EXEEXT) || echo "FAILED TO LINK"
if ENABLE_STATIC
CGO_CFLAGS_EXTRA="-static"
@ -51,7 +50,7 @@ CGO_CFLAGS_EXTRA=""
CGO_LDFLAGS_EXTRA=""
endif
hakgo.bin: lib/libhak.la $(hakgo_OBJECTS)
bin/hakgo$(EXEEXT): lib/libhak.la $(hakgo_OBJECTS)
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
[ -f $(srcdir)/go.sum ] && cp -pf $(srcdir)/go.sum $(builddir)/go.sum >/dev/null 2>&1 || true
@ -59,7 +58,7 @@ hakgo.bin: lib/libhak.la $(hakgo_OBJECTS)
CC=$(CC) \
CGO_CFLAGS="-I$(abs_srcdir)/lib -I$(abs_builddir)/lib $(CFLAGS) $(CGO_CFLAGS_EXTRA)" \
CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhak -ldl $(LIBM) $(CGO_LDFLAGS_EXTRA)" \
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)/hakgo.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)/$@ -modfile $(abs_builddir)/go.mod $(abs_srcdir)/bin/main.go
## ---------------------------------------------------------------
go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod
@ -70,7 +69,6 @@ hakgo.bin: lib/libhak.la $(hakgo_OBJECTS)
.mod.o:
echo $< > $@
endif