simple Makefile with dependency files
This commit is contained in:
parent
d0f67430d8
commit
bee43f9297
9 changed files with 18013 additions and 1 deletions
57
{{cookiecutter.project_name}}/Makefile
Normal file
57
{{cookiecutter.project_name}}/Makefile
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
CC = gcc
|
||||
CXX = g++
|
||||
LD = g++
|
||||
CXXFLAGS := -std=gnu++20 -Wall -Werror -Wpointer-arith -Wfatal-errors
|
||||
CXXFLAGS += -flto -O3
|
||||
#CXXFLAGS += -ggdb3
|
||||
|
||||
CFLAGS = -Wall -Werror -Wpointer-arith -Wfatal-errors
|
||||
|
||||
ifdef LINK_MOSTLY_STATIC
|
||||
LDFLAGS := -static-libstdc++ -Wl,-Bstatic -lboost_program_options
|
||||
LDFLAGS += -Wl,-Bdynamic -lpthread -ldl
|
||||
LDFLAGS += -Wl,--exclude-libs,ALL
|
||||
else
|
||||
LDFLAGS = -lboost_program_options
|
||||
endif
|
||||
|
||||
BUILDDIR = build
|
||||
|
||||
OBJECTS =
|
||||
|
||||
DEPS := $(OBJECTS:.o=.d) $(BUILDDIR)/{{cookiecutter.app_name}}.d
|
||||
|
||||
|
||||
all: $(BUILDDIR)/{{cookiecutter.app_name}}
|
||||
|
||||
|
||||
$(BUILDDIR)/{{cookiecutter.app_name}}: $(OBJECTS) $(BUILDDIR)/{{cookiecutter.app_name}}.o
|
||||
@mkdir -p $(dir $@)
|
||||
@echo link $@
|
||||
@$(LD) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
|
||||
|
||||
|
||||
$(BUILDDIR)/%.o: src/%.cpp Makefile
|
||||
@mkdir -p $(dir $@)
|
||||
@echo compile $@
|
||||
@$(CXX) $(CXXFLAGS) -MQ $@ -MM -MF $(patsubst %.o,%.d,$@) $<
|
||||
@$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
$(BUILDDIR)/%.o: src/%.c Makefile
|
||||
@mkdir -p $(dir $@)
|
||||
@echo compile $@
|
||||
@$(CC) $(CFLAGS) -MQ $@ -MM -MF $(patsubst %.o,%.d,$@) $<
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
install: $(BUILDDIR)/{{cookiecutter.app_name}}
|
||||
install -m 0755 $^ $(DESTDIR)/usr/bin
|
||||
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue