Created
May 27, 2015 16:58
-
-
Save pdobrowolski/4ba7cb443bea5a4a9956 to your computer and use it in GitHub Desktop.
Universal C/Cpp makefile
This file contains 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
# Universal C/Cpp makefile | |
# Source: https://sites.google.com/site/michaelsafyan/software-engineering/how-to-write-a-makefile | |
program_NAME := server | |
program_C_SRCS := $(wildcard *.c) | |
program_CXX_SRCS := $(wildcard *.cpp) | |
program_C_OBJS := ${program_C_SRCS:.c=.o} | |
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o} | |
program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS) | |
program_INCLUDE_DIRS := | |
program_LIBRARY_DIRS := | |
program_LIBRARIES := | |
CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) | |
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir)) | |
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library)) | |
.PHONY: all clean distclean | |
all: $(program_NAME) | |
$(program_NAME): $(program_OBJS) | |
$(CC) $(program_OBJS) -o $(program_NAME) | |
clean: | |
@- $(RM) $(program_NAME) | |
@- $(RM) $(program_OBJS) | |
distclean: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From now on I won't be googling like crazy for sensible makefile every time a program I write reaches beyond 100 lines. I hope.