LIB_LINEDIT          = @LIB_LINEDIT@
CC                   = @CC@ @CFLAGS_MACHINE@
CFLAGS               = @CFLAGS@
CFLAGS_UNSIGNED_CHAR = @CFLAGS_UNSIGNED_CHAR@
LDLIBS               = @LDLIBS@
AR_RC                = @AR_RC@
RANLIB               = @RANLIB@

LIBNAME = $(LIB_LINEDIT)
OBJLIB  = linedit@OBJ_SUFFIX@ terminal@OBJ_SUFFIX@ ctrl_c@OBJ_SUFFIX@

.SUFFIXES:
.SUFFIXES: @OBJ_SUFFIX@ .c $(SUFFIXES)

all: $(LIBNAME)

.c@OBJ_SUFFIX@:
	$(CC) -c $(CFLAGS) $(CFLAGS_UNSIGNED_CHAR) $*.c


$(LIBNAME): $(OBJLIB)
	rm -f $(LIBNAME)
	$(AR_RC)@AR_SEP@$(LIBNAME) $(OBJLIB)
	$(RANLIB) $(LIBNAME)


clean:
	rm -f *@OBJ_SUFFIX@ *.ilk *.pdb *.pch *.idb *.exp $(LIBNAME)


distclean: clean
	rm -f test_linedit@EXE_SUFFIX@ test_noecho@EXE_SUFFIX@

# test files
# under win32: use make W=Y test_linedit.exe (or test_noecho.exe) to
# link the GUI console
# You can also use gplc test_linedit.c and gplc --gui-console test_linedit.c
# even linking the GUI console you can set the env var NO_LE_HOOK to avoid it

W32LNK=..\W32GUICons\w32gc_interf@OBJ_SUFFIX@
# /link /subsystem:windows  (remove the console, obsolete now)

test_linedit@EXE_SUFFIX@: test_linedit@OBJ_SUFFIX@ $(LIBNAME)
	if [ "$$W" != "Y" ]; then W=''; else W="$(W32LNK)"; fi; \
	$(CC) @CC_EXE_NAME_OPT@test_linedit@EXE_SUFFIX@ test_linedit@OBJ_SUFFIX@ $(LIBNAME) $(LDLIBS) $$W

test_noecho@EXE_SUFFIX@: test_noecho@OBJ_SUFFIX@ $(LIBNAME)
	if [ "$$W" != "Y" ]; then W=''; else W="$(W32LNK)"; fi; \
	$(CC) @CC_EXE_NAME_OPT@test_noecho@EXE_SUFFIX@ test_noecho@OBJ_SUFFIX@ $(LIBNAME) $(LDLIBS) $$W


clean-test:
	rm -f test*@OBJ_SUFFIX@ test_linedit@EXE_SUFFIX@ test_noecho@EXE_SUFFIX@


