Skip to content

Instantly share code, notes, and snippets.

@r2p2
Created October 3, 2011 19:25
Show Gist options
  • Select an option

  • Save r2p2/1259984 to your computer and use it in GitHub Desktop.

Select an option

Save r2p2/1259984 to your computer and use it in GitHub Desktop.
Makefile
#LIB=liborm_core
#VERSION=1.0
TARGET=lib$(LIBNAME).so
CC=g++
CFLAGS=-fPIC -g -c -Wall -Weffc++ -Iinclude
LDFLAGS=-shared -Wl,-soname,$(TARGET) -Lbuild -lpthread -lrt
# checks to subdir level, add more if requiered
SOURCES=$(wildcard **/*.cpp) $(wildcard **/**/*.cpp)
OBJS=$(SOURCES:.cpp=.o)
all: dirs $(SOURCES) $(TARGET)
dirs:
cd src && find . -type d -exec mkdir -p ../build/{} \;
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(subst src/,build/,$(OBJS)) -o bin/$@
.cpp.o:
$(CC) $(CFLAGS) $< -o build/$(subst src/,,$@)
clean:
rm -rf build/*
rm -rf bin/*
build:
tar cfv dist/$(TARGET).tar bin/$(TARGET).so include/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment