Build: add basic makefile build

master
heck 9 months ago
parent 86ef74cdd2
commit b0f32bd214
  1. 24
      Makefile
  2. 35
      Makefile.conf
  3. 12
      local.conf.example
  4. 38
      src/Makefile
  5. 24
      test/Makefile

@ -0,0 +1,24 @@
# Copyright 2022, pEp Foundation
# This file is part of libpEpCxx11
# 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
src:
$(MAKE) -C src
test: src
$(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,35 @@
# Copyright 2022, pEp Foundation
# This file is part of libpEpCxx11
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
TARGET=libpEpCxx11.a
# Defaults
DEBUG=1
PREFIX?=$(HOME)
LANG_VERSION=c++11
CXXFLAGS+=-fPIC -Wall -Wextra -ansi -pedantic
ifneq (,$(findstring g++,$(CXX)))
CXXFLAGS+=-fdiagnostics-color=always
else ifneq (,$(findstring clang,$(CXX)))
CXXFLAGS+=-fcolor-diagnostics
endif
######### Overrides #########
-include $(HERE)local.conf
CXXFLAGS+=-std=$(LANG_VERSION)
ifeq ($(DEBUG),1)
CXXFLAGS+=-g -O0
else
CXXFLAGS+=-DNDEBUG=1 -O3
endif
CXXFLAGS+=-I$(PREFIX)/include
LDFLAGS=-L$(PREFIX)/lib

@ -0,0 +1,12 @@
# 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++
# 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 libpEpCxx11
# 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)
$(TARGET): $(OBJECTS)
$(AR) -rc $@ $^
clean:
rm -vf $(TARGET) $(OBJECTS) $(DEPENDS)
rm -f *.d.*
install: $(TARGET)
mkdir -p $(PREFIX)/include/pEp
mkdir -p $(PREFIX)/lib
cp -v $(HEADERS) $(PREFIX)/include/pEp/
cp -v $(TARGET) $(PREFIX)/lib/
uninstall:
cd $(PREFIX)/include/pEp && rm -vf $(HEADERS)
cd $(PREFIX)/lib && rm -vf $(TARGET)

@ -0,0 +1,24 @@
# Copyright 2022, pEp Foundation
# This file is part of libpEpCxx11
# 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++ -lpEpAdapter #-lpthread -ldl -lm
CXXFLAGS:=-I../src $(CXXFLAGS)
# Test
SRC_TEST=$(wildcard test_*.cc)
BIN_TEST=$(subst .cc,,$(SRC_TEST))
.PHONY: tests, all, clean
all: $(BIN_TEST)
clean:
rm -Rf *.dSYM
rm -f $(BIN_TEST)
Loading…
Cancel
Save