source: trunk/testapp/common.mak@ 21617

Last change on this file since 21617 was 21617, checked in by dmik, 14 years ago

testapp/common.mak: Redid debug-% and other shortcut targets to fix a problem where doing "debug-my.exe" would actually try to build an executable named "debug-my.exe" instead of running "my.exe" in the debugger (this is due to the fact that the pattern rule without any requisites overrides the one with a virtual requisite).

File size: 2.5 KB
RevLine 
[21430]1ifndef ODIN
2$(error ODIN variable must be set)
3else
4ifeq ($(shell ls $(ODIN)/include/odin.h),)
5$(error $(ODIN) does not contain include/odin.h)
6endif
7endif
8
9.PHONY: default
10
11default: all
12
13ODIN_DOS = $(subst /,\,$(ODIN))
14
[21588]15DEFINES += -D__WIN32OS2__ -D__i386__ -DSTRICT -D_POSIX_SOURCE \
16 -D_POSIX_C_SOURCE=200112 -D_EMX_SOURCE -D_XOPEN_SOURCE=600 \
17 -D_SVID_SOURCE
[21430]18
[21588]19INCLUDES += -I$(ODIN)/include -I$(ODIN)/include/win
[21430]20
[21588]21CFLAGS += $(DEFINES) $(INCLUDES) -g -DDEBUG -L$(ODIN)/lib/Debug -lkernel32.lib
22
23WRC = $(ODIN)/tools/wrc/bin/Release/wrc.exe
24
[21617]25ODIN_FLAVOR ?= Debug
[21613]26
27ifneq ($(RELEASE)$(REL),)
28ODIN_FLAVOR := Release
29endif
30
[21617]31RUN_SHELL ?=
32DEBUG_SHELL ?= ipmd
[21613]33
[21430]34run-%: %
[21613]35 @echo [Running $<$(if $($<_ARGS), $($<_ARGS)) (shell=$(RUN_SHELL),flavor=$(ODIN_FLAVOR))]
[21430]36 @echo.
[21613]37 @cmd /c "set BEGINLIBPATH=$(ODIN_DOS)\bin\$(ODIN_FLAVOR);$(ODIN_DOS)\bin;%BEGINLIBPATH% && $(RUN_SHELL) $< $($<_ARGS)"
[21449]38 @echo.
[21430]39
[21617]40debug-%: %
41 @make run-$< RUN_SHELL=$(DEBUG_SHELL)
42debug:
43 @make run RUN_SHELL=$(DEBUG_SHELL)
[21613]44
[21617]45ipmd-%: %
46 @make run-$< RUN_SHELL=ipmd
47ipmd:
48 @make run RUN_SHELL=ipmd
[21613]49
[21617]50idbug-%: %
51 @make run-$< RUN_SHELL=idbug
52idbug:
53 @make run RUN_SHELL=idbug
[21613]54
[21617]55r-%:
56 @make $(@:r-%=%) ODIN_FLAVOR=Release
57d-%:
58 @make $(@:d-%=%) ODIN_FLAVOR=Debug
[21613]59
60help:
[21433]61 @echo.
[21613]62 @echo Targets:
63 @echo run-EXE Run EXE in normal shell (default: cmd, RUN_SHELL overrides)
64 @echo debug-EXE Run EXE in debug shell (default: ipmd, DEBUG_SHELL overrides)
65 @echo ipmd-EXE Run EXE in IPMD shell
66 @echo idbug-EXE Run EXE in IDBUG shell
[21449]67 @echo.
[21613]68 @echo Flavors:
69 @echo d-TARGET Run against debug Odin libraries (default)
70 @echo r-TARGET Run against release Odin libraries (RELEASE=1 makes it default)
71 @echo.
72
[21430]73%.exe: %.c
[21545]74 gcc $^ -Zomf -Zmap -Zlinker /PM:VIO -o $@ $(CFLAGS) $(foreach src, $^, $(CFLAGS.$(src))) $(CFLAGS.$@)
[21430]75
[21545]76%.exe:
77 gcc $^ -Zomf -Zmap -Zlinker /PM:VIO -o $@ $(CFLAGS) $(foreach src, $^, $(CFLAGS.$(src))) $(CFLAGS.$@)
78
[21430]79%.s: %.c
80 gcc $< -S -Zomf -o $@ $(CFLAGS)
81
[21588]82%.s: %.rc
83 $(WRC) -s $(DEFINES) $(INCLUDES) $< -o $@
84
[21430]85CLEAN = *.exe *.map *.log
86
87clean::
88 -rm $(CLEAN)
[21449]89
90define run-with-args-gen
91.PHONY: run-$(1)-$(2) run-$(1)-$(3)
92run-$(1)-$(2): $(1)
93 @make -s run-$(1) $(1)_ARGS=$($(1)_ARGS.$(2))
94run-$(1)-$(3):: run-$(1)-$(2)
[21482]95debug-$(1)-$(2): $(1)
96 @make -s debug-$(1) $(1)_ARGS=$($(1)_ARGS.$(2))
[21449]97endef
98
99run-with-args = $(foreach i, $(2), $(eval $(call run-with-args-gen,$(1),$(i),$(3))))run-$(1)-$(3)
Note: See TracBrowser for help on using the repository browser.