]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/Makefile.rules
Set keyword replacement on files
[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 endef
11
12 define clean_exe
13         $(ECHO_CMD)rm -f $(1) $(addsuffix .dbg,$(basename $(1)))
14 endef
15
16 define checkdir
17         @if [ ! -e $(dir $(1)) ]; then mkdir $(dir $(1)); fi
18 endef
19
20 define makedep
21         @echo "Generating dependencies for $<"
22         $(call checkdir,$@)
23         $(ECHO_CMD)$(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \
24         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
25         rm -f $@.$$$$
26 endef
27
28 define link_conapp
29         @echo "Linking $@"
30         $(call checkdir,$@)
31         $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mconsole $^ $(1) -o $@
32 endef
33
34 define link_winapp
35         @echo "Linking $@"
36         $(call checkdir,$@)
37         $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mwindows $^ $(1) -o $@
38 endef
39
40 define makedbg
41         @echo "Stripping debug info from $@"
42         $(call checkdir,$@)
43         $(ECHO_CMD)$(OBJCPY) --only-keep-debug $@ $(addsuffix .dbg,$(basename $@)) ; \
44         $(OBJCPY) --strip-debug $@ ; \
45         $(OBJCPY) --add-gnu-debuglink=$(addsuffix .dbg,$(basename $@)) $@
46 endef
47
48 $(OBJDIR)/%.o: %.c
49         @echo "Compiling $<"
50         $(call checkdir, $@)
51         $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@
52
53 $(OBJDIR)/%.o: %.cpp
54         @echo "Compiling $<"
55         $(call checkdir, $@)
56         $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@
57
58 $(OBJDIR)/%.res: %.rc
59         @echo "Compiling $<"
60         $(call checkdir, $@)
61         $(ECHO_CMD)$(WINDRES) -O coff $< -o $@
62
63 $(OBJDIR)/%.d: %.c
64         $(makedep)
65
66 $(OBJDIR)/%.d: %.cpp
67         $(makedep)
68
69 ifneq ($(ALL_OBJS),)
70 ifneq ($(MAKECMDGOALS),clean)
71 include $(patsubst %.o,%.d,$(filter-out %.res,$(ALL_OBJS)))
72 endif
73 endif