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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 847 - (show annotations)
Wed Sep 19 16:48:57 2012 UTC (7 years, 6 months ago) by mmu_man
File size: 4887 byte(s)
Cleanup. Work around stale open file on virtualbox shared folders.

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

  ViewVC Help
Powered by ViewVC 1.1.26