Makefile.in revision 22347
1##
2# Makefile.source and Makefile: Directions for building and installing OPIE.
3#
4# %%% portions-copyright-cmetz
5# Portions of this software are Copyright 1996 by Craig Metz, All Rights
6# Reserved. The Inner Net License Version 2 applies to these portions of
7# the software.
8# You should have received a copy of the license with this software. If
9# you didn't get a copy, you may request one from <license@inner.net>.
10#
11# Portions of this software are Copyright 1995 by Randall Atkinson and Dan
12# McDonald, All Rights Reserved. All Rights under this copyright are assigned
13# to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and   
14# License Agreement applies to this software.   
15#
16#	History:
17#
18#	Modified by cmetz for OPIE 2.3. Removed manual config -- it's
19#		Autoconf or bust. Replaced user configuration options
20#		with options.h. Eliminated unused variables. Pass down
21#		$(DEBUG) instead of several other variables to the
22#		subdirs. Extended/standard key file support. Added
23#		dependencies on subdir files. Made opietest call silent.
24#		Removed opie-md4, opie-md5, and key aliases. Removed
25#		test target. Make uninstall remove man page aliases.
26#	Modified by cmetz for OPIE 2.22. Removed @LIBOBJS@ from MISSING for
27#		Autoconf target. Re-ordered LFLAGS because some ld's won't
28#		include libmissing properly if it's not at the end.
29#       Modified by cmetz for OPIE 2.21. Added getusershell.o to IRIX
30#               missing functions.
31#       Modified by cmetz for OPIE 2.2. Added NEW_PROMPTS definition.
32#               Added MISSING and new flags-passing for libmissing.
33#               Quote MISSING or lose. Update TEST target for FTPD
34#               variable. Removed line formatting for compile commands
35#               since macro expansion confuses the issue anyway.
36#               Added targets for opieserv. Added targets for opietest.
37#               Removed obselete options.h target. Swapped libmissing
38#               and libopie. Updated manual config options. Added more
39#               explanatory text. Fixed uses of old SYSV and BSD4_3
40#               symbols.
41#       Modified at NRL for OPIE 2.2: Renamed LDFLAGS setting to LIBS,
42#               renamed LDFLAGS in targets to LFLAGS. Added targets for
43#               libopie and libmissing directories. Got rid of PROTOTYPES.
44#               Added opiegen. Fixed RANLIB Autoconf target. 
45#       Modified at NRL for OPIE 2.11: Fixed fatal mistype of Autoconf.
46#	Modified at NRL for OPIE 2.1: Changed targets to reflect source
47#		file name changes. Changed explanation and flags for static
48#		linking. Changed opieinfo target. Removed WHOAMI. Added
49#		Autoconf targets. Changed if conditionals to use test
50#               instead of [. Changed SU_DIR to SU to help autoconf.
51#               Changed FTPDIR and FTPDNAME to FTPD to help autoconf.
52#               Changed HP-UX to HP-UX9 and HP-UX10. Make uninstall
53#               target depend on config. HPUX *is* no longer necessary, but
54#               something does have to be there. Sub in Autoconf @CC@.
55#       Modified at NRL for OPIE 2.04: Re-worded explanation of SU_STAR_CHECK.
56#       Modified at NRL for OPIE 2.02: Added SU_STAR_CHECK flag.
57#       Modified at NRL for OPIE 2.01: Test target makes opiesu and opielogin 
58#               setuid. install target clears that. uninstall target needs to
59#               remove the opiekey symlinks. opieinfo target needs to 
60#               substitute for $(EXISTS). ifdefs target needs to check for 
61#               starting hash. $(LFLAGS) and -o should be at the end of all 
62#               link commands to spoon-feed drain bamaged link editors. Added
63#               A/UX defaults.
64#	Modified heavily at NRL for OPIE 2.0.
65#	Written at Bellcore for the S/Key Version 1 software distribution
66#		(Makefile).
67
68#============================================================================
69# CONFIGURATION PARAMETERS -- CHANGE THESE TO SUIT YOUR MACHINE
70
71# Shell to use for make(1)
72# It's usually a good idea to leave this as-is. On some systems, ksh or bash
73# may be necessary
74SHELL=/bin/sh
75
76# OWNER is the username who should own the OPIE binaries.
77# GROUP is the groupname associated with the OPIE binaries.
78#
79OWNER=0
80GROUP=bin
81
82#  Where should the OPIE standard and extended databases be stored?
83#
84#  Some sites might want to put this elsewhere. If you want to use an old
85# S/Key database, you should create a link from /etc/skeykeys to /etc/opiekeys.
86STD_KEY_FILE=/etc/opiekeys
87EXT_KEY_FILE=/etc/opiekeys.ext
88
89# Are we debugging?
90#
91# The first line will build a normal version of OPIE. You should use it.
92#
93# The second is for brave souls porting OPIE to a new system or trying to
94# debug it and should definitely NOT be used to build a production copy
95# of OPIE. 
96#
97# The third is the above using nifty heap debugger called "Electric Fence".
98DEBUG=-O
99#DEBUG=-DDEBUG=1 -g
100#DEBUG=-DDEBUG=1 -g -lefence
101
102# These parameters are determined by Autoconf and are probably correct.
103# If OPIE doesn't build or work right, try tweaking these.
104CC=@CC@
105YACC=@YACC@
106FTPD=@FTPD@
107LIBS=@LIBS@
108OPTIONS=@DEFS@
109EXISTS=@EXISTS@
110MKDIR=@MKDIR@
111CHOWN=@CHOWN@
112LOCALBIN=@LOCALBIN@
113LOCALMAN=@LOCALMAN@
114SU=@SU@
115ALT_SU=@ALT_SU@
116LOGIN=@LOGIN@
117
118BACKUP=opie.old
119
120CFLAGS=$(DEBUG)
121
122LFLAGS=-Llibopie -Llibmissing -lopie $(LIBS) -lmissing -lopie
123LDEPS=libmissing/libmissing.a libopie/libopie.a
124
125all:	client server
126
127ifdefs:	
128	egrep '^#*if*def' *.c *.h | cut -f2 -d: | sort | uniq
129
130client: libopie/libopie.a libmissing/libmissing.a opietest-passed opiekey opiegen
131
132client-install: client
133	@echo "Installing OPIE client software..."
134	@echo "Copying OPIE key-related files"
135	@if test ! -d $(LOCALBIN); then $(MKDIR) $(LOCALBIN); chmod 755 $(LOCALBIN); fi 
136	@cp opiekey $(LOCALBIN)
137	@$(CHOWN) $(OWNER) $(LOCALBIN)/opiekey
138	@chgrp $(GROUP) $(LOCALBIN)/opiekey
139	@echo "Changing file permissions"
140	@chmod 0511 $(LOCALBIN)/opiekey
141	@echo "Symlinking aliases to opiekey"
142	@-ln -s $(LOCALBIN)/opiekey $(LOCALBIN)/otp-md4
143	@-ln -s $(LOCALBIN)/opiekey $(LOCALBIN)/otp-md5
144	@echo "Installing manual pages"
145	@-for i in otp-md4 otp-md5; do ln -s opiekey.1 $(LOCALMAN)/man1/$$i.1; done
146	@if test ! -d $(LOCALMAN)/man1; then $(MKDIR) $(LOCALMAN)/man1; chmod 755 $(LOCALMAN)/man1; fi; cp opiekey.1 $(LOCALMAN)/man1/opiekey.1; $(CHOWN) $(OWNER) $(LOCALMAN)/man1/opiekey.1; chgrp $(GROUP) $(LOCALMAN)/man1/opiekey.1; chmod 644 $(LOCALMAN)/man1/opiekey.1
147
148server:	libopie/libopie.a libmissing/libmissing.a opietest-passed opielogin opiesu opiepasswd opieinfo opieftpd opieserv
149
150server-install: server
151	@echo "Installing OPIE server software..."
152	@echo "Copying OPIE user programs"
153	@if test ! -d $(LOCALBIN); then $(MKDIR) $(LOCALBIN); chmod 755 $(LOCALBIN); fi 
154	@cp opiepasswd opieinfo $(LOCALBIN)
155	@echo "Changing ownership"
156	@$(CHOWN) $(OWNER) $(LOCALBIN)/opiepasswd $(LOCALBIN)/opieinfo
157	@chgrp $(GROUP) $(LOCALBIN)/opiepasswd $(LOCALBIN)/opieinfo
158	@echo "Changing file permissions"
159	@chmod 0555 $(LOCALBIN)/opieinfo
160	@chmod 4511 $(LOCALBIN)/opiepasswd
161	@echo "Installing OPIE system programs..."
162	@if test ! $(EXISTS) $(LOGIN).$(BACKUP); then echo "Renaming existing $(LOGIN) to $(LOGIN).$(BACKUP)"; mv $(LOGIN) $(LOGIN).$(BACKUP); echo "Clearing permissions on old $(LOGIN)"; chmod 0 $(LOGIN).$(BACKUP); fi
163	@echo "Copying opielogin to $(LOGIN)"
164	@cp opielogin $(LOGIN)
165	@echo "Changing ownership of $(LOGIN)"
166	@$(CHOWN) $(OWNER) $(LOGIN)
167	@chgrp $(GROUP) $(LOGIN)
168	@echo "Changing file permissions of $(LOGIN)"
169	@chmod 4111 $(LOGIN)
170	@if test ! $(EXISTS) $(SU).$(BACKUP); then echo "Renaming existing su to su.$(BACKUP)"; mv $(SU) $(SU).$(BACKUP); echo "Clearing permissions on old su"; chmod 0 $(SU).$(BACKUP); fi
171	@-if test ! -z "$(ALT_SU)"; then if test ! $(EXISTS) $(ALT_SU).$(BACKUP); then echo "Renaming existing su to su.$(BACKUP)"; mv $(ALT_SU) $(ALT_SU).$(BACKUP); fi; echo "Copying opiesu to su"; cp opiesu $(ALT_SU); echo "Changing ownership"; $(CHOWN) $(OWNER) $(ALT_SU); chgrp $(GROUP) $(ALT_SU); echo "Changing file permissions"; chmod 4111 $(ALT_SU); echo "Clearning permissions on old su"; chmod 0 $(ALT_SU).$(BACKUP); fi
172	@echo "Copying opiesu to su"
173	@cp opiesu $(SU)
174	@echo "Changing ownership of su"
175	@$(CHOWN) $(OWNER) $(SU)
176	@chgrp $(GROUP) $(SU)
177	@echo "Changing file permissions of su"
178	@chmod 4111 $(SU)
179	@if test ! $(EXISTS) $(FTPD).$(BACKUP); then echo "Renaming existing ftp daemon to $(FTPD).$(BACKUP)"; mv $(FTPD) $(FTPD).$(BACKUP); echo "Clearing permissions on old ftp daemon"; chmod 0 $(FTPD).$(BACKUP); fi
180	@echo "Copying OPIE ftp daemon"
181	@cp opieftpd $(FTPD)
182	@echo "Changing ownership of ftpd"
183	@$(CHOWN) $(OWNER) $(FTPD)
184	@chgrp $(GROUP) $(FTPD)
185	@echo "Changing file permissions of ftpd"
186	@chmod 0100 $(FTPD)
187	@echo "Making sure OPIE database files exist"
188	@touch $(STD_KEY_FILE) $(EXT_KEY_FILE)
189	@echo "Changing permissions of OPIE database files"
190	@chmod 0644 $(STD_KEY_FILE)
191	@chmod 0600 $(EXT_KEY_FILE)
192	@echo "Changing ownership of OPIE database files"
193	@$(CHOWN) $(OWNER) $(STD_KEY_FILE) $(EXT_KEY_FILE)
194	@chgrp $(GROUP) $(STD_KEY_FILE) $(EXT_KEY_FILE)
195	@-if test ! -z "$(ACCESS_FILE)"; then echo "Creating OPIE access file (don't say we didn't warn you)"; FILE=`echo $(ACCESS_FILE) | sed 's:^-DACCESS_FILE="\(.*\)":\1:'`; touch $$FILE; $(CHOWN) 0 $$FILE; chgrp 0 $$FILE; chmod 0444 $$FILE; fi;
196	@echo "Installing manual pages"
197	@if test ! -d $(LOCALMAN); then $(MKDIR) $(LOCALMAN); chmod 755 $(LOCALMAN); fi
198	@for i in 1 4 5 8; do for j in *.$$i; do if test ! -d $(LOCALMAN)/man$$i; then $(MKDIR) $(LOCALMAN)/man$$i; chmod 755 $(LOCALMAN)/man$$i; fi; cp $$j $(LOCALMAN)/man$$i/$$j; $(CHOWN) $(OWNER) $(LOCALMAN)/man$$i/$$j; chgrp $(GROUP) $(LOCALMAN)/man$$i/$$j; chmod 644 $(LOCALMAN)/man$$i/$$j; done; done
199	@echo "REMEMBER to run opiepasswd on your users immediately."
200
201install: client-install server-install
202
203uninstall:
204	@echo "Un-installing OPIE..."
205	@echo "Removing symlinks"
206	@-for i in otp-md4 otp-md5; do rm $(LOCALBIN)/$$i; done
207	@echo "Removing OPIE programs"
208	@-for i in opiekey opiepasswd opieinfo; do rm $(LOCALBIN)/$$i; done
209	@echo "Removing OPIE manual pages"
210	@-for i in 1 4 5 8; do for j in *.$$i; do rm $(LOCALMAN)/man$$i/$$j; done; done
211	@-rm $(LOCALMAN)/man1/otp-md4.1 $(LOCALMAN)/man1/otp-md5.1
212	@echo "Restoring old binaries"
213	@-for i in $(SU) $(ALT_SU) $(LOGIN) $(FTPD); do FILE=`basename $$i`; if test ! $(EXISTS) $$i.$(BACKUP); then echo "No $$i.$(BACKUP)! Aborting."; exit 1; else echo "Removing $$FILE"; rm $$i || true; echo "Restoring old $$FILE"; mv $$i.$(BACKUP) $$i; fi; done
214	@echo "Resetting permissions"
215	@chmod 4111 $(SU) $(LOGIN)
216	@chmod 0100 $(FTPD)
217	@if test ! -z "$(ALT_SU)"; then chmod 4111 $(ALT_SU); fi
218	@echo "OPIE is now un-installed."
219	@echo "Please verify by hand that this process worked."
220
221opietest-passed:	opietest
222	-./opietest && touch opietest-passed
223
224libopie/libopie.a: libopie/*.c *.h
225	(cd libopie ; $(MAKE) libopie.a CFL='$(CFLAGS) -DSTD_KEY_FILE=\"$(STD_KEY_FILE)\" -DEXT_KEY_FILE=\"$(EXT_KEY_FILE)\"')
226
227libmissing/libmissing.a: libmissing/*.c
228	(cd libmissing ; $(MAKE) libmissing.a CFL='$(CFLAGS)')
229
230clean:
231	-rm -f *.o opiekey opiegen opielogin opiepasswd opiesu opieftpd
232	-rm -f opieserv opieinfo opietest *core* opietest-passed
233	-rm -f Makefile.munge configure.munger y.tab.c .gdb*
234	(cd libopie ; $(MAKE) clean)
235	(cd libmissing ; $(MAKE) clean)
236
237realclean: clean
238	-rm -f *~ core* "\#*\#" Makefile make.log
239	-rm -f config.log config.status config.cache config.h
240	(cd libopie ; $(MAKE) realclean)
241	(cd libmissing ; $(MAKE) realclean)
242
243opiekey:	opiekey.o $(LDEPS)
244		$(CC) $(CFLAGS) opiekey.o $(LFLAGS) -o opiekey
245
246opiegen:	opiegen.o $(LDEPS)
247		$(CC) $(CFLAGS) opiegen.o $(LFLAGS) -o opiegen
248
249opieserv:	opieserv.o $(LDEPS)
250		$(CC) $(CFLAGS) opieserv.o $(LFLAGS) -o opieserv
251
252opieftpd:	opieftpd.o glob.o logwtmp.o popen.o y.tab.o $(LDEPS)
253		$(CC) $(CFLAGS) opieftpd.o glob.o logwtmp.o popen.o y.tab.o $(LFLAGS) -o opieftpd
254
255opielogin:	opielogin.o permsfile.o $(LDEPS)
256		$(CC) $(CFLAGS) opielogin.o permsfile.o $(LFLAGS) -o opielogin
257
258opiepasswd:	opiepasswd.o $(LDEPS)
259		$(CC) $(CFLAGS) opiepasswd.o $(LFLAGS) -o opiepasswd
260
261opiesu:		opiesu.o $(LDEPS)
262		$(CC) $(CFLAGS) opiesu.o $(LFLAGS) -o opiesu
263
264y.tab.c:	ftpcmd.y
265		$(YACC) ftpcmd.y
266
267opieinfo:	opieinfo.o $(LDEPS)
268		$(CC) $(CFLAGS) opieinfo.o $(LFLAGS) -o opieinfo
269
270opietest:	opietest.o $(LDEPS)
271		$(CC) $(CFLAGS) opietest.o $(LFLAGS) -o opietest
272