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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 896 - (hide annotations)
Thu Sep 27 11:16:11 2012 UTC (7 years, 8 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 mmu_man 846 #
2    
3     !message OSDK Makefile engine (nmake) v0.1
4    
5     OSDKB = $(OSDK)\bin
6    
7 mmu_man 865 # quiet if Q=@
8     Q=@
9    
10 mmu_man 846 !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 mmu_man 847 !message Including osdk_config.mk generated from osdk_config.bat.
32     !message Consider editing the makefile instead.
33 mmu_man 846 !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 mmu_man 865 !error Invalid TYPE $(TYPE)"
54 mmu_man 846 !endif
55    
56 mmu_man 868
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 mmu_man 896 !else if exist(C:\PROGRA~1\euphoric\euphoric.exe)
64     EUPHORIC = C:\PROGRA~1\euphoric\euphoric.exe
65 mmu_man 868 !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 mmu_man 896 !else if exist(C:\PROGRA~1\oricutron\oricutron.exe)
75     ORICUTRON = C:\PROGRA~1\oricutron\oricutron.exe
76 mmu_man 868 !endif
77     !endif
78    
79    
80 mmu_man 846 !if "$(EMULATOR)" == ""
81     EMULATOR = oricutron
82     !message Using $(EMULATOR) as default emulator
83     !endif
84    
85 mmu_man 868
86 mmu_man 846 # 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 mmu_man 865 $(Q)$(OSDKB)\cpp.exe -lang-c++ $(CPPFLAGS) -nostdinc $(<) $@.c1
114 mmu_man 846 @echo - compile
115 mmu_man 865 $(Q)$(OSDKB)\compiler.exe -N$(@B) $(CFLAGS) $@.c1 >$@.c2
116 mmu_man 846 @echo - convert C to assembly code
117 mmu_man 865 $(Q)$(OSDKB)\cpp.exe -lang-c++ -imacros $(OSDK)\macro\macros.h -traditional -P $@.c2 $@.s1
118 mmu_man 846 @echo - cleanup output
119 mmu_man 865 $(Q)$(OSDKB)\macrosplitter $@.s1 $@
120 mmu_man 846
121 mmu_man 847 # 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 mmu_man 846 # from .s .asm
127    
128     {.}.asm{BUILD\}.os:
129     @echo Assembling $<
130 mmu_man 865 $(Q)copy $< $@ /Y >NUL
131 mmu_man 846
132     {.}.s{BUILD\}.os:
133     @echo Assembling $<
134 mmu_man 865 $(Q)copy $< $@ /Y >NUL
135 mmu_man 846
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 mmu_man 865 $(Q)mkdir "$(BUILDDIR)"
146 mmu_man 846
147     #buildmsg: makefile
148     # @echo Building the program $(@F) at address 0x$(ADDR)
149    
150 mmu_man 847 # add headers as dependency
151     #$(OBJS): *.h
152    
153 mmu_man 846 $(BUILDDIR)\$(REALTARGET): $(BUILDDIR) $(OBJS)
154     @echo Linking
155 mmu_man 865 $(Q)$(OSDKB)\link65.exe $(OSDKLINK) -d $(OSDK)\lib\ -o BUILD\linked.s -f -q $(OBJS)
156 mmu_man 846 @echo Assembling
157 mmu_man 865 $(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 mmu_man 846 !if "$(TYPE)" == "DISK"
160 mmu_man 865 $(Q)-$(OSDKB)\tap2dsk BUILD\$(@B).tap $@
161 mmu_man 846 !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 mmu_man 868 $(Q)$(EUPHORIC) $(BUILDDIR)\$(REALTARGET)
170 mmu_man 846 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 mmu_man 868 @cd $(ORICUTRON:\oricutron.exe=)
176     $(Q)$(ORICUTRON) -s "$(BUILDDIR)\symbols" "$(BUILDDIR)\$(REALTARGET)"
177 mmu_man 846
178    
179     test: test-$(EMULATOR)
180    
181 mmu_man 860 !ifndef BREAKPOINT
182     BREAKPOINT=_main
183     !endif
184 mmu_man 846
185 mmu_man 860 debug-oricutron: $(BUILDDIR)\$(REALTARGET)
186 mmu_man 868 @cd $(ORICUTRON:\oricutron.exe=)
187     $(Q)$(ORICUTRON) -s "$(BUILDDIR)\symbols" "$(BUILDDIR)\$(REALTARGET)" -r "$(BREAKPOINT)"
188 mmu_man 860
189     debug: debug-oricutron
190    
191 mmu_man 846 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 mmu_man 856 @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 mmu_man 846
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 mmu_man 865 # @echo release: generate a release zip file (TODO)
237 mmu_man 846
238    
239    
240     !endif #_skip_the_rest
241    

  ViewVC Help
Powered by ViewVC 1.1.26