Files
hawk/bin/Makefile.am
hyung-hwan 3232992bbe
continuous-integration/drone/push Build is passing
optimized accesses and manipulation of named variables
2026-04-25 13:20:15 +09:00

112 lines
3.9 KiB
Makefile

AUTOMAKE_OPTIONS = nostdinc
CPPFLAGS_COMMON = \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir) \
-DLANGDIR=\"$(LANGDIR)\" \
-DHOMELANGDIR=\"$(HOMELANGDIR)\" \
-DSYSCONFDIR=\"$(SYSCONFDIR)\"
CFLAGS_COMMON =
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
## specify the libhawk.la file instead of -lhawk.
##Use -l for third party libraries for automatic inclusion to DEPENDENCIES .
LIBADD_COMMON = ../lib/libhawk.la
bin_PROGRAMS = hawk
langdir = $(LANGDIR)
lang_DATA = $(srcdir)/hawk-ko.po $(srcdir)/hawk-zh_CN.po
EXTRA_DIST = hawk.pot hawk-ko.po hawk-zh_CN.po
##################################################
# hawk
##################################################
hawk_SOURCES = cut.c hawk.c sed.c main.c main.h
hawk_CPPFLAGS = $(CPPFLAGS_COMMON)
hawk_CFLAGS = $(CFLAGS_COMMON)
hawk_LDFLAGS = $(LDFLAGS_COMMON)
##
## -lm is omitted from dependency_libs in libhawk.la because
## libhawk contains some C++ code and postdeps_CXX contains -lm.
##
## Under the default libtool configuration, postdeps is empty.
## Under the C++ tagged libtool configuration, postdeps is set to
## the value of postdeps_CXX.
##
## libtool doesn't include -lm in dependency_libs in libhawk.la
## because libtool --tag=CXX is used for mixed C++ code.
##
## specify -lm to a C only target to satisify dependency regardless
## of different behavior depending on the libtool tag.
##
hawk_LDADD = $(LIBADD_COMMON) $(LIBM)
hawk_DEPENDENCIES = $(srcdir)/hawk.pot $(srcdir)/hawk-ko.po $(srcdir)/hawk-zh_CN.po $(LIBADD_COMMON)
$(srcdir)/hawk.pot: $(hawk_SOURCES)
xgettext --keyword=_ --keyword=__ -o $@ $^
xgettext --keyword=HAWK_T -o $@ -j $(top_srcdir)/lib/err.c
$(srcdir)/hawk-ko.po: $(srcdir)/hawk.pot
if [ -f $@ ]; then msgmerge --update $@ $<; else msginit --input=$< --locale=ko --output=$@; fi
$(srcdir)/hawk-zh_CN.po: $(srcdir)/hawk.pot
if [ -f $@ ]; then msgmerge --update $@ $<; else msginit --input=$< --locale=zh_CN --output=$@; fi
if ENABLE_HAWKGO
## the attempt to compose a proper procedure using a regular compiler failed.
## e.g ./configure GOC=opt/go/pkg/tool/linux_amd64/
## while go.m4 is included in autoconf 2.71, the support for the go language
## is very limited and the go language itself is pursuing the module based builder.
##
## 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 += hawkgo
hawkgo_SOURCES = \
../hawk.go \
../hawk-inst.go \
getopt.go \
hawkgo.go
##hawkgo_DEPENDENCIES =
## let the linker to move hawkgo.bin to the actual target
##hawkgo_LINK = mv -f hawkgo.bin hawkgo$(EXEEXT) || echo "FAILED TO LINK"
hawkgo_LINK =
if ENABLE_STATIC
CGO_CFLAGS_ADD="-static"
CGO_LDFLAGS_ADD="-static"
else
CGO_CFLAGS_ADD=""
CGO_LDFLAGS_ADD=""
endif
hawkgo$(EXEEXT): ../lib/libhawk.la $(hawkgo_OBJECTS)
##cp -pf $(top_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
## ---------------------------------------------------------------
CC=$(CC) \
CGO_CFLAGS="-I$(abs_top_srcdir)/lib -I$(abs_top_builddir)/lib $(CFLAGS) $(CGO_CFLAGS_EXTRA) $(CGO_CFLAGS_ADD)" \
CGO_LDFLAGS="-L$(abs_top_builddir)/lib -L$(abs_top_builddir)/lib/.libs -lhawk -ldl $(LIBM) $(CGO_LDFLAGS_EXTRA) $(CGO_LDFLAGS_ADD)" \
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_top_srcdir)/go.mod $(abs_srcdir)/hawkgo.go $(abs_srcdir)/getopt.go
## ---------------------------------------------------------------
go clean -C $(srcdir) -x -modfile $(abs_top_srcdir)/go.mod
## the go to o recipe is fake to deceive make
.go.o:
echo $< > $@
.mod.o:
echo $< > $@
endif