# Makefile for ShellPanel utilities.

#INSTALLDIR = $(HOME)/Unix/bin
#NIBINSTALLDIR = $(HOME)/Library/Resources
INSTALLDIR = /usr/local/bin
NIBINSTALLDIR = /LocalLibrary/Resources

INSTALL_STRIP = -s

EXE = Alert Menu Open Save NIDomain NIOpen NISave Text Inputline 
LINKS = Password Warning
ALL = $(EXE) $(LINKS)
NIBS = English.lproj/InputlinePanel.nib
RC_ARCHS=-arch m68k -arch i486 -arch hppa -arch sparc
CC=cc $(RC_ARCHS)
CFLAGS = -g -Wall -O2 -I.
LIBS = -lni_s -lNeXT_s -lsys_s

.SUFFIXES: .m	# for GNU make

all: ${ALL}

.m: ; ${CC} ${CFLAGS} -o $@ $*.m ${LIBS}

# Inputline is special, in that it depends on some extra stuff.
Inputline: Inputline.m ShellPanel.h InputlinePanel.h InputlinePanel.m
	${CC} ${CFLAGS} -o $@ Inputline.m ${LIBS}

# (I've tried to incorporate the .nib in the executable using:
#	${CC} ${CFLAGS} \
#	    -segcreate __NIB InputlinePanel.nib English.lproj/InputlinePanel.nib/data.nib \
#	    -segprot __NIB r r \
#	    -o $@ Inputline.m ${LIBS}
# but that failed at runtime with a "does not recognize selector error.)

# XXX All others should also depend on ShellPanel.h
#${EXE}: ShellPanel.h

Password:
	ln -s Inputline $@ || true

Warning:
	ln -s Alert $@ || true

install: all
	@mkdirs $(INSTALLDIR) $(NIBINSTALLDIR)
	@for f in $(EXE); do \
	    cmd="install -c $(INSTALL_STRIP) $$f $(INSTALLDIR)/$$f"; \
	    echo "$$cmd"; $$cmd; \
	done
	@pwd=`pwd`;cd $(INSTALLDIR) && $(MAKE) -f $$pwd/Makefile $(LINKS)
	tar cf - $(NIBS) | (cd $(NIBINSTALLDIR) && rm -rf $(NIBS) && tar xf -)
	    

strip: ; -strip ${EXE}
	
clean: ; rm -f ${ALL}

echo_programs: ; @echo ${ALL}
