# -*- Makefile -*- for gettext-runtime/src on VMS using the MMS utility

#### Start of system configuration section. ####

# Directories used by "make install":
prefix = SYS$DATA:[
exec_prefix = $(prefix)
bindir = $(exec_prefix).bin
datadir = $(prefix).share
localedir = $(datadir).locale

# Programs used by "make":

CC = cc

# These flags affect binary compatibility. GNU gettext does not need them,
# but other packages do, and we need to be binary compatible with them.
ABIFLAGS = /name=(as_is,short) /float=ieee

WARN_CFLAGS = /warning

OPTIMFLAGS = /optimize

CFLAGS = $(ABIFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS)
DEFS = "VMS=1","HAVE_CONFIG_H=1","LOCALEDIR=""$(localedir)]"""

INCLUDES = /include=([],[-],[-.intl],[-.lib],[-.-.gettext-tools.lib])

LDADD = libiconv.opt/opt,[-.-.vms]link_options.opt

LN = copy
RM = delete

# Programs used by "make install":
INSTALL = copy
INSTALL_PROGRAM = copy
INSTALL_DATA = copy

#### End of system configuration section. ####

PROGRAMS = gettext.exe, ngettext.exe, envsubst.exe

gettext_OBJECTS = gettext.obj
ngettext_OBJECTS = ngettext.obj
envsubst_OBJECTS = envsubst.obj

all : $(PROGRAMS)
	write sys$output "Nothing else to be done for 'all'."

gettext.obj : gettext.c
	$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS),"INSTALLPREFIX=""$(prefix)]""","INSTALLDIR=""$(bindir)]""") gettext.c

ngettext.obj : ngettext.c
	$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS),"INSTALLPREFIX=""$(prefix)]""","INSTALLDIR=""$(bindir)]""") ngettext.c

envsubst.obj : envsubst.c
	$(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS),"INSTALLPREFIX=""$(prefix)]""","INSTALLDIR=""$(bindir)]""") envsubst.c

libiconv.opt :
	if f$search("sys$library:libiconv.olb") .nes. "" then $(LN) [-.-.vms]with-libiconv.opt libiconv.opt
	if f$search("sys$library:libiconv.olb") .eqs. "" then $(LN) [-.-.vms]without-libiconv.opt libiconv.opt

gettext.exe : $(gettext_OBJECTS),libiconv.opt
	link /executable=gettext.exe $(gettext_OBJECTS),[-.lib]grt.olb/lib,[-.intl]intl.olb/lib,$(LDADD)

ngettext.exe : $(ngettext_OBJECTS),libiconv.opt
	link /executable=ngettext.exe $(ngettext_OBJECTS),[-.lib]grt.olb/lib,[-.intl]intl.olb/lib,$(LDADD)

envsubst.exe : $(envsubst_OBJECTS),libiconv.opt
	link /executable=envsubst.exe $(envsubst_OBJECTS),[-.lib]grt.olb/lib,[-.intl]intl.olb/lib,$(LDADD)

install : all
	create /directory $(prefix)]
	create /directory $(exec_prefix)]
	create /directory $(bindir)]
	$(INSTALL_PROGRAM) gettext.exe $(bindir)]gettext.exe
	$(INSTALL_PROGRAM) ngettext.exe $(bindir)]ngettext.exe
	$(INSTALL_PROGRAM) envsubst.exe $(bindir)]envsubst.exe

installdirs :
	create /directory $(prefix)]
	create /directory $(exec_prefix)]
	create /directory $(bindir)]

uninstall :
	$(RM) $(bindir)]gettext.exe;
	$(RM) $(bindir)]ngettext.exe;
	$(RM) $(bindir)]envsubst.exe;

check : all
	write sys$output "Nothing else to be done for 'check'."

mostlyclean : clean
	write sys$output "Nothing else to be done for 'mostlyclean'."

clean :
	$(RM) *.obj;*
	$(RM) *.exe;*

distclean : clean
	write sys$output "Nothing else to be done for 'distclean'."

maintainer-clean : distclean
	write sys$output "Nothing else to be done for 'maintainer-clean'."
