Last active
August 29, 2015 14:26
-
-
Save carneeki/b18fa1e995f34f34e5ac to your computer and use it in GitHub Desktop.
COMP202 Makefiles
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
Set up directory layout something like this: | |
/home/<username>/src/comp202 | |
. | |
├── lec | |
│ └── week01 | |
├── Makefile | |
├── Makefile.mk | |
├── prac | |
│ └── week01 | |
│ ├── helloworld.c | |
│ ├── Makefile | |
│ ├── name.c | |
│ ├── numberstars.c | |
│ └── printarg.c | |
├── push-ash | |
├── ssh-ash | |
└── tut |
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
PRAC = $(shell find prac/week* -type d) | |
TUT = $(shell find tut/week* -type d) | |
LEC = $(shell find lec/week* -type d) | |
clean_PRAC = $(addprefix clean_,$(PRAC)) | |
clean_TUT = $(addprefix clean_,$(TUT)) | |
clean_LEC = $(addprefix clean_,$(LEC)) | |
all : $(PRAC) $(TUT) # DO NOT BUILD lectures! | |
clean : $(clean_PRAC) $(clean_TUT) $(clean_LEC) | |
.PHONY : $(PRAC) $(TUT) $(LEC) $(clean_PRAC) $(clean_TUT) $(clean_LEC) | |
$(PRAC) : | |
make -C $@ | |
$(TUT) : | |
make -C $@ | |
$(LEC) : | |
make -C $@ | |
$(clean_PRAC) : | |
make -C $(patsubst clean_%,%,$@) clean | |
$(clean_TUT) : | |
make -C $(patsubst clean_%,%,$@) clean | |
push-ash : clean | |
rsync -avzr * <sid>@ash.science.mq.edu.au:/home/student/<number>/<sid>/comp202 | |
push-home : clean | |
rsync -avzr * <username>@<home-hostname>:/home/<username>/src/comp202 |
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
HOST=$(shell hostname) | |
# Run clang on laptop/desktop, gcc on ash/iceberg/anywhere else | |
ifeq ($(HOST),frood-dood) | |
CC=clang | |
else ifeq ($(HOST),missy) | |
CC=clang | |
else | |
CC=gcc | |
endif | |
ifeq ($(CC),gcc) | |
CFLAGS=-O3 -m32 -std=c99 | |
else | |
CFLAGS= | |
endif |
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
# Place this file in prac/week01/Makefile | |
# and make similar files for tut/week02/Makefile | |
# or anywhere else you need them. | |
include ../../Makefile.mk | |
SRC=$(wildcard *.c) | |
OUT=$(SRC:.c=) | |
all : $(OUT) | |
% : %.c | |
$(CC) $(CFLAGS) -o $@ $@.c | |
clean : | |
rm -f $(OUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment