forked from pEp.foundation/CXX-project-template

5 changed files with 136 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||||
|
# Copyright 2021, pEp Foundation
|
||||
|
# This file is part of <project_name>
|
||||
|
# This file may be used under the terms of the GNU General Public License version 3
|
||||
|
# see LICENSE
|
||||
|
|
||||
|
.PHONY: all src test install uninstall clean |
||||
|
|
||||
|
all: src test |
||||
|
|
||||
|
src: |
||||
|
$(MAKE) -C src |
||||
|
|
||||
|
test: |
||||
|
$(MAKE) -C test |
||||
|
|
||||
|
clean: |
||||
|
$(MAKE) -C src clean |
||||
|
$(MAKE) -C test clean |
||||
|
|
||||
|
install: |
||||
|
$(MAKE) -C src install |
||||
|
|
||||
|
uninstall: |
||||
|
$(MAKE) -C src uninstall |
@ -0,0 +1,34 @@ |
|||||
|
# Copyright 2022, pEp Foundation
|
||||
|
# This file is part of <project_name>
|
||||
|
# This file may be used under the terms of the GNU General Public License version 3
|
||||
|
# see LICENSE.txt
|
||||
|
|
||||
|
HERE:=$(dir $(lastword $(MAKEFILE_LIST))) |
||||
|
|
||||
|
TARGET_NAME=pEpHelloWorld |
||||
|
TARGET_STATIC=lib$(TARGET_NAME).a |
||||
|
|
||||
|
# Build config
|
||||
|
# Defaults
|
||||
|
DEBUG=1 |
||||
|
PREFIX?=$(HOME) |
||||
|
|
||||
|
# Overrides
|
||||
|
-include $(HERE)local.conf |
||||
|
|
||||
|
# Constants
|
||||
|
CXXFLAGS+=-std=c++11 -fPIC -Wall -Wextra -ansi -pedantic |
||||
|
CXXFLAGS+=-I$(PREFIX)/include |
||||
|
LDFLAGS+=-L$(PREFIX)/lib |
||||
|
|
||||
|
ifneq (,$(findstring g++,$(CXX))) |
||||
|
CXXFLAGS+=-fdiagnostics-color=always |
||||
|
else ifneq (,$(findstring clang,$(CXX))) |
||||
|
CXXFLAGS+=-fcolor-diagnostics |
||||
|
endif |
||||
|
|
||||
|
ifeq ($(DEBUG),1) |
||||
|
CXXFLAGS+=-g -O0 |
||||
|
else |
||||
|
CXXFLAGS+=-DNDEBUG=1 -O3 |
||||
|
endif |
@ -0,0 +1,13 @@ |
|||||
|
# This is an Example build config file (local.conf) |
||||
|
# you might not need this file, but if the defaults dont work for you |
||||
|
# You can override them here. |
||||
|
# Tweak the values to your needs and rename it to local.conf |
||||
|
|
||||
|
######### C++ Compiler ######### |
||||
|
# Should work with clang and g++ |
||||
|
# CXX=g++ |
||||
|
# DEBUG=1 # DEBUG Build (Default) |
||||
|
# DEBUG=0 # RELEASE Build |
||||
|
|
||||
|
############# DIRS ############# |
||||
|
# PREFIX=$(HOME)/local |
@ -0,0 +1,38 @@ |
|||||
|
# Copyright 2022, pEp Foundation
|
||||
|
# This file is part of <project_name>
|
||||
|
# This file may be used under the terms of the GNU General Public License version 3
|
||||
|
# see LICENSE
|
||||
|
|
||||
|
include ../Makefile.conf |
||||
|
|
||||
|
SOURCE=$(wildcard *.cc) |
||||
|
HEADERS=$(wildcard *.hh *.hxx) |
||||
|
OBJECTS=$(subst .cc,.o,$(SOURCE)) |
||||
|
DEPENDS=$(subst .cc,.d,$(SOURCE)) |
||||
|
CXXFLAGS+= -MMD -MP |
||||
|
|
||||
|
ifneq ($(MAKECMDGOALS),clean) |
||||
|
-include $(DEPENDS) |
||||
|
endif |
||||
|
|
||||
|
.PHONY: all install uninstall clean |
||||
|
.DEFAULT_GOAL := all |
||||
|
|
||||
|
all: $(TARGET_STATIC) |
||||
|
|
||||
|
$(TARGET_STATIC): $(OBJECTS) |
||||
|
$(AR) -rc $@ $^ |
||||
|
|
||||
|
clean: |
||||
|
rm -vf $(TARGET_STATIC) $(OBJECTS) $(DEPENDS) |
||||
|
rm -f *.d.* |
||||
|
|
||||
|
install: $(TARGET_STATIC) |
||||
|
mkdir -p $(PREFIX)/include/pEp |
||||
|
mkdir -p $(PREFIX)/lib |
||||
|
cp -v $(HEADERS) $(PREFIX)/include/pEp/ |
||||
|
cp -v $(TARGET_STATIC) $(PREFIX)/lib/ |
||||
|
|
||||
|
uninstall: |
||||
|
cd $(PREFIX)/include/pEp && rm -vf $(HEADERS) |
||||
|
cd $(PREFIX)/lib && rm -vf $(TARGET_STATIC) |
@ -0,0 +1,27 @@ |
|||||
|
# Copyright 2022, pEp Foundation
|
||||
|
# This file is part of <project_name>
|
||||
|
# This file may be used under the terms of the GNU General Public License version 3
|
||||
|
# see LICENSE
|
||||
|
|
||||
|
include ../Makefile.conf |
||||
|
|
||||
|
CXXFLAGS:=-I../src $(CXXFLAGS) |
||||
|
LDFLAGS:=-L../src $(LDFLAGS) |
||||
|
LDLIBS=-lstdc++ -lpthread -lm -l$(TARGET_NAME) |
||||
|
|
||||
|
# Test
|
||||
|
SRC_TEST=$(wildcard test_*.cc) |
||||
|
BIN_TEST=$(subst .cc,,$(SRC_TEST)) |
||||
|
|
||||
|
.PHONY: all, clean |
||||
|
|
||||
|
all: $(TARGET_STATIC) $(BIN_TEST) |
||||
|
|
||||
|
$(BIN_TEST) : ../src/$(TARGET_STATIC) |
||||
|
|
||||
|
$(TARGET_STATIC): |
||||
|
$(MAKE) -C ../src |
||||
|
|
||||
|
clean: |
||||
|
rm -Rf *.dSYM |
||||
|
rm -f $(BIN_TEST) |
Loading…
Reference in new issue