Skip to content

Instantly share code, notes, and snippets.

@paulbuis
Last active September 3, 2015 17:04
Show Gist options
  • Save paulbuis/1a0b77a48c5a7f5e5207 to your computer and use it in GitHub Desktop.
Save paulbuis/1a0b77a48c5a7f5e5207 to your computer and use it in GitHub Desktop.
Makefile for multilingal compile and link
CC = gcc
FC = gfortran
DC = gdc-4.9
CPP = g++
CFLAGS = -O
FFLAGS = -O
DFLAGS = -O
%_c.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
%_f.o: %.f
$(FC) -c $(FFLAGS) $< -o $@
%_d.o: %.d
$(DC) -c $(DFLAGS) $< -o $@
%_cc.o: %.cc
$(CPP) -c $(CFLAGS) $< -o $@
ALL = hello_c2c hello_cc2c hello_c2cc hello_c2f hello_f2c hello_f2f hello_d2d
all: $(ALL)
hello_cc2c: main_cc.o hello_c.o
$(CPP) -o $@ main_cc.o hello_c.o
hello_c2c: main_c.o hello_c.o
$(CC) -o $@ main_c.o hello_c.o
hello_c2cc: main_c.o hello_cc.o
$(CPP) -o $@ main_c.o hello_cc.o
hello_c2f: main_c.o adapt_c.o hello_f.o
$(FC) -o $@ $?
hello_f2c: main_f.o hello_c.o
$(FC) -o $@ $?
hello_f2f: main_f.o hello_f.o
$(FC) -o $@ $?
hello_d2d: main_d.o hello_d.o
$(DC) -o $@ main_d.o hello_d.o
main_c.o: main.c hello.h
hello_c.o: hello.c hello.h
hello_f.o: hello.f
clean:
rm -f *.o $(ALL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment