exe: Support ARC 7.10 SFX archives
[deark.git] / Makefile
blob7e8c656999989743f2c1c863d2dd58c45c35fa42
2 -include local1.mk
4 CFLAGS ?= -std=c99 -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 ifndef DEARK_RC
14 DEARK_RC:=src/deark.rc
15 endif
16 DEARK_RC_O:=$(OBJDIR)/src/deark-rc.o
17 else
18 DEARK_RC_O:=
19 endif
20 ifdef DEARK_ARFLAGS
21 ARFLAGS:=$(DEARK_ARFLAGS)
22 else
23 ARFLAGS:=urcs
24 endif
26 INCLUDES:=-Isrc
28 ifeq ($(OS),Windows_NT)
29 EXE_EXT:=.exe
30 else
31 EXE_EXT:=
32 endif
33 DEARK_EXE_BASENAME:=deark$(EXE_EXT)
34 DEARK_EXE:=$(DEARK_EXE_BASENAME)
36 DEARK_MAN:=deark.1
37 DEPS_MK:=deps.mk
39 ifneq ($(OBJDIR),obj)
40 DEARK_EXE:=$(OBJDIR)/$(DEARK_EXE_BASENAME)
41 DEARK_MAN:=$(OBJDIR)/$(DEARK_MAN)
42 DEPS_MK:=$(OBJDIR)/$(DEPS_MK)
43 endif
45 -include local2.mk
47 ifeq ($(MAKECMDGOALS),dep)
49 # Regenerate deps.mk only when someone runs "make dep".
50 # (I'm aware that there are ways to do this automatically, and that one might
51 # have to run "make clean" before "make dep" in some cases. But only
52 # developers need to worry about this. Everyone else can just run "make".)
53 dep: $(DEPS_MK)
55 else
57 all: $(DEARK_EXE)
59 include $(DEPS_MK)
61 endif
63 .PHONY: all clean dep install
65 OFILES_MODS_AB:=$(addprefix $(OBJDIR)/modules/,abk.o alphabmp.o amigaicon.o \
66 ansiart.o ar.o asf.o atari-dsk.o atari-img.o autocad.o awbm.o basic-c64.o \
67 arcfs.o apm.o afcp.o arc.o amiga-dsk.o binscii.o \
68 bmff.o apple2-dsk.o applesd.o binhex.o bintext.o bmi.o bmp.o \
69 arj.o bpg.o bsave.o adex.o)
70 OFILES_MODS_CH:=$(addprefix $(OBJDIR)/modules/,cab.o cardfile.o cfb.o \
71 cpio.o d64.o drhalo.o ebml.o emf.o epocimage.o eps.o exe.o \
72 exepack.o dms.o colorix.o diet.o \
73 flif.o fnt.o gemfont.o gemmeta.o gemras.o gif.o grasp.o grob.o gzip.o \
74 corel.o hfs.o hlp.o dsstore.o fli.o fat.o flac.o dlmaker.o crush.o \
75 cdiimage.o clp.o comicchat.o exectext.o gws.o)
76 OFILES_MODS_IO:=$(addprefix $(OBJDIR)/modules/,misc.o misc2.o misc3.o \
77 iccprofile.o icns.o \
78 id3.o ico.o iff.o ilbm.o insetpix.o iptc.o jbf.o jovianvi.o jpeg.o lha.o \
79 j2c.o ogg.o olepropset.o iso9660.o macbinary.o macrsrc.o lzexe.o nufx.o \
80 macpaint.o makichan.o mbk.o mmm.o mp3.o mscompress.o mac-arch.o \
81 msp.o nokia.o os2bmp.o ole1.o os2pack.o \
82 officeart.o lbr.o megapaint.o nie.o installshld.o os2ea.o os2bootlogo.o)
83 OFILES_MODS_PQ:=$(addprefix $(OBJDIR)/modules/,psd.o palmbitmap.o palmpdb.o \
84 pcpaint.o pcx.o pff2.o pict.o pkfont.o png.o pnm.o portfolio.o printptnr.o \
85 packdir.o pack.o packit.o pkm.o pklite.o pif.o \
86 printshop.o psf.o psionapp.o psionpic.o pcf.o plist.o qtif.o)
87 OFILES_MODS_RZ:=$(addprefix $(OBJDIR)/modules/,riff.o rosprite.o rpm.o \
88 rsc.o shg.o spectrum512.o sunras.o t64.o tar.o tga.o tiff.o tim.o \
89 tivariable.o unsupported.o vort.o wad.o wmf.o wpg.o wri.o xface.o \
90 stuffit.o sis.o sauce.o xfer.o zip.o zoo.o rar.o rodraw.o unifont.o rm.o \
91 reko.o sgiimage.o storyboard.o)
92 OFILES_MODS:=$(OFILES_MODS_AB) $(OFILES_MODS_CH) $(OFILES_MODS_IO) \
93 $(OFILES_MODS_PQ) $(OFILES_MODS_RZ)
95 OFILES_DEARK1:=$(addprefix $(OBJDIR)/src/,fmtutil-miniz.o deark-util.o \
96 deark-data.o deark-zip.o deark-tar.o deark-png.o \
97 deark-dbuf.o deark-bitmap.o deark-char.o deark-font.o deark-ucstring.o \
98 fmtutil.o fmtutil-cmpr.o fmtutil-advfile.o fmtutil-arch.o fmtutil-zip.o \
99 fmtutil-fax.o fmtutil-lzh.o fmtutil-lzw.o fmtutil-huffman.o \
100 fmtutil-exe.o fmtutil-lzah.o fmtutil-iff.o \
101 deark-user.o deark-unix.o deark-win.o)
102 OFILES_DEARK2:=$(addprefix $(OBJDIR)/src/,deark-modules.o)
103 OFILES_ALL:=$(OFILES_DEARK1) $(OFILES_DEARK2) $(OFILES_MODS) $(OBJDIR)/src/deark-cmd.o $(DEARK_RC_O)
105 DEARK1_A:=$(OBJDIR)/src/deark1.a
106 $(DEARK1_A): $(OFILES_DEARK1)
107 $(AR) $(ARFLAGS) $@ $^
109 DEARK2_A:=$(OBJDIR)/src/deark2.a
110 $(DEARK2_A): $(OFILES_DEARK2)
111 $(AR) $(ARFLAGS) $@ $^
113 MODS_AB_A:=$(OBJDIR)/modules/mods-ab.a
114 MODS_CH_A:=$(OBJDIR)/modules/mods-ch.a
115 MODS_IO_A:=$(OBJDIR)/modules/mods-io.a
116 MODS_PQ_A:=$(OBJDIR)/modules/mods-pq.a
117 MODS_RZ_A:=$(OBJDIR)/modules/mods-rz.a
118 $(MODS_AB_A): $(OFILES_MODS_AB)
119 $(AR) $(ARFLAGS) $@ $^
120 $(MODS_CH_A): $(OFILES_MODS_CH)
121 $(AR) $(ARFLAGS) $@ $^
122 $(MODS_IO_A): $(OFILES_MODS_IO)
123 $(AR) $(ARFLAGS) $@ $^
124 $(MODS_PQ_A): $(OFILES_MODS_PQ)
125 $(AR) $(ARFLAGS) $@ $^
126 $(MODS_RZ_A): $(OFILES_MODS_RZ)
127 $(AR) $(ARFLAGS) $@ $^
129 # I'm sorry if your linker doesn't like this library order, but the link
130 # command was getting so long that I've decided to start using helper
131 # libraries. I'll consider adding "-Wl,--start-group" and "-Wl,--end-group"
132 # options if that would help.
133 $(DEARK_EXE): $(OBJDIR)/src/deark-cmd.o $(DEARK_RC_O) $(DEARK2_A) $(MODS_AB_A) \
134 $(MODS_CH_A) $(MODS_IO_A) $(MODS_PQ_A) $(MODS_RZ_A) $(DEARK1_A)
135 $(CC) $(LDFLAGS) -o $@ $^
137 $(OBJDIR)/%.o: %.c
138 $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
140 ifdef DEARK_WINDRES
141 $(DEARK_RC_O): $(DEARK_RC) src/deark.ico
142 $(DEARK_WINDRES) $< $@
143 $(DEARK_RC_O:.o=.d):
144 > $@
145 endif
147 DEARK_INSTALLDIR ?= /usr/local/bin
148 INSTALL_TARGET:=$(DEARK_INSTALLDIR)/$(DEARK_EXE_BASENAME)
149 install: $(INSTALL_TARGET)
150 $(INSTALL_TARGET): $(DEARK_EXE)
151 install -s $(DEARK_EXE) $(DEARK_INSTALLDIR)
153 # Quick & dirty man page generation. (experimental/temporary)
154 # Note that this assumes DEARK_EXE does not have an absolute path.
155 .PHONY: man install-man
156 man: $(DEARK_MAN)
157 $(DEARK_MAN): $(DEARK_EXE)
158 help2man -n "extract data from various file formats" -o $@ -N ./$(DEARK_EXE)
159 install-man: $(DEARK_MAN)
160 install $(DEARK_MAN) /usr/share/man/man1
162 clean:
163 rm -f $(OBJDIR)/src/*.[oad] $(OBJDIR)/modules/*.[oad] $(DEARK_MAN) $(DEARK_EXE)
165 ifeq ($(MAKECMDGOALS),dep)
167 $(DEPS_MK): $(OFILES_ALL:.o=.d)
168 cat $(sort $^) > $@
170 $(OBJDIR)/%.d: %.c
171 $(CC) $(CFLAGS) $(INCLUDES) -MM -MT '$$(OBJDIR)/$*.o' -MF $@ $<
173 endif