Skip to content

Instantly share code, notes, and snippets.

@quocle108
Created April 29, 2020 09:51
Show Gist options
  • Select an option

  • Save quocle108/e85b22009f7d6b0384ccda7ba846f246 to your computer and use it in GitHub Desktop.

Select an option

Save quocle108/e85b22009f7d6b0384ccda7ba846f246 to your computer and use it in GitHub Desktop.
# Specify the source files, target files, the build directories,
# and the install directory
SOURCES = phone.cpp
OBJECTS = $(SOURCES:.cpp=.o)
OUTPUTFILE = phone
LIBSTATIC = libhardware.a
LIBDYNAMIC = libsoftware.dylib
STATICDIR = ../staticlib
DYNAMICDIR = ../dynamiclib
INSTALLDIR = ../binaries
#
# Add the parent directory as an include path
#
CFLAGS += -I ../staticlib/include -I ../dynamiclib/include
#
# Default target
#
.PHONY: all
all: $(OUTPUTFILE)
#
# Target to build the executable.
#
$(OUTPUTFILE): $(OBJECTS) \
$(STATICDIR)/$(LIBSTATIC) \
$(DYNAMICDIR)/$(LIBDYNAMIC)
g++ $(LDFLAGS) -o $@ $^
.cpp.o: $(SOURCES)
g++ $(CFLAGS) -c -o $@ $<
.PHONY: install
install:
mkdir -p $(INSTALLDIR)
cp -p $(OUTPUTFILE) $(INSTALLDIR)
.PHONY: clean
clean:
rm -f *.o
rm -f $(OUTPUTFILE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment