Initial commit.
[amiga/xmodule.git] / Makefile
1 ##
2 ##      $VER: XModule_Makefile 4.1 (15.8.98)
3 ##
4 ##      Copyright (C) 1993,94,95,96,97,98 by Bernardo Innocenti
5 ##
6 ##      This Makefile must be processed with GNU make 3.76.1
7 ##      Use 4 chars wide TABs to read this file
8 ##
9 ##      Please see below to know what developement tools you need to
10 ##      install in order to build XModule and all related files.
11 ##
12 ##
13 ##      Relevant build targets:
14 ##
15 ##              make all                - Make all binaries. This is the default
16 ##              make release    - Make distribution archives
17 ##              make bumprev    - Bump the revision number of XModule
18 ##              make newctfiles - Make new .ct files for catalog translators
19 ##              make clean              - Removes all objects and temporary files
20
21 include config.mk
22
23 ###########################################################
24 # Tools used to make this project:
25 ###########################################################
26 #
27 # SAS/C 6.58        is a commercial product. Updates are available on Aminet
28 # PhxAss 4.38       is on Aminet in the archive "dev/asm/PhxAss438.lha"
29 # PhxLnk 4.31       is on Aminet in the archive "dev/asm/PhxLnk431.lha"
30 # FlexCat 2.1       is on Aminet in the archive "dev/misc/FlexCat.lha"
31 # FD2Pragma 2.52    is on Aminet in the archive "dev/misc/FD2Pragma.lha"
32 # ADtoHT 2.1        is on Aminet in the archive "text/hyper/ADtoHT2_1.lha"
33 # RevUp 1.4         is on Aminet in the archive "dev/misc/RevUp1_4.lha"
34 # GNU Make 3.76.1   is on Aminet in the archive "dev/c/make_bin.lha"
35 # GNU MakeInfo 1.64 is part of the GeekGadgets project
36 # scompare          is part of the SAS/C Developement System and is not freely distributable
37 # autodoc           is in the 3.1 NDTK or in the Amiga Developer CD 1.2
38 #
39 # 3.1 Includes      is in the 3.1 NDTK or in the Amiga Developer CD 1.2
40 # XPK 2.5 DTK       is on Aminet in the archive "util/pack/×pk25dev.lha"
41 # ReqTools DTK      is on Aminet in the archive "util/libs/ReqToolDev.lha"
42 #
43 #
44 # My ethernal gratitude to the clever authors of these useful tools!
45 #
46
47 ###########################################################
48 # Additional configuration
49 ###########################################################
50 #
51 # Subdirectories to work in
52 #
53 SUBDIRS := Hooks gadgets manuals
54
55
56 ###########################################################
57 # Source files to compile for the XModule executible
58 ###########################################################
59 #
60 #
61
62 SRCS := Main.c Misc.c Rexx.c Gui.c Requesters.c Prefs.c Locale.c \
63  Audio.c Compress.c App.c Cx.c Help.c Operators.c Instr.c \
64  SongClass.c Library.c XModuleHook.c TrackerHook.c CustomClasses.c \
65  ToolBoxWin.c OptimizationWin.c ClearWin.c InstrumentsWin.c \
66  SongInfoWin.c SequenceWin.c ProgressWin.c SaversWin.c \
67  PlayWin.c PrefsWin.c PatternWin.c PattPrefsWin.c
68
69 # List the objects from the source files
70 OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
71
72
73 # NOTE: SampleWin.o removed because still not updated to new GUI system
74
75
76
77 ###########################################################
78 # Targets to make for normal builds. This is the default
79 ###########################################################
80 #
81 # NOTE: the GST file is put here to have it remade when needed.
82 #       the source files do not depend on $(GST) because otherwise
83 #       make would rebuild all them when the GST is rebuild.
84
85 all: $(GST) $(PROJNAME) Players/32Channels.player subdirs
86
87 final: $(GST) $(PROJNAME)_final Players/32Channels.player subdirs
88
89 subdirs:
90         @$(foreach subdir, $(SUBDIRS), $(MAKE) -w $(MAKEFLAGS) -C $(subdir) @@)
91
92
93
94 ###########################################################
95 # Patch files for special binary versions
96 ###########################################################
97
98 patches:                                                                \
99  Patches/XModule_020.pch                                \
100  Patches/XModule_020_OS30.pch                   \
101  Patches/XModule.guide_39.pch                   \
102  Patches/XModule.guide_40.pch                   \
103  Patches/XModule.doc.pch                                \
104  Patches/pattedit.gadget_020.pch                \
105  Patches/pattedit.gadget_020_OS30.pch
106
107
108 ###########################################################
109 # Files to make for the distribution
110 ###########################################################
111
112 release: all patches catalogs autodocs
113
114 catalogs:
115         @$(MAKE) -w $(MAKEFLAGS) -C catalogs
116
117
118 ###########################################################
119 # Make the Global Symbol Table used to speed up SAS/C
120 ###########################################################
121
122 ifneq ($(strip $(GST)),)
123
124 $(GST): XModulePriv.h Gui.h LocaleStrings.h Gst.c \
125  include/libraries/xmodule.h include/libraries/xmoduleclass.h \
126  include/libraries/songclass.h include/libraries/patteditclass.h \
127  include/pragmas/xmodule_pragmas.h include/clib/xmodule_protos.h
128         $(CC) FROM Gst.c MakeGst=$(GST) NOOBJNAME $(CFLAGS)
129
130 endif
131
132 ###########################################################
133 # Make the main XModule executable
134 ###########################################################
135 #
136 # Generic rule for making all the objects
137 # NOTE: the `:' path separator must be escaped to avoid confusing GNU make
138 #
139 $(OBJS): $(subst :,\:,$(OBJDIR))/%.o: %.c LocaleStrings.h
140         $(CC) $< $(CC_OUT) $@ $(CFLAGS) $(MORE_CFLAGS)
141
142 $(OBJDIR)/Startup.o: Startup.asm
143         $(AS) Startup.asm TO $@ $(ASFLAGS) $(MORE_ASFLAGS) SET "STKSIZE=$(STACKSIZE)"
144
145 # NOTE: the following rule works around the command line length limit of the
146 #       Amiga native shell by striping away the path component from $(OBJECTS)
147 $(PROJNAME): $(OBJDIR)/Startup.o $(OBJS)
148         cd $(OBJDIR) @@\
149         $(LD) FROM $(OBJDIR)/Startup.o $(OBJS:$(OBJDIR)/%=%) TO $@ $(LDFLAGS) $(LIBS) @@\
150         move $@ $(TOP)/$@
151
152 # EXPERIMENTAL: to get better code optimization, we compile all the source
153 # code modules at once, by including all them in a single dummy source file.
154 #
155 $(PROJNAME)_final: $(OBJDIR)/Startup.o $(PROJNAME)_final.o
156         $(LD) FROM $(OBJDIR)/Startup.o $(OBJDIR)/$(PROJNAME)_final.o TO $@ $(LDFLAGS) $(LIBS)
157
158 $(PROJNAME)_final.o: $(PROJNAME)_final.c
159         $(CC) $(PROJNAME)_final.c $(CC_OUT) $(OBJDIR)/$(PROJNAME)_final.o $(CFLAGS) $(MORE_CFLAGS) \
160                 DEF SINGLE_OBJECT
161
162 $(PROJNAME)_final.c: $(SRCS)
163         echo "/** This source file is automatically generated - do not edit **/" >$(PROJNAME)_final.c
164         list $(SRCS) LFORMAT "#include *"%p%n*"" >>$(PROJNAME)_final.c
165
166
167 ###########################################################
168 # Make other executable flavors
169 ###########################################################
170
171 XModule_020: XModule
172         $(MAKE) -u "MORE_CFLAGS=CPU 68020" "MORE_ASFLAGS=MACHINE 68020" XModule
173         Move XModule XModule_020
174         $(MAKE) clean
175
176 XModule_OS30: XModule
177         $(MAKE) -u "MORE_CFLAGS=DEF OS30_ONLY" "MORE_ASFLAGS=SET OS30_ONLY" $(GST) XModule
178         Move XModule XModule_OS30
179         $(MAKE) clean
180
181 XModule_020_OS30: XModule
182         $(MAKE) -u "MORE_CFLAGS=CPU 68020 DEF OS30_ONLY" \
183          "MORE_ASFLAGS=SET OS30_ONLY MACHINE 68020" $(GST) XModule
184         Move XModule XModule_020_OS30
185         $(MAKE) clean
186
187
188
189
190 ###########################################################
191 # Make 32Channels.player
192 ###########################################################
193
194 Player.o: Player.asm
195         $(AS) Player.asm $(ASFLAGS) $(MORE_ASFLAGS)
196
197 Players/32Channels.player: Player.o
198         $(LD) Player.o TO Players/32Channels.player LIB:Small.lib NODEBUG SMALLCODE SMALLDATA
199
200
201
202 ###########################################################
203 # Locale related stuff
204 ###########################################################
205 #
206
207 LocaleStrings.h Locale.c: LocaleStrings_h.sd Locale_c.sd Catalogs/$(PROJNAME).cd
208         $(FLEXCAT) Catalogs/$(PROJNAME).cd LocaleStrings.h=LocaleStrings_h.sd Locale.c=Locale_c.sd
209
210 # Make NewCTFiles to create updated CT files for all supported languages
211
212 NewCTFiles:
213         @$(MAKE) -w $(MAKEFLAGS) -C catalogs NewCTFiles
214
215
216
217
218 ###########################################################
219 # Make xmodule_pragmas.h
220 ###########################################################
221 #
222 # Do not use SAS/C's fd2pragma! What you need here is FD2Pragma 2.52 or newer.
223 # It can be found on Aminet in the archive "dev/misc/FD2Pragma.lha".
224 #
225
226 include/pragmas/xmodule_pragmas.h: xmodule_lib.fd
227         $(FD2PRAGMA) FDFILE xmodule_lib.fd SPECIAL 6 TO include/pragmas/xmodule_pragmas.h
228         $(FD2PRAGMA) FDFILE xmodule_lib.fd SPECIAL 10 TO include/libraries/xmodule_lib.i
229         $(FD2PRAGMA) FDFILE xmodule_lib.fd SPECIAL 18 TO include/proto/xmodule.h
230
231
232
233 ###########################################################
234 # Make AutoDocs
235 ###########################################################
236 #
237 # autodoc is a standard Commodore developer tool.  You can
238 # find it in the 3.1 NDTK.
239 #
240 # ADtoHT 2.1 is an AutoDoc to AmigaGuide file conversion
241 # utility made by Christian Stieber.  It can be found on
242 # Aminet in the directory "text/hyper/".
243 #
244
245 autodocs: Autodocs/xmodule.doc Autodocs/songclass.doc
246
247 Autodocs/xmodule.doc Autodocs/songclass.doc: Library.c SongClass.c
248         $(CP) include/libraries/xmodule.h include/libraries/songclass.h Autodocs/
249         autodoc -t4 -C -I -c Library.c >Autodocs/xmodule.doc
250         autodoc -t4 -C -I -c SongClass.c >Autodocs/songclass.doc
251         SC:Doc/ADtoHT Autodocs/ RAM: Autodocs/ Autodocs/ VERSION 39
252         $(RM) Autodocs/xmodule.h
253         $(RM) Autodocs/songclass.h
254
255
256 ###########################################################
257 # Bump the revision
258 ###########################################################
259 #
260 # RevUp is a developer tool by Boris Folgmann which is similar to BumpRev.
261 # You can find it on Aminet in the archive "dev/misc/RevUp1_4.lha".
262 #
263
264 bumprev:
265         RevUp 3 XModule NOASM EXTRA TINY
266
267
268 ###########################################################
269 # Update dependencies
270 ###########################################################
271 #
272 # EXPERIMENTAL - Do not use
273 #
274
275 depend:
276         gcc -Iinclude: -Iinclude -MM *.c >depend
277
278 # other handy gcc options:
279 # -O2 -fomit-frame-pointer -fstrength-reduce -finline-functions -funroll-loops
280 # -W -Wunused -Wuninitialized -Wparentheses Wreturn-type -Wshadow -Wcast-align
281 # -Wstrict-prototypes
282
283 ###########################################################
284 # Cleanup all mess
285 ###########################################################
286
287 clean:
288         -$(RM) *.pch *.map *.gst *.xref XModule XModule.doc \
289         Locale.c LocaleStrings.h Players/*.player Patches/*.pch $(PROJNAME)_final.c depend
290         -$(RM) $(OBJDIR)/*.o
291         @$(MAKE) -w $(MAKEFLAGS) -C Hooks clean
292         @$(MAKE) -w $(MAKEFLAGS) -C gadgets clean
293         @$(MAKE) -w $(MAKEFLAGS) -C catalogs clean
294
295
296
297 ##################################################################################
298 # Make patches for special executables optimized for different CPU and OS version
299 ##################################################################################
300
301 Patches/XModule_020.pch: XModule_020
302         scompare -o$@ XModule XModule_020
303
304 Patches/XModule_020_OS30.pch: XModule_020_OS30
305         scompare -o$@ XModule XModule_020_OS30
306
307 Patches/pattedit.gadget_020.pch: Gadgets/pattedit.gadget_020
308         scompare -o$@ Gadgets/pattedit.gadget Gadgets/pattedit.gadget_020
309
310 Patches/pattedit.gadget_020_OS30.pch: Gadgets/pattedit.gadget_020_OS30
311         scompare -o$@ Gadgets/pattedit.gadget Gadgets/pattedit.gadget_020_OS30
312
313 Patches/XModule.guide_39.pch: manuals/XModule.guide_39
314         scompare -o$@ manuals/XModule.guide_34 manuals/XModule.guide_39
315
316 Patches/XModule.guide_40.pch: manuals/XModule.guide_40
317         scompare -o$@ manuals/XModule.guide_34 manuals/XModule.guide_40
318
319 Patches/XModule.doc.pch: manuals/XModule.txt
320         scompare -o$@ manuals/XModule.doc manuals/XModule.txt
321
322
323
324 ###########################################################
325 # Make the distribution archives
326 ###########################################################
327 #
328 # Note: We can't use the `#?' wildcard because the `#' character
329 #       is also used to start a comment in a Makefile. This script
330 #       will work only when the dos wildstar flag is set.
331 #
332
333 release: distribution_archive source_archive
334
335 distribution_archive:
336         Execute <<
337                 If NOT EXISTS $(DISTPREFIX)/XModule
338                         MakeDir $(DISTPREFIX)/XModule
339                 EndIf
340
341                 $(CP) XModule $(DISTPREFIX)/XModule/
342                 $(CP) manuals/XModule.doc manuals/HISTORY manuals/README $(DISTPREFIX)/XModule/
343                 $(CP) manuals/XModule.guide_34 $(DISTPREFIX)/XModule/XModule.guide
344                 $(CP) Players/* $(DISTPREFIX)/XModule/Players/
345                 $(CP) Hooks/*.xmhook $(DISTPREFIX)/XModule/Hooks/
346                 $(CP) Gadgets/pattedit.gadget $(DISTPREFIX)/XModule/Gadgets/
347                 $(CP) Patches/*.pch $(DISTPREFIX)/XModule/Patches/
348
349                 $(RM) ALL $(DISTPREFIX)/XModule/Catalogs/**
350                 $(CP) ALL Catalogs $(DISTPREFIX)/XModule/Catalogs/
351
352
353                 CD $(DISTPREFIX)
354                 If EXISTS $(ARCNAME)
355                         $(RM) $(ARCNAME)
356                 EndIf
357                 $(ARCHIVER) $(ARCNAME) XModule/** XModule.info
358         <
359
360 source_archive:
361         Execute <<
362                 If EXISTS $(SRCARCNAME)
363                         $(RM) $(SRCARCNAME)
364                 EndIf
365
366                 $(RM) ALL $(SRCDISTDIR)/XModuleSource/**
367
368                 $(CP) *.c $(DISTPREFIX)/XModuleSource/
369                 $(CP) *.h $(DISTPREFIX)/XModuleSource/
370                 $(CP) *.asm TO $(DISTPREFIX)/XModuleSource/
371                 $(CP) ALL Include $(DISTPREFIX)/XModuleSource/Include
372                 $(CP) XModule.texi MakeFile XModule_rev.rev LocaleStrings_h.sd Locale_c.sd TODO SCOPTIONS $(DISTPREFIX)/XModuleSource/
373
374                 $(CP) FakePlayer.asm $(DISTPREFIX)/XModuleSource/Player.asm
375                 $(RM) $(DISTPREFIX)XModuleSource/FakePlayer.asm
376
377                 If EXISTS $(SRCARCNAME)
378                         $(RM) $(SRCARCNAME)
379                 EndIf
380                 $(ARCHIVER) $(SRCARCNAME) include
381                 CD $(DISTPREFIX)
382                 $(ARCHIVER) $(SRCARCNAME) XModuleSource XModuleSource.info
383         <
384
385
386
387 ###########################################################
388 # Phony targets (targets which arn't really files to make)
389 ###########################################################
390
391 .PHONY: all patches release autodocs distribution_archive source_archive \
392         NewCTFiles bumprev depend clean subdirs $(SUBDIRS)
393
394 #end