# $Id: GNUmakefile.in 46 2023-04-21 12:49:16Z nishi $ # Nuke built-in rules and variables override MAKEFLAGS += -rR # Misc autoconf variable imports. override SRCDIR := @SRCDIR@ override BUILDDIR := @BUILDDIR@ override PACKAGE_VERSION := @PACKAGE_VERSION@ override PACKAGE_TARNAME := @PACKAGE_TARNAME@ override OUTPUT := bin/$(PACKAGE_TARNAME) override WERROR_FLAG := @WERROR_FLAG@ override DEFAULT_CFLAGS := @CFLAGS@ override DEFAULT_CPPFLAGS := @CPPFLAGS@ override DEFAULT_LDFLAGS := @LDFLAGS@ override DEFAULT_LIBS := @LIBS@ # Autoconf dir variables. override prefix := @prefix@ override exec_prefix := @exec_prefix@ override bindir := @bindir@ override sysconfdir := @sysconfdir@ override localstatedir := @localstatedir@ # Macros to make our build system still work from within paths with spaces # or other special characters. override SPACE := $(subst ,, ) MKESCAPE = $(subst $(SPACE),\ ,$(1)) SHESCAPE = $(subst ','\'',$(1)) OBJESCAPE = $(subst .a ,.a' ',$(subst .o ,.o' ',$(call SHESCAPE,$(1)))) # File lists. override CFILES := \ src/main.c \ src/bpkg/refresh.c \ src/bpkg/install.c \ src/bpkg/util.c \ src/bpkg/update.c \ src/bpkg/remove.c \ src/bpkg/list.c \ src/bpkg/sha512.c \ src/bpkg/keep.c \ src/bpkg/unkeep.c \ src/bpkg/clean.c override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/,$(CFILES:.c=.o)) override HEADER_DEPS := $(CFILES:.c=.d) # DEFAULT_VAR definition. define DEFAULT_VAR = ifeq ($(origin $1),default) override $(1) := $(2) endif ifeq ($(origin $1),undefined) override $(1) := $(2) endif endef # Overridable generator executables. $(eval $(call DEFAULT_VAR,CC,@CC@)) # Non-overridable generator executables. override NATIVE_STRIP := @NATIVE_STRIP@ override MKDIR_P := @MKDIR_P@ override INSTALL := @INSTALL@ override INSTALL_PROGRAM := @INSTALL_PROGRAM@ # User command flags. $(eval $(call DEFAULT_VAR,CFLAGS,$(DEFAULT_CFLAGS))) $(eval $(call DEFAULT_VAR,CPPFLAGS,$(DEFAULT_CPPFLAGS))) $(eval $(call DEFAULT_VAR,LDFLAGS,$(DEFAULT_LDFLAGS))) $(eval $(call DEFAULT_VAR,LIBS,$(DEFAULT_LIBS))) # Needed command flags. override CFLAGS += \ -Wall \ -Wextra \ $(WERROR_FLAG) \ -std=c89 override CPPFLAGS := \ -I'$(call SHESCAPE,$(SRCDIR))'/include \ $(CPPFLAGS) \ -DPREFIX=\"$(prefix)\" \ -DVARDIR=\"$(localstatedir)\"\ -DETCDIR=\"$(sysconfdir)\"\ -MMD \ -MP # Default target. .PHONY: all all: $(OUTPUT) # Link rules for the final executable. $(OUTPUT): $(OBJ) $(MKDIR_P) bin $(CC) $(CFLAGS) $(LDFLAGS) '$(call OBJESCAPE,$^)' $(LIBS) -o $@ # Include header dependencies. -include $(HEADER_DEPS) # Compilation rules for *.c files. $(call MKESCAPE,$(BUILDDIR))/%.o: $(call MKESCAPE,$(SRCDIR))/%.c $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(CC) $(CFLAGS) $(CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' # Remove object files and the final executable. .PHONY: clean clean: rm -rf bin $(OBJ) $(HEADER_DEPS) # Remove files generated by configure. .PHONY: distclean distclean: clean rm -rf config.log config.status GNUmakefile # Remove ALL generated files. .PHONY: maintainer-clean maintainer-clean: distclean cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf configure build-aux *'~' autom4te.cache # Install files and executables to the final locations. .PHONY: install install: all $(INSTALL) -d '$(call SHESCAPE,$(DESTDIR)$(bindir))' $(INSTALL_PROGRAM) $(OUTPUT) '$(call SHESCAPE,$(DESTDIR)$(bindir))/' # Install and strip executables. .PHONY: install-strip install-strip: install $(NATIVE_STRIP) '$(call SHESCAPE,$(DESTDIR)$(bindir))'/"$$(basename '$(OUTPUT)')" # Uninstall previously installed files and executables. .PHONY: uninstall uninstall: rm -f '$(call SHESCAPE,$(DESTDIR)$(bindir))'/"$$(basename '$(OUTPUT)')"