Skip to content

Commit

Permalink
Accept Python2 and Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
scemama committed Feb 20, 2020
1 parent 6e15ab7 commit 51e088d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZeroMQ header file

CC=gcc -fPIC
CC=gcc -fPIC
CFLAGS=-O3 -Wall -pedantic -g
PREFIX=/usr/local/

Expand All @@ -9,22 +9,22 @@ PREFIX=/usr/local/
default: libf77zmq.so libf77zmq.a f77_zmq.h

install: libf77zmq.so libf77zmq.a f77_zmq.h
install -D -m 644 libf77zmq.a $(PREFIX)/lib/
install -D -m 644 libf77zmq.so $(PREFIX)/lib/
install -D -m 644 f77_zmq.h $(PREFIX)/include/
install -D -m 644 f77_zmq_free.h $(PREFIX)/include/
install -D -m 644 libf77zmq.a $(PREFIX)/lib/
install -D -m 644 libf77zmq.so $(PREFIX)/lib/
install -D -m 644 f77_zmq.h $(PREFIX)/include/
install -D -m 644 f77_zmq_free.h $(PREFIX)/include/

libf77zmq.so: f77_zmq.o
$(CC) -shared $^ -o $@

libf77zmq.a: f77_zmq.o
libf77zmq.a: f77_zmq.o
$(AR) cr $@ $^

f77_zmq.o: f77_zmq.c f77_zmq.h
$(CC) $(CFLAGS) -c f77_zmq.c -o $@

f77_zmq.h: create_f77_zmq_h.py f77_zmq.c
python3 create_f77_zmq_h.py
python create_f77_zmq_h.py

clean:
$(RM) -f -- f77_zmq.o f77_zmq.h
Expand Down
8 changes: 6 additions & 2 deletions create_f77_zmq_h.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
#
# f77_zmq : Fortran 77 bindings for the ZeroMQ library
# Copyright (C) 2014 Anthony Scemama
Expand All @@ -24,12 +24,16 @@
# Universite Paul Sabatier - Bat. 3R1b4, 118 route de Narbonne
# 31062 Toulouse Cedex 09, France

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import re
import os
import sys
import ctypes


def create_lines(f):
result = f.read()
result = result.replace('\\\n', '')
Expand Down Expand Up @@ -121,7 +125,7 @@ def find_ZMQ_H():
v = os.environ.get("C_INCLUDE_PATH")
if v is None:
v = "/usr/include:/usr/local/include"

for d in v.split(':'):
if d and "zmq.h" in os.listdir(d):
return ("{0}/zmq.h".format(d))
Expand Down

0 comments on commit 51e088d

Please sign in to comment.