Created
November 14, 2016 17:25
-
-
Save davidalbertonogueira/9ef12e01c978179ff086930887b9728a to your computer and use it in GitHub Desktop.
Generic Program makefile and Library makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Makefile for RandomLibrary | |
CC = ~/clang-3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ | |
DEBUG = -g | |
AUXLIBS = | |
AUXINCLUDES = | |
LOCALDEPSINCLUDES = | |
INCLUDES = -I$(AUXINCLUDES) -I$(LOCALDEPSINCLUDES) | |
LIBS = -L/usr/local/lib/ -L$(AUXLIBS) -L$(AUXLIBTURBOPARSER) | |
CFLAGS = -std=c++14 -O3 -Wall -fPIC $(INCLUDES) | |
LDFLAGS = -shared | |
LFLAGS = $(LIBS) | |
HDRS = $(wildcard *.h) | |
HDRS += $(wildcard *.h++) | |
#HDRS += $(shell find $(AUXINCLUDES) $(LOCALDEPSINCLUDES) -name '*.h') | |
#HDRS += $(shell find $(AUXINCLUDES) $(LOCALDEPSINCLUDES) -name '*.h++') | |
SRCS = $(wildcard *.cpp) | |
OBJS = $(SRCS:.cpp=.o) | |
TXTS = $(wildcard *.txt) | |
SCRIPTS = $(wildcard *.sh) | |
#For verbosity | |
LFLAGS += -v | |
CFLAGS += -stdlib=libc++ | |
CFLAGS += $(DEBUG) | |
all : randomlibrary.a randomlibrary.so | |
randomlibrary.a : $(OBJS) | |
@echo Creating static lib $@ | |
ar rcs $@ $(OBJS) | |
randomlibrary.so : $(OBJS) | |
@echo Creating dynamic lib $@ | |
$(CC) -o $@ $(OBJS) $(LDFLAGS) $(LFLAGS) | |
%.o: %.cpp $(HDRS) | |
$(CC) -c $(CFLAGS) $(LFLAGS) -o $@ $< | |
clean: | |
@echo Clean | |
rm -f *~ *.o *~ | |
@echo Success | |
cleanall: | |
@echo Clean All | |
rm -f *~ *.o *~ randomlibrary.a randomlibrary.so | |
@echo Success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Makefile for MyProgram | |
CC = ~/clang-3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ | |
EXEC = MyProgram | |
DEBUG = -g | |
RANDOMLIBRARY = /home/temp/RandomLibrary | |
GOOGLETEST = /home/temp/googletest/googletest-release-1.7.0 | |
GOOGLETEST_INCLUDE = /home/temp/googletest/googletest-release-1.7.0/include | |
GOOGLELOG = /home/temp/googlelog/glog-0.3.4 | |
GOOGLELOG_SRC = /home/temp/googlelog/glog-0.3.4/src | |
INCLUDES = -I$(RANDOMLIBRARY) -I$(GOOGLETEST_INCLUDE) -I$(GOOGLELOG_SRC) | |
LIBS =-L$(RANDOMLIBRARY) -L$(GOOGLETEST) -L$(GOOGLELOG) -L/usr/local/lib/ | |
CFLAGS = -std=c++14 -O3 -Wall -fPIC -pthread $(INCLUDES) | |
LFLAGS = $(LIBS) $(RANDOMLIBRARY)/RANDOMLIBRARY.a $(GOOGLETEST)/libgtest.a $(GOOGLELOG)/.libs/libglog.a | |
HDRS = $(wildcard *.h) | |
HDRS += $(wildcard *.h++) | |
SRCS = $(wildcard *.cpp) | |
OBJS = $(SRCS:.cpp=.o) | |
TXTS = $(wildcard *.txt) | |
SCRIPTS = $(wildcard *.sh) | |
#For verbosity | |
LFLAGS += -v | |
CFLAGS += -stdlib=libc++ | |
CFLAGS += -nostdinc++ | |
CFLAGS += -L~/clang-3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/lib/ | |
CFLAGS += -I~/clang-3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/include/c++/v1/ | |
CFLAGS += -I~/clang-3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/include/c++/ | |
CFLAGS += -I~/clang-3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/include/ | |
CFLAGS += $(DEBUG) | |
all: $(EXEC) | |
$(EXEC): $(OBJS) | |
@echo Compiling program $@ | |
$(CC) $^ $(CFLAGS) $(LFLAGS) -o $@ | |
@echo Success | |
%.o: %.cpp $(HDRS) | |
$(CC) -c $(CFLAGS) $(LFLAGS) -o $@ $< | |
clean: | |
@echo Clean | |
rm -f *~ *.o | |
@echo Success | |
cleanall: | |
@echo Clean All | |
rm -f *~ *.o $(EXEC) | |
@echo Success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment