]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/Makefile.rules
Separate object/binaries in Win32 and Win64 builds. More to be done.
[bacula/bacula] / bacula / src / win32 / Makefile.rules
1 #
2 # Makefile for win32 bacula executables
3 # Using MinGW cross-compiler on GNU/Linux
4 #
5 #  Written by Robert Nelson, June 2006
6 #
7
8 define clean_obj
9         $(ECHO_CMD)rm -f $(1) $(patsubst %.o,%.d,$(filter-out %.res,$(1)))
10         $(ECHO_CMD)rm -f $(1) $(addsuffix .d.*,$(basename $(1)))
11 endef
12
13 define clean_exe
14         $(ECHO_CMD)rm -f $(1) $(addsuffix .dbg,$(basename $(1)))
15 endef
16
17 define checkdir
18         @if [ ! -e $(dir $(1)) ]; then mkdir -p $(dir $(1)); fi
19 endef
20
21 define makedep
22         @echo "Generating dependencies for $<"
23         $(call checkdir,$@)
24         $(ECHO_CMD)$(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \
25         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
26         rm -f $@.$$$$
27 endef
28
29 define link_conapp
30         @echo "Linking $@"
31         $(call checkdir,$@)
32         $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mconsole $^ $(1) -o $@
33 endef
34
35 define link_winapp
36         @echo "Linking $@"
37         $(call checkdir,$@)
38         $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mwindows $^ $(1) -o $@
39 endef
40
41 define makedbg
42         @echo "Stripping debug info from $@"
43         $(call checkdir,$@)
44         $(ECHO_CMD)$(OBJCPY) --only-keep-debug $@ $(addsuffix .dbg,$(basename $@)) ; \
45         $(OBJCPY) --strip-debug $@ ; \
46         $(OBJCPY) --add-gnu-debuglink=$(addsuffix .dbg,$(basename $@)) $@
47 endef
48
49 $(OBJDIR)/%.o: %.c
50         @echo "Compiling $<"
51         $(call checkdir, $@)
52         $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@
53
54 $(OBJDIR)/%.o: %.cpp
55         @echo "Compiling $<"
56         $(call checkdir, $@)
57         $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@
58
59 $(OBJDIR)/%.res: %.rc
60         @echo "Compiling $<"
61         $(call checkdir, $@)
62         $(ECHO_CMD)$(WINDRES) -O coff $< -o $@
63
64 $(OBJDIR)/%.d: %.c
65         $(call checkdir, $@)
66         $(makedep)
67
68 $(OBJDIR)/%.d: %.cpp
69         $(call checkdir, $@)
70         $(makedep)
71
72 ifneq ($(ALL_OBJS),)
73 ifneq ($(MAKECMDGOALS),clean)
74 include $(patsubst %.o,%.d,$(filter-out %.res,$(ALL_OBJS)))
75 endif
76 endif