1.SUFFIXES: 2 3DESTDIR= 4prefix=$(PREFIX) 5bindir=$(prefix)/bin 6mandir=$(prefix)/man 7man1dir=$(mandir)/man1 8sharedir=$(prefix)/share 9getoptdir=$(sharedir)/getopt 10localedir=$(sharedir)/locale 11 12# Define this to 0 to use the getopt(3) routines in this package. 13LIBCGETOPT=1 14 15# Define this to 1 if you do not have the gettext routines 16WITHOUT_GETTEXT=0 17 18# For creating the archive 19PACKAGE=getopt 20VERSION=1.1.6 21BASENAME=$(PACKAGE)-$(VERSION) 22UNLIKELYNAME=a8vwjfd92 23 24SHELL=/bin/sh 25 26CC=gcc 27LD=ld 28RM=rm -f 29INSTALL=install 30MSGFMT=msgfmt 31 32LANGUAGES = ca cs da de es et eu fi fr gl hr hu id it ja nl pl pt_BR ru sl sv tr uk vi zh_CN zh_TW 33MOFILES:=$(patsubst %,po/%.mo,$(LANGUAGES)) 34 35CPPFLAGS+=-DLIBCGETOPT=$(LIBCGETOPT) -DWITHOUT_GETTEXT=$(WITHOUT_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX -Dprogram_invocation_short_name=\"$(PACKAGE)\" -Dprogram_version=\"$(VERSION)\" 36ifeq ($(LIBCGETOPT),0) 37CPPFLAGS+=-I./gnu 38endif 39WARNINGS=-Wall \ 40 -W -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual \ 41 -Wcast-align -Wmissing-declarations \ 42 -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \ 43 -Wnested-externs -Winline 44 45sources=getopt.c 46ifeq ($(LIBCGETOPT),0) 47sources+=gnu/getopt.c gnu/getopt1.c 48endif 49 50objects=$(sources:.c=.o) 51 52binaries=getopt 53 54.PHONY: all clean realclean 55all: $(binaries) all_po 56 57clean: clean_po 58 -$(RM) $(objects) $(binaries) 59 60getopt: $(objects) 61 $(CC) $(LDFLAGS) -o $@ $(objects) 62 63install: getopt install_po 64 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) 65 $(INSTALL) -m 755 getopt $(DESTDIR)$(bindir) 66 $(INSTALL) -m 644 getopt.1 $(DESTDIR)$(man1dir) 67 68install_doc: 69 $(INSTALL) -m 755 -d $(DESTDIR)$(getoptdir) 70 $(INSTALL) -m 755 getopt-parse.bash getopt-parse.tcsh \ 71 getopt-test.bash getopt-test.tcsh \ 72 $(DESTDIR)$(getoptdir) 73 74ifeq ($(WITHOUT_GETTEXT),0) 75all_po: $(MOFILES) 76install_po: all_po 77 $(INSTALL) -m 755 -d $(DESTDIR)$(localedir) 78 for lang in $(LANGUAGES) ; do \ 79 dir=$(localedir)/$$lang/LC_MESSAGES; \ 80 $(INSTALL) -m 755 -d $(DESTDIR)$$dir ;\ 81 $(INSTALL) -m 644 po/$$lang.mo $(DESTDIR)$$dir/getopt.mo ;\ 82 done 83clean_po: 84 $(RM) $(MOFILES) 85else 86all_po: 87install_po: 88clean_po: 89endif 90 91%.o: %.c 92 $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c -o $*.o 93 94%.mo: %.po 95 $(MSGFMT) -o $@ $< 96 97# You need GNU tar for this to work! 98.PHONY: package 99package: clean 100 $(RM) -r $(UNLIKELYNAME) 101 mkdir $(UNLIKELYNAME) 102 ln -s .. $(UNLIKELYNAME)/$(BASENAME) 103 cd $(UNLIKELYNAME) && tar cfvzp ../$(BASENAME).tar.gz --exclude='CVS' --exclude='*.tar.gz' --exclude=$(UNLIKELYNAME) $(BASENAME)/* 104 $(RM) -r $(UNLIKELYNAME) 105 106.PHONY: test 107test: all 108 ./run-tests 109