]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/win32/Makefile.rules
Restore win32 dir from Branch-5.2 and update it
[bacula/bacula] / bacula / src / win32 / Makefile.rules
diff --git a/bacula/src/win32/Makefile.rules b/bacula/src/win32/Makefile.rules
new file mode 100644 (file)
index 0000000..b41d7b5
--- /dev/null
@@ -0,0 +1,79 @@
+#
+# Copyright (C) 2000-2018 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Makefile for win32 bacula executables
+# Using MinGW cross-compiler on GNU/Linux
+#
+#  Written by Robert Nelson, June 2006
+#
+
+define clean_obj
+       $(ECHO_CMD)rm -f $(1) $(patsubst %.o,%.d,$(filter-out %.res,$(1)))
+       $(ECHO_CMD)rm -f $(1) $(addsuffix .d.*,$(basename $(1)))
+endef
+
+define clean_exe
+       $(ECHO_CMD)rm -f $(1) $(addsuffix .dbg,$(basename $(1)))
+endef
+
+define checkdir
+       @if [ ! -e $(dir $(1)) ]; then mkdir -p $(dir $(1)); fi
+endef
+
+define makedep
+       @echo "Generating dependencies for $<"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \
+       sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+       rm -f $@.$$$$
+endef
+
+define link_conapp
+       @echo "Linking $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mconsole $^ $(1) -o $@
+endef
+
+define link_winapp
+       @echo "Linking $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(CXX) $(CFLAGS) $(LDFLAGS) -mwindows $^ $(1) -o $@
+endef
+
+define makedbg
+       @echo "Stripping debug info from $@"
+       $(call checkdir,$@)
+       $(ECHO_CMD)$(OBJCPY) --only-keep-debug $@ $(addsuffix .dbg,$(basename $@)) ; \
+       $(OBJCPY) --strip-debug $@ ; \
+       $(OBJCPY) --add-gnu-debuglink=$(addsuffix .dbg,$(basename $@)) $@
+endef
+
+$(OBJDIR)/%.o: %.c
+       @echo "Compiling $<"
+       $(call checkdir, $@)
+       $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@
+
+$(OBJDIR)/%.o: %.cpp
+       @echo "Compiling $<"
+       $(call checkdir, $@)
+       $(ECHO_CMD)$(CXX) $(CFLAGS) -c $< -o $@
+
+$(OBJDIR)/%.res: %.rc
+       @echo "Compiling $<"
+       $(call checkdir, $@)
+       $(ECHO_CMD)$(WINDRES) $(WINDRESFLAGS) -O coff $< -o $@
+
+$(OBJDIR)/%.d: %.c
+       $(call checkdir, $@)
+       $(makedep)
+
+$(OBJDIR)/%.d: %.cpp
+       $(call checkdir, $@)
+       $(makedep)
+
+ifneq ($(ALL_OBJS),)
+ifneq ($(MAKECMDGOALS),clean)
+include $(patsubst %.o,%.d,$(filter-out %.res,$(ALL_OBJS)))
+endif
+endif