Skip to content

Instantly share code, notes, and snippets.

@sheutettz
Created April 29, 2014 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheutettz/11399803 to your computer and use it in GitHub Desktop.
Save sheutettz/11399803 to your computer and use it in GitHub Desktop.
INCDIR := inc
SRCDIR := src
OBJDIR := obj
#DSTDIR := .
EXENAME := abc.exe
DEBUG := -std=c99 -O3 -Wall -march=pentium -fomit-frame-pointer -fpeephole
#DEBUG += -pedantic
CFLAGS := -DNDEBUG
CFLAGS += -DOS_WIN=1
CFLAGS += $(addprefix -I,$(strip $(shell find_not_dos $(INCDIR) -type d)))
LIBS := -lreadline
SRCS := $(notdir $(shell find_not_dos $(SRCDIR) -type f -name "*.c"))
OBJS := $(SRCS:.c=.o)
empty :=
colon := $(empty):$(empty)
space := $(empty) $(empty)
.PHONY : all clean usage
.SUFFIXES:
%.o : %.c
vpath %.c $(subst $(space),$(colon),$(strip $(shell find_not_dos $(SRCDIR) -type d)))
vpath %.o $(OBJDIR)
usage :
@\echo $(SRCS)
@\echo $(OBJS)
@\echo $(CFLAGS)
@\echo "Usage: all - "
@\echo " build - "
all : $(EXENAME)
#install : build
# @if [ ! -d $(DSTDIR) ]; then \mkdir -p $(DSTDIR)/ ; fi
# \mv -f $(EXENAME) $(DSTDIR)/
$(EXENAME) : ${OBJS}
\gcc -o $(EXENAME) $(addprefix $(OBJDIR)/, $(OBJS)) ${LIBS}
%.o : %.c
@if [ ! -d $(OBJDIR) ]; then \mkdir -p $(OBJDIR)/ ; fi
\gcc ${DEBUG} ${CFLAGS} -c -o $(OBJDIR)/$@ $<
clean :
\rm -f *.dll
@if [ -d $(OBJDIR) ]; then \rm -rf $(OBJDIR)/ ; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment