Skip to content

Instantly share code, notes, and snippets.

@Sammons
Created November 30, 2014 23:41
Show Gist options
  • Save Sammons/be6f994fb0cae0e2f233 to your computer and use it in GitHub Desktop.
Save Sammons/be6f994fb0cae0e2f233 to your computer and use it in GitHub Desktop.
junky gist to make two binaries
# compiler
# clang rocks, try it sometime
# clang, gcc, cc, etc.
CC = gcc
# these are C++ flags
# -std=c++11 -ggdb `pkg-config --cflags opencv`
CFLAGS =
# other includes you want in the command to compile
INCLUDES =
# linker flags
LFLAGS =
# i use things like boost here
# -lboost_system -lboost_filesystem `pkg-config --libs opencv`
LIBS =
#I recommend renaming everything to something
# besides first and second
# every .c file you need for the binaries
FIRST_SRCS = fileone.c filetwo.c
SECOND_SRCS = filethree.c filefour.c
# the object names
FIRST_OBJS = $(FIRST_SRCS:.c=.o)
SECOND_OBJS = $(SECOND_SRCS:.c=.o)
FIRST = outputbinaryname
SECOND = otheroutputbinary
# default make command since first target
all: $(FIRST) $(SECOND)
@echo Success
$(FIRST): $(FIRST_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(SECOND) $(FIRST_OBJS) $(LFLAGS) $(LIBS)
$(SECOND): $(SECOND_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(FIRST) $(SECOND_OBJS) $(LFLAGS) $(LIBS)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
$(RM) *.o *~ $(FIRST) $(SECOND)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment