init makefile project

This commit is contained in:
LingZhaoHui 2022-05-01 13:13:52 +08:00
parent c77d48a997
commit 32166bd857
3 changed files with 101 additions and 0 deletions

5
.gitignore vendored
View File

@ -53,3 +53,8 @@ tags
# Persistent undo
[._]*.un~
*.dep
*.make-*
redis-tools

86
src/Makefile Normal file
View File

@ -0,0 +1,86 @@
# redis-tools makefile
#
REDIS_TOOLS=redis-tools
BUILD_TARGET=redis-tools
BUILD_OBJ=redis-tools.o
OPTIMIZATION?=-O2
NODEPS:=clean
# Default settings
STD=-pedantic -DREDIS_STATIC='' -std=c99
FINAL_LIBS=-lm
DEBUG=-g -ggdb
WARN=-Wall -W -Wno-missing-field-initializers
OPT=$(OPTIMIZATION)
FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS)
FINAL_LDFLAGS=$(DEBUG)
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
ifndef V
QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
QUIET_GEN = @printf ' %b %b\n' $(CCCOLOR)GEN$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;
QUIET_LINK = @printf ' %b %b\n' $(LINKCOLOR)LINK$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
QUIET_INSTALL = @printf ' %b %b\n' $(LINKCOLOR)INSTALL$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) 1>&2;
endif
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
persist-settings: clean
echo STD=$(STD) >> .make-settings
echo WARN=$(WARN) >> .make-settings
echo OPT=$(OPT) >> .make-settings
echo CFLAGS=$(CFLAGS) >> .make-settings
echo LDFLAGS=$(LDFLAGS) >> .make-settings
echo REDIS_CFLAGS=$(REDIS_CFLAGS) >> .make-settings
echo REDIS_LDFLAGS=$(REDIS_LDFLAGS) >> .make-settings
echo PREV_FINAL_CFLAGS=$(FINAL_CFLAGS) >> .make-settings
echo PREV_FINAL_LDFLAGS=$(FINAL_LDFLAGS) >> .make-settings
ifneq ($(strip $(PREV_FINAL_CFLAGS)), $(strip $(FINAL_CFLAGS)))
.make-prerequisites: persist-settings
endif
ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS)))
.make-prerequisites: persist-settings
endif
# Prerequisites target
.make-prerequisites:
@touch $@
%.o: %.c .make-prerequisites
$(REDIS_CC) -MMD -o $@ -c $<
Makefile.dep:
-$(REDIS_CC) -MM *.c > Makefile.dep 2> /dev/null || true
ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
-include Makefile.dep
endif
$(REDIS_TOOLS): $(BUILD_OBJ)
$(REDIS_LD) -o $@ $^ $(FINAL_LIBS)
all: $(REDIS_TOOLS)
@echo ""
@echo "Hint: build success ;)"
@echo ""
clean:
rm -rf Makefile.dep
rm -rf redis-tools
rm -rf *.o
rm -rf *.d
rm -rf .make-prerequisites
rm -rf .make-settings

10
src/redis-tools.c Normal file
View File

@ -0,0 +1,10 @@
#include <stdio.h>
int main(int argc, char **argv) {
return 0;
}