#!/usr/bin/sh # Revised to compile under Cygwin 1.5.12-1 and gcc 3.3.3, but # probably will compile under other Cygwin releases. # This makefile is based on the original makefiles supplied with # the ping implementation from Mike Muuss. # The BINDIR is the directory in which the ping executable will # be installed and the MANDIR is the directory in which the ping # manual page will be installed. prefix = /usr BINDIR = ${prefix}/bin MANDIR = ${prefix}/share/man/man1 # You shouldn't need to change anything below this line. CC= gcc CFLAGS = -O2 CPPFLAGS = -I/usr/include LDFLAGS = -s G = -g INCL = -I. LIBS = # Script (or program) that returns the machine and os types. # You can also edit in the name yourself. MD=`uname -m` OS=`uname -o` # Script (or program) that returns the user and and group, # or just edit in the name yourself. In case the user belongs # to several groups, it will be returned only the first. # You can edit the name and group to one of your preference. MY_USER = `whoami` MY_GROUP = `groups | awk '{print $$1}'` submake: -@dir=$(MD)-$(OS); set -x; \ if [ ! -d $$dir ]; then ${MAKE} ${MFLAGS} config; fi; \ if [ -n "`find Makefile -newer $$dir/Makefile -print`" ]; \ then ${MAKE} ${MFLAGS} config; fi; \ cd $$dir; ${MAKE} ${MFLAGS} ping all: ${MAKE} ${MFLAGS} submake; \ ${MAKE} ${MFLAGS} install ping: $(CC) $(CPPFLAGS) $(INCL) $(G) $(CFLAGS) $(LDFLAGS) -o ping ping-1.0-1.c $(LIBS) # N.B.- symbolic links are used in the subdirectory rather than VPATH # because at least one Sun cc compiler puts the .o in the wrong place # when using VPATH and it's almost impossible to get "make depend" to # do the right thing. config: -@dir=$(MD)-$(OS); set -x; \ mkdir $$dir; chmod ug+w $$dir; \ ln -s ../ping-1.0-1.c $$dir; ln -s ../ping.1 $$dir; \ sed -e "/^all:/d" Makefile >$$dir/Makefile; \ chmod ug+w $$dir/Makefile; \ cd $$dir; ${MAKE} ${MFLAGS} depend install: -@dir=$(MD)-$(OS); set -x; \ install -c -o $(MY_USER) -g $(MY_GROUP) -m 755 -D $$dir/ping.exe ${DESTDIR}${BINDIR}/ping.exe; \ install -c -o $(MY_USER) -g $(MY_GROUP) -m 664 -D $$dir/ping.1 ${DESTDIR}${MANDIR}/ping.1 lint: lint -hbxn $(INCL) ping-1.0-1.c | \ grep -v 'possible pointer alignment problem' clean: -@dir=$(MD)-$(OS); set -x; rm -rf $$dir distclean: -@dir=$(MD)-$(OS); set -x; rm -rf $$dir uninstall: -@dir=$(MD)-$(OS); set -x; \ rm ${DESTDIR}${BINDIR}/ping.exe; \ rm ${DESTDIR}${MANDIR}/ping.1; \ rm -rf $$dir; \ rm ping.1 ping-1.0-1.c Makefile depend: gcc -M ping-1.0-1.c | sed 's/\.o//' | \ awk ' { if ($$1 != prev) \ { if (rec != "") print rec; rec = $$0; prev = $$1; } \ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \ else rec = rec " " $$2 } } \ END { print rec } ' >> makedep; echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep; echo '$$r makedep' >>eddep; echo 'w' >>eddep; cp Makefile Makefile.bak; ed - Makefile > Makefile; echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile; echo '# see make depend above' >> Makefile; # DO NOT DELETE THIS LINE -- make depend uses it