# # To less warnings, enter 'make WARN1=' # CC= gcc WARN0= -Wall -Wstrict-prototypes -pedantic -Wno-long-long \ -Wcast-align -Wpointer-arith #-Wfloat-equal #-Werror WARN1?= -W -Wwrite-strings -Wcast-qual -Wshadow #-Wconversion WOPTS= $(WARN0) $(WARN1) O64= -DLARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 OD ?= /dev/null DEBUG ?= 0 DEP ?= _depend TRGS=stfufs-server stfufs-server-launcher stfufs all: $(TRGS) CF= -O2 LF= -s __debug: CF= -ggdb -fstack-protector -Wstack-protector __debug: LF= __debug: $(TRGS) OPT= $(O64) $(CF) -DDEBUG=$(DEBUG) client: stfufs server: stfufs-server stfufs-server-launcher COBJS=pretocol.o random.o util.o simplexdr.o SRVONLY=stfufs-server.o stfufs-server-fs.o \ stfufs-server-buffer.o stfufs-server-errmap.o CLIONLY=stfufs-client.o stfufs-client-fuse.o \ stfufs-client-buffer.o stfufs-client-errmap.o SRVOBJS0=$(SRVONLY) $(COBJS) SRVOBJS=$(SRVOBJS0:%=$(OD)/%) CLIOBJS0=$(CLIONLY) $(COBJS) CLIOBJS=$(CLIOBJS0:%=$(OD)/%) ALLOBJS=$(SRVONLY) $(CLIONLY) $(COBJS) stfufs-server: $(SRVOBJS) $(CC) $(LF) -o $@ $(SRVOBJS) stfufs-server-launcher: stfufs-server-launcher.c $(CC) $(LF) -o $@ $(OPT) $(WOPTS) $< stfufs: $(CLIOBJS) $(CC) $(LF) -o $@ $(CLIOBJS) `pkg-config --libs fuse` ODS = $(OD)/stamp $(ODS): test -d $(OD) || mkdir $(OD) touch $@ stfufs-client-fuse.o: stfufs-client-fuse.c $(CC) -o $@ -c $< `pkg-config --cflags fuse` $(OPT) $(WOPTS) $(OD)/%.o: %.c $(ODS) $(DEP) $(CC) -o $@ -c $< $(OPT) $(WOPTS) $(OD)/stfufs-client-buffer.o: stfufs-buffer.c $(ODS) $(DEP) $(CC) -o $@ -c $< $(OPT) $(WOPTS) -DSTFUFS_CLIENT $(OD)/stfufs-server-buffer.o: stfufs-buffer.c $(ODS) $(DEP) $(CC) -o $@ -c $< $(OPT) $(WOPTS) -DSTFUFS_SERVER # This is not currently cross-compiler compatible. Sorry. # That would require using just c preprocessor and perl/... # I'll leave this exercise to be done later... stfufs-server-errmap.c: stfufs-client-errmap.c stfufs-errmaps.h sh $< gen-srv-errmap ./gen-srv-errmap > $@ rm ./gen-srv-errmap $(DEP): Makefile.build for i in *.c; do gcc -MM $(OPT) $$i; done \ | sed -e '/^[a-z]/ s|^|$(OD)/|' -e \ 's|buffer.o:|client-buffer.o $(OD)/stfufs-server-buffer.o:|' \ > $(DEP) include $(DEP) install: $(TRGS) chkprefix sed -n '/^install.sh:/,/^ *$$/ p' Makefile.build \ | tail -n +4 | sh -ves chkprefix: ALWAYS @[ x"$(PREFIX)" != x ] \ || { sed -n 's/^#prfx: \?/ /p;' Makefile.build; false; } #prfx: #prfx: Can not install: PREFIX missing. #prfx: #prfx: files to be installed: #prfx: #prfx: PREFIX/bin/stfufs #prfx: PREFIX/bin/stfufs-server #prfx: PREFIX/lib/stfufs/stfufs-server- #prfx: #prfx: Try for example: 'make install PREFIX=/usr' or 'make install PREFIX=/usr/local' #prfx: install.sh: exit 1 # this target is not to be run : die () { echo "$@" >&2; exit 1; } [ -d "$PREFIX" ] || die Directory "'"$PREFIX"'" does not exist [ -d "$PREFIX/bin" ] || { set -x; mkdir -m 755 -p "$PREFIX/bin"; } [ -d "$PREFIX/lib/stfufs" ] \ || { set -x; mkdir -m 755 -p "$PREFIX/lib/stfufs"; } : grep ' TCP FUSE .* protocol version 2' $PREFIX/bin/stfufs-server \ && cp $PREFIX/bin/stfufs-server $PREFIX/lib/stfufs/stfufs-server-2 || true test -x stfufs && cp stfufs $PREFIX/bin || true cp stfufs-server-launcher $PREFIX/bin/stfufs-server eval `sh version.h` cp stfufs-server $PREFIX/lib/stfufs/stfufs-server-$protver .PHONY: ALWAYS tags: etags *.c *.h clean: rm -rf stfufs-server-errmap.c TAGS _depend* _obj* *~ distclean: clean rm -f $(TRGS)