Last active
August 29, 2015 14:14
-
-
Save ylogx/d3b6fdfd83338e74a74a to your computer and use it in GitHub Desktop.
A makefile to compile all source code in a given folder
This file contains hidden or 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
######################################################################### | |
# | |
# Makefile - This Makefile compiles all c files in given folder | |
# Copyright (c) 2014-2015 Shubham Chaudhary <[email protected]> | |
# | |
######################################################################### | |
#SPECIFIED_SRC_FILE = $(foreach d,$(SPECIFIED_SRC_DIRS),$(wildcard $(addprefix $(d)/*,*.c))) | |
#CC = gcc | |
#all: | |
# $(CC) -o .out lelemon.c -Wall | |
#SRCS=$(wildcard *.c) | |
#OBJS=(SRCS:.c=.o) | |
#all: $(OBJS) | |
CC = gcc | |
#CFLAGS = -g -O2 -std=gnu99 -static -Wall -Wextra -Isrc -rdynamic -fomit-frame-pointer | |
CFLAGS = -g -O2 -std=gnu99 -Wall -Wextra -Isrc -rdynamic -fomit-frame-pointer | |
#Tell make to make one .out file for each .cpp file found in the current directory | |
all: $(patsubst %.c, %.out, $(wildcard *.c)) | |
#Rule how to create arbitary .out files. | |
#First state what is needed for them e.g. additional headers, .cpp files in an include folder... | |
#Then the command to create the .out file, probably you want to add further options to the g++ call. | |
%.out: %.c Makefile | |
-$(CC) $(CFLAGS) $< -o $@ -lm | |
# $(CC) $(CFLAGS) $< -o $@ | |
clean: | |
rm *.out | |
rm -rf *.out.dSYM/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment