/[projet1]/users/mmu_man/sdk-makefile-engine/make/engine.nmk
Defence Force logotype

Contents of /users/mmu_man/sdk-makefile-engine/make/engine.nmk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 896 - (show annotations)
Thu Sep 27 11:16:11 2012 UTC (7 years, 6 months ago) by mmu_man
File size: 5900 byte(s)
Work around space madness when checking for emulators

* Neither nmake nor make can be made to use %ProgramFiles% correctly nor the hardcoded long name due to space issues.
* Just bet on being lucky to find it in C:\PROGRA~1 ...

1 #
2
3 !message OSDK Makefile engine (nmake) v0.1
4
5 OSDKB = $(OSDK)\bin
6
7 # quiet if Q=@
8 Q=@
9
10 !if "$(NAME)" == ""
11 !if !exist(osdk_config.mk)
12
13 osdk_config.mk: osdk_config.bat
14 @<<genconfig.bat > $@
15 @ECHO OFF
16 call osdk_config.bat
17 echo NAME=%OSDKNAME%
18 echo ADDR=%OSDKADDR:$$=%
19 echo FILES=%OSDKFILE%
20 <<
21 @echo Generated osdk_config.mk from osdk_config.bat.
22 @echo Consider editing the makefile instead.
23 @echo Please rerun $(MAKE) now.
24
25 all clean test: osdk_config.mk
26
27 _skip_the_rest = 1
28 !endif
29
30 !if exist(osdk_config.mk)
31 !message Including osdk_config.mk generated from osdk_config.bat.
32 !message Consider editing the makefile instead.
33 !include osdk_config.mk
34 !endif
35 !endif
36
37 # avoid errors with empty variables when generating osdk_config.mk
38 !ifndef _skip_the_rest
39
40 !if "$(NAME)" == ""
41 !error No NAME given in makefile and no osdk_config.bat
42 !endif
43
44 !if "$(TYPE)" == ""
45 TYPE = TAPE
46 !endif
47
48 !if "$(TYPE)" == "TAPE"
49 EXT=tap
50 !elseif "$(TYPE)" == "DISK"
51 EXT=dsk
52 !else
53 !error Invalid TYPE $(TYPE)"
54 !endif
55
56
57 # try to autodetect Euphoric
58 !if "$(EUPHORIC)" == ""
59 !if exist($(OSDK)\euphoric\euphoric.exe)
60 EUPHORIC = $(OSDK)\euphoric\euphoric.exe
61 !else if exist($(OSDK)\..\euphoric\euphoric.exe)
62 EUPHORIC = $(OSDK)\..\euphoric\euphoric.exe
63 !else if exist(C:\PROGRA~1\euphoric\euphoric.exe)
64 EUPHORIC = C:\PROGRA~1\euphoric\euphoric.exe
65 !endif
66 !endif
67
68 # try to autodetect Oricutron
69 !if "$(ORICUTRON)" == ""
70 !if exist($(OSDK)\oricutron\oricutron.exe)
71 ORICUTRON = $(OSDK)\oricutron\oricutron.exe
72 !else if exist($(OSDK)\..\oricutron\oricutron.exe)
73 ORICUTRON = $(OSDK)\..\oricutron\oricutron.exe
74 !else if exist(C:\PROGRA~1\oricutron\oricutron.exe)
75 ORICUTRON = C:\PROGRA~1\oricutron\oricutron.exe
76 !endif
77 !endif
78
79
80 !if "$(EMULATOR)" == ""
81 EMULATOR = oricutron
82 !message Using $(EMULATOR) as default emulator
83 !endif
84
85
86 # system defines
87 # the -DATMOS is for Contiki
88 SYSDEFINES = -D__16BIT__ -D__NOFLOAT__ -DATMOS
89 CPPFLAGS = $(CPPFLAGS) -I $(OSDK)\include
90 CPPFLAGS = $(CPPFLAGS) $(SYSDEFINES) $(DEFINES)
91 OPTIMIZE = -O2
92 CFLAGS = $(OPTIMIZE)
93
94 REALTARGET=$(NAME).$(EXT)
95
96 BUILDDIR=$(MAKEDIR)\BUILD
97
98 #HACK: append suffixes to suffixless names in FILES
99 #HACK: and relocate them to BUILD\
100 #_FILES = $(FILES) $(EMPTY)
101 # we always have at least 1 file anyway
102 OBJS=BUILD\$(FILES: =.os BUILD\).os
103
104 .SUFFIXES: .s
105
106 # build rules
107 #.os = output asm
108
109 # from .c
110 {.}.c{BUILD\}.os:
111 @echo Compiling $<
112 @echo - preprocess
113 $(Q)$(OSDKB)\cpp.exe -lang-c++ $(CPPFLAGS) -nostdinc $(<) $@.c1
114 @echo - compile
115 $(Q)$(OSDKB)\compiler.exe -N$(@B) $(CFLAGS) $@.c1 >$@.c2
116 @echo - convert C to assembly code
117 $(Q)$(OSDKB)\cpp.exe -lang-c++ -imacros $(OSDK)\macro\macros.h -traditional -P $@.c2 $@.s1
118 @echo - cleanup output
119 $(Q)$(OSDKB)\macrosplitter $@.s1 $@
120
121 # This causes a stale open file VirtualBox on shared folders
122 # which can't be deleted until closing the cmd.
123 # workaround is to pipe type's output
124 # @$(OSDKB)\tr < $@.s1 > $@
125
126 # from .s .asm
127
128 {.}.asm{BUILD\}.os:
129 @echo Assembling $<
130 $(Q)copy $< $@ /Y >NUL
131
132 {.}.s{BUILD\}.os:
133 @echo Assembling $<
134 $(Q)copy $< $@ /Y >NUL
135
136
137 !message
138
139 # targets
140
141 all: $(BUILDDIR) $(BUILDDIR)\$(REALTARGET)
142
143 $(BUILDDIR):
144 @echo Building the program $(@F) at address 0x$(ADDR)
145 $(Q)mkdir "$(BUILDDIR)"
146
147 #buildmsg: makefile
148 # @echo Building the program $(@F) at address 0x$(ADDR)
149
150 # add headers as dependency
151 #$(OBJS): *.h
152
153 $(BUILDDIR)\$(REALTARGET): $(BUILDDIR) $(OBJS)
154 @echo Linking
155 $(Q)$(OSDKB)\link65.exe $(OSDKLINK) -d $(OSDK)\lib\ -o BUILD\linked.s -f -q $(OBJS)
156 @echo Assembling
157 $(Q)$(OSDKB)\xa.exe BUILD\linked.s -o BUILD\final.out -e BUILD\xaerr.txt -l BUILD\symbols -bt $$$(ADDR)
158 $(Q)$(OSDKB)\header.exe $(OSDKHEAD) build\final.out BUILD\$(@B).tap $$$(ADDR)
159 !if "$(TYPE)" == "DISK"
160 $(Q)-$(OSDKB)\tap2dsk BUILD\$(@B).tap $@
161 !endif
162 @echo Build of $(@F) finished
163
164 #XXX: tap2dsk doesn't return anything so return value is random!!!
165
166 # echo > $@
167
168 test-euphoric: $(BUILDDIR)\$(REALTARGET)
169 $(Q)$(EUPHORIC) $(BUILDDIR)\$(REALTARGET)
170 cls
171 # Euphoric usually puts some garbage in the console when on white bg,
172 # so clear the screen on exit
173
174 test-oricutron: $(BUILDDIR)\$(REALTARGET)
175 @cd $(ORICUTRON:\oricutron.exe=)
176 $(Q)$(ORICUTRON) -s "$(BUILDDIR)\symbols" "$(BUILDDIR)\$(REALTARGET)"
177
178
179 test: test-$(EMULATOR)
180
181 !ifndef BREAKPOINT
182 BREAKPOINT=_main
183 !endif
184
185 debug-oricutron: $(BUILDDIR)\$(REALTARGET)
186 @cd $(ORICUTRON:\oricutron.exe=)
187 $(Q)$(ORICUTRON) -s "$(BUILDDIR)\symbols" "$(BUILDDIR)\$(REALTARGET)" -r "$(BREAKPOINT)"
188
189 debug: debug-oricutron
190
191 release: $(BUILDDIR)\$(REALTARGET)
192 @echo Generating dist files
193 @-mkdir REL
194 @-mkdir "REL\$(NAME)"
195 @copy /Y $(BUILDDIR)\$(REALTARGET) "REL\$(NAME)\"
196 #TODO: generate the .nfo
197
198 zip: release
199 #XXX: merge ?
200 # http://superuser.com/questions/110991/can-you-zip-a-file-from-the-command-prompt-using-only-windows-built-in-capabili
201
202
203 clean:
204 @echo Cleaning up...
205 @-del /f $(BUILDDIR)\*.os.c1 2>NUL
206 @-del /f $(BUILDDIR)\*.os.c2 2>NUL
207 @-del /f $(BUILDDIR)\*.os.s1 2>NUL
208 @-del /f $(BUILDDIR)\*.os 2>NUL
209 @-del /f $(BUILDDIR)\symbols 2>NUL
210 @-del /f $(BUILDDIR)\final.out 2>NUL
211 @-del /f $(BUILDDIR)\xaerr.txt 2>NUL
212 @-del /f $(BUILDDIR)\linked.s 2>NUL
213 @-del /f $(BUILDDIR)\$(NAME).tap 2>NUL
214 @-del /f $(BUILDDIR)\$(NAME).dsk 2>NUL
215 @-rd BUILD 2>NUL
216
217 #DEBUG:
218 dumpenv:
219 @echo CPPFLAGS=$(CPPFLAGS)
220 @echo OBJS=$(OBJS)
221
222 #echo del osdk_config.mk
223
224 # shortcuts
225 te: test-euphoric
226 to: test-oricutron
227
228
229 help:
230 @echo possible targets:
231 @echo all (default): generate the binary
232 @echo clean: remove files
233 @echo test: test with the default emulator ($(EMULATOR))
234 @echo te, test-euphoric: test with Euphoric
235 @echo to, test-oricutron: test with Oricutron
236 # @echo release: generate a release zip file (TODO)
237
238
239
240 !endif #_skip_the_rest
241

  ViewVC Help
Powered by ViewVC 1.1.26