makefile.dj2 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. # Makefile for Info-ZIP's UnZip, UnZipSFX and fUnZip using DJGPP v2.01 or
  2. # higher, by Frank Donahoe. Last updated: 21 Jul 2008
  3. # This Makefile is specifically tailored for GNU make and GNU C and
  4. # may not work with a generic Unix-compatible make utility. The latest
  5. # make version is 3.78.1. Thanks to Eli Zaretskii for generously responding
  6. # to questions with advice on the changes needed to make install work under
  7. # DJGPP version 2.0x.
  8. # Features used:
  9. # - pattern rules (%.o : %.c, etc.)
  10. # - GNU-specific conditionals and functions (ifeq, $(patsubst,,),...)
  11. # - simply expanded variables (VAR := text)
  12. #
  13. # The stand-alone executable requires DPMI services to run. If running
  14. # in a DOS window under Windows 3.1 or later, the dpmi server is auto-
  15. # matically present. Under DOS, if a DPMI server is not loaded, the
  16. # program will look for "cwsdpmi.exe." If found, it will be loaded for
  17. # the duration of the program.
  18. #
  19. # cwsdpmi is a "free" dpmi server written by Charles W. Sandmann
  20. # (sandman@clio.rice.edu). It may be found, among other sites, on SimTel
  21. # Net at the URL:
  22. #
  23. # ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/csdpmi?[b,s].zip
  24. #
  25. # and on its mirrors worldwide. The latest version as of this writing is 5.
  26. # Archives with the b postscript contain the binaries. An alternate server
  27. # is found, l.c., in the archive pmode??[b,s].zip. The latest (20001022) is
  28. # v1.3.
  29. # Separators colon and <sp> are used in Unix, semi-colon and <sp> in DOS.
  30. VPATH=. msdos
  31. ifdef NOASM
  32. USE_ASMCRC=
  33. else
  34. USE_ASMCRC=1
  35. endif
  36. .PHONY : clean install uninstall
  37. # UnZip flags
  38. # LOCAL_UNZIP may be set in "AUTOEXEC.BAT" or defined in "djgpp.env" under
  39. # [make] as in the example below. Or, if you habitually work in a DOS box
  40. # under Windows9x, right click on the MS-DOS icon, select properties, then
  41. # program, to find a slot called batch file, where you may specify the path
  42. # to a file which will set the variables of choice every time the box is
  43. # opened.
  44. # See, for example, DOSWILD, in the file INSTALL.
  45. # [make]
  46. # +BUTT=-mcpu=pentiumpro
  47. # +LOC=-W -Wall
  48. # +LOCAL_UNZIP=-DUSE_UNSHRINK
  49. # BUTT may be defined to specify the target system. With gcc v2.95,
  50. # optimizing options like "-mcpu=pentiumpro -march=pentiumpro" are supported,
  51. # but the traditional "-m386" and "-m486" options of previous gcc 2.x
  52. # version will continue to work.
  53. # So if you are in the habit of compiling from source, programs for your
  54. # own use, it is well to consult gcc's manual for options suitable to
  55. # your processer and to set BUTT accordingly. Consult INSTALL for
  56. # LOCAL_UNZIP.
  57. LOC=
  58. CC=gcc
  59. LD=$(CC)
  60. CPPFLAGS=-I. $(INC_BZ2LIB) -DDOS -DUSE_VFAT $(ASMFLG) $(LOCAL_UNZIP) $(LOC)
  61. ASFLAGS=$(CPPFLAGS)
  62. CFLAGS=-Wall -O2 $(BUTT) $(CPPFLAGS)
  63. # See INSTALL for discussion of SFX_EXDIR.
  64. # EXDIR=-DSFX_EXDIR
  65. FUN_FLAGS=$(CFLAGS) -DFUNZIP
  66. # Include OFP for a modest decrease in size of unzipsfx.exe.
  67. OFP=-fomit-frame-pointer
  68. SFX_FLAGS=-Wall -O2 $(CPPFLAGS) -DSFX $(EXDIR) $(OFP)
  69. LDFLAGS=-s
  70. # general-purpose stuff
  71. # If cp.exe is not found change to CP=copy /Y .
  72. CP = cp -fp
  73. # If install.exe is not found change to INSTALL=$(CP) . To prevent a
  74. # conflict with any of the many different "install's" that might be found
  75. # in the path, GNU install will be called as `ginstall'. This also bypasses
  76. # a stub bug that cropped up with the install from fil316b.zip.
  77. INSTALL=ginstall
  78. # The default value of RM is "rm -f" . If rm.exe is not found, uncomment
  79. # the following:
  80. # RM=del
  81. # Laszlo Molnar who wrote DJ Packer and Markus F. X. J. Oberhumer who wrote
  82. # the compression library used by the DJ Packer have collaborated on the
  83. # Ultimate Packer for eXecutables, which has recently been released. Look
  84. # for upx???d.zip at http://upx.sourceforge.net/
  85. # As an alternative, look for "djp.exe", now two years old, in the archive
  86. # mlp107[b,s].zip, found in the same location as csdpmi?[b,s].zip (see above).
  87. # Do not add the option -s to djp.exe without making the required changes
  88. # to the target zipinfo$E. Uncomment the three lines beginning with $(DJP)
  89. # or $(DJPSX).
  90. #DJP = djp -q
  91. #DJPSX = djp -q -s
  92. DJP = upx -qq --best
  93. DJPSX = $(DJP)
  94. E = .exe
  95. O = .o
  96. M=msdos
  97. # defaults for crc32 stuff and system dependent headers
  98. ifdef USE_ASMCRC
  99. ASMFLG = -DASM_CRC
  100. CRCA_O = crc_gcc$O
  101. else
  102. ASMFLG =
  103. CRCA_O =
  104. endif
  105. # optional inclusion of bzip2 decompression
  106. IZ_BZIP2 = bzip2
  107. ifdef USEBZ2
  108. INC_BZ2LIB = -I$(IZ_BZIP2)
  109. LOCAL_UNZIP:=-DUSE_BZIP2 $(LOCAL_UNZIP)
  110. LD_BZ2LIB = -L$(IZ_BZIP2) -lbz2
  111. LIBBZIP2 = $(IZ_BZIP2)/libbz2.a
  112. else
  113. INC_BZ2LIB =
  114. LD_BZ2LIB =
  115. LIBBZIP2 =
  116. endif
  117. # object files
  118. OBJS1 = unzip$O crc32$O $(CRCA_O) crypt$O envargs$O explode$O
  119. OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
  120. OBJS3 = process$O ttyio$O ubz2err$O unreduce$O unshrink$O zipinfo$O
  121. OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O
  122. OBJX = unzipsfx$O crc32_$O $(CRCA_O) crypt_$O extract_$O fileio_$O \
  123. globals_$O inflate_$O match_$O process_$O ttyio_$O ubz2err_$O $M_$O
  124. OBJF = funzip$O crc32-$O $(CRCA_O) crypt-$O globals-$O inflate-$O ttyio-$O
  125. OBJECTS_ALL = $(sort $(OBJS) $(OBJX) $(OBJF) crc_gcc$O)
  126. # Common header files included by all C sources:
  127. UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
  128. # executable files
  129. UNZIPS = unzip$E zipinfo$E funzip$E unzipsfx$E
  130. # pattern rules to compile the sources:
  131. %$O : %.c
  132. $(CC) $(CFLAGS) -c $< -o $@
  133. %-$O: %.c
  134. $(CC) $(FUN_FLAGS) -c $< -o $@
  135. %_$O: %.c
  136. $(CC) $(SFX_FLAGS) -c $< -o $@
  137. %sfx$O: %.c
  138. $(CC) $(SFX_FLAGS) -c $< -o $@
  139. all: unzips
  140. unzips: unzip$E zipinfo$E funzip$E unzipsfx$E
  141. unzip$E: $(OBJS) $(LIBBZIP2)
  142. $(LD) $(LDFLAGS) $(OBJS) $(LD_BZ2LIB) -o $@
  143. # $(DJP) $@
  144. zipinfo$E: unzip$E
  145. stubify -g $@
  146. stubedit $@ runfile=unzip argv0=zipinfo
  147. funzip$E: $(OBJF)
  148. $(LD) $(LDFLAGS) $(OBJF) -o $@
  149. # $(DJP) $@
  150. unzipsfx$E: $(OBJX)
  151. $(LD) $(LDFLAGS) $(OBJX) -o $@
  152. # $(DJPSX) $@
  153. # create/update the library for the optional bzip2 support:
  154. $(IZ_BZIP2)/libbz2.a:
  155. $(MAKE) -C $(IZ_BZIP2) -f Makebz2.iz CC="$(CC)" RM="$(RM)"
  156. # explicit compilation instructions:
  157. crc_gcc$O: crc_i386.S # 32bit, GNU AS
  158. $(CC) $(ASFLAGS) -x assembler-with-cpp -c -o $@ $<
  159. # BIN_PATH may be defined in djgpp.env [make] or defined below. If the
  160. # installation is to the directory containing gcc.exe etc. place the
  161. # following in djgpp.env:
  162. # [make]
  163. # +BIN_PATH=%\DJDIR%\bin
  164. # Even if so placed, it can be over-ridden here by, say:
  165. # BIN_PATH=c:\usr\bin
  166. install:
  167. -@if not exist $(BIN_PATH)\nul mkdir $(BIN_PATH)
  168. command.com /c for %f in ($(UNZIPS)) do $(INSTALL) %f $(BIN_PATH) > NUL
  169. uninstall:
  170. command.com /c for %f in ($(UNZIPS)) do $(RM) $(BIN_PATH)\%f > NUL
  171. clean:
  172. $(MAKE) -C $(IZ_BZIP2) -f Makebz2.iz CC="$(CC)" RM="$(RM)" clean
  173. ifeq ($(firstword $(RM)), del)
  174. $(RM) *$O
  175. $(RM) *.~
  176. $(RM) *.exe
  177. else
  178. $(RM) $(OBJECTS_ALL) *.~ *.exe
  179. endif
  180. # Source dependencies:
  181. crc_gcc$O: crc_i386.S
  182. crc32$O: crc32.c $(UNZIP_H) zip.h crc32.h
  183. crc32-$O: crc32.c $(UNZIP_H) zip.h crc32.h
  184. crc32_$O: crc32.c $(UNZIP_H) zip.h crc32.h
  185. crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
  186. crypt-$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
  187. crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
  188. envargs$O: envargs.c $(UNZIP_H)
  189. explode$O: explode.c $(UNZIP_H)
  190. extract$O: extract.c $(UNZIP_H) crc32.h crypt.h
  191. extract_$O: extract.c $(UNZIP_H) crc32.h crypt.h
  192. fileio$O: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
  193. fileio_$O: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
  194. funzip$O: funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
  195. globals$O: globals.c $(UNZIP_H)
  196. globals-$O: globals.c $(UNZIP_H)
  197. globals_$O: globals.c $(UNZIP_H)
  198. inflate$O: inflate.c inflate.h $(UNZIP_H)
  199. inflate-$O: inflate.c inflate.h $(UNZIP_H) crypt.h
  200. inflate_$O: inflate.c inflate.h $(UNZIP_H)
  201. list$O: list.c $(UNZIP_H)
  202. match$O: match.c $(UNZIP_H)
  203. match_$O: match.c $(UNZIP_H)
  204. msdos$O: msdos/msdos.c $(UNZIP_H)
  205. msdos_$O: msdos/msdos.c $(UNZIP_H)
  206. process$O: process.c $(UNZIP_H) crc32.h
  207. process_$O: process.c $(UNZIP_H) crc32.h
  208. ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  209. ttyio-$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  210. ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  211. ubz2err$O: ubz2err.c $(UNZIP_H)
  212. ubz2err_$O: ubz2err.c $(UNZIP_H)
  213. unreduce$O: unreduce.c $(UNZIP_H)
  214. unshrink$O: unshrink.c $(UNZIP_H)
  215. unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
  216. unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
  217. zipinfo$O: zipinfo.c $(UNZIP_H)