Skip to content

Instantly share code, notes, and snippets.

@siddontang
Created December 6, 2023 18:08
Show Gist options
  • Save siddontang/9c5601034311d882150153d107ffeb02 to your computer and use it in GitHub Desktop.
Save siddontang/9c5601034311d882150153d107ffeb02 to your computer and use it in GitHub Desktop.
Support pre-build in Makefile
# Refer to https://stackoverflow.com/questions/1612278/pre-build-step-in-makefile
CC=gcc
.PHONY: all clean
.SECONDARY: main-build
all: pre-build main-build
pre-build:
@echo PRE
post-build:
@echo POST
main-build: target
target: $(OBJS)
$(CC) -o $@ $(OBJS)
@$(MAKE) --no-print-directory post-build
clean:
rm -f $(OBJS) target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment