2 # This Makefile should run fine with both pmake and gmake
6 CFLAGS = @CFLAGS@ @DEFS@ @NO_GETOPT@ @NO_LIBPAPER@ @NO_STRERROR@
11 LDFLAGS = -L. -l$(TARGET) @LIBPAPER@
14 BINDIR = $(prefix)/bin
15 LIBDIR = $(prefix)/lib
16 INCDIR = $(prefix)/include
17 MAN1DIR = $(prefix)/man/man1
18 MAN3DIR = $(prefix)/man/man3
19 INFODIR = $(prefix)/info
21 # getopt may be installed or not, if not take our copy
25 LIBRARY = lib$(TARGET).a
28 INFO = doc/$(TARGET).info
31 LIBOBJECTS = library.o ean.o code128.o code39.o code93.o i25.o \
32 msi.o plessey.o codabar.o \
34 EXEOBJECTS = main.o cmdline.o $(GETOPT_O)
35 ALLSOURCES = $(LIBOBJECTS:.o=.c) $(EXEOBJECT:.o=.c)
38 #Hmm... "RM" is undefined in pmake
41 all: $(TARGET) $(LIBRARY) $(MAN1) $(MAN3) $(INFO) sample
43 $(TARGET): $(LIBRARY) $(EXEOBJECTS)
44 $(CC) $(CFLAGS) $(EXEOBJECTS) $(LDFLAGS) -o $(TARGET)
46 sample: sample.o $(LIBRARY)
47 $(CC) $(CFLAGS) sample.o $(LDFLAGS) -o $@
49 # Avoid the standard CFLAGS, to avoid -Wall and -DNO_GETOPT
50 compat/getopt.o: compat/getopt.c
51 $(CC) -O -c compat/getopt.c -o $@
53 $(LIBRARY): $(LIBOBJECTS)
54 $(AR) r $(LIBRARY) $(LIBOBJECTS)
57 $(MAN1) $(MAN3): doc/doc.$(TARGET)
58 awk -f doc/manpager doc/doc.$(TARGET)
61 # Unfortunately, pmake has no "-C". Also, "pmake -n" doesn't follow the cd.
62 $(INFO): doc/doc.$(TARGET)
66 $(INSTALL) -d $(BINDIR) $(INCDIR) $(LIBDIR) $(MAN1DIR) \
68 $(INSTALL) -c $(TARGET) $(BINDIR)
69 $(INSTALL) -c -m 0644 $(HEADER) $(INCDIR)
70 $(INSTALL) -c -m 0644 $(LIBRARY) $(LIBDIR)
71 $(INSTALL) -c -m 0644 $(MAN1) $(MAN1DIR)
72 $(INSTALL) -c -m 0644 $(MAN3) $(MAN3DIR)
73 $(INSTALL) -c -m 0644 $(INFO) $(INFODIR)
76 $(RM) -f $(BINDIR)/$(TARGET)
77 $(RM) -f $(INCDIR)/$(HEADER)
78 $(RM) -f $(LIBDIR)/$(LIBRARY)
79 $(RM) -f $(MAN1DIR)/$(MAN1)
80 $(RM) -f $(MAN3DIR)/$(MAN3)
81 $(RM) -f $(INDODIR)/$(INFO)
83 #Make clean keeps the compiled documents
85 $(RM) -f *.o */*.o *~ */*~ $(TARGET) $(LIBRARY)
86 $(RM) -f $(MAN1) $(MAN3) core sample
87 cd doc && $(MAKE) terse
91 if [ -f build ]; then debian/rules clean; fi
92 # remove the configure stuff as well
93 $(RM) -f Makefile config.h config.log config.status config.cache \
97 cd doc && $(MAKE) clean
99 Makefile: Makefile.in configure
102 configure: configure.in
105 .depend: $(ALLSOURCES)
106 $(CC) $(CFLAGS) -MM $(ALLSOURCES) > $@
111 @if [ "x" = "x$(RELEASE)" ]; then \
112 n=`basename \`pwd\``; cd ..; tar cvf - $$n | gzip > $$n.tar.gz; \
113 echo 'you can set a numeric $$(RELEASE) to make a named tar'; \
115 if [ -d ../$(TARGET)-$(RELEASE) ]; then \
116 rm -rf ../$(TARGET)-$(RELEASE); \
118 mkdir ../$(TARGET)-$(RELEASE) || exit 1; \
119 cp -a . ../$(TARGET)-$(RELEASE) && cd .. && \
120 tar --exclude '*/CVS*' \
121 -cvzf $(TARGET)-$(RELEASE).tar.gz $(TARGET)-$(RELEASE); \
124 # print the version, as I usually forget to update it when distributing
126 @grep -n VERSION $(HEADER) /dev/null
127 @grep -n set.version doc/doc.$(TARGET) /dev/null
128 @grep -n dpkg.-i INSTALL /dev/null
130 # and this is how I make the distribution
131 distrib: $(INFO) distclean tar printv
134 .PHONY: all install uninstall mostlyclean clean disclean depend \
137 # Only if make is gmake, have a rule to conditionally include .depend