From c04051c034a5de33ba25e3182191d854edbbb516 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Fri, 27 Sep 2013 18:02:33 +0200 Subject: Modified Makefile to generate shared library * library is called libSimpleParser.so * parser was renamed to clc * test and clc are using the shared library --- Makefile | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 09fdd49..f71ad1c 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,46 @@ -LIB_FILES = src/nodes.cc src/tree.cc src/utils.cc -PROG_FILES = main.cc -TEST_FILES = test.cc +CXX = g++ +CXXFLAGS = -std=c++11 -W -Wall -Wextra -pedantic -fpic -FLAGS = -std=c++11 -W -Wall -Wextra -pedantic -PARSER = -o bin/parser $(FLAGS) $(PROG_FILES) $(LIB_FILES) +SRC_DIR = src +BIN_DIR = bin -all: dev test +LIB_SRC = $(SRC_DIR)/nodes.cc \ + $(SRC_DIR)/tree.cc \ + $(SRC_DIR)/utils.cc \ + $(SRC_DIR)/parser.cc +LIB_OBJ = $(subst .cc,.o,$(LIB_SRC)) -dev: $(PROG_FILES) $(LIB_FILES) - g++ -g $(PARSER) +TEST_SRC = test.cc +CLC_SRC = clc.cc -release: $(PROG_FILES) $(LIB_FILES) - g++ -O3 $(PARSER) +all: lib test clc -test: $(LIB_FILES) $(TEST_FILES) - g++ -O3 -o bin/test -lgtest $(TEST_FILES) $(FLAGS) $(LIB_FILES) - ./bin/test +lib: $(BIN_DIR)/libSimpleParser.so; +test: $(BIN_DIR)/test; +clc: $(BIN_DIR)/clc; +$(BIN_DIR)/libSimpleParser.so: $(LIB_OBJ) + $(CXX) -shared -o $(BIN_DIR)/libSimpleParser.so $(LIB_OBJ) $(CXXFLAGS) + +$(BIN_DIR)/test: $(BIN_DIR)/libSimpleParser.so + $(CXX) -o $(BIN_DIR)/test $(TEST_SRC) -lgtest -L$(BIN_DIR)/ -lSimpleParser + ./$(BIN_DIR)/test + +$(BIN_DIR)/clc: $(BIN_DIR)/libSimpleParser.so + $(CXX) -o $(BIN_DIR)/clc $(CLC_SRC) -L$(BIN_DIR)/ -lSimpleParser + +install: $(BIN_DIR)/libSimpleParser.so $(BIN_DIR)/clc + install -m 0755 $(BIN_DIR)/libSimpleParser.so /usr/lib + install -m 0755 $(BIN_DIR)/clc /usr/bin + +.PHONY: clean; +clean: + rm -f $(LIB_OBJ) + rm -f $(BIN_DIR)/* + +depend: .depend + +.depend: $(LIB_SRC) + $(CXX) -M $(CXXFLAGS) $< > $@ + +include .depend -- cgit v1.2.3