Last active
August 29, 2015 14:11
-
-
Save charles-l/ab9c2afbf2c5ac208488 to your computer and use it in GitHub Desktop.
Generic, minimal makefile that should work in most situations
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
| LIBS="libname1 libname2" | |
| IGNOREFILES := file1.c file2.c | |
| BIN=binname | |
| CC=gcc-4.9 | |
| ########################################################### | |
| #### NOTHING SHOULD NEED TO BE CHANGED BELOW THIS LINE #### | |
| ########################################################### | |
| # Compiler options | |
| CFLAGS=`pkg-config --cflags $(LIBS)` -I. | |
| LDFLAGS=`pkg-config --libs $(LIBS)` | |
| # Find project files | |
| SOURCES=$(shell bash -c 'find . -name "*.c" $(foreach i, $(IGNOREFILES), -not -name "$(i)") -type f') | |
| OBJ=$(SOURCES:.c=.o) | |
| all: $(BIN) | |
| .c.o: | |
| @echo CC $< | |
| @$(CC) $(CFLAGS) -c $< -o $@ | |
| $(BIN): $(OBJ) | |
| @echo LN $^ | |
| @$(CC) -o $@ $^ $(LDFLAGS) | |
| clean: | |
| @-rm -f $(OBJ) $(BIN) | |
| @echo done cleaning | |
| .PHONY: all clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment