Edited some module descriptions
[deark.git] / Makefile
blobadbf9b01b9ed7c65d37da047c3db29727bfef3c9
2 -include local1.mk
4 CFLAGS ?= -g -O2 -Wall -Wextra -Wmissing-prototypes -Wformat-security -Wno-unused-parameter
5 LDFLAGS ?= -Wall
7 ifdef DEARK_OBJDIR
8 OBJDIR:=$(DEARK_OBJDIR)
9 else
10 OBJDIR:=obj
11 endif
12 ifdef DEARK_WINDRES
13 DEARK_RC_O:=$(OBJDIR)/src/deark-rc.o
14 else
15 DEARK_RC_O:=
16 endif
17 ifdef DEARK_ARFLAGS
18 ARFLAGS:=$(DEARK_ARFLAGS)
19 else
20 ARFLAGS:=urcs
21 endif
23 INCLUDES:=-Isrc
25 ifeq ($(OS),Windows_NT)
26 EXE_EXT:=.exe
27 else
28 EXE_EXT:=
29 endif
30 DEARK_EXE_BASENAME:=deark$(EXE_EXT)
31 DEARK_EXE:=$(DEARK_EXE_BASENAME)
33 DEARK_MAN:=deark.1
34 DEPS_MK:=deps.mk
36 ifneq ($(OBJDIR),obj)
37 DEARK_EXE:=$(OBJDIR)/$(DEARK_EXE_BASENAME)
38 DEARK_MAN:=$(OBJDIR)/$(DEARK_MAN)
39 DEPS_MK:=$(OBJDIR)/$(DEPS_MK)
40 endif
42 -include local2.mk
44 ifeq ($(MAKECMDGOALS),dep)
46 # Regenerate deps.mk only when someone runs "make dep".
47 # (I'm aware that there are ways to do this automatically, and that one might
48 # have to run "make clean" before "make dep" in some cases. But only
49 # developers need to worry about this. Everyone else can just run "make".)
50 dep: $(DEPS_MK)
52 else
54 all: $(DEARK_EXE)
56 include $(DEPS_MK)
58 endif
60 .PHONY: all clean dep install
62 OFILES_MODS_AB:=$(addprefix $(OBJDIR)/modules/,abk.o alphabmp.o amigaicon.o \
63 ansiart.o ar.o asf.o atari-dsk.o atari-img.o autocad.o awbm.o basic-c64.o \
64 arcfs.o apm.o afcp.o arc.o amiga-dsk.o \
65 bmff.o apple2-dsk.o applesd.o binhex.o bintext.o bmi.o bmp.o \
66 arj.o bpg.o bsave.o)
67 OFILES_MODS_CH:=$(addprefix $(OBJDIR)/modules/,cab.o cardfile.o cfb.o \
68 cpio.o d64.o drhalo.o ebml.o emf.o epocimage.o eps.o exe.o dms.o \
69 flif.o fnt.o gemfont.o gemmeta.o gemras.o gif.o grasp.o grob.o gzip.o \
70 hfs.o hlp.o dsstore.o fli.o fat.o flac.o ccx.o crush.o)
71 OFILES_MODS_IO:=$(addprefix $(OBJDIR)/modules/,misc.o iccprofile.o icns.o \
72 id3.o ico.o iff.o ilbm.o insetpix.o iptc.o jbf.o jovianvi.o jpeg.o lha.o \
73 j2c.o ogg.o olepropset.o iso9660.o macbinary.o macrsrc.o \
74 macpaint.o makichan.o mbk.o mp3.o mscompress.o msp.o nokia.o os2bmp.o ole1.o \
75 officeart.o lbr.o megapaint.o nie.o isz.o os2ea.o)
76 OFILES_MODS_PQ:=$(addprefix $(OBJDIR)/modules/,psd.o palmbitmap.o palmpdb.o \
77 pcpaint.o pcx.o pff2.o pict.o pkfont.o png.o pnm.o portfolio.o printptnr.o \
78 packdir.o pack.o \
79 printshop.o psf.o psionapp.o psionpic.o pcf.o plist.o qtif.o)
80 OFILES_MODS_RZ:=$(addprefix $(OBJDIR)/modules/,riff.o rosprite.o rpm.o \
81 rsc.o shg.o spectrum512.o sunras.o t64.o tar.o tga.o tiff.o tim.o \
82 tivariable.o unsupported.o vort.o wad.o wmf.o wpg.o wri.o xface.o \
83 stuffit.o sis.o sauce.o xfer.o zip.o zoo.o rodraw.o unifont.o rm.o)
84 OFILES_MODS:=$(OFILES_MODS_AB) $(OFILES_MODS_CH) $(OFILES_MODS_IO) \
85 $(OFILES_MODS_PQ) $(OFILES_MODS_RZ)
87 OFILES_DEARK1:=$(addprefix $(OBJDIR)/src/,fmtutil-miniz.o deark-util.o \
88 deark-data.o deark-zip.o deark-tar.o deark-png.o \
89 deark-dbuf.o deark-bitmap.o deark-char.o deark-font.o deark-ucstring.o \
90 fmtutil.o fmtutil-cmpr.o fmtutil-advfile.o fmtutil-zip.o \
91 fmtutil-fax.o fmtutil-lzh.o fmtutil-lzw.o fmtutil-huffman.o \
92 deark-user.o deark-unix.o deark-win.o)
93 OFILES_DEARK2:=$(addprefix $(OBJDIR)/src/,deark-modules.o)
94 OFILES_ALL:=$(OFILES_DEARK1) $(OFILES_DEARK2) $(OFILES_MODS) $(OBJDIR)/src/deark-cmd.o $(DEARK_RC_O)
96 DEARK1_A:=$(OBJDIR)/src/deark1.a
97 $(DEARK1_A): $(OFILES_DEARK1)
98 $(AR) $(ARFLAGS) $@ $^
100 DEARK2_A:=$(OBJDIR)/src/deark2.a
101 $(DEARK2_A): $(OFILES_DEARK2)
102 $(AR) $(ARFLAGS) $@ $^
104 MODS_AB_A:=$(OBJDIR)/modules/mods-ab.a
105 MODS_CH_A:=$(OBJDIR)/modules/mods-ch.a
106 MODS_IO_A:=$(OBJDIR)/modules/mods-io.a
107 MODS_PQ_A:=$(OBJDIR)/modules/mods-pq.a
108 MODS_RZ_A:=$(OBJDIR)/modules/mods-rz.a
109 $(MODS_AB_A): $(OFILES_MODS_AB)
110 $(AR) $(ARFLAGS) $@ $^
111 $(MODS_CH_A): $(OFILES_MODS_CH)
112 $(AR) $(ARFLAGS) $@ $^
113 $(MODS_IO_A): $(OFILES_MODS_IO)
114 $(AR) $(ARFLAGS) $@ $^
115 $(MODS_PQ_A): $(OFILES_MODS_PQ)
116 $(AR) $(ARFLAGS) $@ $^
117 $(MODS_RZ_A): $(OFILES_MODS_RZ)
118 $(AR) $(ARFLAGS) $@ $^
120 # I'm sorry if your linker doesn't like this library order, but the link
121 # command was getting so long that I've decided to start using helper
122 # libraries. I'll consider adding "-Wl,--start-group" and "-Wl,--end-group"
123 # options if that would help.
124 $(DEARK_EXE): $(OBJDIR)/src/deark-cmd.o $(DEARK_RC_O) $(DEARK2_A) $(MODS_AB_A) \
125 $(MODS_CH_A) $(MODS_IO_A) $(MODS_PQ_A) $(MODS_RZ_A) $(DEARK1_A)
126 $(CC) $(LDFLAGS) -o $@ $^
128 $(OBJDIR)/%.o: %.c
129 $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
131 ifdef DEARK_WINDRES
132 $(DEARK_RC_O): src/deark.rc
133 $(DEARK_WINDRES) $< $@
134 $(DEARK_RC_O:.o=.d):
135 > $@
136 endif
138 DEARK_INSTALLDIR ?= /usr/local/bin
139 INSTALL_TARGET:=$(DEARK_INSTALLDIR)/$(DEARK_EXE_BASENAME)
140 install: $(INSTALL_TARGET)
141 $(INSTALL_TARGET): $(DEARK_EXE)
142 install -s $(DEARK_EXE) $(DEARK_INSTALLDIR)
144 # Quick & dirty man page generation. (experimental/temporary)
145 .PHONY: man install-man
146 man: $(DEARK_MAN)
147 $(DEARK_MAN): $(DEARK_EXE)
148 help2man -n "extract data from various file formats" -o $@ -N $(DEARK_EXE)
149 install-man: $(DEARK_MAN)
150 install $(DEARK_MAN) /usr/share/man/man1
152 clean:
153 rm -f $(OBJDIR)/src/*.[oad] $(OBJDIR)/modules/*.[oad] $(DEARK_MAN) $(DEARK_EXE)
155 ifeq ($(MAKECMDGOALS),dep)
157 $(DEPS_MK): $(OFILES_ALL:.o=.d)
158 cat $(sort $^) > $@
160 $(OBJDIR)/%.d: %.c
161 $(CC) $(CFLAGS) $(INCLUDES) -MM -MT '$$(OBJDIR)/$*.o' -MF $@ $<
163 endif