home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnuawk.zip / pc / Makefile < prev    next >
Makefile  |  1997-06-23  |  12KB  |  359 lines

  1. # Makefile for gawk (GNU awk)                                   2 Jan 1997
  2. #
  3. # - for GNU C (djgpp)         [32bit executable for DOS]
  4. # - for GNU C (emx)           [32bit executable for OS/2 or DOS or Win32]
  5. # - for MS-Visual C/C++ 4.x   [Win32 executable for Windows 95 & NT]
  6. # - for Microsoft C 7         [16bit ececutable for DOS]
  7. # - for Microsoft C 6.00A     [16bit executable for OS/2 or DOS]
  8.  
  9. # Tested with GNU make and dmake-3.8 under OS/2 and DOS, and ndmake and
  10. # Microsoft nmake under DOS.  Compiling with dmake under DOS may require the 
  11. # DOS-only version of dmake (so that swapping works).  nmake requires a
  12. # few edits in the configuration section below.
  13.  
  14. default:
  15.     @echo "Enter $(MAK) target "
  16.     @echo " where 'target' is chosen from                          " 
  17.     @echo "  djgpp ... DOS 32-bit exe [GNU C, Delorie, v2]         "
  18.     @echo "  djgppv1 . DOS 32-bit exe [GNU C, Delorie, v1]         "
  19.     @echo "  emx ..... OS/2 32-bit exe [emx/gcc; uses emxlibc.dll] "
  20.     @echo "  emxnt ... NT exe [emx/gcc with RSXNT]                 "
  21.     @echo "  emxbnd .. OS/2 and DOS 32-bit exe [emx/gcc]           "
  22.     @echo "  msc ..... DOS exe [Microsoft C 7 & 8 (AKA 1.52)]      "
  23.     @echo "  msc6 .... DOS exe [Microsoft C 6.00a]                 "
  24.     @echo "  msc6os2 . OS/2 exe [Microsoft C 6.00a]                "
  25.     @echo "  msc6bnd . OS/2 and DOS exe [Microsoft C 6.00a]        "
  26.     @echo "  vcWin32 . Win32 exe [Microsoft Visual C]              "
  27.     @echo "  ----------------------------------------------------- "
  28.     @echo "  test .... Perform tests (see README_d/README.pc)      "
  29.     @echo "  install . Install gawk under $(prefix)/               "
  30.  
  31. # Support dropped in 3.0
  32. # - for Microsoft C 5.1       [16bit executable for OS/2 or DOS]
  33. #    @echo "  msc51     DOS exe [Microsoft C 5.1]                   "
  34. #    @echo "  msc51bnd  OS/2 and DOS exe [Microsoft C 5.1]          "
  35.  
  36. #======================= Configuration ==================================
  37. RSPFILE = gawk.rsp
  38. #
  39. # Choose method for passing arguments to the linker.
  40. #
  41. # If compiling under OS/2 or if make can pass long lines
  42. #LDRSP = $(GAWKOBJS)
  43. #LNKRSP = $(LDRSP)
  44. #
  45. # else if make == dmake
  46. # Response files for linker: dmake allows the macro expansion
  47. #   $(macro_name:modifier_list:modifier_list:...)
  48. # The macro mktmp creates a temporary file for the linker. 
  49. # The 't' modifier is for tokenization. 
  50. #LDRSP =   @$(mktmp $(<:t"\n"))
  51. #LNKRSP = @$(mktmp $(<:t"+\n") ) # Space before final paren req
  52. #
  53. # else use brain-dead approach (emxbnd will need 'tr').
  54. RSP = $(RSPFILE)
  55. LDRSP = @$(RSP)
  56. LNKRSP = $(LDRSP)
  57. #------------------------------------------------------------------------
  58. # Some makes do not define MAKE (and ndmake does not allow a define).
  59. # Define MAK to be your make command.
  60. #MAKE = dmake
  61. MAK = $(MAKE) $(MAKEFILE)
  62. #MAK = $(MAKE)
  63. #MAKEFILE = -f Makefile
  64. #MAK = make45 $(MAKEFILE)
  65. #------------------------------------------------------------------------
  66. # Define the base directory for the install. "make install" will install
  67. # in bin, lib/awk, man, and info under $(prefix)/. Most likely, you should
  68. # edit config.h so that $(prefix)/lib/awk appears as part of DEFPATH.
  69. #prefix =
  70. prefix = c:/gnu
  71. #
  72. # Define the install method. Method 1 is Unix-like (and requires cat,
  73. # cp, mkdir, sed, and sh); method 2 uses gawk and batch files.
  74. install = 1
  75. #------------------------------------------------------------------------
  76. # To work around command-line length problems, this makefile assumes
  77. # that $($X) can be expanded.  If using a make (such as nmake) which 
  78. # cannot handle such macros, define DO_LNK and DO_BIND for your target 
  79. # as $(L<target>) and $(B<target>), resp.; e.g.,
  80. #DO_LNK = $(LvcWin32)
  81. #DO_BIND= $(BvcWin32)
  82. # and then comment the following:
  83. DO_LNK = $($(LNK))
  84. DO_BIND= $($(BIND))
  85. #========================================================================
  86. # End of general configuration. Some platform-specific configuration
  87. # notes appear below.
  88.  
  89.  
  90. #========================================================================
  91. #========================== DJGPP =======================================
  92. #========================================================================
  93.  
  94. LDJG = $(CC) $(LF) -o gawk.exe $(LDRSP) $(LF2)
  95. BDJG = stubify -g awk.exe | stubedit awk.exe runfile=gawk
  96.  
  97. djgpp:
  98.     $(MAK) all \
  99.     CC=gcc O=.o CF=-O \
  100.     LNK=LDJG LF=-s LF2=-lm \
  101.     BIND=BDJG
  102.  
  103. djgpp-debug:
  104.     $(MAK) all \
  105.     CC=gcc O=.o CF=-g \
  106.     LNK=LDJG LF2=-lm \
  107.     BIND=BDJG
  108.  
  109. LDJGv1 = $(CC) $(LF) -o gawk $(LDRSP) $(LF2)
  110. #BDJGv1 = coff2exe -s /djgpp/bin/go32.exe gawk
  111. BDJGv1 = coff2exe gawk
  112.  
  113. djgppv1:
  114.     $(MAK) all \
  115.     CC=gcc O=.o CF=-O \
  116.     LNK=LDJGv1 LF=-s LF2=-lm \
  117.     BIND=BDJGv1
  118.  
  119. #========================================================================
  120. #========================== EMX =========================================
  121. #========================================================================
  122.  
  123. # Link command for OS/2 versions.
  124. LEMX = $(CC) $(LF) -o $@ $(GAWKOBJS) gawk.def -lbsd $(LF2)
  125.  
  126. # Link and bind for DOS and OS/2 versions.
  127. # emx-09 needs '-p' emx option here or in EMXOPT environ var.
  128. LEMXBND = $(CC) $(LF) -o a.out $(LDRSP) gawk.def -lbsd $(LF2)
  129. BEMX = emxbind -bs -o $@ a.out -p
  130. #BEMX = emxbind -bs /emx/bin/emx.exe a.out $@ -p
  131. BEMXD = emxbind -b -o $@ a.out -p
  132.  
  133. emx:
  134.     $(MAK) all \
  135.     "CC=gcc -Zomf" O=.obj "CF=-O -DOS2" \
  136.     LNK=LEMX "LF=-s -Zcrtdll -Zstack 512" RSP=
  137.  
  138. emxnt:
  139.     $(MAK) all \
  140.     "CC=gcc -Zwin32 -Zcrtdll=crtrsxnt" O=.o "CF=-O -DOS2" \
  141.     LNK=LEMX "LF=-s -Zstack 512" RSP=
  142.  
  143. emxbnd:
  144.     $(MAK) all \
  145.     CC=gcc O=.o "CF=-O -DOS2 -DMSDOS" OBJ=popen.o \
  146.     LNK=LEMXBND \
  147.     BIND=BEMX "P=|tr \" \" \"\n\""
  148.  
  149. emxbnd-debug:
  150.     $(MAK) all \
  151.     CC=gcc O=.o "CF=-g -DOS2 -DMSDOS" OBJ=popen.o \
  152.     LNK=LEMXBND \
  153.     BIND=BEMXD "P=|tr \" \" \"\n\""
  154.  
  155. #========================================================================
  156. #========================== MSC =========================================
  157. #========================================================================
  158.  
  159. # stdargv, glob, and director are from Stewartson's sh. These provide
  160. # globbing and enhanced argument-passing. MSC setargv.obj is a 
  161. # more limited alternative (and it will permit a bound version).
  162. #STDARGV = stdargv.obj glob.obj director.obj 
  163. STDARGV = setargv.obj
  164.  
  165. # Optimization and library options:
  166. # Os == optimize for size, Ot == optimize for speed, G2 == 286 or better
  167. #MSCOPT = -Os -G2
  168. MSCOPT = -Ot # -G2
  169. # Alternate lib, does not use math coprocessor.
  170. #MSCLIB = llibca
  171. #MSCCL = -FPa
  172. # Emulator lib, uses math coprocessor if present.
  173. MSCLIB = llibce
  174. MSCCL = -FPi
  175. #MSCCL = -FPc
  176.  
  177. LMSC = link $(LF) $(LNKRSP) $(STDARGV)/NOE,$@,,/NOD:llibce $(MSCLIB)$(LF2)/STACK:0x5420,nul
  178.  
  179. # CLMSC-linking works when building under OS/2
  180. CLMSC = $(CC) -o $@ $(LF) $(GAWKOBJS) $(STDARGV) $(LF2) -link /NOE/NOI/STACK:0x6f00
  181.  
  182. BMSC = bind $@ /n DOSMAKEPIPE DOSCWAIT
  183.  
  184.  
  185. # Ugly hack: config.h defines __STDC__ if not defined on command-line.
  186. # OS/2 versions can't use -Za in getid.c. MSC7 uses stub headers in pc/ 
  187. # due to ANSI conflicts. MSC 5.1 defines __STDC__=0 regardless of ANSI flag.
  188.  
  189. # dmake-3.8 runs out of memory under DOS. Request that dmake
  190. # swap itself out on these targets. Note that this won't have
  191. # any affect on the bound OS/2 and DOS version of dmake-3.8.
  192.  
  193. .SWAP: msc msc-debug msc6 msc6os2 msc6bnd msc51 check
  194.  
  195. msc: 
  196.     $(MAK) all \
  197.     "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Ze -Ipc/include $(MSCOPT)" \
  198.     OBJ=popen.obj \
  199.     LNK=LMSC P=+
  200. Lmsc = $(LMSC)  # for broken makes (nmake) which cannot expand $($X)
  201. Bmsc =
  202.  
  203. msc-debug: 
  204.     $(MAK) all \
  205.     "CC=cl $(MSCCL)" O=.obj "CF=-AL -Ze -Ipc/include -W2 -Zi -Od" \
  206.     OBJ=popen.obj \
  207.     LNK=LMSC LF2=/CO P=+
  208.  
  209. msc6: 
  210.     $(MAK) builtin.obj \
  211.     "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Za $(MSCOPT) -Od"
  212.     $(MAK) all \
  213.     "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -Za $(MSCOPT)" \
  214.     OBJ=popen.obj \
  215.     LNK=LMSC P=+
  216. Lmsc6 = $(LMSC)  # for broken makes (nmake) which cannot expand $($X)
  217. Bmsc6 =
  218.  
  219. msc6os2: 
  220.     $(MAK) builtin.obj \
  221.     "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -DOS2 -UMSDOS $(MSCOPT) -Od"
  222.     $(MAK) all \
  223.     "CC=cl $(MSCCL)" O=.obj "CF=-AL -DOS2 -UMSDOS $(MSCOPT)" \
  224.     LNK=LMSC "LF2=p,gawk.def" P=+
  225.  
  226. msc6bnd:
  227.     $(MAK) builtin.obj \
  228.     "CC=cl -nologo $(MSCCL)" O=.obj "CF=-AL -DOS2 $(MSCOPT) -Od"
  229.     $(MAK) all \
  230.     "CC=cl $(MSCCL)" O=.obj "CF=-AL -DOS2 $(MSCOPT)" \
  231.     OBJ=popen.obj \
  232.     LNK=LMSC "LF2=p,gawk.def" P=+ \
  233.     BIND=BMSC
  234. Lmsc6bnd = $(LMSC)  # for broken makes (nmake) which cannot expand $($X)
  235. Bmsc6bnd = $(BMSC)
  236.  
  237.  
  238. # Windows '95 / NT 
  239. LvcWin32 = link -nologo -subsystem:console -release -out:$@ $(LNKRSP)
  240.  
  241. vcWin32:
  242.     $(MAK) all \
  243.     "CC=cl -nologo" O=.obj "CF=-o2 -DWIN32 -D__STDC__=0" \
  244.     LNK=LvcWin32
  245.  
  246.  
  247. # Support dropped in 3.0
  248. #msc51: 
  249. #    $(MAK) all \
  250. #    "CC=cl $(MSCCL)" O=.obj "CF=-AL -Za -D_MSC_VER=510 $(MSCOPT)" \
  251. #    OBJ=popen.obj \
  252. #    LNK=LMSC P=+
  253. #
  254. #msc51bnd:
  255. #    $(MAK) all \
  256. #    "CC=cl -AL ($MSCCL)" O=.obj "CF=-DOS2 -D_MSC_VER=510 $(MSCOPT)" \
  257. #    OBJ=popen.obj \
  258. #    LNK=CLMSC "LF=-Lp -Fb" "LF2=gawk.def"
  259.  
  260. #========================================================================
  261.  
  262. # Define BIND for BINDless compiles, otherwise $($(BIND)) may break.
  263. BIND = EMPTY
  264. EMPTY=
  265.  
  266. # bitwise operations (-DBITOPS) and non-decimal input data (-DNONDECDATA) are
  267. # undocumented in 3.0.3.  They may be enabled in config.h, or added to CFLAGS.
  268. CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H
  269.  
  270. # object files
  271. AWKOBJS1 = array$O builtin$O eval$O field$O gawkmisc$O io$O main$O
  272. AWKOBJS2 = missing$O msg$O node$O re$O version$O
  273. AWKOBJS = $(AWKOBJS1) $(AWKOBJS2)
  274.  
  275. ALLOBJS = $(AWKOBJS) awktab$O getid$O $(OBJ)
  276.  
  277. # LIBOBJS
  278. #       GNU and other stuff that gawk uses as library routines.
  279. LIBOBJS= getopt$O getopt1$O regex$O dfa$O random$O
  280.  
  281. GAWKOBJS = $(ALLOBJS) $(LIBOBJS)
  282.  
  283. # clear out suffixes list
  284. # .SUFFIXES:
  285. .SUFFIXES: .c $O
  286.  
  287. .c$O:
  288.     $(CC) -c $(CFLAGS) $<
  289.  
  290. # rules to build gawk
  291. all : gawk.exe
  292.  
  293. gawk.exe:: $(GAWKOBJS) $(RSP)
  294.     $(DO_LNK)
  295.     $(DO_BIND)
  296.  
  297. $(RSPFILE) : $(GAWKOBJS)
  298.     echo $(AWKOBJS1)$P > $@
  299.     echo $(AWKOBJS2)$P >> $@
  300.     echo awktab$O getid$O $(OBJ) $(LIBOBJS)$P >> $@
  301.  
  302. $(ALLOBJS):    awk.h dfa.h regex.h config.h
  303.  
  304. gawkmisc$O:    pc/gawkmisc.pc
  305.  
  306. getopt$O:    getopt.h
  307.  
  308. getopt1$O:    getopt.h
  309.  
  310. main$O:    patchlevel.h
  311.  
  312. # A bug in ndmake requires the following rule
  313. awktab$O: awk.h awktab.c
  314.     $(CC) -c $(CFLAGS) awktab.c
  315.  
  316. awktab.c:    awk.y
  317.     bison -o $@ awk.y
  318.  
  319. alloca$O:    alloca.c
  320.  
  321.  
  322. install: install$(install)
  323.  
  324. install1: 
  325.     echo extproc sh $(prefix)/bin/igawk.cmd > igawk.cmd
  326.     echo shift >> igawk.cmd
  327.     cat pc/awklib/igawk >> igawk.cmd
  328.     sed "s;igawk;$(prefix)/bin/igawk;" pc/awklib/igawk.bat > igawk.bat
  329.     sh mkinstal.sh $(prefix)/bin
  330.     sh mkinstal.sh $(prefix)/lib/awk $(prefix)/man/man1 $(prefix)/info
  331.     cp *awk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin
  332.     cp awklib/eg/lib/* pc/awklib/igawk.awk $(prefix)/lib/awk
  333.     cp doc/*.1 $(prefix)/man/man1
  334.     cp doc/gawk.info $(prefix)/info
  335.  
  336. # install2 is equivalent to install1, but doesn't require cp, sed, etc.
  337. install2:
  338.     gawk -v prefix=$(prefix) -f install.awk
  339.  
  340. clean:
  341.     rm -rf gawk gawk.exe *.o *.obj core a.out $(RSPFILE)
  342. #    cd doc && $(MAKE) clean
  343. #    cd test && $(MAKE) clean
  344. #    cd awklib && $(MAKE) clean
  345.  
  346. awklib/eg: doc/gawk.texi
  347.     rm -fr awklib/eg
  348.     sh -c "cd awklib && ../gawk -f extract.awk ../doc/gawk.texi"
  349.  
  350. check:
  351.     @echo "Running the tests requires several unix-like utilities.  The"
  352.     @echo "recommendation is to copy pc/Makefile.tst to test/Makefile.  Under"
  353.     @echo "DOS, it may be necessary to run make from the test directory."
  354. # The `-k' option to make should be unnecessary if using pc/Makefile.tst.
  355. #    sh -c "cd test && $(MAK) -k AWK=../gawk.exe"
  356.     sh -c "cd test && $(MAK) AWK=../gawk.exe bigtest extra"
  357.  
  358. test:    check
  359.